var rub_on="";
page_active ="";
lapage = "";
// ******************* //
function start_navigation(){	
	// LEFT MENU //
	this.menu = document.getElementById("nav");	
	this.menu.onmouseover=new Function("rd()");
	this.menu.onmouseout=new Function("d();");
	this.submenus = this.menu.getElementsByTagName("span");
	for (var i = 0; i < this.submenus.length; i++){			
		this.submenus[i].onmouseover =new Function("hm(true);s('"+this.submenus[i].id+"');");			
		if (document.getElementById("ss_"+this.submenus[i].id)) {			
		document.getElementById("ss_"+this.submenus[i].id).onmouseover=new Function("rd()");
		document.getElementById("ss_"+this.submenus[i].id).onmouseout=new Function("d();");					
		}						
	}// FIN BOUCLE 1 //	
	
	if (document.getElementById("bt_retour")) {
	document.getElementById("bt_retour").onclick= function(){
	window.history.back();
	}
	}
}
// ******************* //

function invi(divID,flag){
	if (document.getElementById("ss_"+divID)) {
	letop = getTop(document.getElementById(divID))+105;
	document.getElementById("ss_"+divID).style.top = letop+"px";	
	document.getElementById("ss_"+divID).style.visibility=(flag)?'hidden':'visible';	
	}		
}


var retd;
var rub_encours="";

function h(i){invi(i,1);}
function s(i){invi(i,0);}
function d(){retd=setTimeout("hm(false)",400);}
function rd(){clearTimeout(retd);
	
}

// ******************* //
function hm(action) {
this.menu = document.getElementById("nav");
this.submenus = this.menu.getElementsByTagName("span");
	for (var i = 0; i < this.submenus.length; i++){
	h(this.submenus[i].id);		
	}		
}
// ******************* //


function getTop(MyObject)  {
    if (MyObject.offsetParent)
        return (MyObject.offsetTop);
    else
        return (MyObject.offsetTop);
}



function GetXmlHttpObject(handler){ 
var objXMLHttp=null
	if (window.XMLHttpRequest){
	objXMLHttp=new XMLHttpRequest()
	}else if (window.ActiveXObject){
	objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
	}
return objXMLHttp
}


num_photo = 1;
function active_nav_photo() {
	if (tab.length-1 > 1) {
	document.getElementById("bt_suivant").style.visibility='visible';
	}
	if (document.getElementById("desc_photo")){
	document.getElementById("desc_photo").innerHTML=tab_desc[1];
	}
	if (document.getElementById("photo_medium")){
		document.getElementById("photo_medium").onclick = function () {		
			if (tab_grande[num_photo]!="") {
			show_zoom ('g-'+tab_grande[num_photo]);
			}
		}
	}
}


function photo_suivante () {
num_photo = num_photo + 1;
if (num_photo==tab.length-1) {
document.getElementById("bt_suivant").style.visibility='hidden';
}
if (num_photo>1) {
document.getElementById("bt_precedent").style.visibility='visible';
}
document.getElementById("photo_medium").src="../img_dyna/m-"+tab[num_photo]+".jpg";
if (tab_grande[num_photo]!='') {
document.getElementById("photo_medium").style.cursor='pointer';
}else {
document.getElementById("photo_medium").style.cursor='default';
}
if (document.getElementById("desc_photo")){
document.getElementById("desc_photo").innerHTML=tab_desc[num_photo];
}
}

function photo_precedente () {
num_photo = num_photo - 1;
if (num_photo==1) {
document.getElementById("bt_precedent").style.visibility='hidden';
}
if (tab.length>1) {
document.getElementById("bt_suivant").style.visibility='visible';
}
document.getElementById("photo_medium").src="../img_dyna/m-"+tab[num_photo]+".jpg";
if (tab_grande[num_photo]!='') {
document.getElementById("photo_medium").style.cursor='pointer';
}else {
document.getElementById("photo_medium").style.cursor='default';
}
if (document.getElementById("desc_photo")){
document.getElementById("desc_photo").innerHTML=tab_desc[num_photo];
}
}

function get_transp (lay) {
if (document.all) {
document.getElementById(lay).style.setAttribute("filter", "alpha(opacity=80);");
}else {
document.getElementById(lay).style.MozOpacity= 0.8;
document.getElementById(lay).style.filter= "alpha(opacity=0.8)";	
}
}

function vide_form(text,lay) {
if (document.getElementById(lay).value == text){
document.getElementById(lay).value ="";
}
}

function affiche_popup (num) {
if (document.getElementById("popup_page")){
document.getElementById("popup_page").style.visibility='visible';
document.getElementById("popup_page").style.display='block';
//document.getElementById("contenu_popup").innerHTML='';
}
}

function ferme_popup(){
if (document.getElementById("popup_page")){
document.getElementById("popup_page").style.visibility='hidden';
document.getElementById("popup_page").style.display='none';
document.getElementById("contenu_popup").innerHTML='';
}
}


function montre_popup(leid,lg) {
texte_popup(leid,lg);
num_popup = 0;
tab_photo= new Array;
tab_texte = new Array;
}

function texte_popup(leid,lg) {

var fadddddd;
clearTimeout(fadddddd);
setOpacity(document.getElementById("popup_page"), 100);
var xmlHttp=GetXmlHttpObject();
if (xmlHttp==null){
alert ("Browser does not support HTTP Request");
return;
} 
document.getElementById("contenu_popup").innerHTML="<div align='center'><br><br><br><br><br><br><br><br><img src='../img_com/loading.gif' alt='' width='20' height='20' border='0'><br>chargement<br><br></div>"; 
document.getElementById("popup_page").style.visibility='visible';
document.getElementById("popup_page").style.display='block';
var url="../_inc/fonc_montre_popup.php";
xmlHttp.onreadystatechange=function() { 
        if (xmlHttp.readyState==4){
            if (xmlHttp.status==200){
              changed_html('contenu_popup',xmlHttp,leid,lg);
			  }
		}
    }
xmlHttp.open("POST",url,true);
xmlHttp.setRequestHeader('Content-type','application/x-www-form-urlencoded'); 
xmlHttp.send("id="+leid+"&lg="+lg+"&sid="+Math.random());
}

function changed_html(lay,dett,leid,lg) {
document.getElementById(lay).innerHTML=dett.responseText; 
photo_popup(leid,lg);
}


function photo_popup(leid,lg) {
var xmlHttp=GetXmlHttpObject();
if (xmlHttp==null){
alert ("Browser does not support HTTP Request");
return;
} 
var url="../_inc/fonc_photo_popup.php";
xmlHttp.onreadystatechange=function() { 
        if (xmlHttp.readyState==4){
            if (xmlHttp.status==200){
              liste_photo_popup(xmlHttp,leid);
			  }
		}
    }
xmlHttp.open("POST",url,true);
xmlHttp.setRequestHeader('Content-type','application/x-www-form-urlencoded'); 
xmlHttp.send("id="+leid+"&lg="+lg+"&sid="+Math.random());
}
num_popup = 0;
tab_photo= new Array;
tab_texte = new Array;
function liste_photo_popup(cont_photo,leid) {
tab_total = cont_photo.responseText.split("##;");
tab_photo.length = 0;
tab_texte .length = 0;
//document.getElementById('contenu_popup').innerHTML=cont_photo.responseText;

tab_photo = tab_total[0].split("==");
tab_texte = tab_total[1].split("==");

document.getElementById("texte_photo_popup").innerHTML=tab_texte[0];
document.getElementById("gr_photo_popup").src="../img_dyna/g-"+tab_photo[0]+".jpg";
if (tab_photo.length > 1) {
document.getElementById("bt_popup_suivant").style.visibility='visible';
}

}

function photo_popup_suivante () {
num_popup = num_popup + 1;
if (num_popup==tab_photo.length-1) {
document.getElementById("bt_popup_suivant").style.visibility='hidden';
}
if (num_popup>0) {
document.getElementById("bt_popup_precedent").style.visibility='visible';
}

if (tab_photo[num_popup]!="") {
document.getElementById("gr_photo_popup").src="../img_dyna/g-"+tab_photo[num_popup]+".jpg";
if (document.getElementById("texte_photo_popup")){
document.getElementById("texte_photo_popup").innerHTML=tab_texte[num_popup];
}
}


}

function photo_popup_precedente () {
num_popup = num_popup - 1;
if (num_popup==0) {
document.getElementById("bt_popup_precedent").style.visibility='hidden';
}
if (tab_photo.length>1) {
document.getElementById("bt_popup_suivant").style.visibility='visible';
}
if (tab_photo[num_popup]!="") {
document.getElementById("gr_photo_popup").src="../img_dyna/g-"+tab_photo[num_popup]+".jpg";
if (document.getElementById("texte_photo_popup")){
document.getElementById("texte_photo_popup").innerHTML=tab_texte[num_popup];
}
}
}



// ********************* FIN AJAX HOME ACTU ************************//

function setOpacity(obj, opacity) {
  opacity = (opacity == 100)?100:opacity;
  
  // IE/Win
  obj.style.filter = "alpha(opacity:"+opacity+")";
  
  // Safari<1.2, Konqueror
  obj.style.KHTMLOpacity = opacity/100;
  
  // Older Mozilla and Firefox
  obj.style.MozOpacity = opacity/100;
  
  // Safari 1.2, newer Firefox and Mozilla, CSS3
  obj.style.opacity = opacity/100;
}


function fadeIn(objId,opacity) {
  if (document.getElementById) {
    obj = document.getElementById(objId);
    if (opacity <= 100) {
      setOpacity(obj, opacity);
      opacity += 4;
	  fadddddd =  window.setTimeout("fadeIn('"+objId+"',"+opacity+")", 20);
    }else {
	clearTimeout(fadddddd);
	setOpacity(obj, 100);
	}
  }
}

function fadeOut(objId,opacity) {
  if (document.getElementById) {
    obj = document.getElementById(objId);
    if (opacity >0) {
      setOpacity(obj, opacity);
      opacity -= 2;
	  fadddddd =  window.setTimeout("fadeOut('"+objId+"',"+opacity+")", 50);
    }else {
	clearTimeout(fadddddd);
	setOpacity(obj, 0);
	}
  }
}


// Ouvre fenetre //
function OW(theURL,winName,features) {
  window.open(theURL,winName,features);
}



function add_panier(leid,liste_panier) {
var xmlHttp=GetXmlHttpObject();
if (xmlHttp==null){
alert ("Browser does not support HTTP Request");
return;
} 
var url="../_inc/add_caddie.php";
xmlHttp.onreadystatechange=function() { 
        if (xmlHttp.readyState==4){
            if (xmlHttp.status==200){
              statut_panier(liste_panier);
			  }
		}
    }
xmlHttp.open("POST",url,true);
xmlHttp.setRequestHeader('Content-type','application/x-www-form-urlencoded'); 
xmlHttp.send("id_prod="+leid+"&liste_panier="+liste_panier+"&sid="+Math.random());
}

function statut_panier(liste_panier) {
document.getElementById("affiche_change_panier").style.visibility="visible";
fadeOut("affiche_change_panier",100);
}

function ouvre_login () {
document.getElementById('identif_user').style.visibility= "visible";
}

function fermer_login () {
document.getElementById('identif_user').style.visibility= "hidden";
}

function show_zoom (id_image) {
if (document.getElementById("zoom")) {	
	document.getElementById("cache_zoom").style.visibility ="visible";	
	document.getElementById("zoom").style.visibility ="visible";
	document.getElementById("zoom_centre").innerHTML='<br><br><br><br><br><br><br><br><br><br><img src="../img_com/loading.gif" width="20" height="20" alt=""><br><br><br><br><br><br><br><br><br><br><br>';
	scrollTo(0,0);
	alertSize("cache_zoom");
	change_zoom (id_image);
	}
}

function alertSize(lay) {
	myHeight = 0;
	taille_doc = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myHeight = window.innerHeight;
	taille_doc = document.body.clientHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myHeight = document.documentElement.clientHeight;
	taille_doc = document.body.clientHeight;
  }
  if (myHeight > taille_doc) {
  document.getElementById(lay).style.height = myHeight+"px";
  }else {
  document.getElementById(lay).style.height = taille_doc+"px";
  }
  
}

function close_zoom (lay) {
document.getElementById("cache_zoom").style.visibility ="hidden";
document.getElementById(lay).style.visibility ="hidden";
id_image ="";
}

function change_zoom (id_image) {
var theimage;
theimage ="";
theimage = new Image;
theimage.src = "../img_dyna/"+id_image+".jpg";
	if (theimage.complete){
	initImage(theimage);
	} else {
		theimage.onload = function () {		
		initImage(theimage);
		}
	}
}

// FADE HOME ACTU //
function initImage(theimage) {
  imageId = 'zoom_centre';
  image = document.getElementById(imageId);
  setOpacity(image, 0);
  //image.style.visibility = 'visible';
  document.getElementById("zoom_centre").innerHTML = '<div><img src="../img_com/vide.gif" name="zoom_image" id="zoom_image" Onclick="close_zoom (\'zoom\');" title="Cliquez pour fermer la photo" alt="Cliquez pour fermer la photo"></div>';
  document.images['zoom_image'].src=theimage.src
fadeIn(imageId,0);
}

function change_flash(flash) {
if (old_flash!="") {
document.getElementById(old_flash).className = "";
}
document.getElementById("adatpation_flash").innerHTML ='<object type="application/x-shockwave-flash" width="542" height="375" data="flash/'+flash+'.swf"><param name="movie" value="flash/'+flash+'.swf" /><param name="quality" value="high" /><param name="wmode" value="transparent" /></object>';
document.getElementById(flash).className = "swf_on";
old_flash = flash;
}











