AnimStep = 1;
AnimTarget = 1;
AlphaProcent = 100;
AlphaDelta = 0;

totalAdv = document.movingadvs.totaladvs.value;
AnimStepMax = 6;
//alert(totalAdv)
PlayHandle = -1;
PlayAnim   = -1;

var Links = new Array();
for (i=1;i<=totalAdv;i++){
if (i==1){
	if (document.movingadvs.template1.value == 6)
		Links[i]="index.asp";
	else if (document.movingadvs.template1.value == 2){
		Links[i]="webpage.asp?webID="+document.movingadvs.webpage1.value;
	}
	else if (document.movingadvs.template1.value == 5){
		Links[i]="product_details.asp?menu=&PID="+document.movingadvs.product1.value;
	}
}
else if (i==2){
	if (document.movingadvs.template2.value == 6)
		Links[i]="index.asp";
	else if (document.movingadvs.template2.value == 2){
		Links[i]="webpage.asp?webID="+document.movingadvs.webpage2.value;
	}
	else if (document.movingadvs.template2.value == 5){
		Links[i]="product_details.asp?menu=&PID="+document.movingadvs.product2.value;
	}
}
else if (i==3){
	if (document.movingadvs.template3.value == 6)
		Links[i]="index.asp";
	else if (document.movingadvs.template3.value == 2){
		Links[i]="webpage.asp?webID="+document.movingadvs.webpage3.value;
	}
	else if (document.movingadvs.template3.value == 5){
		Links[i]="product_details.asp?menu=&PID="+document.movingadvs.product3.value;
	}
}
else if (i==4){
	if (document.movingadvs.template4.value == 6)
		Links[i]="index.asp";
	else if (document.movingadvs.template4.value == 2){
		Links[i]="webpage.asp?webID="+document.movingadvs.webpage4.value;
	}
	else if (document.movingadvs.template4.value == 5){
		Links[i]="product_details.asp?menu=&PID="+document.movingadvs.product4.value;
	}
}
else if (i==5){
	if (document.movingadvs.template5.value == 6)
		Links[i]="index.asp";
	else if (document.movingadvs.template5.value == 2){
		Links[i]="webpage.asp?webID="+document.movingadvs.webpage5.value;
	}
	else if (document.movingadvs.template5.value == 5){
		Links[i]="product_details.asp?menu=&PID="+document.movingadvs.product5.value;
	}
}
else if (i==6){
	if (document.movingadvs.template6.value == 6)
		Links[i]="index.asp";
	else if (document.movingadvs.template6.value == 2){
		Links[i]="webpage.asp?webID="+document.movingadvs.webpage6.value;
	}
	else if (document.movingadvs.template6.value == 5){
		Links[i]="product_details.asp?menu=&PID="+document.movingadvs.product6.value;
	}
}
else if (i==7){
	if (document.movingadvs.template7.value == 6)
		Links[i]="index.asp";
	else if (document.movingadvs.template7.value == 2){
		Links[i]="webpage.asp?webID="+document.movingadvs.webpage7.value;
	}
	else if (document.movingadvs.template7.value == 5){
		Links[i]="product_details.asp?menu=&PID="+document.movingadvs.product7.value;
	}
}
else if (i==8){
	if (document.movingadvs.template8.value == 6)
		Links[i]="index.asp";
	else if (document.movingadvs.template8.value == 2){
		Links[i]="webpage.asp?webID="+document.movingadvs.webpage8.value;
	}
	else if (document.movingadvs.template8.value == 5){
		Links[i]="product_details.asp?menu=&PID="+document.movingadvs.product8.value;
	}
}
else if (i==9){
	if (document.movingadvs.template9.value == 6)
		Links[i]="index.asp";
	else if (document.movingadvs.template9.value == 2){
		Links[i]="webpage.asp?webID="+document.movingadvs.webpage9.value;
	}
	else if (document.movingadvs.template9.value == 5){
		Links[i]="product_details.asp?menu=&PID="+document.movingadvs.product9.value;
	}
}
else if (i==10){
	if (document.movingadvs.template10.value == 6)
		Links[i]="index.asp";
	else if (document.movingadvs.template10.value == 2){
		Links[i]="webpage.asp?webID="+document.movingadvs.webpage10.value;
	}
	else if (document.movingadvs.template10.value == 5){
		Links[i]="product_details.asp?menu=&PID="+document.movingadvs.product10.value;
	}
}
}
 
var Imgs = new Array();
for (i=1;i<=totalAdv;i++){
if (i==1){Imgs[i]=new Image();Imgs[i].src=document.movingadvs.advImagePath1.value;}
else if (i==2){Imgs[i]=new Image();Imgs[i].src=document.movingadvs.advImagePath2.value;}
else if (i==3){Imgs[i]=new Image();Imgs[i].src=document.movingadvs.advImagePath3.value;}
else if (i==4){Imgs[i]=new Image();Imgs[i].src=document.movingadvs.advImagePath4.value;}
else if (i==5){Imgs[i]=new Image();Imgs[i].src=document.movingadvs.advImagePath5.value;}
else if (i==6){Imgs[i]=new Image();Imgs[i].src=document.movingadvs.advImagePath6.value;}
else if (i==7){Imgs[i]=new Image();Imgs[i].src=document.movingadvs.advImagePath7.value;}
else if (i==8){Imgs[i]=new Image();Imgs[i].src=document.movingadvs.advImagePath8.value;}
else if (i==9){Imgs[i]=new Image();Imgs[i].src=document.movingadvs.advImagePath9.value;}
else if (i==10){Imgs[i]=new Image();Imgs[i].src=document.movingadvs.advImagePath10.value;}
}

var animbtn1 = document.getElementById("animbtn1");
var animbtn2 = document.getElementById("animbtn2");
var animbtn3 = document.getElementById("animbtn3");
var animbtn4 = document.getElementById("animbtn4");
var animbtn5 = document.getElementById("animbtn5");
var animbtn6 = document.getElementById("animbtn6");
var animbtn7 = document.getElementById("animbtn7");
var animbtn8 = document.getElementById("animbtn8");
var animbtn9 = document.getElementById("animbtn9");
var animbtn10 = document.getElementById("animbtn10");

var animimage = document.getElementById("animimage");
var animplay = document.getElementById("animplay");
PlayPause();
function MouseOver(No){
	     if(No==1){ animbtn1.style.color='#0099FF';}
	else if(No==2){ animbtn2.style.color='#0099FF';}
	else if(No==3){ animbtn3.style.color='#0099FF';}
	else if(No==4){ animbtn4.style.color='#0099FF';}
	else if(No==5){ animbtn5.style.color='#0099FF';}
	else if(No==6){ animbtn6.style.color='#0099FF';}
	else if(No==7){ animbtn7.style.color='#0099FF';}
	else if(No==8){ animbtn8.style.color='#0099FF';}
	else if(No==9){ animbtn9.style.color='#0099FF';}
	else if(No==10){ animbtn10.style.color='#0099FF';}
}
function MouseOut(No){
	     if(No==1){ animbtn1.style.color='#003366';}
	else if(No==2){ animbtn2.style.color='#003366';}
	else if(No==3){ animbtn3.style.color='#003366';}
	else if(No==4){ animbtn4.style.color='#003366';}
	else if(No==5){ animbtn5.style.color='#003366';}
	else if(No==6){ animbtn6.style.color='#003366';}
	else if(No==7){ animbtn7.style.color='#003366';}
	else if(No==8){ animbtn8.style.color='#003366';}
	else if(No==9){ animbtn9.style.color='#003366';}
	else if(No==10){ animbtn10.style.color='#003366';}
}
function SetCurrent(No){
		 if(totalAdv==1){ animbtn1.style.backgroundColor = 'white';}
	else if(totalAdv==2){ animbtn1.style.backgroundColor = 'white'; animbtn2.style.backgroundColor = 'white';}
	else if(totalAdv==3){ animbtn1.style.backgroundColor = 'white';
	animbtn2.style.backgroundColor = 'white';
	animbtn3.style.backgroundColor = 'white';}
	else if(totalAdv==4){ animbtn1.style.backgroundColor = 'white';
	animbtn2.style.backgroundColor = 'white';
	animbtn3.style.backgroundColor = 'white';
	animbtn4.style.backgroundColor = 'white';}
	else if(totalAdv==5){ animbtn1.style.backgroundColor = 'white';
	animbtn2.style.backgroundColor = 'white';
	animbtn3.style.backgroundColor = 'white';
	animbtn4.style.backgroundColor = 'white';
	animbtn5.style.backgroundColor = 'white';}
	else if(totalAdv==6){ animbtn1.style.backgroundColor = 'white';
	animbtn2.style.backgroundColor = 'white';
	animbtn3.style.backgroundColor = 'white';
	animbtn4.style.backgroundColor = 'white';
	animbtn5.style.backgroundColor = 'white';
	animbtn6.style.backgroundColor = 'white';}
	else if(totalAdv==7){ animbtn1.style.backgroundColor = 'white';
	animbtn2.style.backgroundColor = 'white';
	animbtn3.style.backgroundColor = 'white';
	animbtn4.style.backgroundColor = 'white';
	animbtn5.style.backgroundColor = 'white';
	animbtn6.style.backgroundColor = 'white';
	animbtn7.style.backgroundColor = 'white';}
	else if(totalAdv==8){ animbtn1.style.backgroundColor = 'white';
	animbtn2.style.backgroundColor = 'white';
	animbtn3.style.backgroundColor = 'white';
	animbtn4.style.backgroundColor = 'white';
	animbtn5.style.backgroundColor = 'white';
	animbtn6.style.backgroundColor = 'white';
	animbtn7.style.backgroundColor = 'white';
	animbtn8.style.backgroundColor = 'white';}
	else if(totalAdv==9){ animbtn1.style.backgroundColor = 'white';
	animbtn2.style.backgroundColor = 'white';
	animbtn3.style.backgroundColor = 'white';
	animbtn4.style.backgroundColor = 'white';
	animbtn5.style.backgroundColor = 'white';
	animbtn6.style.backgroundColor = 'white';
	animbtn7.style.backgroundColor = 'white';
	animbtn8.style.backgroundColor = 'white';
	animbtn9.style.backgroundColor = 'white';}
	else if(totalAdv==10){ animbtn1.style.backgroundColor = 'white';
	animbtn2.style.backgroundColor = 'white';
	animbtn3.style.backgroundColor = 'white';
	animbtn4.style.backgroundColor = 'white';
	animbtn5.style.backgroundColor = 'white';
	animbtn6.style.backgroundColor = 'white';
	animbtn7.style.backgroundColor = 'white';
	animbtn8.style.backgroundColor = 'white';
	animbtn9.style.backgroundColor = 'white';
	animbtn10.style.backgroundColor = 'white';}
	
	     if(No==1){ animbtn1.style.backgroundColor = '#C0D0FF';}
	else if(No==2){ animbtn2.style.backgroundColor = '#C0D0FF';}
	else if(No==3){ animbtn3.style.backgroundColor = '#C0D0FF';}
	else if(No==4){ animbtn4.style.backgroundColor = '#C0D0FF';}
	else if(No==5){ animbtn5.style.backgroundColor = '#C0D0FF';}
	else if(No==6){ animbtn6.style.backgroundColor = '#C0D0FF';}
	else if(No==7){ animbtn7.style.backgroundColor = '#C0D0FF';}
	else if(No==8){ animbtn8.style.backgroundColor = '#C0D0FF';}
	else if(No==9){ animbtn9.style.backgroundColor = '#C0D0FF';}
	else if(No==10){ animbtn10.style.backgroundColor = '#C0D0FF';}
} 
function AnimShowMenu(Show){
	if(Show) Show = "visible"; else Show = "hidden";
	document.getElementById("animctrl").style.visibility = Show;
}
function PlayPause(){
	if(PlayHandle==-1){
		animplay.style.background = 'url(images/anim_pause.gif)';
		PlayHandle = window.setInterval("ShowNextAd()", 5000);
	} else {
		animplay.style.background = 'url(images/anim_play.gif)';
		window.clearInterval(PlayHandle);
		PlayHandle =-1;
	}
	animplay.style.backgroundColor = 'White';
}
function ShowNextAd(){
	ShowAd(1+ AnimStep%AnimStepMax);
}
function Anim(){
	if(AlphaDelta>0){
		AlphaProcent += AlphaDelta;
		if(AlphaProcent>=100){AlphaDelta = 0;AlphaProcent=100;}
	} else if(AlphaDelta<0) {
		AlphaProcent += AlphaDelta;
		if(AlphaProcent<=0){
			AlphaDelta = -AlphaDelta;
			AlphaProcent=0;
			animimage.innerHTML = "<a href='"+Links[AnimTarget]+"'><img src='"+Imgs[AnimTarget].src+"' border='0'></a>";
			//alert(AnimTarget);
			AnimStep = AnimTarget;
			SetCurrent(AnimStep);
		}
	}
	try{animimage.filters.alpha.opacity = AlphaProcent;}catch(err){}
	try{animimage.style.opacity = AlphaProcent/100;} catch(err) {}
	try{animimage.style.MozOpacity = AlphaProcent/100;} catch(err) {}
	try{animimage.style.HTMLOpacity = AlphaProcent/100;} catch(err) {}	
	if(AlphaDelta == 0){
		window.clearInterval(PlayAnim);
		if(PlayHandle!=-1) PlayHandle = window.setInterval("ShowNextAd()", 5000);
	}
}
function ShowAd(No){
	if(No!=AnimStep){
		window.clearInterval(PlayAnim);
		if(PlayHandle!=-1) window.clearInterval(PlayHandle);
		AnimTarget = No;
		AlphaDelta = - 10;
		PlayAnim = window.setInterval("Anim()", 50);
	}
}