$(document).ready(function(){

	DisplayText();

	

	RotateOne();

	RotateTwo();

});



var max_images = new Array(3,3);



function DisplayText(){

	window.setTimeout(function() {

		$("#text1").toggle(2000);

	},1000);	

	

	window.setTimeout(function() {

		$("#text2").toggle(2000);

	},2000);

	

	window.setTimeout(function() {

		$("#text3").toggle(2000);

	},3000);

}



function RotateOne(){

	var margin =98;

	var width=193;

	var height=193;	

			

	setTimeout("RotateNext(1, " + margin + ", " + width + ", " + height + ", 1)", 3000);

}



function RotateTwo(){

	var margin =98;

	var width=193;

	var height=193;	

			

	setTimeout("RotateNext(1, " + margin + ", " + width + ", " + height + ", 2)", 4000);

}



function RotateNext(i, margin, width, height, selector){

	if(i == max_images[selector-1])

		next_image = 1;

	else

		next_image = i+1;

			

	$("#img" + selector + "-" + i).stop().animate({width:'0px',height:''+height+'px',marginLeft:''+margin+'px',opacity:'0.5'},{duration:500});

	window.setTimeout(function() {

	$("#img" + selector + "-" + next_image).stop().animate({width:''+width+'px',height:''+height+'px',marginLeft:'0px',opacity:'1'},{duration:500});

	},500);	

	

	setTimeout("RotateNext(" + next_image + ", " + margin + ", " + width + ", " + height + ", " + selector + ")", 5000);

}
