var target;
var targetG;

var l=10;
var k = 0;
var i=13;

var timer;

var Anum = 1;
var Cnum = 1;

var SSplaying = true;


function rotate(j) {
	targetA = document.getElementById('frame'+Anum);
	targetC = document.getElementById('frame'+Cnum);
	
	if (j == 0) {
	l=10;
	k=0;
	i = j+1;
	
	targetA.style.opacity= (k/10);
	targetA.style.filter = "alpha(opacity:"+ (k*10) +")";
	
	targetA.style.display='';
	
	clearTimeout(timer);
	timer = setTimeout("rotate("+i+");",10);
	}
	else if (j > 0 && j<=11) {
	targetC.style.opacity= (l/10);
	targetC.style.filter = "alpha(opacity:"+ (l*10) +")";
	
	targetA.style.opacity= (k/10);
	targetA.style.filter = "alpha(opacity:"+ (k*10) +")";
	l = l-1;
	k = k+1;
	i=j+1;
	clearTimeout(timer);
	timer = setTimeout("rotate("+i+");",40);
	}
	else if (j == 12) {
	l = 0;
	k = 10;
	
	targetC.style.opacity= 0;
	targetC.style.filter = "alpha(opacity:0)";
	
	targetA.style.opacity= 1;
	targetA.style.filter = "alpha(opacity:100)";
	
	targetC.style.display='none';
	
	i=j+1;
	
	clearTimeout(timer);
	if (SSplaying) {timer = setTimeout("nextPic();",4000);}
	}
}

function nextPic() {
	endTrans();	
	Cnum = Anum;
	Anum = Anum+1;
	if (Anum>Atotal) {
		Anum = 1;
	}
	dotOn(Cnum);
	dotOff(Anum);
	clearTimeout(timer);
	rotate(0);
}

function prevPic() {
	endTrans();
	Cnum = Anum;
	Anum = Anum - 1;
	if (Anum < 1) {Anum = Atotal;}
	dotOn(Cnum);
	dotOff(Anum);
	clearTimeout(timer);
	rotate(0);
}

function toPic(num) {
	endTrans();
	Cnum = Anum;
	Anum = num;
	dotOn(Cnum);
	dotOff(Anum);
	clearTimeout(timer);
	rotate(0);
}

function playShow() {
	SSplaying = true;
	disablePlay();
	enableStop();
	if (i==13) {nextPic();}
}

function stopShow() {
	SSplaying = false;
	disableStop();
	enablePlay();
	if (i==13) {clearTimeout(timer);}
}

function enablePlay() {
	document.getElementById('playB').innerHTML = '<a href="javascript:playShow()"><img src="images/home/controls/playB.gif" alt="Stop" width="26" height="28" onMouseOver="playOver(this,\'play\')" onMouseOut="playOut(this,\'play\')"></a>';
}

function enableStop() {
	document.getElementById('stopB').innerHTML = '<a href="javascript:stopShow()"><img src="images/home/controls/stopB.gif" alt="Stop" width="28" height="28" onMouseOver="playOver(this,\'stop\')" onMouseOut="playOut(this,\'stop\')"></a>';
}

function disablePlay() {
	document.getElementById('playB').innerHTML = '<img src="images/home/controls/playB3.gif" width="26" height="28">';
}

function disableStop() {
	document.getElementById('stopB').innerHTML = '<img src="images/home/controls/stopB3.gif" width="28" height="28">';
}

function endTrans() {
	targetA = document.getElementById('frame'+Anum);
	targetC = document.getElementById('frame'+Cnum);
	targetC.style.opacity= 0;
	targetC.style.filter = "alpha(opacity:0)";
	targetA.style.opacity= 1;
	targetA.style.filter = "alpha(opacity:100)";
}
