
/*** Gestion des l'affichage des Chapeau ***/

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.obj = obj + "Object" 
    eval(this.obj + "=this") 
    return this 
} 


function changeTxt(p_txt){
	this.el.innerText = p_txt
}

function changeHTML(p_txt){
	 this.el.innerHTML = p_txt
}

function changeImg(p_src){
	this.el.src = p_src
}

function changeName(p_name){
	this.el.name = p_name
}

img_tab=null;

function InitialiseImgChapeau_U()
{ 
   IdChapU=new Object();
   IdChapU.img=new ConstructSimpleObj('img_mid');
   IdChapU.titre_long=new ConstructSimpleObj('cu_titre_long');
//   IdChapU.win_titre=new ConstructSimpleObj('divWinHead0');
//	 initImgTab();
} 


/*********  Tableau des Chapeaux des deux collection  **********/

function Chapeau_U(p_src, p_titre_court, p_titre_long, p_desc, p_ref, p_img_nb) 
{   
	this.src	= p_src;  
	this.ref	= p_ref;  
	this.titre_court	= p_titre_court;  
	this.titre_long	= p_titre_long;  
	this.desc	= p_desc;
	this.img_nb	= p_img_nb;
}

function addNewImg(p_chapeau_u)
{
	img_tab[img_tab.length] = p_chapeau_u;
}

function initImgTab()
{
	img_tab = new Array(); 

	addNewImg( new Chapeau_U("chapeaux/cu_mid1.jpg", "Engivrez-Vous", "Engivrez-Vous", "Matière : Feuilleté de papier pailleté, non tissé, Plumes, Perles", "Ref: Engivrez-Vous", 1));
	addNewImg( new Chapeau_U("chapeaux/cu_mid2.jpg", "L'Amour en cage", "L'Amour en cage", "Matière : Feuilleté de papier, non tissé, Rose naturelle stabilisée", "Ref : L'amour en cage", 1));
	addNewImg( new Chapeau_U("chapeaux/cu_mid3.jpg", "Chrysanthème", "Chrysanthème", "Matière : Feuilleté de papier, fils de fer", "Ref : Chrysanthème", 2));
	addNewImg( new Chapeau_U("chapeaux/cu_mid4.jpg", "Voiletta", "Violetta", "Matière : Feuilleté de papier, organza", "Ref : Violetta", 2));
	addNewImg( new Chapeau_U("chapeaux/cu_mid5.jpg", "Echecs et Dame", "Echecs et Dame", "Matière : Feuilleté de papier, non tissé, fil métalique", "Ref: Echecs et Dame", 2));
	addNewImg( new Chapeau_U("chapeaux/cu_mid6.jpg", "Orange", "Orange", "Matière : Feuilleté de papier", "Ref : Orange", 1));
	addNewImg( new Chapeau_U("chapeaux/cu_mid7.jpg", "Le manège enchanté", "Le manège enchanté", "Matière : Feuilleté de papier, non tissé", "Ref: Le Manège enchanté", 1));
	addNewImg( new Chapeau_U("chapeaux/cu_mid8.jpg", "Marguerite", "Marguerite", "Matière : Feuilleté de papier", "Ref : Marguerite", 1));
	addNewImg( new Chapeau_U("chapeaux/cu_mid9.jpg", "Postit", "Postit", "Matière : Feuilleté de papier, non tissé", "Ref : Postit", 1));
	addNewImg( new Chapeau_U("chapeaux/cu_mid10.jpg", "Tooneyes", "Tooneyes", "Matière : Feuilleté de papier, non tissé", "Ref : Tooneyes", 1));

// index de la dernière photo ajoutée
	img_index=img_tab.length;
}


function showImg(p_img_num)
{
	//alert(img_tab[arguments[0]].src);
	if ((img_tab == null) || (p_img_num == null)) return;

	IdChapU.img.changeImg(img_tab[p_img_num-1].src);
	img_index = p_img_num;
	//alert("this.img_mid.name = " + this.img_mid.name);
//	IdChapU.img.changeName(p_img_num); // ne fonctionne pas

//  alert("img_tab[p_img_num-1].src = " + img_tab[p_img_num-1].src + "\np_img_num = " + p_img_num);
		
	IdChapU.titre_long.changeHTML(img_tab[p_img_num-1].titre_long);
//	IdChapU.win_titre.changeHTML(img_tab[p_img_num-1].titre_long);
//	writedebug("this.img_mid.name = " + this.img_mid.name);
}

/*
function addWindow_MultiImages()
{
	win_script = "<div style='text-align:left;'><h2 id='chap_win_titre'>Margueritte</h2> <div id='chap_win_desc'>Mon beau chapeau que j aime bien</div>Zoom : <a href='#'><img src='res1/view_medium.gif' border='0' onclick='changeImgSize(1)'></a><a href='#'><img src='res1/view_large.gif' border='0' onclick='changeImgSize(2)'></a><br><img id='img_big' name='1' src='res1/chap_1.gif'></div>";
	
	addWindow("Margueritte",win_script,30,10,630,540,"white","white",false);
}
*/

function showImgWin()
{
  link1="";
  link2="";
	
	imgBig1="chapeaux/cu_big" + img_index + ".jpg";
	imgBig2="chapeaux/cu_big" + img_index + "_2.jpg";

	if(img_tab[img_index-1].img_nb == 2)
	{
		 link1 = "<a href='javascript:change_img(1);'>[1]</a>";
		 link2 = "<a href='javascript:change_img(2);'>[2]</a>";
	}
	
  text = '<!DOCTYPE HTML PUBLIC"-//W3C//DTDHTML4.01Transitional//EN"><html><head>'
	text += '<title>' + img_tab[img_index-1].titre_long + '</title>'
	text += '<style>#chap_titre{font-family: "Courier New", Courier, monospace;font-weight:bold;font-size: 20px;color: #EF9696;text-align:left;}'
	text += '#cu_desc{font-family:Verdana,Geneva,Arial,Helvetica,sans-serif;font-size:12px;color: #F2ACAC;text-align:left;}'
	text += '#chap_taille{font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;font-size: 10px;color: #F6C4C4;text-align:left;}'
	text += '#PP{text-align:left;margin-bottom:0px;margin-top:0px;margin-right:0px;margin-left:0px;text-indent:0px;}'
	text += '#img_big{text-align:center;   vertical-align: middle; }</style>'
	text += '<script language="JavaScript">'
	text += 'function change_img(p_img_nb) {	document.img_big.src = (p_img_nb == 1) ? "'+imgBig1+'" : "'+imgBig2+'";}'
	text += '</script>'
	text += '</head>'
	text += '<BODY bgcolor="#000000" LEFTMARGIN="0" TOPMARGIN="0" MARGINHEIGHT="0" MARGINWIDTH="0"> <table summary="" border="0" cellpadding="0" cellspacing="0"><tbody><tr height="5%" bgcolor="#404040"><td colspan="4"><br><div ><span id="chap_titre">'
	text += img_tab[img_index-1].titre_long;
	text += '</span><p id="PP"><span id="cu_desc">';
	text += img_tab[img_index-1].desc;
	text += '</span><p id="PP"><span id="chap_taille">'
	text += img_tab[img_index-1].ref ;
	text += ' </span><p id="PP">'
	if(img_tab[img_index-1].img_nb == 2)
  {
	    text += '<span>' + link1 + "&nbsp;"+ link2 + '</span>';
	}
	text +=  '</div></td><td width="15"></td></tr><tr height="5"  bgcolor="#404040"> <td colspan="5"></td></tr><tr height="20"> <td colspan="5"></td></tr><tr height="4"><td width="15"></td><td colspan="3"  height="6" bgcolor="#ededed"></td><td></td></tr> <tr  height="90%"><td width="15"></td><td width="4" bgcolor="#ededed"></td><td><img id="img_big" name="img_big" src="';
	text += "chapeaux/cu_big" + img_index + ".jpg";
	text += '"></td><td width="4" bgcolor="#ededed"></td><td></td></tr><tr height="25"><td width="15"></td><td colspan="3"  height="6" bgcolor="#ededed"></td><td></td></tr></tbody></table></BODY></HTML>'

//	writedebug(text);


	chapWindow = window.open('','Chapeau','width=720,height=760,screenX=0,screenY=0,resizable=1,toolbar=0,location=0,directories=0,menuBar=0,scrollbars=1'); 
	chapWindow.document.open(); 
	chapWindow.document.write(text); 
	chapWindow.focus(); 

}
