document.write('<div id="transp" style="position:absolute;display:none;z-index:800;"></div>');
document.write('<div id="divbulle" style="position:absolute;display:none;z-index:250;width:300px;height:160px;margin:5px;margin-top:14px;margin-bottom:14px !important;	margin:5px;background-image:url(/script/cadre.php?S=imgarroncote&W=300&H=160&C=000000);background-position:center;background-repeat:repeat-y;border:0px solid black;text-decoration:none;"><div style=""><div id="id2309039" style="float:right;width:295px;height:155px;margin:2px;margin-top:11px;	margin-bottom:11px !important;	margin:2px;background-image:url(/script/cadre.php?S=imgarroncote&W=295&H=155&C=DBDBDB);background-position:center;background-repeat:repeat-y;border:0px solid black;text-decoration:none;"><div style="padding:2px;"><div style="text-align:center;margin:3px;"><span style="font-family:Arial;font-size:16px;color:#2D2C22;font-weight:bold;" id="">AJOUT DANS LE PANIER</span></div><center><div id="id2337557" style="background-color:#000000;width:240px;height:2px;" onmouseover="" onmouseout="" onclick=""><div style=""><div style="clear:both;"></div></div></div></center><br style="clear:both;"><div style="text-align:center;margin:3px;"><span style="font-family:Arial;font-size:12px;color:#2D2C22;font-weight:bold;" id="">Vous venez d\'ajouter dans votre panier :</span></div><div style="text-align:center;margin:3px;"><span style="font-family:Arial;font-size:16px;color:#FF0000;font-weight:bold;" id="AjoutePanier"></span></div><br style="clear:both;"><div id="id2337715" style="float:left;width:300px;height:auto;" onmouseover="" onmouseout="" onclick=""><div style=""><div style="float:left;width:110px;height:30px;margin:5px;margin-top:14px;margin-bottom:14px !important;margin:5px;cursor : pointer;background-image:url(/script/cadre.php?S=imgarroncote&W=110&H=30&C=999999);background-position:center;background-repeat:repeat-y;border:0px solid black;text-decoration:none;cursor:pointer;" onmouseover="this.style.backgroundImage=\'url(/script/cadre.php?S=imgarroncote&W=110&H=30&C=000000)\';" onmouseout="this.style.backgroundImage=\'url(/script/cadre.php?S=imgarroncote&W=110&H=30&C=999999)\';" onclick="javascript:hideAjoutPanier();"><div style=""><div id="id2337751" style="float:right;width:105px;height:25px;margin:2px;margin-top:11px;margin-bottom:11px !important;margin:2px;background-image:url(/script/cadre.php?S=imgarroncote&W=105&H=25&C=D0CFC2);background-position:center;background-repeat:repeat-y;border:0px solid black;text-decoration:none;" onmouseover="this.style.backgroundImage=\'url(/script/cadre.php?S=imgarroncote&W=105&H=25&C=FFFFFF)\';" onmouseout="this.style.backgroundImage=\'url(/script/cadre.php?S=imgarroncote&W=105&H=25&C=D0CFC2)\';">	<div style="padding:2px;"><div style="text-align:center;margin:3px;"><span style="font-family:Arial;font-size:12px;color:#2D2C22;font-weight:bold;" id="">&#x25BA;&#x20;Continuer</span></div><div style="clear:both;"></div></div>	</div><div style="clear:both;"></div></div></div><div id="id2337792" style="float:left;width:50px;height:20px;" onmouseover="" onmouseout="" onclick=""><div style=""><div style="clear:both;"></div></div></div><div  style="float:left;width:110px;height:30px;margin:5px;	margin-top:14px;margin-bottom:14px !important;margin:5px;cursor : pointer;background-image:url(/script/cadre.php?S=imgarroncote&W=110&H=30&C=999999);background-position:center;background-repeat:repeat-y;border:0px solid black;text-decoration:none;" onmouseover="this.style.backgroundImage=\'url(/script/cadre.php?S=imgarroncote&W=110&H=30&C=000000)\';" onmouseout="this.style.backgroundImage=\'url(/script/cadre.php?S=imgarroncote&W=110&H=30&C=999999)\';"  onclick="javascript:redirect();"><div style=""><div style="float:right;width:105px;height:25px;margin:2px;margin-top:11px;margin-bottom:11px !important;margin:2px;background-image:url(/script/cadre.php?S=imgarroncote&W=105&H=25&C=D0CFC2);background-position:center;background-repeat:repeat-y;border:0px solid black;text-decoration:none;" onmouseover="this.style.backgroundImage=\'url(/script/cadre.php?S=imgarroncote&W=105&H=25&C=FFFFFF)\';" onmouseout="this.style.backgroundImage=\'url(/script/cadre.php?S=imgarroncote&W=105&H=25&C=D0CFC2)\';" onclick=""><div style="padding:2px;"><div style="text-align:center;margin:3px;"><span style="font-family:Arial;font-size:12px;color:#2D2C22;font-weight:bold;" id="">&#x25BA;&#x20;Mon panier</span></div><div style="clear:both;"></div></div></div><div style="clear:both;"></div></div></div><div style="clear:both;"></div></div></div><div style="clear:both;"></div></div></div><div style="clear:both;"> </div></div></div>');
document.write('<div id="transp2" style="position:absolute;display:none;z-index:200;"></div>');


heavyImage = new Image();
heavyImage.src = "https://www2.photim.com/includes/ajax-loader.gif";

function envoiAttente() { 
	  	 
	var largeur = screen.width/2;
	var el = document.getElementById("transp");
	var hauteur;
				 
   	// firefox is ok
	var hauteur = document.documentElement.scrollHeight;
	
	// now IE 7 + Opera with "min window"
	if(document.documentElement.clientHeight > hauteur ) {
		hauteur  = document.documentElement.clientHeight;
	}
	// last for safari
	if(document.body.scrollHeight > hauteur) {
		hauteur = document.body.scrollHeight;
	}

	
	var height=0;
	if (self.innerHeight) // all except Explorer
	{
		height = self.innerHeight;
	}
	else {
		if (document.documentElement && document.documentElement.clientHeight) // Explorer 6 Strict Mode
		{
			height = document.documentElement.clientHeight;
		}
		else {
			if (document.body) // other Explorers
			{
				height = document.body.clientHeight;
			}
		}
	}
	//alert(height); 
	
	
	var offsetY =0;
	if (self.pageYOffset) // all except Explorer
	{
		offsetY = self.pageYOffset;
	}
	else {
		if (document.documentElement && document.documentElement.scrollTop)				// Explorer 6 Strict
		{
			offsetY = document.documentElement.scrollTop;
		}
		else {
			if (document.body) // all other Explorers
			{
				offsetY = document.body.scrollTop;
			}
		}
	}
	//alert(offsetY); 

	var PosX = parseInt((height+offsetY)/2);
	
			
	
 	if (el) { 
		el.style.height = hauteur+"px";
		el.style.width = "100%";
		el.style.display = 'block';
		 	
		var strChUserAgent = navigator.userAgent;
		var intSplitStart = strChUserAgent.indexOf("(",0);
		var intSplitEnd = strChUserAgent.indexOf(")",0);
		var strChMid = strChUserAgent.substring(intSplitStart, intSplitEnd);
		
		if(strChMid.indexOf("MSIE 6") != -1) {
					 
			var frame = document.createElement("iframe");   
			frame.setAttribute("id","myframe");
			frame.setAttribute("src","http://www2.photim.com/NewCmd/test.html");
			frame.setAttribute("width",screen.width+"px");
			frame.setAttribute("height","100%");
			frame.setAttribute("style","display:none;");
			frame.setAttribute("scrolling","no");
			frame.setAttribute("marginwidth","0");
			frame.setAttribute("marginheight","0");
			frame.setAttribute("frameborder","0");
			frame.setAttribute("vspace","0");
			frame.setAttribute("hspace","0");
			el.appendChild(frame);
			 
			 
		}
		 
	}
    
	var img = document.createElement('img');
	img.setAttribute('src', 'https://www2.photim.com/includes/ajax-loader.gif')
	img.setAttribute('id', 'imgattente');
	img.setAttribute('width', '32px');
	img.setAttribute('height', '32px');
	img.style.display = 'block';
 	img.style.position = 'absolute';
	img.style.top  = PosX+'px';
	img.style.left = largeur + 'px';
	el.appendChild(img);
} 

		
function Ajouter2Panier(Arti,Qte)
{
	if (document.cookie.length==0)
		window.location.href="nocookies.xml";
	else
		AjoutePhp(Arti);
}

function RefreshLigPanier(Qte)
{ 
	if (Qte>1)
 		var msg = " Lignes dans le panier";
 	else
 		var msg = " Ligne dans le panier";	
 	 
  
 	/*var noeud = document.getElementById('nb_panier');
    while (noeud.childNodes.length>0) 
    {
		noeud.removeChild(noeud.firstChild);
		alert("toto");
	}
	document.getElementById("nb_panier").innerHTML = "";
	document.getElementById("nb_panier").innerHTML = Qte + msg;*/
 	
 	var noeud = document.getElementById('panier');
    while (noeud.childNodes.length>0) 
    {
		noeud.removeChild(noeud.firstChild);
	}
	
	var divParent = document.getElementById('panier');
	var nouveauLabel = document.createElement('span');
	nouveauLabel.id = "lab_panier" ;
	nouveauLabel.appendChild(document.createTextNode(Qte + msg));
	divParent.appendChild(nouveauLabel);
	
	document.getElementById("lab_panier").style.color = "#C0B091" ;
	document.getElementById("lab_panier").style.fontWeight  = "bold";
	document.getElementById("lab_panier").style.fontSize  = "12px";
	document.getElementById("lab_panier").style.textAlign  = "center";
	document.getElementById("lab_panier").style.marginTop  = "5px";
	 
	
 	
}


function hideAjoutPanier()
{
	if (document.getElementById)
	{
		document.getElementById("divbulle").style.display = "none" ;
	}
	
	var noeud=document.getElementById('AjoutePanier');
    while (noeud.childNodes.length>0) 
    {
		noeud.removeChild(noeud.firstChild);
	}
	
	if (el = document.getElementById("transp")) {
		el.style.display = 'none';
		el.style.height = "1px";
		el.style.width =  "1px";
	}
}

function AjouterOldPanier(Arti)
{
	ChUrl = 'http://www2.photim.com/NewCmd/ajoute.xml?R=' + escape(Arti) + '&N=1' + '&Id=' + document.getElementById("xf_field_model_menugauche0_id").value ;
	ChParams = 'width=300, height=220, toolbar=0, location=0, directories=0, scrollbars=0, resizeable=0, copyhistory=0 menubar=0' ;
	window.open (ChUrl,'AjPanier',ChParams) ;
}

function AjouterNewPanier(Arti,Retour)
{
	var hauteur;
	var Qte = 1;
	
	if (window.innerHeight && window.scrollMaxY) 
		hauteur = window.innerHeight + window.scrollMaxY;  
 	else if (document.body && document.body.offsetHeight) 
 		hauteur = document.body.offsetHeight;
 		
	var el = document.getElementById("transp");
		
	if (el) {
		el.style.height = hauteur + "px";
		el.style.width = "100%";
		el.style.display = 'block';
	}
	
	var div = document.getElementById("divbulle");
	if (div)
	{
		var div = document.getElementById("divbulle");
		div.style.display="block";
		
		var X=posX;
		if (X>680)
			X = 680 ;
		
        var Y=(posY+20)-300;
        if (Y<=0)
        	Y = 20;
          
       	div.style.top=Y+"px";
        div.style.left=X+"px";
        
        scrollTo(X,Y);
        
        switch(Retour)
        {
        	case ("-1"):
        		document.getElementById("txt_ajout").innerHTML    =  "Impossible d'ajouter dans votre panier :";
        		document.getElementById("AjoutePanier").innerHTML =  "Article incohérent !";
        		break;
        	case ("-2"):
        		document.getElementById("txt_ajout").innerHTML    =  "Impossible d'ajouter dans votre panier :";
        		document.getElementById("AjoutePanier").innerHTML =  "Article inconnu !";
        		break;
        	case ("-9"):
        		document.getElementById("txt_ajout").innerHTML    =  "Impossible d'ajouter dans votre panier :";
        		document.getElementById("AjoutePanier").innerHTML =  "Abonnement ou Annonces présent";
        		break;
        	case ("-10"):
        		document.getElementById("txt_ajout").innerHTML    =  "Impossible d'ajouter dans votre panier :";
        		document.getElementById("AjoutePanier").innerHTML =  "Erreur ";
        		break;
        	case ("-20"):
        		document.getElementById("txt_ajout").innerHTML    =  "Impossible d'ajouter dans votre panier :";
        		document.getElementById("AjoutePanier").innerHTML =  "Erreur de création du panier";
        		break;
        	default:
        		 document.getElementById("AjoutePanier").innerHTML =  Qte + " X " + Arti.replace(/&/g,'&amp;');
        }
       	       	
       	document.getElementById("Affic_Panier").style.display =  'block'; 
  	}
}

function AjoutePhp(Arti)
{  
	var xhr_object = null; 
	 	 
 	if(window.XMLHttpRequest) // Firefox 
 	{
 		xhr_object = new XMLHttpRequest(); 
 	}
 	else if(window.ActiveXObject) // Internet Explorer 
 	{
 		xhr_object = new ActiveXObject("Microsoft.XMLHTTP"); 
 	}
 	else // XMLHttpRequest non supporté par le navigateur 
 	{ 
 		AjouterOldPanier(Arti);
 		exit();
 	} 
 	
  	var method   =  "GET" ; 
 	var filename = "/NewCmd/ajoutenew.php"; 
 	var data     = null; 
 	//var id       = document.getElementById("xf_field_model_menugauche0_id").value ;
 	id = ""; 
 	 
 	if(Arti != "" && id != "") {
 	   data = "R="+ escape(Arti) + "&N=1&Id=" + id; 
 	}
 	else {
 		//alert(document.location.pathname);
 		var pages = document.location.pathname.split("/");
 		window.location.href="/NewCmd/ajoute.xml?R="+ escape(Arti) + "&N=1&P=" + pages[2];
 		return;
 	}
 	
 	
 	if(method == "GET" && data != null) { 
 	   filename += "?" + data + "&nocache=" + Math.random(); 
 	   data      = null; 
 	} 
 	 alert(filename);
 	xhr_object.open(method, filename, true); 
 	
 	xhr_object.onreadystatechange = function() { 
 	   if(xhr_object.readyState == 4) { 
 	      var tmp = xhr_object.responseText.split(":"); 
 	      /*if(typeof(tmp[1]) != "undefined") { 
 	        alert("toto");
 	      } */
 	     
 	     if (tmp[0]>=0)
 	     	RefreshLigPanier(tmp[0]); 
 	      	     	
 	    AjouterNewPanier(Arti,tmp[0]);
 	   } 
 	}
 	 
 	xhr_object.send(data); 
 	
 	
}

function RecupId()
{
	var xhr_object = null; 
	 	var toto;
	 	 
 	if(window.XMLHttpRequest) // Firefox 
 	{
 		xhr_object = new XMLHttpRequest(); 
 	}
 	else  
 	{
 		xhr_object = new ActiveXObject("Microsoft.XMLHTTP"); 
 	}
 	 
 	  
 	var method   =  "GET" ; 
 	var filename = "/NewCmd/recupid.php"; 
 	var data     = null; 
 	 
 	  
 	if(method == "GET") { 
 	   filename += "?" + "nocache=" + Math.random(); 
 	   data      = null; 
 	} 
 	 
 	xhr_object.open(method, filename, true); 
 	
 	xhr_object.onreadystatechange = function() { 
 	   if(xhr_object.readyState == 4) { 
 	      var tmp = xhr_object.responseText.split(":"); 
 	      document.getElementById("xf_field_model_menugauche0_id").value = tmp[0];
 	   } 
 	}
 	 
 	xhr_object.send(data); 
 	 
}

function redirect()
{
	window.location.href="/NewCmd/commande.xml";	
}

function afficdiv()
{  
	var el = document.getElementById("transp");
	var hauteur;
	var Qte = 1;
	
	if (window.innerHeight && window.scrollMaxY) 
		hauteur = window.innerHeight + window.scrollMaxY;  
 	else if (document.body && document.body.offsetHeight) 
 		hauteur = document.body.offsetHeight;
 	else
 	 	hauteur=document.body.clientWidth ;
 	 	
 	if (el) {  
		el.style.height =  "100%";   
		el.style.width = "100%";
		el.style.display = 'block';
		el.style.zIndex = 100;
		
		var strChUserAgent = navigator.userAgent;
		var intSplitStart = strChUserAgent.indexOf("(",0);
		var intSplitEnd = strChUserAgent.indexOf(")",0);
		var strChMid = strChUserAgent.substring(intSplitStart, intSplitEnd);
		
		if(strChMid.indexOf("MSIE 6") != -1) {
						 
			var frame = document.createElement("iframe");   
			frame.setAttribute("id","myframe");
			frame.setAttribute("src","https://www2.photim.com/NewCmd/test.html");
			frame.setAttribute("width","100%");
			frame.setAttribute("height","900px");
			frame.setAttribute("style","display:none;");
			frame.setAttribute("scrolling","no");
			frame.setAttribute("marginwidth","0");
			frame.setAttribute("marginheight","0");
			frame.setAttribute("frameborder","0");
			frame.setAttribute("vspace","0");
			frame.setAttribute("hspace","0");
			el.appendChild(frame);
			 
		}
	}
}


function refreshpanier()
{
	var xhr_object = null; 
	 
 	if(window.XMLHttpRequest) // Firefox 
 	{
 		xhr_object = new XMLHttpRequest(); 
 	}
 	else if(window.ActiveXObject) // Internet Explorer 
 	{
 		xhr_object = new ActiveXObject("Microsoft.XMLHTTP"); 
 	}
 	else // XMLHttpRequest non supporté par le navigateur 
 	{ 
 		exit();
 	} 
 	
  	var method   =  "GET" ; 
 	var filename = "/NewCmd/ajoutenew.php"; 
 	var data     = null; 
 	var id       = document.getElementById("xf_field_model_menugauche0_id").value ;
 	data = "Id=" + id; 
 	
 	
 	 
 	
 	if(method == "GET" && data != null) { 
 	   filename += "?" + data + "&nocache=" + Math.random(); 
 	   data      = null; 
 	} 
 	
 	xhr_object.open(method, filename, true); 
 	
 	xhr_object.onreadystatechange = function() { 
 	   if(xhr_object.readyState == 4) { 
 	    	var tmp = xhr_object.responseText.split(":"); 
 	     	 
 	     
 	     	if (tmp[0]>=0) {
 	     	 	     	   
	 	     	if (tmp[0]>1)
			 		var msg = tmp[0]+" articles";
			 	else
			 		var msg = tmp[0]+" article";	
			 	 
			  
			 	var noeud = document.getElementById('panier');
			    while (noeud.childNodes.length>0) 
			    {
					noeud.removeChild(noeud.firstChild); 
				}
				 

				 
				var divParent = document.getElementById('panier');
				var nouveauLabel = document.createElement('span');
				nouveauLabel.id = "lab_panier" ;
				nouveauLabel.appendChild(document.createTextNode(msg));
				divParent.appendChild(nouveauLabel);
				
				document.getElementById("lab_panier").style.color = "#000000" ;
				document.getElementById("lab_panier").style.fontWeight  = "bold";
				document.getElementById("lab_panier").style.fontSize  = "11px";
				document.getElementById("lab_panier").style.fontFamily  = "Arial"; 
				document.getElementById("lab_panier").style.lineHeight  = "24px"; 
 	     	}
 		} 
 	}
 	 
 	xhr_object.send(data); 
 	
 	
}
		
var posX=0;posY=0;
var posX; // Variable globale Position X de la Mouse
var posY; // Variable globale Position Y de la Mouse

function WhereMouse( e ){
  var DocRef;    // Variable pour IE uniquement

  // L'événement est passée à la fonction
  // donc tous sauf IE…
  if( e){                     // Dans ce cas on obtient directement la position dans la page
    posX = e.pageX;
    posY = e.pageY;
  }
  else{                      // Dans ce cas on obtient la position relative à la fenêtre d'affichage
    posX = event.clientX;
    posY = event.clientY;

    //-- Il faut traiter le CAS des DOCTYPE sous IE
    if( document.documentElement && document.documentElement.clientWidth) // Donc DOCTYPE
      DocRef = document.documentElement;   // Dans ce cas c'est documentElement qui est réfèrence
    else
      DocRef = document.body;                    // Dans ce cas c'est body qui est réfèrence

    //-- On rajoute la position liée aux ScrollBars
    posX += DocRef.scrollLeft;
    posY += DocRef.scrollTop;
  }
}




var ref = window.location.href;
var page = ref.substring((ref.lastIndexOf("/"))+1);
if (( page.indexOf("bondecmd.xml") != -1) || ( page.indexOf("chxabo.xml") != -1))
{
	if (document.cookie.length==0)
		window.location.href="nocookies.xml";
}

//== INITIALISATION ================
document.onmousemove = WhereMouse;

