

var fpServices=new Array();function fpService(A,B){this.cid=A;this.pid=B;this.qty=0;this.typ="s"}function fpAddService(A){fps=fpServices[A.value];if(fps==undefined){fps=new fpService(A.value.split("-")[0],A.value.split("-")[1]);if(A.value=="contrator"){fps.typ="co"}fpServices[A.value]=fps}fps.qty=A.checked?1:0;if(computePrice){fSetPrice=parseFloat(getPriceInHTML(document.getElementById("serprice_"+A.value).innerHTML));if(!A.checked){fSetPrice=0-fSetPrice}fProductPrice=parseFloat(getPriceInHTML(document.getElementById("productPrice").innerHTML));setPriceInHTML(document.getElementById("productPrice"),(fProductPrice+fSetPrice).toFixed(2))}}function getPriceInHTML(A){return(A.replace("&nbsp;","").match(/[^\d]*(\d+[,.]\d+)[^\d]*/)[1]).replace(",",".")}function setPriceInHTML(A,B){A.innerHTML=A.innerHTML.replace("&nbsp;","").replace(/([^\d]*)(\d+[,.]\d+)([^\d]*)/,"$1"+B.replace(".",",")+"$3").replace(/(\d+)(\d{3},\d{2})/,"$1&nbsp;$2")}function purchaseProductCo(){fpServices=new Array();fps=new fpService(-1,-1);fps.typ="co";fpServices.contrator=fps;fps.qty=1;purchaseProductServices(3)}function purchaseProductService(A,B){fpServices=new Array();fps=new fpService(A,B);fpServices[A+"-"+B]=fps;fps.qty=1;purchaseProductServices(4)}function purchaseBundle(G,C,F,B,D,E){URLPurchase="/info/basket/purchase_ba.cfm";var A="";for(i=0;i<F.split(",").length-1;i++){A+=",o"}for(ser in fpServices){if(fpServices[ser].typ=="s"&&fpServices[ser].qty>0){C+=","+fpServices[ser].cid;F+=","+fpServices[ser].pid;B+=","+fpServices[ser].qty;A+=","+fpServices[ser].typ}}URLPurchase+="?affPop=OK&baskdo=addproduct&FROMOPTIONCADDIE=yes&lstType="+A+"&Product_ID="+F+"&Product_CID="+C+"&qty="+B+"&BAId="+G+"&pp="+D+"&addedFrom="+E;if(fpServices.contrator!=undefined&&fpServices.contrator.qty>0){URLPurchase+="&okcontrator=oui"}Shop_AddProduct(URLPurchase)}function purchaseProduct(A){fpServices=new Array();purchaseProductServices(A);URLPurchase="/info/basket/purchase_ba.cfm"}function purchaseProductServices(A){URLPurchase="/info/basket/purchase_ba.cfm";purchaseBundle(BAId,cidsBase,pidsBase,qtysBase,pp,A)}; 
        
	

loc_Txt_erreur_mutlipleAssurance = "Vous ne pouvez ajouter plusieurs assurances pour un même produit";
loc_Txt_erreur_mutlipleExtentionGarantie = "Vous ne pouvez ajouter plusieurs extention de garanties pour un même produit";
loc_Txt_ChargementEnCours = "Chargement en cours...";
loc_Txt_ErreurDeChargment = "Erreur de chargement";
loc_Txt_ImpossibleAjouterService = "Impossible d\'ajouter ce service";
function OptServ(B,A,C){this.prd_cid=B;this.prd_pid=A;this.prd_bunid=C;this.prd_px=null;this.prd_pxhc=null;this.coeff=null;this.coeffmin=null;this.HaveCoeff=null}OptServ.prototype.set_prd_price=function(A){this.prd_price=A};OptServ.prototype.set_prd_price_horscoeff=function(A){this.prd_pxhc=A};OptServ.prototype.set_coeff=function(A){this.coeff=A};OptServ.prototype.set_coeffmin=function(A){this.coeffmin=A;this.HaveCoeff=(A==1)};OptServ.prototype.init=function(){$(".ctLstOpts").height($(".ctLstCat").height()+5);$(".pkObjOS").draggable({helper:"clone",opacity:"0.5",appendTo:$("#pkdragg")[0]});$(".pkTarget").droppable({accept:".pkObjOS",tolerance:"touch",drop:mypk.drop,activeClass:"pkTargetActive",hoverClass:"pkTargetHover"})};OptServ.prototype.ajoutOpt=function(B,J){if(typeof B=="string"){B=$(B)}if(typeof J=="string"){J=$(J)}$("#OneShotHelp")[0].style.display="none";var C=false,A=false,G=0,D=0,H=0,I=0,F=1;$("#pkTarget li.pkObjOS").each(function(){if(this.getAttribute("isservice")){C=C||this.getAttribute("isAssurance");A=A||this.getAttribute("isExtentionGarantie")}});if((B[0].getAttribute("isAssurance")&&C)||(B[0].getAttribute("isExtentionGarantie")&&A)){if(B[0].getAttribute("isAssurance")){$.prompt("<h3>"+loc_Txt_ImpossibleAjouterService+"</h3><p>"+loc_Txt_erreur_mutlipleAssurance+"</p>",{prefix:"brownJqi"})}if(B[0].getAttribute("isExtentionGarantie")){$.prompt("<h3>"+loc_Txt_ImpossibleAjouterService+"</h3><p>"+loc_Txt_erreur_mutlipleExtentionGarantie+"</p>",{prefix:"brownJqi"})}}else{if($("#pksel_"+B[0].id).length!=0){var E=$("#pksel_"+B[0].id+" input")[0];E.value=parseInt(E.value)+1}else{var E=B.clone();E[0].id="pksel_"+E[0].id;J.append(E)}}this.refreshPrice()};OptServ.prototype.drop=function(A,B){mypk.ajoutOpt(B.draggable,B.element)};OptServ.prototype.refreshPrice=function(){var A=0,F=0,D=0,C=0,E=1,G=null;$("#pkTarget li").each(function(){var I=parseInt(this.getElementsByTagName("input")[0].value),H=parseFloat(this.getAttribute("px"));if(this.getAttribute("isservice")){D+=H*I}else{if(this.getAttribute("isoption")){F+=H*I;C+=I}}});if(C>=5){E=0.9}else{if(C>=3){E=0.95}else{if(C==2){E=0.97}}}if(E!=1){$("#pkPrice").removeClass().addClass("priceEco");document.getElementById("pkPrice").style.marginTop="30px";var B=$("#packEcoValue").html("<strong>- "+(100-E*100)+"%</stong>")}else{$("#pkPrice").removeClass().addClass("price")}A=this.prd_pxhc*parseInt($("#qte_CID"+this.prd_cid+"PID"+this.prd_pid)[0].value);A+=F*E;if(this.HaveCoeff){if(A>this.coeffmin){A=A*this.coeff}}A+=D;A=Math.round(A*100)/100+" &euro;";A=A.replace(/\./gi,",");if((G=A.indexOf(","))>-1){if(A.charAt(G+2)==" "){A=A.replace(/ /gi,"0 ")}}$("#PackOptionServicePrice")[0].innerHTML=A};OptServ.prototype.plusMoins=function(C,B){var A=$("#qte_"+C)[0];A.value=parseInt(A.value)+B;if(A.value==0){if($("#qte_"+C).hasClass("TheProduct")){A.value=1}else{$("#pksel_"+C).remove();if($("#pkTarget li").length==0){$("#OneShotHelp")[0].style.display="block"}}}this.refreshPrice()};OptServ.prototype.getNewList=function(D,C,E,A){$(".lstOpts .pkObjOS").remove();$(".lstOpts .ttrLstOpts").html(A);$(".lstOpts .ctLstOpts").html("<div class='loading'>"+loc_Txt_ChargementEnCours+"<br><img src='/images/img-loading-mini.gif' width='20' heigth='20'/></div>");var B="/shared/ficheprod/getoptionsservicesproductbygroup.cfm?";B+="cid="+this.prd_cid;B+="&pid="+this.prd_pid;B+="&type="+D;B+="&optcid="+C;B+="&optcatid="+E;callHttpRequestRdc(B,"mypk.getNewList_retour","mypk.getNewList_erreur")};OptServ.prototype.getNewList_retour=function(A){$(".lstOpts .ctLstOpts").html(A.getElementsByTagName("datas")[0].childNodes[0].nodeValue);$(".pkObjOS").draggable({helper:"clone",opacity:"0.5",appendTo:$("#pkdragg")[0]})};OptServ.prototype.getNewList_erreur=function(){$(".lstOpts .ctLstOpts").html("<div class='erreur'>"+loc_Txt_ErreurDeChargment+"</div>")};OptServ.prototype.Acheter=function(){if(typeof (pageTracker)!="undefined"){var E="FicheProduitHT_pack_auto";if(typeof (gmht)!="undefined"){E="FicheProduitGMHT_pack_auto"}pageTracker._trackEvent("Boutons",E,"Ajouter_au_panier")}var A="/info/basket/purchase_ba.cfm",D=this.prd_cid,F=this.prd_pid,B="",C=$("#qte_CID"+this.prd_cid+"PID"+this.prd_pid)[0].value;A+="?affPop=OK";A+="&baskdo=addproduct";A+="&FROMOPTIONCADDIE=yes";A+="&BaId="+this.prd_bunid;A+="&pp="+this.prd_cid+"|"+this.prd_pid;$("#pkTarget li").each(function(){D+=","+this.getAttribute("cid");F+=","+this.getAttribute("pid");B+=(B==""?"":",")+(this.getAttribute("isoption")?"o":"")+(this.getAttribute("isservice")?"s":"");C+=","+this.getElementsByTagName("input")[0].value});A+="&Product_ID="+F;A+="&Product_CID="+D;A+="&qty="+C;A+="&lstType="+B;A+="&r="+Math.round(Math.random()*100000);Shop_AddProduct(A)}; 
        var lstSidHT = new Array('5');function highlightWord(node,word) {
	return true;
	// Iterate into this nodes childNodes
	if (node.hasChildNodes) {
		var hi_cn;
		for (hi_cn=0;hi_cn<node.childNodes.length;hi_cn++)
			highlightWord(node.childNodes[hi_cn],word);
	}
	
	// And do this node itself
	if (node.nodeType == 3) { // text node
		tempNodeVal = node.nodeValue.toLowerCase();
		tempWordVal = word.toLowerCase();
		if (tempNodeVal.indexOf(tempWordVal) != -1) {
			pn = node.parentNode;
			if (pn.className != "searchword") {
				// word has not already been highlighted!
				nv = node.nodeValue;
				ni = tempNodeVal.indexOf(tempWordVal);
				// Create a load of replacement nodes
				before = document.createTextNode(nv.substr(0,ni));
				docWordVal = nv.substr(ni,word.length);
				after = document.createTextNode(nv.substr(ni+word.length));
				hiwordtext = document.createTextNode(docWordVal);
				hiword = document.createElement("span");
				hiword.className = "searchword";
				hiword.appendChild(hiwordtext);
				pn.insertBefore(before,node);
				pn.insertBefore(hiword,node);
				pn.insertBefore(after,node);
				pn.removeChild(node);
			}
		}
	}
}

function googleSearchHighlight() {
  	if (!document.createElement) return;
  	ref = document.referrer;
  	if (ref.indexOf('?') == -1) return;
  	qs = ref.substr(ref.indexOf('?')+1);
  	qsa = qs.split('&');
  	for (i=0;i<qsa.length;i++) {
  		qsip = qsa[i].split('=');
  	        if (qsip.length == 1) continue;
          	if (qsip[0] == 'q' || qsip[0] == 'p' || qsip[0]=='s') { // q= for Google, p= for Yahoo, sp-q for Atomz
  				words = unescape(qsip[1].replace(/\+/g,' ')).split(/\s+/);
  	            for (w=0;w<words.length;w++) 
		  			highlightWord(document.getElementById("fpContainerOuter").lastChild,words[w]);
  	        }
	  	}
	}

function purchase(cidoption,pid){document.forms['purchase' + cidoption + pid].submit()}
function poppurchase() {document.forms['purchase'].submit()}
function caddie() {opener.location.href="/info/basket/t_caddie.cfm";opener.focus();self.close();}

function resizePopXL2 ( obj )
	{
		document.getElementById("txt_PopXl2").style.display='none'
		obj.style.display='block'
		my_div2 = document.getElementById("div_popupXL2")
		if ( obj.height + 60 > document.body.clientHeight )
			{
				obj.height_origine = obj.height
				obj.height = document.body.clientHeight - 100
				document.getElementById("img_zoompopupXL2").style.display='block'
			}
		my_div2.style.width = (obj.width+4) + "px"
		my_div2.style.height = (obj.height + 40 + 6) + "px"
		my_div2.style.top = (((document.documentElement.clientHeight-obj.height-40)/2)+document.documentElement.scrollTop) + "px"	
		my_div2.style.left = (((document.documentElement.clientWidth-obj.width)/2)+document.documentElement.scrollLeft) + "px"		
	}
function popupXL2(of,loc) {

		if (typeof(vcis) != "undefined" ) vcis('hidden');

		var my_div , my_div2;
		if ( loc == null ) loc = 'fr-fr'
		
		if ( ! ( my_div = document.getElementById("div_opaque") ) )
			{
				my_div = document.createElement("DIV")
				my_div.id = "div_opaque"
				document.body.appendChild( my_div ) 
			}	
		my_div.style.cssText="position:absolute;z-index:99;top:0px;left:0px;filter:alpha(opacity:60);display:;background:white"
		my_div.style.opacity = .6
		my_div.style.height = document.body.scrollHeight + "px"
		my_div.style.width =  document.body.scrollWidth + "px"
	
		if ( ! ( my_div2 = document.getElementById("div_popupXL2") ) )
			{
				my_div2 = document.createElement("DIV")
				my_div2.id = "div_popupXL2"
				document.body.appendChild( my_div2 ) 
			}	
		my_div2.style.padding = '2px'	
		my_div2.style.background = 'white'
		my_div2.style.zIndex = 101	
		my_div2.style.position = 'absolute'
		my_div2.style.filter = null
		my_div2.style.opacity = 1
		my_div2.style.width = "550px"
		my_div2.style.height = "60px"
		my_div2.style.top = (((document.body.clientHeight-130)/2)+document.body.scrollTop) + "px"	
		my_div2.style.left = (((document.body.clientWidth-550)/2)+document.body.scrollLeft) + "px"
		my_div2.style.display="block";
		my_div2.style.border="1px solid black"
		var tmphtml = "<div style='width:100%;text-align:center' id='txt_PopXl2'><img src='http://www.rueducommerce.fr/image/img-loading-sm.gif' width='65' height='49'/></div>"
		tmphtml += "<img src='" + document.getElementById('xlCont').getElementsByTagName("img")[0].src + "' onload='resizePopXL2(this)' id='img_PopXL2' onclick=\"document.getElementById('div_popupXL2').style.display='none';document.getElementById('div_opaque').style.display='none';vcis('visible');\" style='display:none'>" 
		imgbtacht = "/images/bouton_acheter.gif";
		if ( loc != 'fr-fr' ) imgbtacht = "/images/locales/"+loc+"/bouton_acheter.gif" ;
		if ( document.getElementById('fp_imgachat_main') )
		tmphtml += "<img src='"+imgbtacht+"' onclick=\"document.getElementById('div_popupXL2').style.display='none';vcis('visible');document.getElementById('fp_imgachat_main').onclick()\" width='108' height='40' style='float:left;cursor:pointer' id='bt_acheter_zoom'>"	
		tmphtml += "<img src='/images/shops/"+loc+"/ficheprod/bouton_fermer.gif' onclick=\"document.getElementById('div_popupXL2').style.display='none';document.getElementById('div_opaque').style.display='none';vcis('visible');\" width='108' height='40' style='float:right;cursor:pointer'>"
		tmphtml += "<img src='/images/xlocales/zoom_plus.gif' id='img_zoompopupXL2' onclick=\"popupXL2_zoom(this)\" width='95' height='51' style='position:absolute;top:5px;left:5px;cursor:pointer;display:none;filter:alpha(opacity:40);opacity:0.4' onmouseover=\"this.style.filter=null;this.style.opacity=1\" onmouseout=\"this.style.filter='alpha(opacity:40)';this.style.opacity=0.4\">"	
		my_div2.innerHTML = tmphtml
		
	}
function popupXL2_zoom (btzoom)
	{
		obj = document.getElementById("img_PopXL2")
		my_div2 = document.getElementById("div_popupXL2")
		if ( obj.height == obj.height_origine )
			{
				obj.height = document.body.clientHeight - 100
				btzoom.src='/images/xlocales/zoom_plus.gif'
			}
		else
			{
				obj.height = obj.height_origine
				btzoom.src='/images/xlocales/zoom_moins.gif'
			}
		

		my_div2.style.width = (obj.width+4) + "px"
		my_div2.style.height = (obj.height + 40 + 6) + "px"

		my_div2.style.left = (((document.body.clientWidth-obj.width)/2)+document.body.scrollLeft) + "px"		
	}

function showpopDesc(idpopdesc,e) {

	var posx = 0;
	var posy = 0;
	if (!e) var e = window.event;
	if (e.pageX || e.pageY)	{
		posx = e.pageX;
		posy = e.pageY;
		}
	else if (e.clientX || e.clientY) {
		posx = e.clientX + document.documentElement.scrollLeft;
		posy = e.clientY + document.documentElement.scrollTop;
		}


	with (document.getElementById(idpopdesc).style) {
		display='block';
		left = posx+5+'px';
		top = parseInt(posy)+5+'px';
		}
	}

function hidepopDesc(idpopdesc) {
	document.getElementById(idpopdesc).style.display='none';
	}
	
/* la pastille d'économie */
function getReduction(cid,pid,pk)
  {
    var url = "/shared/prix/ajax/fp/getEconomie.cfm?c=" + cid + "&p=" + pid + (pk != null ? "&pk=" + pk : "")
    callHttpRequestRdc(url,"getReductionBack")
  }
function getReductionBack( xmlRequest )
  {
    if ( xmlRequest.getElementsByTagName("erreur").length == 0 ) /* y'a pas d'erreur */
      {
        var sid = getCookie("SID");
        var eco = "0";
        if ( lstSidHT.find(sid)>=0 )
           eco = xmlRequest.getElementsByTagName("ecoht")[0].childNodes[0].nodeValue
        else
           eco = xmlRequest.getElementsByTagName("ecottc")[0].childNodes[0].nodeValue

        if (eco != "0")
          {
            if ( xmlRequest.getElementsByTagName("soldes").length == 1 ) {
                $("#fpReduc").addClass("fpReducPriceSoldes");
                $("#fpReduc .fpReducAvec").html('&nbsp;');
                $("#fpReduc .fpReducEco").html('&nbsp;');
                $("#fpReducPrice").html("-" + eco + (eco.indexOf("%")==-1?"€":"") )
            }
            else
            	$("#fpReducPrice").html(eco + (eco.indexOf("%")==-1?"€":"") )
            $("#fpReduc").css("display","block");
            $("#fpReduc").css("visibility","visible");
          }
      }
  }

  function purchaseProduct(_from)
{
  fpServices = new Array();
  purchaseProductServices(_from);
	URLPurchase = "/info/basket/purchase_ba.cfm";
}

function purchaseProductServices(_from)
{
	URLPurchase = "/info/basket/purchase_ba.cfm";
	purchaseBundle(BAId,cidsBase,pidsBase,qtysBase,pp,_from);
}
//achete par t_cente_blocprix
function acheterProduct(productId,cid)
{
	if (typeof(pageTracker) != 'undefined') {
		pageTracker._trackEvent('Boutons', 'FicheProduitHT', 'Ajouter_au_panier');//tracking xiti pour le button acheter
	}	
	URLPurchase = "http://www.rueducommerce.fr/info/basket/purchase.cfm";
	URLPurchase += "?Product_ID="+productId+"&Product_CID="+cid;
				
	window.location.href= URLPurchase;
}

//pour les produit avec les services sélectioné
function acheterProductSer(productId,cid)
{
	if (typeof(pageTracker) != 'undefined') {
		pageTracker._trackEvent('Boutons', 'FicheProduitHT_et_services', 'Ajouter_au_panier');//tracking xiti pour le button acheter
	}
	URLPurchase = "/info/basket/purchase_ba.cfm";
	var typs = "";
	for (i=0;i<pidsBase.split(",").length-1;i++) typs += ",o"
		
	for (ser in fpServices)
		if (fpServices[ser].typ == "s" && fpServices[ser].qty > 0) {
			cidsBase += "," + fpServices[ser].cid;
			pidsBase += "," + fpServices[ser].pid;
			qtysBase += "," + fpServices[ser].qty;
			typs += "," + fpServices[ser].typ;
		}

	URLPurchase += "?baskdo=addproduct&FROMOPTIONCADDIE=yes"
				+"&lstType="+typs
				+"&Product_ID="+pidsBase
				+"&Product_CID="+cidsBase
				+"&qty="+qtysBase
				+"&BAId="+BAId
				+"&pp="+pp
				+"&addedFrom=2"
			
	if (fpServices["contrator"] != undefined && fpServices["contrator"].qty > 0)
		URLPurchase += "&okcontrator=oui";
		
	window.location.href=URLPurchase;
}
//pour les produit en bundle
function acheterBundle(url)
{
	if (typeof(pageTracker) != 'undefined') {
		var sTrackEvent = 'FicheProduitHT_pack_front';
		if (typeof(gmht) != 'undefined')
			sTrackEvent = 'FicheProduitGMHT_pack_front';

		pageTracker._trackEvent('Boutons', sTrackEvent, 'Ajouter_au_panier'); //tracking xiti pour le button acheter
	}

	window.location.href= url;
}

function chrono(champ,jour,mois,annee,heure,minute,seconde) {
 if (document.getElementById && document.getElementById(champ)) {
  var now = new Date()
  var goal = new Date(annee,mois-1,jour,heure,minute,seconde)
  var ts = (goal.getTime() - now.getTime())/1000
  if (ts > 0){
   var j = Math.floor(ts/(3600*24))
   var h = Math.floor((ts-j*24*3600)/3600)
   var m = Math.floor((ts-j*24*3600-h*3600)/60)
   var s = Math.floor(ts-j*24*3600-h*3600-m*60)
   var html = ((j>1)?j+" jours ":(j>0)?j+" Jour ":"")
   + ((h<10)?" 0":" ")+h+"h "
   + ((m<10)?"0":"")+m+"mn "
   + ((s<10)?"0":"")+s+"s "
   document.getElementById(champ).innerHTML = "Plus que " + html + " !"
  }
  else document.getElementById(champ).innerHTML = " C\'est fini ! "
 }
}

function fpchronoSoldeFlash(_date) {
	try {
		var oReg = /(\d\d\d\d)-(\d\d)-(\d\d) (\d\d):(\d\d):(\d\d)/;
		var aMatch = oReg.exec(_date);
		var oEndDate = new Date(aMatch[1], aMatch[2] - 1, aMatch[3], aMatch[4], aMatch[5], aMatch[6]);
		var iTime = oEndDate.getTime() - new Date().getTime();
		if (iTime > 0) {
			iTime = iTime / 1000;
			var iH = Math.floor(iTime / 3600);
			var iM = Math.floor((iTime - 3600 * iH) / 60);
			var iS = Math.floor(iTime - 3600 * iH - 60 * iM);
			$('#fpsoldesflash .chronomin').html(iH + "h " + ((iM<10)?"0":"") + iM + "mn " + ((iS<10)?"0":"") + iS + "s");
		} else {
			$('#fpsoldesflash .chronoatt').html("");
			$('#fpsoldesflash .chronomin').html("C'est fini!");
		}
	} catch (e) {
	}
}
/***********************/
/* Fonctions générales */
/** ******************** */
var idzCustomData;
function HideContent(d)
{
	if(d.length < 1) { return; }
	document.getElementById(d).style.display = "none";
}
function ShowContent(d,left,top) {
	if(d.length < 1) { return; }
	var dd = document.getElementById(d);
	
  dd.style.left = left+"px";
  dd.style.top = top +"px";
  
	dd.style.display = "block";
}

function GMHTFormatPrix(valeur,decimal,separateur) {
  if (typeof decimal == 'undefined') decimal = 2;
  if (typeof separateur == 'undefined') separateur = " ";
  // formate un chiffre avec 'decimal' chiffres après la virgule et un
	// separateur
	var val_format=Math.round(valeur*100)/100;
	var deci=Math.round( Math.pow(10,decimal)*(val_format-Math.floor(Math.abs(valeur)))) ;
	var val=Math.floor(Math.abs(valeur));
				
	if ((decimal==0)||(deci==Math.pow(10,decimal))) {val=Math.round(Math.abs(valeur)); deci=0;}
	var val_format=val+"";
	var nb=val_format.length;
	for (var i=1;i<4;i++) {
		if (val>=Math.pow(10,(3*i))) {
			val_format=val_format.substring(0,nb-(3*i))+separateur+val_format.substring(nb-(3*i));
		}
	}
	if (decimal>0) {
		var decim="";
		for (var j=0;j<(decimal-deci.toString().length);j++) {decim+="0";}
		deci=decim+deci.toString();
		val_format=val_format+","+deci;
	}	
	if (parseFloat(valeur)<0) {val_format="-"+val_format;}
	
	return val_format;
}

function isGoodPrice ( px )
  {
    if ( typeof px == "undefined" ) return false;
    if (( typeof px == "string" ) && ( px == "" )) return false;
    if ( getPriceFloat( px ) != 0 ) return true;
  }

function getPriceFloat ( inn ) {

  if ((typeof inn == "undefined")||(inn == ""))
    return 0;
  else if (typeof inn == "number")
    return inn;
  else
    return parseFloat( inn.replace(/,/gi,".").replace(/ /gi,"") );
}

function chrono(jour,mois,annee,heure,minute,seconde) {
  var now = new Date()
  var goal = new Date(annee,mois-1,jour,heure,minute,seconde)
  var ts = (goal.getTime() - now.getTime())/1000
  if (ts > 0)
    {
    var j = Math.floor(ts/(3600*24))
    var h = Math.floor((ts-j*24*3600)/3600)
    var m = Math.floor((ts-j*24*3600-h*3600)/60)
    var s = Math.floor(ts-j*24*3600-h*3600-m*60)
    var html = ((j>1)?j+" jours ":(j>0)?j+" Jour ":"")
      + ((h<10)?" 0":" ")+h+"h "
      + ((m<10)?"0":"")+m+"mn "
      + ((s<10)?"0":"")+s+"s "
    $(".vfchronofpghmt").html( "Plus que " + html + " !" );
    }
  else $(".vfchronofpghmt").html( " C'est fini ! " );
}

function startChrono(jour,mois,annee,heure,minute,seconde) {
		chrono(jour,mois,annee,heure,minute,seconde)
    setTimeout("startChrono("+jour+","+mois+","+annee+","+heure+","+minute+","+seconde+")",1000);
}

/** ************** */
/* CLASS : GMHT */
/** ************* */
oimage = function() {
	this.s = arguments[0];
	this.m = arguments[1];
	this.l = arguments[2];
}


gmht = function ( _p_cid , _p_mpid_master , _p_product_id , _p_partnumber , _p_objectgroup_id, _p_fiche_rdc_active , _p_taux3fois , _p_seuil3fois , _p_coefpromo , _p_coefpromo_seuil , _p_5x_min , _p_5x_max , _p_5x_actif ) {
  /* les propriétés */
  _this = this;
  $.gmht = this;
  this.offers = new Array();
	this.images = new Array();
	this.currentImage = null;
	this.cid = null;
	this.monde = null;
	this.mpid_master = null;
	this.product_id = null;
	this.partnumber = null;
	this.objectgroup_id = null;
	this.comparateur = null;
	this.comparateur_order = null;
	this.fiche_rdc_active = true;
	this.NomMarchand_RueDuCommerce = "Rue du Commerce";
	this.coefpromo_seuil = null;
	this.coefpromo = null;
	this._5x_min = null;
  	this._5x_max = null;
  	this._5x_actif = null;
  	this.seuilEconomie = 45;
	this.maxLinesLivraison = 8;
	this.prix_rdc = 0;
	
	/* partie constructeur */
	this.cid = _p_cid;
	this.mpid_master = _p_mpid_master;
	this.product_id = _p_product_id;
	this.partnumber = _p_partnumber;
	this.objectgroup_id = _p_objectgroup_id;
	this.fiche_rdc_active = _p_fiche_rdc_active;
	this.coefpromo_seuil = _p_coefpromo_seuil;
	this.coefpromo = _p_coefpromo;
	this._5x_min = _p_5x_min;
  this._5x_max = _p_5x_max;
  this._5x_actif = _p_5x_actif;
  	this.installment_3x_for_product = false;
  	this.installment_3x_for_representant = false;
	this.installment_3x_for_productRdcDispo = false;
	this.ope_fraisportgratuit = false;
	/* fin partie constructeur */
	
	this.defaultVisuelSmall = "http://www.rueducommerce.fr/images/no_result.small.jpg";
	this.defaultVisuelMedium = "http://www.rueducommerce.fr/images/no_result.large.jpg";
	this.defaultVisuelLarge = "http://www.rueducommerce.fr/images/no_result.large.jpg";

	this.load = function () {
	
	  var domaine = document.location.href;
    domaine = domaine.substr ( 7 , domaine.indexOf("/",7) - 7 ); // 7 c'est
																	// pour
																	// http://
    if (( domaine == "www.rueducommerce.fr" ) || ( domaine == "search.rueducommerce.fr" ))
      url = "http://www.rueducommerce.fr/m/dws/product_offer_enhanced.php?mpid=" + this.mpid_master + "&fpgmht=1";
    else {
      url = "/proxy.cfm?url=" + escape( "http://www.rueducommerce.fr/m/dws/product_offer_enhanced.php?mpid=" + this.mpid_master + "&fpgmht=1" );
      //url = "/m/dws/product_offer_enhanced.php?mpid=" + this.mpid_master + "&fpgmht=1";		
	}
	
    callHttpRequestRdc( url , this , this )
  	if ($('div.videoFP img').length > 0)
     {
  		$('div.videoFP').hide();
  		$('div.imgVideo').click($('div.videoFP img').attr('onclick')).show();
	   }
	}

  this.ventesFlashHT = function (xmlrequest) {
    if( xmlrequest.getElementsByTagName("venteflashHT")[0].childNodes[0].nodeValue != 'vide') {;
      var vf = xmlrequest.getElementsByTagName("venteflashHT")[0]
      var datefin = vf.getElementsByTagName("datefin")[0].childNodes[0].nodeValue;
      var prix =  getPriceFloat(vf.getElementsByTagName("prix")[0].childNodes[0].nodeValue);
      var prixref = getPriceFloat(vf.getElementsByTagName("prixref")[0].childNodes[0].nodeValue);

      var fprix = getPriceFloat(prix);
      var fprixref = getPriceFloat(prixref);

      this.offers[0]["prix"]["flash"] = new Array();
      this.offers[0]["prix"]["flash"]["datefin"] = datefin;
      this.offers[0]["prix"]["flash"]["prix"] = prix;      
      this.offers[0]["prix"]["flash"]["retail"] = prixref;
      this.offers[0]["prix"]["flash"]["ecotaxe"] = this.offers[0]["prix"]["normal"]["ecotaxe"];
         

      if ( this.offers[0]["prix"]["normal"]["retail"] != "" ) fprixref = getPriceFloat(this.offers[0]["prix"]["normal"]["retail"]); 

      this.offers[0]["prix"]["flash"]["economie"] = fprixref - fprix;
      this.offers[0]["prix"]["flash"]["economiepc"] =  ( ( (fprixref - fprix) * 100 ) / fprixref ) ;
      this.displayBlocPrice(); 
    }
  }
  	
	this.callback = function( xmlrequest ) {
	
	  if ( xmlrequest.getElementsByTagName("venteflashHT").length == 1) { this.ventesFlashHT(xmlrequest); return false; }
    var offres = xmlrequest.getElementsByTagName("offre");

    if (offres.length == 0) offres = xmlrequest.getElementsByTagName("offer");

    for ( var i = 0 ; i < offres.length ; i++ )
      {
        /* lecture de l'offre dans un tableau temporaire */
        tmp_offre = new Array();
        tmp_offre["position"] = i;
        // infos marchand
        var marchand = offres[i].getElementsByTagName("marchand")[0];
        tmp_offre["marchand"] = new Array();
        tmp_offre["marchand"]["nom"] = marchand.getElementsByTagName("nom")[0].childNodes[0].nodeValue;
        tmp_offre["marchand"]["note"] = marchand.getElementsByTagName("note")[0].hasChildNodes() ? marchand.getElementsByTagName("note")[0].childNodes[0].nodeValue : "";
        tmp_offre["marchand"]["mention"] = marchand.getElementsByTagName("mention")[0].hasChildNodes() ? marchand.getElementsByTagName("mention")[0].childNodes[0].nodeValue : "";
        if(0 === i){
        	tmp_offre["marchand"]["url_merchantsheet"] = marchand.getElementsByTagName("url_merchantsheet")[0].hasChildNodes() ? marchand.getElementsByTagName("url_merchantsheet")[0].childNodes[0].nodeValue : "";
        }
        
        if ( tmp_offre["marchand"]["nom"] == this.NomMarchand_RueDuCommerce ) tmp_offre["marchand"]["note"] = 5;
        
        /* l'offre RDC a été désactivée entre temps. */
        /*
		 * if ( ( tmp_offre["marchand"]["nom"] == this.NomMarchand_RueDuCommerce ) &&
		 * (this.fiche_rdc_active == false) ) continue;
		 */
          
        // infos qu'on reprend telque prix / soldes / promo / flash
        var noeud_prix = null;
        var tmp_prix = offres[i].getElementsByTagName( "prix" )
        for ( var k = 0 ; k < tmp_prix.length ; k++ ) {
          if ( tmp_prix[k].getElementsByTagName("normal").length > 0 ) {
             noeud_prix = tmp_prix[k];
             break;
          }
        }
       
        tmp_offre["prix"] = new Array();
        lst = new Array( "normal" , "soldes" , "promo" , "flash" );
        for ( var k = 0 ; k < lst.length ; k++)
          {
            var noeud = lst[k];
            if ( noeud_prix.getElementsByTagName( noeud ).length > 0 )
              {
                tmp_offre["prix"][ noeud ] = new Array();
                var node = noeud_prix.getElementsByTagName( noeud )[0];
                for ( var j = 0 ; j < node.childNodes.length ; j++ )
                  {
                    if ( node.childNodes[j].nodeType == 1 )
                        tmp_offre["prix"][ noeud ][node.childNodes[j].nodeName] = node.childNodes[j].hasChildNodes() ? node.childNodes[j].childNodes[0].nodeValue : "";
                  }
              }
          }
          
        if ( $(offres[i]).find("livraisonmini prix").length > 0)
          tmp_offre["prix"]["fraisdeport"] = $(offres[i]).find("livraisonmini prix").text();

        if ( tmp_offre["marchand"]["nom"] == this.NomMarchand_RueDuCommerce )
          {
			/*
			 * if ( (this.prix_rdc > 0) ) { tmp_offre["prix"]["normal"]["prix"] =
			 * GMHTFormatPrix(this.prix_rdc); }
			 */
			
            var px = getPriceFloat ( tmp_offre["prix"]["normal"]["prix"] )
            
            /* calcule du 3 fois */
            if ( px >= _p_seuil3fois )
              {
                tmp_offre["prix"]["prix3x"] = ( px * ( 1 + ( _p_taux3fois / 100 ) ) ) / 3 ;
                tmp_offre["prix"]["prix3x"] = GMHTFormatPrix( tmp_offre["prix"]["prix3x"] );
              }
            else { tmp_offre["prix"]["prix3x"] = ""; }
          }
        else { tmp_offre["prix"]["prix3x"] = ""; }
        
        if ( $(offres[i]).find("prix3xrdc").length > 0 &&  $(offres[i]).find("prix3xrdc").text() != "") {
        	tmp_offre["prix"]["installments"] =  new Array();
        	tmp_offre["prix"]["installments"]["3x"] = getPriceFloat ( $(offres[i]).find("prix3xrdc").text());
			if (tmp_offre["marchand"]["nom"] == this.NomMarchand_RueDuCommerce && this.coefpromo < 1 &&  getPriceFloat(tmp_offre["prix"]["normal"]["prix"]) >= this.coefpromo_seuil) {
				tmp_offre["prix"]["installments"]["3x"] =  getPriceFloat((this.coefpromo * getPriceFloat(tmp_offre["prix"]["normal"]["prix"]) / 3) * 1.034).toFixed(2) ;
				this.installment_3x_for_productRdcDispo = true;
			}
			else if (tmp_offre["marchand"]["nom"] == this.NomMarchand_RueDuCommerce){
				this.installment_3x_for_productRdcDispo = true;
			}			
        	this.installment_3x_for_product = true;
        	if (tmp_offre["position"] == 0) {
        		this.installment_3x_for_representant = true;
        	}
        }

		tmp_offre["garantie"] = offres[i].getElementsByTagName("garantie")[0].childNodes[0].nodeValue
		
        /* infos livraison */
        tmp_offre["livraisons"] = new Array();
          /* livraison la moins chère */
        tmp_offre["livraisons"]["mini"] = new Array();
        var livraisons = offres[i].getElementsByTagName("livraisons")[0].getElementsByTagName("livraisonmini")[0];
        elts = new Array( "delai" , "date" , "moyen" , "prix" )
        for ( var elt = 0 ; elt < elts.length ; elt++ )
          {
            var tmp = livraisons.getElementsByTagName(elts[elt])
            tmp_offre["livraisons"]["mini"][ elts[elt] ] = tmp.length == 1 && tmp[0].childNodes.length == 1 ? tmp[0].childNodes[0].nodeValue : "";
          }
          
          
          /* autre mode de livraison */
        tmp_offre["livraisons"]["autre"] = new Array();
        livraisons = offres[i].getElementsByTagName("livraisons")[0].getElementsByTagName("livraisonautre");
        elts = new Array( "delai" , "moyen" , "prix" )
        for ( var j = 0 ; j < livraisons.length ; j++ )
          {
            tmp_offre["livraisons"]["autre"][j] = new Array();
            for ( var elt = 0 ; elt < elts.length ; elt++ )
              {
                var tmp = livraisons[j].getElementsByTagName(elts[elt])
                tmp_offre["livraisons"]["autre"][j][ elts[elt] ] = tmp.length == 1 ? tmp[0].childNodes[0].nodeValue : "";
              }
          }

        /* les visuels */
        if ( this.images.length == 0 )
        {
			var visuels = offres[i].getElementsByTagName("visuels");
			if(visuels.length > 0 && visuels[0].childNodes.length > 0){
				var bigVisuel = "";
				for ( var j = 0 ; j < visuels.length ; j++ )
				{
					try {bigVisuel = visuels[j].getElementsByTagName("big")[0].childNodes[0].nodeValue}
					catch(e){
						try {bigVisuel = visuels[j].getElementsByTagName("maxi")[0].childNodes[0].nodeValue}
						catch(e){bigVisuel = ""}
					}
					
					this.addImage(
						visuels[j].getElementsByTagName("mini")[0].childNodes[0].nodeValue,
						visuels[j].getElementsByTagName("medium")[0].childNodes[0].nodeValue,
						bigVisuel
					);
				}
			}
        }
        
        /* le stock */
        var st = offres[i].getElementsByTagName("stock")[0];
        tmp_offre["stock"] = new Array();
        tmp_offre["stock"]["code"] = st.getElementsByTagName("code")[0].childNodes[0].nodeValue;
        tmp_offre["stock"]["libelle"] = st.getElementsByTagName("libelle")[0].childNodes[0].nodeValue;
        
        /* autres infos */
        tmp_offre["url_achat"] = offres[i].getElementsByTagName("url_achat")[0].childNodes[0].nodeValue;
        tmp_offre["cgv"] = offres[i].getElementsByTagName("url_cgv")[0].hasChildNodes() ? offres[i].getElementsByTagName("url_cgv")[0].childNodes[0].nodeValue : "";
        tmp_offre["cgv"] = offres[i].getElementsByTagName("url_cgv")[0].hasChildNodes() ? offres[i].getElementsByTagName("url_cgv")[0].childNodes[0].nodeValue : "";

        /* état */
        tmp_offre["etat"] = new Array()
        tmp_offre["etat"]["is_occasion"] = false;
        tmp_offre["etat"]["text"] = "";
        if ( $(offres[i]).find("condition").length != 0 ) {
          tmp_offre["etat"]["is_occasion"] = $(offres[i]).find("condition").attr("is_occasion") == 1;
          tmp_offre["etat"]["text"] = $(offres[i]).find("condition").text();
        }
                 

        /* fin lecture de l'offre */
		
		/* Calcul du reprensentant, qui sera en position 0 */
		if (i == 0) {
			// Premiere offre rencontree, on la met representante
			this.offers.push( tmp_offre );
		} else {
			// Calcul du prix de l'offre courante
			var px_f = getPriceFloat(tmp_offre["prix"]["normal"]["prix"]);
			if (tmp_offre["marchand"]["nom"] == this.NomMarchand_RueDuCommerce && this.coefpromo < 1 && px_f >= this.coefpromo_seuil) {
				px_f *= this.coefpromo;
			}
			// Calcul du prix frais de port compris de l'offre courante
			var px_f_fdpin = px_f;
			if (tmp_offre["prix"]["fraisdeport"]) {
				px_f_fdpin += getPriceFloat(tmp_offre["prix"]["fraisdeport"]);
			}
			px_f_fdpin = Math.round(px_f_fdpin*100)/100;
			// Calcul du prix de l'offre actuellement representante
			var px_f_1 = getPriceFloat(this.offers[0]["prix"]["normal"]["prix"]);
			if (this.offers[0]["marchand"]["nom"] == this.NomMarchand_RueDuCommerce && this.coefpromo < 1 && px_f_1 >= this.coefpromo_seuil) {
				px_f_1 *= this.coefpromo;
			}
			// Calcul du prix frais de port compris de l'offre representante
			var px_f_fdpin_1 = px_f_1;
			if (this.offers[0]["prix"]["fraisdeport"]) {
				px_f_fdpin_1 += getPriceFloat(this.offers[0]["prix"]["fraisdeport"]);
			}
			px_f_fdpin_1 = Math.round(px_f_fdpin_1*100)/100;
			// Si l'offre courante est en stock et moins chere fdpin que l'offre
			// 0, on la passe representante
			if (tmp_offre["stock"]["code"] == '2' && (px_f_fdpin < px_f_fdpin_1 || px_f_fdpin == px_f_fdpin_1 && tmp_offre["marchand"]["nom"] == this.NomMarchand_RueDuCommerce )) {
				//gestion du shift en position 0 de l'offre RDC pour le 3 fois
				if (this.installment_3x_for_productRdcDispo){
					this.installment_3x_for_representant = true;
				}
				tmp_offre["position"] = 0;
				this.offers.unshift( tmp_offre );
				// On decale les positions des offres suivante, qui ont changees
				
			} else {
				this.offers.push( tmp_offre );
			}
		}
      }
	for (j = 0; j < this.offers.length; j++) {
		this.offers[j]["position"]  = j;
	}
    this.displayImages();
    if (offres.length > 0)  {
    	/* maskage de certain block si rdc n'est pas le représentant */
    	if (this.offers[0]["marchand"]["nom"] != this.NomMarchand_RueDuCommerce ){
    		$(".tab_AccessoiresetServices, .tab_PkOptServ, .tab_BundleAuto, .tab_NosPacks , .reducssite, .uneuros, .prodcomp, .srvrdc, .opemkg").hide();
			$(".infoLivtrans").remove();
		} else {
		  /*
			 * le représentant est RDC donc on affiche pas les services GM et on
			 * regarde si y'a pas une vente flash
			 */
			$(".srvgm").hide();
			callHttpRequestRdc( "/shared/venteflash/ajax/venteflash.cfm?cid="+this.cid+"&pid="+this.product_id , this  )
		}
		
    	/* chargement fini... on peux afficher le contenu */
    	this.displayBlocPrice();
    	this.displayBlocLivraison();
  		// this.displayBlocService();
  		this.displayBlocMarchand();
  		
  		if (this.installment_3x_for_product && !this.installment_3x_for_representant) {
  	    	$("#installments").show();
  	    	$("#installments .desc ul li").html("Paiement en 3 fois disponible chez "+(this.installment_3x_for_productRdcDispo==true?this.NomMarchand_RueDuCommerce:"un autre marchand"));
  	    	$("#showinstallmentsoffer").show().click(function(){$.gmht.comparateur_show ();/* this.showOffer(this.installment_3x_for_offer) */});
  	    	// $(".pricemarchand .px_ctc").append("<br /><span
			// class='installments'>ou 3x
			// "+offre["prix"]["installments"]["3x"]+"&nbsp;&euro;</span>")
  	    }
  		/*
		 * if ( this.offers[0]["marchand"]["mention"] != "" ) {
		 * $(".mention").html(this.offers[0]["marchand"]["mention"]).show(); }
		 */
  		$(".fp .content .waiter").hide();
  		$(".fp .content .center").show();
		  $(".fp .content .right").show();
    } else {
    	// Pas d'offres, on masque
    	$(".fp .content .waiter").hide();
    	$(".fp .blcPrice, .fp .trsp, .fp .services, .fp .uneuros").hide();
    	$(".tab_AccessoiresetServices, .tab_PkOptServ, .tab_BundleAuto, .tab_NosPacks").hide();
    	$(".fp .center, .fp .inactive").show();
    	$(".fp .content .right").show();
    	$(".fp .marchands, .fp .reducs").hide();
    }
  }
  
  this.callbackError = function() {
    // Pas d'offres, on masque
    $(".fp .content .waiter").hide();
    $(".fp .blcPrice, .fp .trsp, .fp .services, .fp .uneuros").hide();
    $(".tab_AccessoiresetServices, .tab_PkOptServ, .tab_BundleAuto, .tab_NosPacks").hide();
    $(".fp .center, .fp .inactive").show();
    $(".fp .content .right").show();
    $(".fp .marchands, .fp .reducs").hide();
  }

	this.addImage = function (_s, _m, _l) {
		this.images.push(new oimage(_s, _m, _l));
	}

	this.stopwait = function () {
		$(".fp .content .waiter").hide();
		$(".fp .content .center").show();
		$(".fp .content .right").show();
	}


	this.purchase = function ( num ) {
		if (typeof(pageTracker) != 'undefined') {	
			var oDivComparateur = document.getElementById('popcomparateur');
			var sTrackEvent = 'FicheProduitGMHT';
			if(oDivComparateur.style.display == 'block')
				sTrackEvent = 'FicheProduitGMHT_comparateur_offres';
			pageTracker._trackEvent('Boutons', sTrackEvent, 'Ajouter_au_panier'); // tracking
																					// xiti
																					// pour
																					// le
																					// button
																					// acheter
		}
		if ($('#popcomparateur').is(':hidden') && this.offers[num]["marchand"]["nom"] == this.NomMarchand_RueDuCommerce && this.offers[num]["url_achat"].match(new RegExp("product_cid="+this.cid+".*product_id="+this.product_id))) {
			Shop_AddProduct('/info/basket/purchase.cfm?affPop=OK&baskdo=addproduct&FROMOPTIONCADDIE=yes&Product_CID='+this.cid+'&Product_ID='+this.product_id);
		} else {
			document.location.href = "http://www.rueducommerce.fr" + this.offers[num]["url_achat"];
		}

	}

  this.getCgv = function ( num ) {
    window.open ( this.offers[num]["cgv"] , '' , '' );
  }
  
  this.getMerchantSheet = function ( num ){
    if ( this.offers[num]["marchand"]["nom"] == this.NomMarchand_RueDuCommerce)
     window.open( "/aide/cgv.htm" , '', '');
    else
	   window.open( this.offers[num]["marchand"]["url_merchantsheet"], '', '');  
  }

  /** ********************** */
  /* fonctions d'affichage */
  /** ********************** */
  
  /*
	 * libelle pour l'économie (entré : tableau à 2 dim avec au moins en elt
	 * economie et economiepc
	 */
  this.getLibEconomie = function ( px )
  {
    var tmp_px = getPriceFloat( px["economie"] );
    var tmp_pc = getPriceFloat( px["economiepc"] );
    if ( tmp_px < this.seuilEconomie )
      return GMHTFormatPrix( tmp_pc , 0 )  + "&nbsp;%"
    else
      return GMHTFormatPrix( tmp_px , 0 ) + "&nbsp;&euro;"
  }
  
  /* Affichage des visuels */
	this.displayImages = function () {
	
		var defaultVisuel = false;
		if(this.images.length == 0){
			this.addImage(
				this.defaultVisuelSmall,
				this.defaultVisuelMedium,
				this.defaultVisuelLarge
			);
			defaultVisuel = true;
		}
		
		$('#mainimg img').attr('l',this.images[0].l).attr('m',this.images[0].m).attr('src',this.images[0].m);
		$('#thumbs>img').remove();	
		
		if(!defaultVisuel){
			for (i = 0; i< this.images.length && i < 4; i++) {
				img = this.images[i];
				$('#thumbs').append( 
						$('<img />')
							.attr("src",img.s).attr("m",img.m).attr("l",img.l)
							.mouseover (function(){
								$('#mainimg img').attr('src',$(this).attr('m')).attr('l',$(this).attr('l'));
							}));
			}
		}
	}

  /* Affichage du bloc prix */
  this.displayBlocPrice = function ( _p_offer_num ) {
  
    if ( typeof _p_offer_num == "undefined" ) _p_offer_num = 0;
    var offre = this.offers[_p_offer_num];
    
    var cgv = "<br><div style='font-size:10px;color:#5A5A5A;float:left;font-weight:normal' class='venduetexpedie'>Vendu et expédié par : <br><strong style='float:left;margin-right:5px'>"+ offre["marchand"]["nom"] +"</strong>";
    if ( ( offre["marchand"]["note"] != "" ) && (offre["marchand"]["nom"] != this.NomMarchand_RueDuCommerce) ) {
		    cgv += "<div class='stars'>";
			  if (offre["marchand"]["note"]>0) cgv += "<div style='width:" + (20*Math.floor(offre["marchand"]["note"])) + "%'></div>";
		    cgv += "</div>";
		    cgv += "</div><span onclick='gmht.getMerchantSheet(0)' class='cgv' style='clear:both'>(Voir les évaluations et CGV)</span>";
		}
		else {
		    cgv += "</div><span onclick='gmht.getMerchantSheet(0)' class='cgv' style='clear:both'>(Voir CGV)</span>";
    }
		
    
    var prix_finale = getPriceFloat( offre["prix"]["normal"]["prix"] );
	if (prix_finale < 150) {
		$(".opemkg3").hide();
	}
    
	idzCustomData = {"univers":this.monde,"client_id":"0","cart_amount":0,"product_price":prix_finale,"step":"","page_type":"fp"};
	
    /* retail */
    if ( isGoodPrice (offre["prix"]["normal"]["retail"]) && getPriceFloat(offre["prix"]["normal"]["economiepc"]) >= 3 )
      $("#retail em").html( getPriceFloat(offre["prix"]["normal"]["retail"]).toFixed(2) + "&nbsp;&euro;" );
    else
      $("#retail").hide();

    /* gestion solde / flash */
    if ( typeof offre["prix"]["soldes"] != "undefined" )
      {
        /* affichage du bandeau solde */
        var sd = $("<div class='soldefp'>")
        $(".blcPrice").before( sd );
        
        /* affichage des prix */
        $(".pricevf,.pricepromo").hide();
        
        if ( offre["prix"]["soldes"]["retail"] == offre["prix"]["normal"]["retail"] ) $("#retail").hide();
        
        $(".pricemarchand").addClass("prixBarre");
        $(".pricemarchand .px_ctc").html(offre["prix"]["soldes"]["retail"]+"&nbsp;&euro;")
        $(".pricemarchand .px_lib").html ( $(".pricemarchand .px_lib").html().replace(/:/gi , ' avant les soldes :' )  )

        var i = 2;
        while ( typeof offre["prix"]["soldes"]["demarque" + i] != "undefined" )
          {
            var lib_demarque = "Prix "+i+"eme démarque :"; 
            i++;
          }
        
        if ( lib_demarque ) {
			 $(".pricesoldes .pxsld .px_lib").html ( $(".pricesoldes .pxsld .px_lib").html().replace('Prix Soldé :' , lib_demarque )  )
		}

        $(".pricesoldes .pxsld .px_ctc").html( offre["prix"]["soldes"]["prix"] + "&nbsp;&euro;")

        if ( isGoodPrice(offre["prix"]["soldes"]["ecotaxe"]) )
          $(".ecoPart span").html( offre["prix"]["soldes"]["ecotaxe"] + "&nbsp;&euro;" );
        else $(".ecoPart").hide();
        
        prix_finale = getPriceFloat( offre["prix"]["soldes"]["prix"] );

      }
    else if ( typeof offre["prix"]["flash"] != "undefined" )
      {
        /* affichage du bandeau vente flash */
        var vf = $("<div class='vfchronofpghmt'>")
        $(".blcPrice").before( vf );
        // exemple de date : 2009-11-29 00:00:00
        var dte = offre["prix"]["flash"]["datefin"].replace(/[-:]/gi," ");
        dte = dte.split(" ");
        startChrono( dte[2] , dte[1] , dte[0] , dte[3] , dte[4] , dte[5] );
        
        /* affichage des prix */
        $(".pricesoldes,.pricepromo").hide();
        $(".pricemarchand").addClass("prixBarre");
        $(".pricemarchand .px_ctc").html(GMHTFormatPrix(offre["prix"]["flash"]["retail"])+"&nbsp;&euro;");
        $(".pricevf .px_ctc").html(GMHTFormatPrix(offre["prix"]["flash"]["prix"]) + "&nbsp;&euro;");
        $(".pricevf .px_lib").html( $(".pricevf .px_lib").html() + cgv );
        if ( isGoodPrice(offre["prix"]["flash"]["ecotaxe"]) )
          $(".ecoPart span").html( offre["prix"]["flash"]["ecotaxe"] + "&nbsp;&euro;" );
        else $(".ecoPart").hide();
        prix_finale = getPriceFloat( offre["prix"]["flash"]["prix"] );
        $(".pricevf").show();
        $(".pricemarchand .cgv,.pricemarchand div.venduetexpedie").hide();     
		$(".coeffpromo").remove();
		$(".coeffpromosoldes").remove();
		$(".opemkg3").hide();
      }
    else if ( ( typeof offre["prix"]["promo"] != "undefined" ) && ( offre["marchand"]["nom"] != this.NomMarchand_RueDuCommerce) ) /*
																																	 * les
																																	 * promos
																																	 * non
																																	 * RDC
																																	 */
      {
        $(".pricesoldes,.pricevf").hide();
        $(".pricemarchand").addClass("prixBarre");
        $(".pricemarchand .px_ctc").html(offre["prix"]["promo"]["retail"]+"&nbsp;&euro;")
        $(".pricepromo .px_ctc").html(offre["prix"]["promo"]["prix"] + "&nbsp;&euro;");
        
        $(".pricepromo .px_lib").html( $(".pricemarchand .px_lib").html() + cgv );
        $(".pricemarchand .px_lib").html("")
        
        if ( isGoodPrice(offre["prix"]["promo"]["ecotaxe"]) )
          $(".ecoPart span").html( offre["prix"]["promo"]["ecotaxe"] + "&nbsp;&euro;" );
        else $(".ecoPart").hide();
        prix_finale = getPriceFloat( offre["prix"]["promo"]["prix"] );
      }
    else
      {
        $(".pricesoldes,.pricevf,.pricepromo").hide();
        if ( isGoodPrice(offre["prix"]["normal"]["prix"]) )
          {
            $(".pricemarchand .px_ctc").html(offre["prix"]["normal"]["prix"]+"&nbsp;&euro;")
            $(".pricemarchand .px_lib").html( $(".pricemarchand .px_lib").html() + cgv )
          }
          
        if ( isGoodPrice(offre["prix"]["normal"]["ecotaxe"]) )
          $(".ecoPart span").html( offre["prix"]["normal"]["ecotaxe"] + "&nbsp;&euro;" )
        else
          $(".ecoPart").hide();
      }

    /* les promo RDC */
    if ( offre["marchand"]["nom"] == this.NomMarchand_RueDuCommerce)
      {
        if (( this.coefpromo < 1 ) && ( prix_finale > this.coefpromo_seuil ))
          {
            $(".pricemarchand").addClass("prixBarre");
            $(".pricepromo .px_ctc").html( GMHTFormatPrix(prix_finale * this.coefpromo) + "&nbsp;&euro;");
            $(".prices .px_lib .cgv,.prices .px_lib br,.prices  .venduetexpedie,.prices #installments").remove();
            $(".pricepromo .px_lib").html ( $(".pricepromo .px_lib").html().replace(/promo/gi , '"-' + (100-this.coefpromo*100) + '%"' ) + cgv  );
            $(".pricepromo").show();
			
			if ($(".vfchronofpghmt").length == 0) {
				if ( typeof offre["prix"]["soldes"] == "undefined" )
				{
					var sd = $("<div class='coeffpromo'>")
					$(".blcPrice").before( sd );
				} else {
					$(".soldefp").remove();
					var sd = $("<div class='coeffpromosoldes'>")
					$(".blcPrice").before( sd );
				}
			}
            
            if ( isGoodPrice(offre["prix"]["normal"]["economie"]) )
            {
              // y'avait déjà une économie
              var px = getPriceFloat( offre["prix"]["normal"]["economie"] );
              var pc = getPriceFloat( offre["prix"]["normal"]["economiepc"] );
              var newpx = px + ( prix_finale - prix_finale * this.coefpromo );
              var newpc = Math.round( px * newpx / px );
              offre["prix"]["normal"]["economie"] = GMHTFormatPrix ( newpx );
              offre["prix"]["normal"]["economiepc"] = newpc;
            }
            else
            {
              // y'avait pas d'économie avant
              var px = getPriceFloat( offre["prix"]["normal"]["prix"] );
              offre["prix"]["normal"]["economie"] = GMHTFormatPrix ( px - px  * this.coefpromo );
              offre["prix"]["normal"]["economiepc"] = 100 - 100 * this.coefpromo;
            }
          }
        else $(".pricepromo").hide();
      }

    /*
	 * affichage de l'économie => on prends toutes les économies valide et on
	 * prends la plus grande valeur
	 */
    var lstEconomie = new Array();
    if ( isGoodPrice(offre["prix"]["normal"]["economiepc"]) )
      lstEconomie.push( {"economiepc":getPriceFloat(offre["prix"]["normal"]["economiepc"]),"economie":getPriceFloat(offre["prix"]["normal"]["economie"])} );
    if (( typeof offre["prix"]["soldes"] != "undefined") && ( isGoodPrice(offre["prix"]["soldes"]["economiepc"])))
      lstEconomie.push( {"economiepc":getPriceFloat(offre["prix"]["soldes"]["economiepc"]),"economie":getPriceFloat(offre["prix"]["soldes"]["economie"])} );
    if (( typeof offre["prix"]["flash"] != "undefined") && ( isGoodPrice(offre["prix"]["flash"]["economiepc"]))) 
      lstEconomie.push( {"economiepc":getPriceFloat(offre["prix"]["flash"]["economiepc"]),"economie":getPriceFloat(offre["prix"]["flash"]["economie"])} );
    if (( typeof offre["prix"]["promo"] != "undefined") && ( isGoodPrice(offre["prix"]["promo"]["economiepc"]))) 
      lstEconomie.push( {"economiepc":getPriceFloat(offre["prix"]["promo"]["economiepc"]),"economie":getPriceFloat(offre["prix"]["promo"]["economie"])} );
    if (lstEconomie.length > 0)
    {
      lstEconomie.sort( function(a,b) {return a["economie"] - b["economie"]} ).reverse();
      $(".econom .px_ctc em").html( this.getLibEconomie ( lstEconomie[0] ) );
    }
    else
      $(".econom").hide();

    /* on barre tous les prix à barrer */
    $(".prices .prixBarre .px_ctc").each( function () { $(this).html( "<em>" + $(this).html() + "</em>" ) } );

    /* le 5 fois */
    if (( prix_finale >= this._5x_min ) && ( prix_finale <= this._5x_max ) && ( this._5x_actif == 1 ) && (isGoodPrice(offre["prix"]["normal"]["prix5x"])) )
      $("#cinqfois .ctc").html( offre["prix"]["normal"]["prix5x"] + "&nbsp;&euro;");
    else $("#cinqfois").hide();
    
    // Le nouveau 3x
    if (this.installment_3x_for_product && this.installment_3x_for_representant && isGoodPrice (offre["prix"]["installments"]["3x"])) {
    	$("#installments").show();
    	$("#installments .desc ul li").html("Paiement en 3 fois disponible chez "+(offre["marchand"]["nom"] == this.NomMarchand_RueDuCommerce?this.NomMarchand_RueDuCommerce:"ce marchand"));
    	$(".blcPrice .price:last:visible .px_ctc").append("<br /><span class='installments'>ou 3x "+offre["prix"]["installments"]["3x"]+"&nbsp;&euro;</span>")
    }

    /* la dispo */
    $("#dispo").html( this.getDispo(0) );

    if (offre["etat"]["is_occasion"]) {
      $('<table cellspacing="0" cellpadding="0">').html("<tr><td>Produit d'occasion : "+offre["etat"]["text"]+"</td></tr>").appendTo( $("div.blcPrice") )
    }
    
  }
  
  this.getDispo = function ( _p_pos ) {
    if ( this.offers[_p_pos]["marchand"]["nom"] == this.NomMarchand_RueDuCommerce)
      return "<img src='http://www.rueducommerce.fr/shared/delais/delai.afm?cid="+this.cid+"&pid="+this.product_id+"&s=10&pn="+this.partnumber+"&loc=FProd&r=0&oid="+this.objectgroup_id+"'>";
    else
      return "<div class='text_dispo_" + this.offers[_p_pos]["stock"]["code"] + "'>" + this.offers[_p_pos]["stock"]["libelle"] + "</div>";
  }
  
  /* Affichage du bloc livraison */
  this.displayBlocLivraison = function ( _p_nummarchand ) {
    if ( typeof _p_nummarchand == "undefined" ) _p_nummarchand = 0;
    if ( this.offers[_p_nummarchand]["marchand"]["nom"] == this.NomMarchand_RueDuCommerce )
      this.displayBlocLivraison_RDC(_p_nummarchand);
    else
      this.displayBlocLivraison_default(_p_nummarchand);
    
    if ( $(".fp .trsp ul:first li").length == 0 ) $(".fp .trsp").hide();
    else
 	{
	  	this._undisplayBlocLivraison();
	  	this._fixedBlocLivraison();
    }
  }
  
  /* fixation de la hauteur */
  this._fixedBlocLivraison = function( ) {
	  $(".fp .trsp ul li").hide();
	  $(".fp .trsp ul li:first").show();
	  $(".fp .trsp").css( "height","auto" );
	  if ($(".fp .trsp ul li").length > 1) {
		$("#moretrsp").show().click(function(){$(".fp .trsp ul li").show();$("#moretrsp").hide()});  
	  }
  }
  
  /*
	 * modifie la liste si elle fait plus de maxLinesLivraison lignes ajout d'un
	 * bouton + d'infos pour afficher toutes les lignes ajout d'un bouton -
	 * d'infos pour masquer les lignes
	 */ 
  this._undisplayBlocLivraison = function( ) {
  	
  	var eltsLi = $(".fp .trsp ul:first li").get();
  	var eltsLiToDisplay = new Array();
	
  	if ( eltsLi.length > this.maxLinesLivraison ) {
  		$(".fp .trsp ul:first li").remove();
  		for ( var cpt=0; cpt < eltsLi.length; cpt++ ) {
  			if ( cpt >= this.maxLinesLivraison ){
  				$(eltsLi[cpt]).css("display","none");
  			}
  			if ( cpt == this.maxLinesLivraison ) {
  				var eltLiShow = $("<li id='btShowLivraison'>").html("<span class='linkShow'>+ d'infos</span>");
				$(".fp .trsp ul:first").append(eltLiShow);
				var context = this;
				$('#btShowLivraison').click( 
					function() {
						$('#btShowLivraison ~ li').show("");
						$('#btShowLivraison').css("display","none");
						$('#btHideLivraison').css("display","block");
						context._fixedBlocLivraison();
					}
				);
  			}
			$(".fp .trsp ul:first").append(eltsLi[cpt]);
			if ( ( cpt +1 ) == eltsLi.length ) {
  				var eltLiHide = $("<li id='btHideLivraison'>").html("<span class='linkShow'>- d'infos</span>");
  				$(eltLiHide).css("display","none");
				$(".fp .trsp ul:first").append(eltLiHide);
  				var context = this;
				$('#btHideLivraison').click( 
					function() {
						$('#btShowLivraison ~ li').hide("");
						$('#btShowLivraison').css("display","block");
						$('#btHideLivraison').css("display","none");
						context._fixedBlocLivraison();
					}
				);
  			} 
  		}
  	}
  }
  
  this.displayBlocLivraison_RDC = function ( _p_nummarchand ) {
    if ( typeof _p_nummarchand == "undefined" ) _p_nummarchand = 0;
    var dataliv = this.offers[_p_nummarchand]["livraisons"];
    
    /* cas transporteur spéciale */
    if ( dataliv["mini"]["moyen"] == "Transporteur spécial" )
      {
      	/*if (this.cid == 9 && (this.objectgroup_id == 2816 || this.objectgroup_id == 2817)){
			$(".fp .trsp ul li:first").append( " <strong>offerte</strong>" );
			this.ope_fraisportgratuit = true;
		} else {*/
			$(".fp .trsp ul li:first").append( " pour <strong>" +  dataliv["mini"]["prix"] + "&nbsp;&euro;</strong>" );
		//}
      	return true;
      }

    /* autres cas */
    var lst_transport = new Array();
    var rg = new RegExp("[^a-zA-Z0-1]","g");

    lst_transport[ dataliv["mini"]["moyen"].replace(rg,"_") ] = dataliv["mini"];
    
    for ( i = 0 ; i < dataliv["autre"].length ; i++ )
      {
        lst_transport[ dataliv["autre"][i]["moyen"].replace(rg,"_") ] = dataliv["autre"][i];
      }

    var donotdisplay_colissimo = false;
    
	if ( typeof lst_transport["Relai"] != "undefined" )
      {
        var px = getPriceFloat ( lst_transport["Relai"]["prix"] );

        var txt = "Livraison en point relais ";
        if ( px == 0 ) txt += "<strong>offerte</strong>";
        else txt += "pour <strong>" + lst_transport["Relai"]["prix"] + "&nbsp;&euro;</strong>";
        txt += ". <span onclick=\"window.open('/Aide/29-Modes-de-livraison/#03')\">(+ d'infos)</span>";
        var li = $("<li>").html( txt );
        li.append( " Prévue en <strong>3 à 5 jours ouvrés</strong>" );
        $(".fp .trsp ul").append( li );
      }

    if ( (! donotdisplay_colissimo) && ( typeof lst_transport["Livraison_Normale"] != "undefined" ) )
      {
        var txt = "Livraison par Colissimo ";
        var px = getPriceFloat ( lst_transport["Livraison_Normale"]["prix"] );
        if ( px == 0 ) txt += "<strong>gratuite</strong>";
        else txt += "pour <strong>" + lst_transport["Livraison_Normale"]["prix"] + "&nbsp;&euro;</strong>";
        txt += ". <span onclick=\"window.open('/Aide/29-Modes-de-livraison/#01')\">(+ d'infos)</span>";
        var li = $("<li>").html( txt );
        if ( typeof lst_transport["Livraison_Normale"]["date"] != "undefined" )
        {
          var reg_date  = new RegExp("([0-9]{2,2}/[0-9]{2,2}/[0-9]{4,4})", "gi");
          li.append( lst_transport["Livraison_Normale"]["date"].replace( reg_date , "<strong>$1</strong>" ) ) ;
        }
        else
        {
          li.append( " Prévue en <strong>2 à 3 jours ouvrés</strong>" );
        }
        $(".fp .trsp ul").append( li );
      }

    if ( typeof lst_transport["Chronopost"] != "undefined" )
      {
        var px = getPriceFloat ( lst_transport["Chronopost"]["prix"] );
        donotdisplay_colissimo = ( px < 10 );
      
        var txt = "Livraison en <strong>24h</strong> par Chronopost ";
        if ( px == 0 ) txt += "<strong>gratuite</strong>";
        else txt += "pour <strong>" + lst_transport["Chronopost"]["prix"] + "&nbsp;&euro;</strong>";
        txt += ". <span onclick=\"window.open('/Aide/29-Modes-de-livraison/#02')\">(+ d'infos)</span>";
        var li = $("<li>").html( txt );
        $(".fp .trsp ul").append( li );
      }
    
  }

	this.displayBlocLivraison_default = function ( _p_nummarchand ) {

    if ( typeof _p_nummarchand == "undefined" ) _p_nummarchand = 0;
    var dataliv = this.offers[_p_nummarchand]["livraisons"];
    var lst_trsp = new Array ( dataliv["mini"] );
    lst_trsp = lst_trsp.concat( dataliv["autre"] );
    for ( var i = 0 ; i < lst_trsp.length ; i++ )
      {

        var lib = trim(lst_trsp[i]["moyen"]);
        var px = getPriceFloat ( lst_trsp[i]["prix"] );
        if ( px == 0 ) lib += " offert";
        else lib += " " + lst_trsp[i]["prix"] + "&nbsp;&euro;";

        var li = $("<li>").html( lib );

        if ( typeof lst_trsp[i]["date"] != "undefined" )
          {
            var reg_date  = new RegExp("([0-9]{2,2}/[0-9]{2,2}/[0-9]{4,4})", "gi");
            li.append( "<br />"+lst_trsp[i]["date"].replace( reg_date , "<strong>$1</strong>" ) );
          }
        else
          {
            var delais = lst_trsp[i]["delai"]; 
            if (delais > 48) delais = Math.ceil(delais / 24) + " jours ouvrés."
            else delais += "h ouvrées."
            li.append( "<br />Livraison prévue en <strong>" + delais + "</strong>");
          }
        $(".fp .trsp ul").append( li );
      }
    
  }

	/* Affichage du bloc autre marchand */
	this.displayBlocMarchand = function () {

    if ( this.offers.length > 1 )
      {
        for ( var i = 1 ; i < this.offers.length && i < 5 ; i++ )
          {
					var px_f = getPriceFloat(this.offers[i]["prix"]["normal"]["prix"]);
				    if (this.offers[i]["marchand"]["nom"] == this.NomMarchand_RueDuCommerce && this.coefpromo < 1 && px_f > this.coefpromo_seuil) {
						px_f *= this.coefpromo;
					}
					var html = "<h3>"+this.offers[i]["marchand"]["nom"]+"</h3><div class='prixMarchand'>"+GMHTFormatPrix(px_f)+"&nbsp;&euro;</div>";
            html += "<br class='clear'/>";
            if (this.offers[i]["prix"]["installments"] && this.offers[i]["prix"]["installments"]["3x"] ) {
            	html += "<span class='installments'>3x "+this.offers[i]["prix"]["installments"]["3x"]+"&nbsp;€</span>"
            }
            if ( this.offers[i]["marchand"]["note"] != "")
              {
    				    html += "<div class='stars'>";
    					  if (this.offers[i]["marchand"]["note"]>0) html += "<div style='width:" + (20*Math.floor(this.offers[i]["marchand"]["note"])) + "%'></div>";
    				    html += "</div>";
				      }
            else
              {
                html += "<div style='float:left'>";
                html += "Pas de note";
                html += "</div>";
              }
            html += "<div class='garantie' style='float:right'>"+this.offers[i]["garantie"]+"</div>"
				    html += "<br class='clear'/>";

            var div = $("<div class='ligneMarchand'>").html(html);
            $(".fp .marchands .linkOffre").before(div);
          }
        $(".fp .marchands .linkOffre span#nb").html(this.offers.length);
      }
    else { $(".fp .marchands").hide(); }
	}

	this.getMinPrice = function ( ) {
  
  	var min = getPriceFloat( this.offers[0]["prix"]["normal"]["prix"] );

    for ( var i = 1 ; i < this.offers.length ; i ++ )
      {
        tmp = getPriceFloat ( this.offers[i]["prix"]["normal"]["prix"] );
        if ( min > tmp ) min = tmp;
      }

    return GMHTFormatPrix( min );
  }
  
	this.getMinPriceFP = function ( ) {

  	var min = getPriceFloat ( this.offers[0]["prix"]["normal"]["prix"] ) + getPriceFloat( this.offers[0]["prix"]["fraisdeport"] );

    for ( var i = 1 ; i < this.offers.length ; i ++ )
      {
        tmp = getPriceFloat ( this.offers[i]["prix"]["normal"]["prix"] ) + getPriceFloat ( this.offers[i]["prix"]["fraisdeport"] ) ;
        if ( min > tmp ) min = tmp;
      }

    return GMHTFormatPrix ( min );
  }
	
	/** ***************** */
	/* le configurateur */
	/** ***************** */
	this.comparateur_show = function () {
	
    /* affichage du div transparent */
    if ( ! ( my_div = document.getElementById("div_opaque") ) )
			{
				my_div = document.createElement("DIV")
				my_div.id = "div_opaque"
				document.body.appendChild( my_div )
			}
		my_div.style.cssText="position:absolute;z-index:99;top:0px;left:0px;filter:alpha(opacity:60);display:;background:white"
		my_div.style.opacity = .6
		my_div.style.height = document.body.scrollHeight + "px"
		my_div.style.width =  document.body.scrollWidth + "px"
    /* affichage du div comparateur */
    my_div2 = document.getElementById("popcomparateur")
		my_div2.style.filter = null;
		my_div2.style.opacity = 1;
		my_div2.style.width = "920px";
		// my_div2.style.height = "60px"
		my_div2.style.top = (10+document.documentElement.clientHeight) + "px"
		my_div2.style.left = ( ( (document.documentElement.clientWidth-920) /2) + document.documentElement.scrollLeft) + "px"
		

		if (this.comparateur == null) this.comparateur = this.offers.slice();
		this.comparateur_displayListe();
		var prixPdtComp = getPriceFloat(this.comparateur[0]["prix"]["normal"]["prix"]);
		if (this.comparateur[0]["marchand"]["nom"] == this.NomMarchand_RueDuCommerce && this.coefpromo < 1 && prixPdtComp > this.coefpromo_seuil) {
			prixPdtComp *= this.coefpromo;
		}
		
		$("#popcomparateur .blocproduit span.px").html( this.getMinPrice()+ "&nbsp;&euro;"  );
		$("#popcomparateur .blocproduit .col3").html( "<span class='merch'>Vendu par <b>"+this.comparateur[0]["marchand"]["nom"] + "</b></span><br /><span class='px'>" + GMHTFormatPrix(prixPdtComp) + "&nbsp;&euro;</span>"  );
		if (this.installment_3x_for_product && this.comparateur[0]["prix"]["installments"] && this.comparateur[0]["prix"]["installments"]["3x"]) {
			$("#popcomparateur .blocproduit .col3").append("<br /><span class='installments'>ou 3x "+this.comparateur[0]["prix"]["installments"]["3x"]+"&nbsp;&euro;</span>");
        }
		$("#popcomparateur .blocproduit .dispo").html(this.getDispo(this.comparateur[0]["position"]));
		$("#popcomparateur .blocproduit .garantie").html( this.comparateur[0]["garantie"]);
		$("#popcomparateur .blocproduit .fraisport").html("Frais de port "+ (this.comparateur[0]["livraisons"]["mini"]["prix"]  == "0.00" || (this.ope_fraisportgratuit && this.comparateur[0]["marchand"]["nom"] == this.NomMarchand_RueDuCommerce) ? "gratuits":("à partir de "+this.comparateur[0]["livraisons"]["mini"]["prix"]+"&nbsp;&euro;")) );
		$("#popcomparateur .blocproduit .col3").append("<div class='btht pngFix' onclick='gmht.purchase("+this.comparateur[0]["position"]+");return false;'></div>");
		my_div2.style.display = "block";
    hauteurMax = document.documentElement.clientHeight - 20;
    if ( document.getElementById("popcomparateur").offsetHeight > hauteurMax)
      {
        $("#popcomparateur .ctc").css("height",(hauteurMax-200)+"px")
        $("#popcomparateur .ctc").css("overflow","auto");
        my_div2.style.width = "860px";
        my_div2.style.left = ( ( (document.documentElement.clientWidth-860) /2) + document.documentElement.scrollLeft) + "px"
      }

    my_div2.style.top = (((document.documentElement.clientHeight-document.getElementById("popcomparateur").offsetHeight)/2)+document.documentElement.scrollTop) + "px"
  }

  this.comparateur_displayListe =  function ( _p_order ) {
	  
	 if (this.installment_3x_for_product) {
		 $("#installmentspicto").show();
		 if (this.installment_3x_for_representant) {
			 $("#installmentspicto .text").html("disponible<br />chez le marchand choisi!");
		 } else {
			 $("#installmentspicto .text").html("disponible chez d'autres marchands<br /><u>Comparez les offres ci-dessous</u>");
		 }
	 } else {
		 $("#popcomparateur .blocproduit").css("width","906px");
	 }
    if ( typeof _p_order == "undefined" ) _p_order = null;
    this.comparateur_orderBy(_p_order);
    
    $("#ListeOffre tr.data").remove();
    for ( var i = 0 ; i < this.comparateur.length ; i++ )
      {
        var tr = $("<tr class='data "+((this.comparateur[i]["marchand"]["mention"]!="")&&(1==2)?'noborder':'')+" ligne"+(i%2)+"'>");
        var tds = "<td class='col1'>" + this.comparateur[i]["marchand"]["nom"] + "<br>";

        if ( this.comparateur[i]["marchand"]["note"] != "")
              {
    				    tds += "<div class='stars'>";
    					  if (this.comparateur[i]["marchand"]["note"]>0) tds += "<div style='width:" + (20*Math.floor(this.comparateur[i]["marchand"]["note"])) + "%'></div>";
    				    tds += "</div>";
				      }
            else
              {
                tds += "Pas de note";
              }
        tds += "</td>";
         
        tds += "<td class='col2'>"+this.getDispo(this.comparateur[i]["position"])+"</td>";
        tds += "<td class='col3'>"+this.comparateur[i]["livraisons"]["mini"]["date"];
        if (this.comparateur[i]["livraisons"]["mini"]["prix"] == "0.00" || (this.ope_fraisportgratuit && this.comparateur[i]["marchand"]["nom"] == this.NomMarchand_RueDuCommerce))
            tds += "<br />gratuit";
          else
            tds += "<br />à partir de <span class='fp'>"+this.comparateur[i]["livraisons"]["mini"]["prix"]+"&nbsp;&euro;</span>";
        tds += "</td>";
		
		var prixPdtComp = getPriceFloat(this.comparateur[i]["prix"]["normal"]["prix"]);
		if (this.comparateur[i]["marchand"]["nom"] == this.NomMarchand_RueDuCommerce && this.coefpromo < 1 && prixPdtComp > this.coefpromo_seuil) {
			prixPdtComp *= this.coefpromo;
		}
		// if ( $("#ListeOffre .col5").length > 0 ) { // condition temporaire
		// pour évité des problèmes de code js a jour mais pas le code de la
		// fiche !
	    tds += "<td class='col4'>" + this.comparateur[i]["garantie"] + "</td>";
	    // }
		tds += "<td class='col5'>"+GMHTFormatPrix(prixPdtComp)+"&nbsp;&euro;";
        if (this.installment_3x_for_product && this.comparateur[i]["prix"]["installments"] && this.comparateur[i]["prix"]["installments"]["3x"]) {
        	tds += "<br /><span class='installments'>ou 3x "+this.comparateur[i]["prix"]["installments"]["3x"]+"&nbsp;&euro;</span>";
        }
        tds += "</td>";
	        
        
        
        tds += "<td class='col6'><div class='btht pngFix' onclick='gmht.purchase("+this.comparateur[i]["position"]+");return false;'></div>";
        tr.html(tds);
        $("#ListeOffre").append( tr );
        // mention marchand pas encore actif, (pour plus tard)
        /*
		 * if ( this.comparateur[i]["marchand"]["mention"] != "" ) { var tr2 =
		 * $("<tr class='data'>"); var tds2 = "<td class='mentioncompligne"+(i%2)+" pngFix' colspan='7'>" +
		 * this.comparateur[i]["marchand"]["mention"] + "</td>";
		 * tr2.append(tds2); $("#ListeOffre").append( tr2 ); }
		 */
      }
    if (typeof DD_belatedPNG != "undefined" ) DD_belatedPNG.fix('.pngFix');
  }
  
  this.comparateur_close = function () {
    $("#div_opaque , #popcomparateur").hide();
  }
	this.comparateur_orderBy = function ( _p_order ) {
 	   this.comparateur = this.offers.slice();
 	   this.comparateur.sort( eval("sort_" + ( _p_order != null ? _p_order : 'prixtot_asc' ) ) );
 	   if ( _p_order != null )
      {
       $("#ListeOffre th img").each( function() { this.src = this.src.replace(/On.gif/gi,".gif") } );
       $("#ListeOffre th img." + _p_order).each( function() { this.src = this.src.replace(/.gif/gi,"On.gif") } );
      }
  }
	this.purchaseComp = function (_cid, _pid) {
		if (typeof(pageTracker) != 'undefined') {	
			pageTracker._trackEvent('Boutons', 'FicheProduitGMHT_upsell', 'Ajouter_au_panier'); // tracking
																								// xiti
																								// pour
																								// le
																								// button
																								// acheter
		}		
		Shop_AddProduct('/info/basket/purchase.cfm?affPop=OK&baskdo=addproduct&FROMOPTIONCADDIE=yes&Product_CID='+_cid+'&Product_ID='+_pid);
	}
}

function sort_date_liv_desc ( a , b ) { return sort_date_liv_asc ( b , a ); }
function sort_date_liv_asc ( a , b ) { return parseInt(a["livraisons"]["mini"]["delai"]) - parseInt(b["livraisons"]["mini"]["delai"]); }
function sort_prix_desc ( a , b ) { return sort_prix_asc ( b , a ); }
function sort_prix_asc ( a , b ) { return getPriceFloat(a["prix"]["normal"]["prix"]) - getPriceFloat(b["prix"]["normal"]["prix"]); }
function sort_fraisport_desc ( a , b ) { return sort_fraisport_asc ( b , a ); }
function sort_fraisport_asc ( a , b ) { return getPriceFloat(a["prix"]["fraisdeport"]) - getPriceFloat(b["prix"]["fraisdeport"]); }
function sort_prixtot_desc ( a , b ) { return sort_prixtot_asc ( b , a ); }
function sort_prixtot_asc ( a , b ) {
  var av = getPriceFloat(a["prix"]["normal"]["prix"]) + getPriceFloat(a["prix"]["fraisdeport"]);
  var bv = getPriceFloat(b["prix"]["normal"]["prix"]) + getPriceFloat(b["prix"]["fraisdeport"]);
  return av - bv;
}


