/* Script pour les diapo d'image sur la page d'accueil */


var timerID = 0;
var Speed = 3000;
var img_tab=null;

function ConstructSimpleObj(obj,nest){ 
    nest=(!nest) ? '':'document.'+nest+'.' 
    this.el=bw.dom?document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?eval(nest+'document.'+obj):0; 
//    this.css=bw.dom?document.getElementById(obj).style:bw.ie4?document.all[obj].style:bw.ns4?eval(nest+'document.'+obj):0; 
    this.changeTxt=changeTxt; 
    this.changeHTML=changeHTML; 
    this.changeImg=changeImg;
    this.changeHref=changeHref;
    this.obj = obj + "Object" 
    eval(this.obj + "=this") 
    return this 
} 

function changeImg(p_src){
	this.el.src = p_src
}

function changeTxt(p_txt){
	this.el.innerText = p_txt
}

function changeHTML(p_txt){
	 this.el.innerHTML = p_txt
}

var initialised; 
function InitialiseImg(){ 
  IDImg = new Object();
   IDImg.img_mid = new ConstructSimpleObj('img_mid');
   IDImg.img_titre_court = new ConstructSimpleObj('img_titre_court');
   initialised=true;
} 


function Start() {
	InitialiseImg();
	img_index = 1;
	timerID  = setTimeout("NextImg()", Speed);
}

function Stop() {
	if(timerID) clearTimeout(timerID);
	timerID  = 0;
}

function NextImg() 
{
	if(timerID) clearTimeout(timerID);
	
	if (IDImg == null) return;
img_index = ((img_index + 1) > img_tab.length) ? 1 : (img_index + 1);

    // Determine if the browser supports filters
    var dofilter = false;
    if (IDImg.img_mid &&
        typeof IDImg.img_mid.filters != 'undefined' &&
        typeof IDImg.img_mid.filters[0] != 'undefined' ) {
      	dofilter = true;
    }
    // Apply the filters for the image transition
    if (dofilter) {
    	IDImg.img_mid.filters[0].Apply();
    }

	IDImg.img_mid.changeImg(img_tab[img_index-1].src);

    if (dofilter) {
    	IDImg.img_mid.filters[0].Play();
    }
//	IDImg.img_titre_court.changeHTML(img_tab[img_index-1].titre_court);
//	alert("innerHTML " + IDImg.img_titre_court.el.innerHTML);
//	alert("innerText " + IDImg.img_titre_court.el.innerText);
	timerID  = setTimeout("NextImg()", Speed);
}

function changeHref(p_txt){
	 this.el.href = p_txt;
}

function GoToImgPage()
{
//	alert(img_tab[img_index-1].src);
//	alert(img_tab[img_index-1].Img_link);	
//	window.location.href(img_tab[img_index-1].Img_link); 
   	IMG_href = new ConstructSimpleObj('img_ref');
	IMG_href.changeHref(img_tab[img_index-1].Img_link);
}


function Img(p_src, p_titre_court, p_Img_link) 
{   
	this.src	= p_src;  
	this.titre_court	= p_titre_court;  
	this.Img_link	= p_Img_link;
}

function addNewImg(p_Img)
{
	img_tab[img_tab.length] = p_Img;
}

function initImgTab()
{
	img_tab = new Array(); 
	addNewImg( new Img("nouveau/img_1.jpg", " ", "acc_bijoux.html"));
	addNewImg( new Img("nouveau/img_2.jpg", " ", "acc_bijoux.html"));
	addNewImg( new Img("nouveau/img_3.jpg", " ", "acc_bijoux.html"));
	addNewImg( new Img("nouveau/img_4.jpg", " ", "acc_bijoux.html"));
	addNewImg( new Img("nouveau/img_5.jpg", " ", "acc_bijoux.html"));
	addNewImg( new Img("nouveau/img_6.jpg", " ", "acc_bijoux.html"));
	addNewImg( new Img("nouveau/img_7.jpg", " ", "acc_bijoux.html"));
	addNewImg( new Img("nouveau/img_8.jpg", " ", "acc_bijoux.html"));
/*	addNewImg( new Img("nouveau/img_9.jpg", " ", "acc_mitaines.html"));
	addNewImg( new Img("nouveau/img_10.jpg", " ", "acc_mitaines.html"));
	addNewImg( new Img("nouveau/img_11.jpg", " ", "acc_mitaines_2.html"));
	addNewImg( new Img("nouveau/img_12.jpg", " ", "acc_mitaines_2.html"));
	addNewImg( new Img("nouveau/img_13.jpg", " ", "acc_mitaines_2.html"));
	addNewImg( new Img("nouveau/img_14.jpg", " ", "acc_mitaines_2.html"));
	addNewImg( new Img("nouveau/img_15.jpg", " ", "acc_mitaines_2.html"));
	addNewImg( new Img("nouveau/img_16.jpg", " ", "acc_mitaines_2.html"));
	addNewImg( new Img("nouveau/img_17.jpg", " ", "acc_mitaines_2.html"));
	addNewImg( new Img("nouveau/img_18.jpg", " ", "acc_mitaines_2.html"));
	addNewImg( new Img("nouveau/img_19.jpg", " ", "acc_mitaines_2.html"));
	addNewImg( new Img("nouveau/img_20.jpg", " ", "acc_mitaines_2.html"));
	addNewImg( new Img("nouveau/img_21.jpg", " ", "acc_mitaines_3.html"));
	addNewImg( new Img("nouveau/img_22.jpg", " ", "acc_mitaines_3.html"));
	addNewImg( new Img("nouveau/img_23.jpg", " ", "acc_mitaines_3.html"));
	addNewImg( new Img("nouveau/img_24.jpg", " ", "acc_mitaines_3.html"));
	addNewImg( new Img("nouveau/img_25.jpg", " ", "acc_mitaines_3.html"));
	addNewImg( new Img("nouveau/img_26.jpg", " ", "acc_mitaines_3.html"));
	addNewImg( new Img("nouveau/img_27.jpg", " ", "acc_mitaines_3.html"));
	addNewImg( new Img("nouveau/img_28.jpg", " ", "acc_mitaines_3.html"));
	addNewImg( new Img("nouveau/img_29.jpg", " ", "acc_mitaines_3.html"));
	addNewImg( new Img("nouveau/img_30.jpg", " ", "acc_mitaines_3.html"));
	addNewImg( new Img("nouveau/img_31.jpg", " ", "acc_mitaines_4.html"));
	addNewImg( new Img("nouveau/img_32.jpg", " ", "acc_mitaines_4.html"));
	addNewImg( new Img("nouveau/img_33.jpg", " ", "acc_mitaines_4.html"));
	addNewImg( new Img("nouveau/img_34.jpg", " ", "acc_mitaines_4.html"));
	addNewImg( new Img("nouveau/img_35.jpg", " ", "acc_mitaines_4.html"));
*/
}

function ChangePoeme()
{	
	var poeme_tab=null;
	poeme_tab = new Array(); 
	poeme_tab[poeme_tab.length] = "poeme_etoles.gif";
	poeme_tab[poeme_tab.length] = "poeme_mitaines.gif";
	poeme_tab[poeme_tab.length] = "poeme_bijoux.gif";
	poeme_tab[poeme_tab.length] = "poeme_chapeau.gif";
	
	poeme_img = new ConstructSimpleObj('img_poeme');
	poeme_img.changeImg("test/" + poeme_tab[Math.floor(Math.random() * (3+1))]);
}
