var killphoto=1
var bannerlinknum=2
var oldbannerlinknum=1
var newphoto=2
var botphoto=3
var totphoto=5

function movenext(){
	
	blendimage('homeContent'+killphoto,'homeContent'+newphoto,'homeContent'+botphoto,'bannerLink'+bannerlinknum,'bannerLink'+oldbannerlinknum,700)

	
	newphoto=newphoto+1
	bannerlinknum=bannerlinknum+1
	oldbannerlinknum=oldbannerlinknum+1
    killphoto=killphoto+1
    botphoto=botphoto+1
	if (newphoto>totphoto){
		newphoto=1	
	}
    if (killphoto>totphoto){
		killphoto=1	
	}
    if (botphoto>totphoto){
		botphoto=1	
	}
	if (bannerlinknum>totphoto){
		bannerlinknum=1	
	}
	if (oldbannerlinknum>totphoto){
		oldbannerlinknum=1	
	}
}


//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 + ")";
}


function blendimage(divkill, divnew, divbot, bannerlink, oldbannerlink, millisec) {
	var speed = Math.round(millisec / 100);
	var timer = 0;
	
	//set the current image as background
	document.getElementById(divnew).style.display='block'
	document.getElementById(divbot).style.zIndex=3
	document.getElementById(divkill).style.zIndex=4
	document.getElementById(divnew).style.zIndex=5

	//alert(bannerlink);
	document.getElementById(bannerlink).style.backgroundColor='#999999';
	document.getElementById(oldbannerlink).style.backgroundColor='';
	
	//make image transparent
	changeOpac(0, divnew);
	changeOpac(100, divbot);
	
	//make new image

	//fade in image
	x=100
	for(i = 0; i <= 100; i++) {
		setTimeout("changeOpac(" + i + ",'" + divnew + "')",(timer * speed));
		setTimeout("changeOpac(" + x + ",'" + divkill + "')",(timer * speed));
		timer++;
		x--
	}
}

function clearit(whichdiv){
	clearInterval(startit);
	for (i=1;i<=totphoto;i++){
		if (i==whichdiv){
		document.getElementById("homeContent"+i).style.display = 'block'
		}else{
		document.getElementById("homeContent"+i).style.display = 'none'
		}
	}
	changeOpac(100, "homeContent"+whichdiv);
	var div1 = document.getElementById('bannerLink1');
	var div2 = document.getElementById('bannerLink2');
	var div3 = document.getElementById('bannerLink3');
	var div4 = document.getElementById('bannerLink4');
	var div5 = document.getElementById('bannerLink5');
	
	switch(whichdiv) {
			case 1:
				div1.style.backgroundColor = '#999999';
				div2.style.backgroundColor = '';
				div3.style.backgroundColor = '';
				div4.style.backgroundColor = '';
				div5.style.backgroundColor = '';
			break;
			
			case 2:
				div1.style.backgroundColor = '';
				div2.style.backgroundColor = '#999999';
				div3.style.backgroundColor = '';
				div4.style.backgroundColor = '';
				div5.style.backgroundColor = '';
			break;
			
			case 3:
				div1.style.backgroundColor = '';
				div2.style.backgroundColor = '';
				div3.style.backgroundColor = '#999999';
				div4.style.backgroundColor = '';
				div5.style.backgroundColor = '';
			break;
			
			case 4:
				div1.style.backgroundColor = '';
				div2.style.backgroundColor = '';
				div3.style.backgroundColor = '';
				div4.style.backgroundColor = '#999999';
				div5.style.backgroundColor = '';
			break;
			
			case 5:
				div1.style.backgroundColor = '';
				div2.style.backgroundColor = '';
				div3.style.backgroundColor = '';
				div4.style.backgroundColor = '';
				div5.style.backgroundColor = '#999999';
			break;
	}
	
}

function startit(){
	startit=setInterval ('movenext()', 5000);
	document.getElementById('bannerLink1').style.backgroundColor='#999999';
}