	var current_news=0;
		
	function gohomenav(flag,divid){
			var dC=document.getElementsByTagName("div");
			mod=0;
				for(var dI=0; dI<dC.length; dI++){
				cur=dC[dI].id;
					if(cur.indexOf(divid)>-1){
						mod=mod+1;
					}
				}

		prev_div=divid+((current_news-1+mod)%mod);
		current_div=divid+((current_news)%mod);
		next_div=divid+((current_news+1)%mod);
		time=850;
			if(flag==0){
				document.getElementById(prev_div).style.display = 'block';
				opacity(prev_div,divid,0,100,time);
				opacity(current_div,divid,100,0,time);
				document.getElementById(current_div).style.display = 'none';
				//current_news=current_news-1;
				current_news=(current_news-1+mod)%mod;
				
			} else {
			
				document.getElementById(next_div).style.display = 'block';
				opacity(current_div,divid,100,0,time);
				opacity(next_div,divid,0,100,time);
				document.getElementById(current_div).style.display = 'none';
				
				current_news=current_news+1;
			}	
	}

		function opacity(id,divid, opacStart, opacEnd, millisec) {
			//speed for each frame
			var speed = Math.round(millisec / 100);
			var timer = 0;
			clearInterval(auto_viewer);
			//determine the direction for the blending, if start and end are the same nothing happens
					if(opacStart > opacEnd) {
						for(i = opacStart; i >= opacEnd; i--) {
							setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
							timer++;
						}
					} else if(opacStart < opacEnd) {
						for(i = opacStart; i <= opacEnd; i++)
							{
							setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
							timer++;
						}
					}
			auto_viewer=setInterval("gohomenav(1,'"+divid+"')", 4000);
		}

//change the opacity for different browsers
function changeOpac(opacity, id) {
    var object = document.getElementById(id).style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
} 


//var auto_viewer1=setInterval("gohomenav(1,'main_ph1_div')", 4000);


