
//--------------------------------------------------------------------------------------------------------------------- Initialisation des pages
function loadedPage(oPage){
 switch(oPage){
  case "frmIndex":
  _wallPaper= document.getElementById("wallPaper"); 
  _bigCaddy = document.getElementById("bigCaddy"); 
  _footFrame= document.getElementById("footFrame");  
  _headFrame= document.getElementById("headFrame");  
  _mainFrame= document.getElementById("mainFrame"); 
  _menuFrame= document.getElementById("menuFrame"); 
  _moveFrame= document.getElementById("moveFrame");
  _statusBar= document.getElementById("statusBar");
//   
   resizePage(oPage); quickMenu("mainFrame"); parseItem();
//
  _wallPaper.style.visibility= "visible"; 
  _footFrame.style.visibility= "visible";
  _statusBar.style.visibility= "visible"; 
  _menuFrame.style.visibility= "visible";
  _headFrame.style.visibility= "visible";
//   
 break;
//
 case "boutique":
		resizePage(oPage);
		parent.quickMenu("mainFrame")			
	break;
//
 case "eContact":
  resizePage(oPage);
  var monPanier = top.monPanier;  
  var totArticle = top.totArticle;
		parent._mainFrame.style.visibility = "visible";
	 try{parent.swPrint.style.visibility = "hidden"} catch(noIz){};  
 if (top.totArticle){
  var text = spaTEXT;
  var moneyCash = top.moneyCash;
  for (i=0; i<totArticle; i++){
   document.getElementById("bonCmde").value =
   text= text+monPanier[i][2]+monPanier[i][3]+", "+monPanier[i][5]+" à "+monPanier[i][4].toFixed(2)+moneyCash[0][3]+retTEXT; }
  document.getElementById("panoCmde").style.visibility = "visible"; }
		else{ document.getElementById("panoCmde").style.visibility = "hidden";}	
  break;
 }
}
//
//--------------------------------------------------------------------------------------------------------------------- Dimensionnement des pages
function resizePage(oPage){
 switch(oPage){
  case "frmIndex":
// 
 scrLarg = screen.availWidth;
 scrHaut = screen.availHeight;
 winLarg = document.body.clientWidth;
 winHaut = document.body.clientHeight;
 if((winLarg<1000)||(winHaut<800)){try{self.resizeTo(1100,870);} catch(izIE){""}; }
//
 menuHaut = winHaut - menu_Top - footHaut;
	mainLeft = menuLarg + 70;
	((mainLeft <= menuLarg)? mainLeft = menuLarg:'');
   with(_wallPaper.style){top= 0; left= 0; width= winLarg; height= winHaut;};
   with(_footFrame.style){top= winHaut-50; left= 0; width= winLarg; height= 50};
   with(_headFrame.style){top= head_Top; left= mainLeft; width= 490; height= 70};
   with(_menuFrame.style){top= menu_Top; left=0; width= menuLarg; height= menuHaut-50;};
   with(_mainFrame.style){top= main_Top; left= mainLeft ; width= mainLarg; height= mainHaut;};
   if(izClic==false){
    with(_moveFrame.style){left= scrLarg; width= fly_Larg; height = fly_Haut};
   }else{
    if(winLarg<fly_Larg){fly_Larg = winLarg};    
    fly_Left = winLarg - fly_Larg - 20;
    fly_Top = (winHaut - 25) - (fly_Haut + footHaut);
    with(_moveFrame.style){left= fly_Left; top= fly_Top; width= fly_Larg};
   }
  break;
//
  case "boutique":
			with(document.getElementById("mainFrame").style){ top= 70;	left= (document.body.clientWidth -500)/2; width= 500};
		break;
//
  case "eContact":
			with(document.getElementById("pageName").style){top=10; left=15;}; 
   with(document.getElementById("panoPost").style){top= 40; left=65; width= 620; height= parent.mainHaut -100;};
			if (document.body.clientWidth>900){
   	with(document.getElementById("panoText01").style){top=20; left= 700} 
   	with(document.getElementById("panoText02").style){top=190;left= 730}
			} else{
			 document.body.style.overflow= "hidden";
				with(document.getElementById("panoText01").style){top=20; left= document.body.clientWidth + 20;} 
   	with(document.getElementById("panoText02").style){top=190;left= document.body.clientWidth + 20;}
			}
  break;
 }
}
//
//--------------------------------------------------------------------------------------------------------------------- Chargement menu images 
function quickMenu(oLayer){
 var oIndex = 0
 var nbImag = listArray.length;
 cellsByRow = Math.round(mainLarg/cellLarg);
 var nbRows = Math.ceil(listArray.length/cellsByRow);
//
//--- Création tableau
 document.getElementById(oLayer).innerHTML =
  '<table id="tabThumbs" width="100%" cellspacing="0" cellpadding="0" align="center" border="0"><tr><td align="center" width="130" height="0"></td></tr></table>'; var myConteneur = document.getElementById("tabThumbs");  
//--- Nettoyage tableau
 for(i= myConteneur.rows.length; i<0; i--){myConteneur.deleteRow(-1)}
//--- Insertion vignettes
 for (i=1; i<=nbRows; i++){
  newRow= myConteneur.insertRow(-1); newRow.style.height = cellHaut;
  for(j=0; j<cellsByRow; j++){
   var oTarg = "targ_"+oIndex;
   var oName = listArray[oIndex][0];
   var oMini = listArray[oIndex][1];
   if(oMini){
    newCell= newRow.insertCell(-1); newCell.align= "center"; with(newCell.style){width= cellLarg; height= cellHaut;};
    newCell.innerHTML=
    '<table id='+oName+' border="0" align="center" cellpadding="0" cellspacing="0">'+
//--- Calque Image / swf  ( vignette )  
    '<tr><td height="130" onmouseOut="swMenus('+oIndex+',this,0)" onmouseOver="swMenus('+oIndex+',this,1)" onmouseup="swMenus('+oIndex+',this,3)">'+
    '<div style="position:relative" id='+oTarg+' align="center"></div></td></tr>'+
//--- Séparation
    '<tr><td height="7"></td></tr>'+
//--- Tableau Etiquette nom Fiche + Caddy      
    '<tr><td><table width="170" height="20" border="0" align="center" cellpadding="0" cellspacing="0">'+
    '<tr><td background="images/skin00/fonds/textBack.png" class="url_Out" onmouseOut="swMenus('+oIndex+',this,0)" onmouseOver="swMenus('+oIndex+',this,1)" '+
    'onClick="swMenus('+oIndex+',this,4)">&nbsp;'+oName+
    '<td width="20" valign="bottom" class="urlOver">'+
    '<img src='+oImage[14]+' alt='+my_Text[5]+' onmouseOver="_statusBar.innerHTML= my_Text[20]" onClick="swMenus('+oIndex+',this,5)">'+
    '</td></tr></table></td></tr><tr><td height="30"></td></tr></table>';
//--- Insertion dynamique vignette Flash
    put_SWF(oMini, oName, oTarg, 1, 170, 130, oIndex);
//--- Fin d'installation des vignettes
   }
   oIndex++; if(oIndex >= nbImag){ newCell= newRow.insertCell(-1); newCell.id = "emptyLastCell"; break};
  }
 }
 _mainFrame.style.visibility = "visible";
}
//
//--------------------------------------------------------------------------------------------------------------------- Préparation de tableau
function parseItem(){
//
 openItem = keyCode[91].split("|")[0];// [
 clozItem = keyCode[93].split("|")[0];// ]
//  
 for (i=0; i<listArray.length; i++){
  dataFiche[i] = listArray[i][7];
  item_Data = dataFiche[i].split(openItem);
  for(j=1; j<item_Data.length; j++){ item_Data[j] = item_Data[j].split(clozItem); }
  dataFiche[i]= item_Data;}  
}
//
//--------------------------------------------------------------------------------------------------------------------- switcher
function swMenus(oIndex, oObjet, oMode){//openPage('+oPage+',10,0)
// case 1: Mouse over
// case 2: Mouse down
// case 3: Mouse up 
// case 4: Mouse Click
 switch(oMode){
 case 0:
  if(izClic ==true){break;}; 
  if(izClic == false){ 
   _statusBar.innerHTML= "";    
   _statusBar.className= "flash02";
   izOver = false; izShow= false; oObjet.className= "url_Out";
   while (_moveFrame.firstChild) {_moveFrame.removeChild(_moveFrame.firstChild);}
   with(_moveFrame.style){left = scrLarg; visibility = "hidden"; };};
 break;
//---
 case 1:
  if((izOver==true)||(izClic==true)){break;};  
  izOver = true; screenMod = 0; oObjet.className= "urlOver";
  _statusBar.className= "flash01";
  _statusBar.innerHTML= my_Text[20];
 break;
 case 2: break;
 case 3: openPage(oIndex,10,2); break;
 case 4: izClic= true; screenMod= 1; loadFiche(oIndex, 0); break;
 case 5: izClic= true; screenMod= 2; loadFiche(oIndex, 0); break; 
 }
}
//--------------------------------------------------------------------------------------------------------------------- 
function showFlyer(oLeft, oTop, oLarg, oHaut, oMode){//--- X, Y, Largeur, Hauteur, mode
 switch(oMode){
  case 0:  
   fly_Larg= oLarg; fly_Haut= oHaut;
   fly_Left= (winLarg - 20) - fly_Larg ;
   fly_Top = (winHaut - 30) - (fly_Haut + footHaut);
//---
   try{ _X = event.clientX; _Y= event.clientY; } catch(idBrowser){ _X = 0; _Y = 0; fly_Left = fly_Left - 20 ; fly_Top = fly_Top - 30; };
   if( (_X >= fly_Left) && (_Y>= fly_Top) ) {fly_Top = 70};
  break;
  case 1:
   CallByClick = true; izClic = true;
   fly_Top = (winHaut - 25) - (fly_Haut + footHaut);		
   fly_Left= winLarg - fly_Larg - 20; fly_Top= oTop; fly_Larg= oLarg; fly_Haut= oHaut; break
 }
 with(_moveFrame.style){visibility= "visible"; top= fly_Top; left= fly_Left; height= fly_Haut; width= fly_Larg;}; 
}
//
//--------------------------------------------------------------------------------------------------------------------- 
function hideFlyer(oMode){
 switch(oMode){
  case 0:
   try{document.getElementById("fly_Cache").style.visibility="hidden"}catch(izHide){};
   break;
  case 1:
   CallByClick = false; izClic = false;
			_mainFrame.style.visibility = "visible";	
   var fly_Larg = 500, fly_Haut = 300, fly_Left = scrLarg, fly_Top = scrHaut;
   with(_moveFrame.style){visibility= "hidden"; top= fly_Top; left= fly_Left; height= fly_Haut; width= fly_Larg;};
  break;
 }
}
//
//--------------------------------------------------------------------------------------------------------------------- 
function openPage(idxPage, idxFrame, openMode){
//
	switch(openMode){
		case 0:// by flash Menu
		 var urlPage = oPages[idxPage];
			var _Target = document.getElementById(oFrame[idxFrame]);
//
			_Target.style.visibility = "hidden";
			mainHaut = winHaut -( main_Top + footHaut + 15 ); 
			_Target.innerHTML = '<iframe id ="newFrame" src= '+urlPage+' width="100%" height="100%"></iframe>';
 		with(	_Target.style){top= main_Top - 10; left= mainLeft ; width= mainLarg; height= mainHaut;};
		break;
  case 1://--- Ouverture mode fenétré / url dans oPages: 
			var urlPage = oPages[idxPage];
			draw_Flyer(urlPage, idxFrame);
			_statusBar.className= "flash00";
//
		break; 
		case 2://--- Ouverture mode fenétré / url dans listArray:  	
			var urlPage = listArray[idxPage][3];
			draw_Flyer(urlPage, idxFrame);
		break;
 }
}
//
//---------------------------------------------------------------------------------------------------------------------
function draw_Flyer(urlPage, idxFrame){
		var urlFond = "_flash/scr_Label.swf";
		fly_Haut = winHaut - footHaut; fly_Larg = winLarg - 50; fly_Left = (winLarg - fly_Haut)/2; 
//--- Nettoyage
 		while (_moveFrame.firstChild) {_moveFrame.removeChild(_moveFrame.firstChild);};
//--- Création & insertion iFrame
 		_moveFrame.innerHTML = 
 		'<table width="100%" height="99%" border="0" cellpadding="0" cellspacing="0"><tr><td height="17">'+
 		'<table align ="right" border="0" cellspacing="0" cellpadding="0"><tr>'+
 		'<td valign="top" width="13"></td><td valign="top" width="13"></td><td valign="top" width="13"></td>'+
 		'<td width="13" height="13"><img src='+oImage[0]+' width="13" height="13" class="urlOver" onClick="hideFlyer(1)">'+
 		'</td></tr></table></td></tr><tr><td><iframe id="inFrame"></iframe></td></tr><tr><td height="17">'+
 		'<table height="15" align="right" border="0" cellpadding="0" cellspacing="0"><tr>'+
 		'<td valign="top" width="1"></td>'+
 		'<td id="swPrint" align="middle" class="urlOver" bgcolor="#333333" width="70" '+
			'onClick="toPrint(_moveFrame)">'+my_Text[99]+'</td>'+// switch: Imprimer la Page
 		'<td valign="top" width="1"></td>'+// Séparation verticale
 		'<td id="swClose" align="middle" class="urlOver" bgcolor="#333333" width="70" '+
			'onClick="top.hideFlyer(1)">'+my_Text[101]+'</td>'+// switch: Fermer la Page
 		'</tr></table></td></tr></table>';
		 with(document.getElementById("inFrame")){ src= urlPage; style.width= "100%"; style.height= "100%"; style.border= "none";}
//			
	  showFlyer(fly_Left,0,fly_Larg,fly_Haut,1); // X, Y, Largeur, Hauteur, mode pleine page 
//
}
//
//--------------------------------------------------------------------------------------------------------------------- Chargement animation flash
function put_SWF(oRoot, oName, oTarg, oMode, oLarg, oHaut, oIndex ){// Objet, Index(, Mode,
//
 var intTop = oRoot.indexOf("/",0)+1;
 var intEnd = oRoot.indexOf(".",intTop);
 var urlSWF = oRoot.slice(0,intEnd);
 var id_SWF = oRoot.slice(0,intEnd);                                                                              
//
 switch (oMode){
//--- Utilise AC code  
  case 0:
   AC_FL_RunContent(
   'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0',
   'pluginspage', 'http://www.macromedia.com/go/put_SWFplayer',
   'src',urlSWF,'id',oName,'name',oName,'movie',urlSWF,
   'allowScriptAccess','sameDomain',
   'allowFullScreen', 'true',
   'wmode', 'transparent',
   'devicefont', 'false',
   'bgcolor', '#000000',
   'scale', 'showall',
   'quality', 'high',
   'align', 'middle',
   'height', '100%',
   'width', '100%',
   'menu', 'true',
   'play', 'true'
   );
  break;
//--- Utilise swfobject Code
  case 1:
   var attributes = { }; 
   var params = {
    loop: "0",
    quality: "high",
    wmode: "transparent"
   };
   if (oIndex == -1){
    var flashvars = {oArticle:listArray[indexFiche][0], _Larg:oLarg, _Haut:oHaut};
   } else {
    var flashvars = {idxTablo:oIndex, itemRoot:listArray[oIndex][6], _Larg:oLarg, _Haut:oHaut};
   }// expressInstallSwfurl, flashvars, params, attributes
   return swfobject.embedSWF(oRoot, oTarg, oLarg, oHaut, "9.0.0","http://www.macromedia.com/go/put_SWFplayer", flashvars, params, attributes);
  break;
 }
}
// ---------------------------------  Cmde  Achats: Ajout panier
function addPart(oIndex, oMode){
// document.getElementById("zoToBuy").style.visibility = "visible";
// document.getElementById("zoCodes").style.visibility = "visible";
// document.getElementById("swCaddy").style.visibility = "hidden"; 
 hideFlyer(1);
 
}

function add2Buy(oMode){
//  monPanier[x][0] => Index liste article
//  monPanier[x][1] => Désignation  et type
//  monPanier[x][2] => Réference de commande
//  monPanier[x][3] => Prix unité (format texte)
//  monPanier[x][4] => Quantité commandée
 var in_monCaddy = false;
 switch (oMode){
  case false:
    if(countPart>1){_statusBar.innerHTML= my_Text[8] + countPart + " " + oTitre
   } else {_statusBar.innerHTML= my_Text[8] + countPart + " " + oTitre}
  break; 
//
  case true:
   if(countPart==0){ break;}; // pas de quantité donnée.
   _statusBar.className = "flash00"; _statusBar.innerHTML = my_Text[11];
//--- Ajout / vérification doublon
   totArticle = monPanier.length;
   if (totArticle==1){// Pas d'article ajouté, index 0   
    monPanier[totArticle] = new Array();
    for(j=0; j<monPanier[0].length; j++){ monPanier[totArticle][j] = monPanier[0][j]};
    alert(my_Text[12] + monPanier[0][2]);
   } else {
//--- Vérification Référence déjà existante dans le panier   
    for(i=1; i<totArticle; i++){
      if(monPanier[i][3]==monPanier[0][3]){
      monPanier[i][5] = monPanier[i][5] + monPanier[0][5]; alert(my_Text[13] + monPanier[i][2]); in_monCaddy = true;}
    if (in_monCaddy == false){ 
      monPanier[totArticle] = new Array(); for(j=0; j<monPanier[0].length; j++){ monPanier[totArticle][j] = monPanier[0][j]}; alert(my_Text[12] + monPanier[0][2]);}
  }};
  _monCaddy.className = "buyOver";
  countPart=0; _zoQuanta.value = countPart;
  document.getElementById("goToBuy").className="url_Out";
  _monCaddy.style.backgroundImage= "url("+oImage[16]+")"; 
  _statusBar.className = "flash02"; _statusBar.innerHTML = ""; 
  totArticle = monPanier.length - 1; _monCaddy.innerHTML = totArticle;
  _bigCaddy.className = "buyOver";_bigCaddy.style.visibility= "visible";   
  break;
 }
}
//
function toPrint(oFrame){
 oFrame.focus();
		document.frames("inFrame").document.getElementById("cssLink").href= "../include/forPrinting.css";
	 document.frames("inFrame").focus(); window.print();
		document.frames("inFrame").document.getElementById("cssLink").href= "../include/upperStyle.css";
}
//
//--------------------------------------------------------------------------------------------------------------------- Fin des porocédures