//animation device settings
var cycletime = 5;		//Cycle time in seconds

var num_images = 2;		//IMPORTANT - name the # of images to be cycled here
						//Animation will break if incorrect

//Define all images here, in the same format
headerimages = new Array();

headerimages[1] = new Image(225,190);
headerimages[1].src = "/images/girls.png";

headerimages[2] = new Image(225,190);
headerimages[2].src = "/images/birthday.png";



//animation specs and functions - DONT TOUCH
var myAnimA = new YAHOO.util.Anim('imgfront');
myAnimA.duration = 1.2;
myAnimA.method = YAHOO.util.Easing.easeOut;

var myAnimB = new YAHOO.util.Anim('imgback');
myAnimB.duration = 1.2;
myAnimB.method = YAHOO.util.Easing.easeOut;

var current_image = 1;		//Tracking the current image displayed

function startCycle(){
	var tempdur = myAnimB.duration;

	myAnimB.duration = 0.1;
	myAnimB.attributes.opacity = { to: 0 };
	myAnimB.animate();
	
	myAnimB.duration = tempdur;
	
	setTimeout("cycleA()",cycletime*1000);
}

function cycleA(){//switch in new back image, fade front image
	document.getElementById('imgback').style.display="inline";
	current_image++;
	if(current_image>num_images){current_image = 1;}

	document.imgback.src = headerimages[current_image].src;

	myAnimA.attributes.opacity = { to: 0 };
	myAnimB.attributes.opacity = { to: 1 };

	myAnimA.animate();
	myAnimB.animate();

	setTimeout("hideFront()",1000);
	
	setTimeout("cycleB()",cycletime*1000);
	
}

function cycleB(){//switch in new front image, fade back image
	document.getElementById('imgfront').style.display="inline";
	current_image++;
	if(current_image>num_images){current_image = 1;}
	
	document.imgfront.src = headerimages[current_image].src;

	myAnimA.attributes.opacity = { to: 1 };
	myAnimB.attributes.opacity = { to: 0 };
	myAnimA.animate();
	myAnimB.animate();
	
	setTimeout("hideBack()",1000);
	
	setTimeout("cycleA()",cycletime*1000);
}


function hideFront(){//Function to resolve IE display issues
	document.getElementById('imgfront').style.display="none";
}

function hideBack(){//Function to resolve IE display issues
	document.getElementById('imgback').style.display="none";
}