
/* Classs Constructors */

function OneImage(location,width,height){
	this.location=location;
	this.width=width;
	this.height=height;
}

function OneText(content,CSSclass){
	this.content=content;
	this.CSSclass=CSSclass;
}

function OneRotation(title,text,image){
	this.title=title;
	this.text=text;
	this.image=image;
}

var InRotation=Array();
var TotItems= 0; var CurrentItem = 0;



/******** CONFIG *********/
 var timer = 5000; /* time interval for rotation in ms */

var ImageDivHolder1 = 'MainImgWrap1'; /* id of the div with the background image */
var ImageDivHolder2 = 'MainImgWrap2'; /* id of the div with the background image */
var Titleh1Holder = 'MainImgWrapTitle'; /* id of the h1 with the background image */
var ImagePHolder = 'MainImgWrapTexte'; /* id of the div with the background image */

/** Elements to Rotate**/

// Rotation 1
InRotation[0] = new OneRotation(
			new OneText('&nbsp;','empty'),
			new OneText('&nbsp;','empty'),
			new OneImage('./images/img_main.jpg','367','352')
			);

// Rotation 2
InRotation[1] = new OneRotation(
			new OneText('&nbsp;','empty'),
			new OneText('&nbsp;','empty'),
			new OneImage('./images/img_main1.jpg','367','352')
			);

InRotation[2] = new OneRotation(
			new OneText('&nbsp;','empty'),
			new OneText('&nbsp;','empty'),
			new OneImage('./images/img_main2.jpg','367','352')
			);

InRotation[3] = new OneRotation(
			new OneText('&nbsp;','empty'),
			new OneText('&nbsp;','empty'),
			new OneImage('./images/spring_hhchiro.jpg','367','352')
			);

for(var j=0;j<InRotation.length;j++){		
	 var imgs = new Image();
    imgs.src = InRotation[parseInt(j)].image.location;					
}
/*** END CONFIG*/


var TotItems= InRotation.length;

function RotateImg(){


	var WrapDiv1 = document.getElementById(ImageDivHolder1)
	var WrapDiv2 = document.getElementById(ImageDivHolder2)
	var TitleDiv = document.getElementById(Titleh1Holder);
	var TextDiv = document.getElementById(ImagePHolder);
	
	WrapDiv1.style.backgroundImage="url('"+InRotation[parseInt(CurrentItem)].image.location+"')";
	WrapDiv1.style.zindex=1;
	WrapDiv2.style.zindex=0;
	
	TitleDiv.innerHTML = InRotation[parseInt(CurrentItem)].title.content;
	TextDiv.innerHTML = InRotation[parseInt(CurrentItem)].text.content;

	if(CurrentItem<TotItems-2){WrapDiv2.style.backgroundImage="url('"+InRotation[parseInt(CurrentItem)+1].image.location+"')";}

   setTimeout("RotateImg()",timer);
	(CurrentItem>TotItems-2)?CurrentItem=parseInt(0):CurrentItem++;

	
}