/* allJSFiles.js concatene tout les Js ci dessous
 * yvesrocher.js
 * addToFavorites.js
 * addToCart.js
 * scroll_v.js
 * urlencode.js
 * buildRequest.js
 * sarissa.js
 * flashobject_nurun.js,
 * swfobject.js
 * functions.js
 * fonctions_accueil.js
 * fonctions_general.js
 * fonctions_catalogue.js
 */
/***********************************************
 * urlencode.js
 ***********************************************/
var mErrorMessage = null;
var mAddToCartErrorMessage = null;

if (screen.width <= 1024) {
document.write('<link rel="STYLESHEET" type="text/css" href="/images/css2/littlescreen.css" />');
}
var isIE = false;

function URLEncode( str )
{
	// The Javascript escape and unescape functions do not correspond
	// with what browsers actually do...
	var SAFECHARS = "0123456789" +					// Numeric
					"ABCDEFGHIJKLMNOPQRSTUVWXYZ" +	// Alphabetic
					"abcdefghijklmnopqrstuvwxyz" +
					"-_.!~*'()";					// RFC2396 Mark characters
	var HEX = "0123456789ABCDEF";

	var plaintext = str;
	var encoded = "";
	for (var i = 0; i < plaintext.length; i++ ) {
		var ch = plaintext.charAt(i);
	    if (ch == " ") {
		    encoded += "+";				// x-www-urlencoded, rather than %20
		} else if (SAFECHARS.indexOf(ch) != -1) {
		    encoded += ch;
		} else {
		    var charCode = ch.charCodeAt(0);
			if (charCode > 255) {
				encoded += "+";
			} else {
				encoded += "%";
				encoded += HEX.charAt((charCode >> 4) & 0xF);
				encoded += HEX.charAt(charCode & 0xF);
			}
		}
	} // for

	return encoded;
};

function URLDecode( str )
{
   // Replace + with ' '
   // Replace %xx with equivalent character
   // Put [ERROR] in output if %xx is invalid.
   var HEXCHARS = "0123456789ABCDEFabcdef";
   var encoded = str;
   var plaintext = "";
   var i = 0;
   while (i < encoded.length) {
       var ch = encoded.charAt(i);
	   if (ch == "+") {
	       plaintext += " ";
		   i++;
	   } else if (ch == "%") {
			if (i < (encoded.length-2)
					&& HEXCHARS.indexOf(encoded.charAt(i+1)) != -1
					&& HEXCHARS.indexOf(encoded.charAt(i+2)) != -1 ) {
				plaintext += unescape( encoded.substr(i,3) );
				i += 3;
			} else {
				plaintext += "%[ERROR]";
				i++;
			}
		} else {
		   plaintext += ch;
		   i++;
		}
	} // while
   return plaintext;
};


/***********************************************
 * buildRequest.js
 ***********************************************/

/**
 * Title:        Ajax
 * Description: This class uses some jquery functions in order to make the code more robust including ajax calls. 
 * 				It replaces the old class AJAXRequest who's deprecated  
 * @author Abdelatif Djeghem
 * @version 1.0
*/
function Ajax (pMethod, pUrl, pData, pProcess, pAsync, pDosend){
	
	var ajax = this;
	
	ajax.pMethod = pMethod;
	ajax.pUrl = pUrl;
	ajax.pData = pData;
	ajax.pProcess = pProcess;
	ajax.pAsync = pAsync;
	ajax.pDosend = pDosend;
	
	ajax.attributes = new Array();
	
	// XMLHttpRequest object
	ajax.xhr = null;
	
	//if (typeof Ajax.initialized == "undefined" ) {
		
		// ajaxRequestNew method 
		Ajax.prototype.ajaxRequestNew = function(){
			
			var self = this;
			
			if (ajax.pProcess != null && ajax.pProcess != ""){
				self.process = ajax.pProcess;	
			}
			
		    if (ajax.pDosend || typeof ajax.pDosend == 'undefined') {
			    if (!ajax.pData) {
			    	ajax.pData = "";
			    }
		    }
		    
		    // if no pMethod specified, then default to POST
		    if (!ajax.pMethod) {
		        ajax.pMethod = "POST";
		    }
		    
		    ajax.pMethod = ajax.pMethod.toUpperCase();
		    
		    if (typeof ajax.pAsync == 'undefined' || ajax.pAsync == null) {
		        ajax.pAsync = true;
		    }
		    
		    ajax.xhr = $.ajax({
			   async: ajax.pAsync,
			   type: ajax.pMethod,
			   url: ajax.pUrl,
			   processData: true,
			   data: ajax.pData,
			   success: function(data){
				   self.process(data, ajax);
			   },
			   error: function(textStatus){
				   alert("There was a problem retrieving the XML data:\n" + textStatus);
			   }
			});
		}
		
		// processPostalCodeCityLookupNew method
		Ajax.prototype.processPostalCodeCityLookupNew = function(node){
			
			var cityHtml = '';
			var provinceHtml = '';
			var regionHtml = '';
			var maxCityLength = 38;
			try {
				maxCityLength = maxL;
			}catch(e){}
			
			switch (node) {
			case "city" : 	var city = ajax.getAttribute("name");
							var attribute = ajax.getAttribute("attribute");
							var selected = (attribute != null && attribute.length > 0);
							var longestCityName = city.length > longestCityName ? city.length : 0;
		        			var displayCity = city.toLowerCase();
		        			var tempCity = displayCity.split(' ');
		        			displayCity = '';
					        for(var c = 0; c < tempCity.length; c++) {
					        	displayCity += tempCity[c].substring(0,1).toUpperCase() + tempCity[c].substring(1,tempCity[c].length) + ' ';
					        }
					        if(cityIsText){
				        		cityHtml = '<input type="text" value="' + displayCity + '" style="width:150px;" id="city" name="city" maxlength="'+maxCityLength+'" size="'+maxCityLength+'" /><br/> ';
					        }	
					        else if(selected == "true"){
				        		cityHtml += '<option value="' + city + '" selected>' + displayCity + '</option>';
					        }
							else{
			        			cityHtml += '<option value="' + city + '">' + displayCity + '</option>';
							}
					        
							break;
							
			case "zone" : 	var zoneId = ajax.getAttribute("id");
				    		if(validShipType2Zone && unValidZones != null){
				    			for(zone in unValidZones){
				    				if(zoneId == zone && unValidZones[zone] == globShipmentMethodTypeId) {
				    					showHideValidateButton = true;
				    					break;
				    				}
				    			}
				    		}
				    		
							break;
							
			case "province" :	
				    		var provinceId = ajax.getAttribute("id");
				    		var provinceName = ajax.getAttribute("name");
				    		var attribute = ajax.getAttribute("attribute");
				    		
			        		if(validShipType2Province && unValidProvinces != null){
			        			for(prov in unValidProvinces){
			        				if(provinceId == prov && unValidProvinces[prov] == globShipmentMethodTypeId) {
			        					showHideValidateButton = true;
			        					break;
			        				}
			        			}
			        		}
			        		
			        		var selected = (attribute != null && attribute.nodeValue.length > 0);
			        		
			        		if(provinceIsText){
			        			provinceHtml = provinceName+'<input type="hidden" value="' + provinceId + '" style="width:150px;" id="stateProvinceGeoId" name="stateProvinceGeoId" /> ';
			        		}
			        		else if(selected=="true"){
			        			provinceHtml += '<option value="' + provinceId + '" selected>' + provinceName + '</option>';
			        		}
			        		else{
			        			provinceHtml += '<option value="' + provinceId + '">' + provinceName + '</option>';
			        		}
			        		
			        		break;
					    		
			case "region" :
        					var regionId = ajax.getAttribute("id");
			        		var region = ajax.getAttribute("name");
			        		var attribute = ajax.getAttribute("attribute");
			        		
			        		var selected = (attribute != null && attribute.nodeValue.length > 0);
			        		
			        		if(regionIsText){
			        			regionHtml = region+'<input type="hidden" value="' + regionId + '" style="width:150px;" id="locality" name="locality" /> ';
			        		}
			        		else if(selected=="true"){
				        		regionHtml += '<option value="' + regionId + '" selected>' + region + '</option>';
			        		}
							else{
			        			regionHtml += '<option value="' + regionId + '">' + region + '</option>';
							}
			        		
							break;
			}
			
		    var myCityHtml = '';
		    var myProvinceHtml = '';
		    var myRegionHtml = '';
		    
		    if(cityIsText){
		    	myCityHtml = (cityHtml=='')? '<span> --- </span>' : '<span>'+cityHtml+' </span>';
		    }
		    else{
		    	myCityHtml = '<span><select style="width:150px;" id="city" name="city" onChange="localValidate();" maxlength="'+maxCityLength+'">';
			    myCityHtml += cityHtml +' </select></span>';
		    }
		    
		    $("#ajaxPostalCodeCityLookup").html(myCityHtml);
		    
			if($("#ajaxPostalCodeProvinceLookup")){
				if(provinceIsText){
			    	myProvinceHtml = (provinceHtml == '')? '<span> --- </span>' : '<span>'+provinceHtml +' </span>';
				}
			    else{
					myProvinceHtml = '<span><select style="width:150px;" id="stateProvinceGeoId" name="stateProvinceGeoId" onChange="localValidate();" >';
				    myProvinceHtml += provinceHtml +' </select></span>';
			    }
				
				$("ajaxPostalCodeProvinceLookup").html(myProvinceHtml);
				if(showHideValidateButton ){
	        		$("#boutonvalidboxId").style.display = "none";
	        		$("#infoboutonvalidboxId").style.display = "block";
				} else if($("#infoboutonvalidboxId") != null){
					$("#boutonvalidboxId").show();
					$("#infoboutonvalidboxId").hide();
				}
			}
			
			if($("#ajaxPostalCodeRegionLookup")){
				if(regionIsText)
			    	myRegionHtml = (regionHtml == '')? '<span> --- </span>' : '<span>'+regionHtml +' </span>';
			    else{
					myRegionHtml = '<span><select style="width:150px;" id="locality" name="locality" onChange="localValidate();" >';
				    myRegionHtml += regionHtml +' </select></span>';
			    }
				$("#ajaxPostalCodeRegionLookup").html(myRegionHtml);
			}
			
			localValidate();
			
		}
		
		// processAddToCartNew method
		Ajax.prototype.processAddToCartNew = function(){
			
			var numberOfItems = ajax.getAttribute("numberOfItems");
		    var grandTotal = ajax.getAttribute("grandTotal");
		    var numberAdjustments = ajax.getAttribute("numberAdjustments");
		    var numberOfPromos = ajax.getAttribute("numberOfPromos");
		    var currency = ajax.getAttribute("currency");
		    var cartTotalLabel = ajax.getAttribute("cartTotalLabel");
		    var productInMyCart = ajax.getAttribute("productInMyCart");
		    var productsInMyCart = ajax.getAttribute("productsInMyCart");
		    var emptyCart = ajax.getAttribute("emptyCart");
		    var errMsg = ajax.getAttribute("errorMsg");

		    /* GDU  New vars for redesign 08 - Free Shipping */
			var ajaxAmountForFree = ajax.getAttribute("ajaxAmountForFree");
			var freeShippingText = ajax.getAttribute("freeShippingText");
			var giftLabel = ajax.getAttribute("giftLabel");
			var giftsLabel = ajax.getAttribute("giftsLabel");

			/* JMA Coremetrics */
			var cmProdId = ajax.getAttribute("cmProdId");
			var cmProdName = ajax.getAttribute("cmProdName");
			var cmProdQt = ajax.getAttribute("cmProdQt");
			var cmProdUnitPrice = ajax.getAttribute("cmProdUnitPrice");
			var cmProdCatId = ajax.getAttribute("cmProdCatId");
			var cmProdAtt = ajax.getAttribute("cmProdAtt");
			
	    	ajax.makeMicroCart(numberOfItems, numberOfPromos, grandTotal, productInMyCart, productsInMyCart, 
	    			emptyCart, freeShippingText, giftLabel, giftsLabel, errMsg, cmProdId, cmProdName, cmProdQt,
	    			cmProdUnitPrice, cmProdCatId, cmProdAtt);

		}
		
		Ajax.prototype.getAttribute = function (name){
			if(name != null){
				return ajax.attributes[name];
			}
		}
		
		Ajax.prototype.setAttribute = function (name, value){
			if(name != null && value != null){
				ajax.attributes[name] = value;
			}
		}
		
		// setXmlData method
		Ajax.prototype.setXmlData = function(xml, element, attributes, node){
			
			var data = null;
			
			$(xml).find(element).each(function(){
				if (typeof node != 'undefined' && node != null){
					$(this).find(node).each(function(){
						for (var i = 0; i < attributes.length; i++){
							var attrName = attributes[i];
							var attrValue = ajax.getAttrValue(this, attrName);
							if (typeof attrValue != null){
								ajax.setAttribute(attrName, attrValue)
							}
						}
					});
				}
				else {
					for (var i = 0; i < attributes.length; i++){
						var attrName = attributes[i];
						var attrValue = ajax.getAttrValue(this, attrName);
						ajax.setAttribute(attrName, attrValue);
					}					
				}
			});
		}
		
		// makeMicroCart method 
		Ajax.prototype.makeMicroCart = function(numberOfItems, numberOfPromos, grandTotal, productInMyCart, productsInMyCart, 
    					emptyCart, freeShippingText, giftLabel, giftsLabel, errMsg, cmProdId, cmProdName, cmProdQt,
    					cmProdUnitPrice, cmProdCatId, cmProdAtt){
			
			if(errMsg == null || errMsg == "null"){
		 		makeMicroCartHTML(numberOfItems, numberOfPromos, grandTotal, productInMyCart, productsInMyCart, emptyCart, 
		 				freeShippingText, giftLabel, giftsLabel);
			} 
			else {
					mErrorMessage = errMsg;
					try{
						errMsg = "<font color='red'>"+URLDecode(errMsg)+"</font>";
						document.getElementById("with-or-without-errors").innerHTML = errMsg;
					}catch(e){
						//IE error, we might want to do something in the future.
					}
					makeMicroCartHTML(numberOfItems, numberOfPromos, grandTotal, productInMyCart, productsInMyCart, 
							emptyCart, freeShippingText, giftLabel, giftsLabel);
			}
			
			ajax.coremetricsGenerateShopAction(cmProdId, cmProdName, cmProdQt, cmProdUnitPrice, cmProdCatId, cmProdAtt);
		}
		
		// coremetricsGenerateShopAction method 
		Ajax.prototype.coremetricsGenerateShopAction = function(cmProdId, cmProdName, cmProdQt, cmProdUnitPrice, cmProdCatId, cmProdAtt){
			if(cmProdId != null && cmProdName != null && cmProdQt != null && cmProdUnitPrice != null && cmProdCatId != null && cmProdAtt != null){
		 		coremetricsGenerateShopAction5(cmProdId, cmProdName, cmProdQt, cmProdUnitPrice, cmProdCatId, cmProdAtt);
		 	}			
		}
		
		// getAttrValue method 
		Ajax.prototype.getAttrValue = function(node, attrName){
			if (node && attrName){
				var attr = $(node).attr(attrName);
				return (typeof attr != "undefined" && attr != null) ? attr : null;
			}
		}
		
		//Ajax.initialized = true;
	//}
}

// Added by Abdel for Bird 2.8
function processAddToCartNew(xmlDocument, ajax){
	
	var addToCartAttributes = new Array("numberOfItems", "grandTotal", "numberAdjustments", "numberOfPromos", "currency",
			"cartTotalLabel", "productInMyCart", "productsInMyCart", "emptyCart", "errorMsg", "ajaxAmountForFree", "freeShippingText",
			"giftLabel", "giftsLabel", "cmProdId", "cmProdName", "cmProdQt", "cmProdUnitPrice", "cmProdCatId", "cmProdAtt");
	
    if (xmlDocument) {
    	var response = xmlDocument;
        var parser = new DOMParser();
	    xmlDocument = parser.parseFromString(response, "text/xml");
	    ajax.setXmlData(xmlDocument, 'shoppingCartData', addToCartAttributes);
	    ajax.processAddToCartNew();
    }
    else {
    	alert("There was a problem retrieving the XML data:\n" + ajax.xhr.statusText);
    }
}

 function AJAXRequest( pMethod, pUrl, pData, pProcess, pAsync, pDosend) {
    var self = this;
    // check the dom to see if this is IE or not
    if (window.XMLHttpRequest) {
        self.AJAX = new XMLHttpRequest();
    } else if (window.ActiveXObject) {
    	// Only if it is not a JWebUnit Test
        // Instantiate the latest MS ActiveX Objects
        if (navigator.userAgent != "ProsodieJWebUnit" && _ms_XMLHttpRequest_ActiveX) {
            self.AJAX = new ActiveXObject(_ms_XMLHttpRequest_ActiveX);
        } else {
	    // loops through the various versions of XMLHTTP to ensure we're using the latest
	    var versions = ["Msxml2.XMLHTTP.7.0", "Msxml2.XMLHTTP.6.0", "Msxml2.XMLHTTP.4.0", "MSXML2.XMLHTTP.3.0", "MSXML2.XMLHTTP",
                        "Microsoft.XMLHTTP"];

            for (var i = 0; i < versions.length ; i++) {
                try {
		    // try to create the object
		    // if it doesn't work, we'll try again
		    // if it does work, we'll save a reference to the proper one to speed up future instantiations
                    self.AJAX = new ActiveXObject(versions[i]);

                    if (self.AJAX) {
                        _ms_XMLHttpRequest_ActiveX = versions[i];
                        break;
                    }
                }
                catch (objException) {
                // trap; try next one
                } ;
            }

            ;
        }
    }

    self.process = pProcess;

    // create an anonymous function to log state changes
    self.AJAX.onreadystatechange = function( ) {
        //logger("AJAXRequest Handler: State =  " + self.AJAX.readyState);
        self.process(self.AJAX);
    }

    // if no pMethod specified, then default to POST
    if (!pMethod) {
        pMethod = "POST";
    }
    pMethod = pMethod.toUpperCase();

    if (typeof pAsync == 'undefined' || pAsync == null) {
        pAsync = true;
    }
    self.AJAX.open(pMethod, pUrl, pAsync);

    if (pMethod == "POST") {
		if (self.AJAX.overrideMimeType) {
          self.AJAX.setRequestHeader("Connection", "close");
        }
        self.AJAX.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        self.AJAX.setRequestHeader("Method", "POST " + pUrl + "HTTP/1.1");
        self.AJAX.setRequestHeader("X-Requested-With", "XMLHttpRequest");
    }
    // if pDosend is true or undefined, send the request
    // only fails is pDosend is false
    // you'd do this to set special request headers
    if ( pDosend || typeof pDosend == 'undefined' ) {
	    if ( !pData ) pData="";
	    self.AJAX.send(pData);
    }
    return self.AJAX;
}

/***********************************************
 * sarissa.js
 ***********************************************/
 function Sarissa(){};
Sarissa.PARSED_OK = "Document contains no parsing errors";
Sarissa.PARSED_EMPTY = "Document is empty";
Sarissa.PARSED_UNKNOWN_ERROR = "Not well-formed or other error";
var _sarissa_iNsCounter = 0;
var _SARISSA_IEPREFIX4XSLPARAM = "";
var _SARISSA_HAS_DOM_IMPLEMENTATION = document.implementation && true;
var _SARISSA_HAS_DOM_CREATE_DOCUMENT = _SARISSA_HAS_DOM_IMPLEMENTATION && document.implementation.createDocument;
var _SARISSA_HAS_DOM_FEATURE = _SARISSA_HAS_DOM_IMPLEMENTATION && document.implementation.hasFeature;
var _SARISSA_IS_MOZ = _SARISSA_HAS_DOM_CREATE_DOCUMENT && _SARISSA_HAS_DOM_FEATURE;
var _SARISSA_IS_SAFARI = (navigator.userAgent && navigator.vendor && (navigator.userAgent.toLowerCase().indexOf("applewebkit") != -1 || navigator.vendor.indexOf("Apple") != -1));
var _SARISSA_IS_IE = document.all && window.ActiveXObject && navigator.userAgent.toLowerCase().indexOf("msie") > -1  && navigator.userAgent.toLowerCase().indexOf("opera") == -1;
if(!window.Node || !Node.ELEMENT_NODE){
    Node = {ELEMENT_NODE: 1, ATTRIBUTE_NODE: 2, TEXT_NODE: 3, CDATA_SECTION_NODE: 4, ENTITY_REFERENCE_NODE: 5,  ENTITY_NODE: 6, PROCESSING_INSTRUCTION_NODE: 7, COMMENT_NODE: 8, DOCUMENT_NODE: 9, DOCUMENT_TYPE_NODE: 10, DOCUMENT_FRAGMENT_NODE: 11, NOTATION_NODE: 12};
};

// IE initialization
if(_SARISSA_IS_IE){
    // for XSLT parameter names, prefix needed by IE
    _SARISSA_IEPREFIX4XSLPARAM = "xsl:";
    // used to store the most recent ProgID available out of the above
    var _SARISSA_DOM_PROGID = "";
    var _SARISSA_XMLHTTP_PROGID = "";
    var _SARISSA_DOM_XMLWRITER = "";
    /**
     * Called when the Sarissa_xx.js file is parsed, to pick most recent
     * ProgIDs for IE, then gets destroyed.
     * @private
     * @param idList an array of MSXML PROGIDs from which the most recent will be picked for a given object
     * @param enabledList an array of arrays where each array has two items; the index of the PROGID for which a certain feature is enabled
     */
    Sarissa.pickRecentProgID = function (idList){
        // found progID flag
        var bFound = false , e;
        for(var i=0; i < idList.length && !bFound; i++){
            try{
                var oDoc = new ActiveXObject(idList[i]);
                o2Store = idList[i];
                bFound = true;
            }catch (objException){
                // trap; try next progID
                 e = objException;
            };
        };
        if (!bFound) {
            throw "Could not retreive a valid progID of Class: " + idList[idList.length-1]+". (original exception: "+e+")";
        };
        idList = null;
        return o2Store;
    };
    // pick best available MSXML progIDs
    _SARISSA_DOM_PROGID = null;
    _SARISSA_THREADEDDOM_PROGID = null;
    _SARISSA_XSLTEMPLATE_PROGID = null;
    _SARISSA_XMLHTTP_PROGID = null;
    if(!window.XMLHttpRequest){
        /**
         * Emulate XMLHttpRequest
         * @constructor
         */
        XMLHttpRequest = function() {
            if(!_SARISSA_XMLHTTP_PROGID){
                _SARISSA_XMLHTTP_PROGID = Sarissa.pickRecentProgID(["Msxml2.XMLHTTP.6.0", "Msxml2.XMLHTTP.4.0", "MSXML2.XMLHTTP.3.0", "MSXML2.XMLHTTP", "Microsoft.XMLHTTP"]);
            };
            return new ActiveXObject(_SARISSA_XMLHTTP_PROGID);
        };
    };
    // we dont need this anymore
    //============================================
    // Factory methods (IE)
    //============================================
    // see non-IE version
    Sarissa.getDomDocument = function(sUri, sName){
        if(!_SARISSA_DOM_PROGID){
            _SARISSA_DOM_PROGID = Sarissa.pickRecentProgID(["Msxml2.DOMDocument.5.0", "Msxml2.DOMDocument.4.0", "Msxml2.DOMDocument.3.0", "MSXML2.DOMDocument", "MSXML.DOMDocument", "Microsoft.XMLDOM"]);
        };
        var oDoc = new ActiveXObject(_SARISSA_DOM_PROGID);
        // if a root tag name was provided, we need to load it in the DOM object
        if (sName){
            // create an artifical namespace prefix
            // or reuse existing prefix if applicable
            var prefix = "";
            if(sUri){
                if(sName.indexOf(":") > 1){
                    prefix = sName.substring(0, sName.indexOf(":"));
                    sName = sName.substring(sName.indexOf(":")+1);
                }else{
                    prefix = "a" + (_sarissa_iNsCounter++);
                };
            };
            // use namespaces if a namespace URI exists
            if(sUri){
                oDoc.loadXML('<' + prefix+':'+sName + " xmlns:" + prefix + "=\"" + sUri + "\"" + " />");
            } else {
                oDoc.loadXML('<' + sName + " />");
            };
        };
        return oDoc;
    };
    // see non-IE version
    Sarissa.getParseErrorText = function (oDoc) {
        var parseErrorText = Sarissa.PARSED_OK;
        if(oDoc.parseError.errorCode != 0){
            parseErrorText = "XML Parsing Error: " + oDoc.parseError.reason +
                "\nLocation: " + oDoc.parseError.url +
                "\nLine Number " + oDoc.parseError.line + ", Column " +
                oDoc.parseError.linepos +
                ":\n" + oDoc.parseError.srcText +
                "\n";
            for(var i = 0;  i < oDoc.parseError.linepos;i++){
                parseErrorText += "-";
            };
            parseErrorText +=  "^\n";
        }
        else if(oDoc.documentElement == null){
            parseErrorText = Sarissa.PARSED_EMPTY;
        };
        return parseErrorText;
    };
    // see non-IE version
    Sarissa.setXpathNamespaces = function(oDoc, sNsSet) {
        oDoc.setProperty("SelectionLanguage", "XPath");
        oDoc.setProperty("SelectionNamespaces", sNsSet);
    };
    /**
     * Basic implementation of Mozilla's XSLTProcessor for IE.
     * Reuses the same XSLT stylesheet for multiple transforms
     * @constructor
     */
    XSLTProcessor = function(){
        if(!_SARISSA_XSLTEMPLATE_PROGID){
            _SARISSA_XSLTEMPLATE_PROGID = Sarissa.pickRecentProgID(["Msxml2.XSLTemplate.5.0", "Msxml2.XSLTemplate.4.0", "MSXML2.XSLTemplate.3.0"]);
        };
        this.template = new ActiveXObject(_SARISSA_XSLTEMPLATE_PROGID);
        this.processor = null;
    };
    /**
     * Imports the given XSLT DOM and compiles it to a reusable transform
     * <b>Note:</b> If the stylesheet was loaded from a URL and contains xsl:import or xsl:include elements,it will be reloaded to resolve those
     * @argument xslDoc The XSLT DOMDocument to import
     */
    XSLTProcessor.prototype.importStylesheet = function(xslDoc){
        if(!_SARISSA_THREADEDDOM_PROGID){
            _SARISSA_THREADEDDOM_PROGID = Sarissa.pickRecentProgID(["Msxml2.FreeThreadedDOMDocument.5.0", "MSXML2.FreeThreadedDOMDocument.4.0", "MSXML2.FreeThreadedDOMDocument.3.0"]);
            _SARISSA_DOM_XMLWRITER = Sarissa.pickRecentProgID(["Msxml2.MXXMLWriter.5.0", "Msxml2.MXXMLWriter.4.0", "Msxml2.MXXMLWriter.3.0", "MSXML2.MXXMLWriter", "MSXML.MXXMLWriter", "Microsoft.XMLDOM"]);
        };
        xslDoc.setProperty("SelectionLanguage", "XPath");
        xslDoc.setProperty("SelectionNamespaces", "xmlns:xsl='http://www.w3.org/1999/XSL/Transform'");
        // convert stylesheet to free threaded
        var converted = new ActiveXObject(_SARISSA_THREADEDDOM_PROGID);
        // make included/imported stylesheets work if exist and xsl was originally loaded from url
        if(xslDoc.url && xslDoc.selectSingleNode("//xsl:*[local-name() = 'import' or local-name() = 'include']") != null){
            converted.async = false;
            converted.load(xslDoc.url);
        } else {
            converted.loadXML(xslDoc.xml);
        };
        converted.setProperty("SelectionNamespaces", "xmlns:xsl='http://www.w3.org/1999/XSL/Transform'");
        var output = converted.selectSingleNode("//xsl:output");
        this.outputMethod = output ? output.getAttribute("method") : "html";
        this.template.stylesheet = converted;
        this.processor = this.template.createProcessor();
        // (re)set default param values
        this.paramsSet = new Array();
    };

    /**
     * Transform the given XML DOM and return the transformation result as a new DOM document
     * @argument sourceDoc The XML DOMDocument to transform
     * @return The transformation result as a DOM Document
     */
    XSLTProcessor.prototype.transformToDocument = function(sourceDoc){
        this.processor.input = sourceDoc;
        var outDoc = new ActiveXObject(_SARISSA_DOM_XMLWRITER);
        this.processor.output = outDoc;
        this.processor.transform();
        var oDoc = new ActiveXObject(_SARISSA_DOM_PROGID);
        oDoc.loadXML(outDoc.output+"");
        return oDoc;
    };

    /**
     * Transform the given XML DOM and return the transformation result as a new DOM fragment.
     * <b>Note</b>: The xsl:output method must match the nature of the owner document (XML/HTML).
     * @argument sourceDoc The XML DOMDocument to transform
     * @argument ownerDoc The owner of the result fragment
     * @return The transformation result as a DOM Document
     */
    XSLTProcessor.prototype.transformToFragment = function (sourceDoc, ownerDoc) {
        this.processor.input = sourceDoc;
        this.processor.transform();
        var s = this.processor.output;
        var f = ownerDoc.createDocumentFragment();
        if (this.outputMethod == 'text') {
            f.appendChild(ownerDoc.createTextNode(s));
        } else if (ownerDoc.body && ownerDoc.body.innerHTML) {
            var container = ownerDoc.createElement('div');
            container.innerHTML = s;
            while (container.hasChildNodes()) {
                f.appendChild(container.firstChild);
            }
            ownerDoc.removeChild(container);
        }
        else {
            var oDoc = new ActiveXObject(_SARISSA_DOM_PROGID);
            if (s.substring(0, 5) == '<?xml') {
                s = s.substring(s.indexOf('?>') + 2);
            }
            var xml = ''.concat('<my>', s, '</my>');
            oDoc.loadXML(xml);
            var container = oDoc.documentElement;
            while (container.hasChildNodes()) {
                f.appendChild(container.firstChild);
            }
            oDoc.removeChild(container);
        }
        return f;
    };

    /**
     * Set global XSLT parameter of the imported stylesheet
     * @argument nsURI The parameter namespace URI
     * @argument name The parameter base name
     * @argument value The new parameter value
     */
    XSLTProcessor.prototype.setParameter = function(nsURI, name, value){
        /* nsURI is optional but cannot be null */
        if(nsURI){
            this.processor.addParameter(name, value, nsURI);
        }else{
            this.processor.addParameter(name, value);
        };
        /* update updated params for getParameter */
        if(!this.paramsSet[""+nsURI]){
            this.paramsSet[""+nsURI] = new Array();
        };
        this.paramsSet[""+nsURI][name] = value;
    };
    /**
     * Gets a parameter if previously set by setParameter. Returns null
     * otherwise
     * @argument name The parameter base name
     * @argument value The new parameter value
     * @return The parameter value if reviously set by setParameter, null otherwise
     */
    XSLTProcessor.prototype.getParameter = function(nsURI, name){
        nsURI = nsURI || "";
        if(this.paramsSet[nsURI] && this.paramsSet[nsURI][name]){
            return this.paramsSet[nsURI][name];
        }else{
            return null;
        };
    };
}else{ /* end IE initialization, try to deal with real browsers now ;-) */
    if(_SARISSA_HAS_DOM_CREATE_DOCUMENT){
        /**
         * <p>Ensures the document was loaded correctly, otherwise sets the
         * parseError to -1 to indicate something went wrong. Internal use</p>
         * @private
         */
        Sarissa.__handleLoad__ = function(oDoc){
            Sarissa.__setReadyState__(oDoc, 4);
        };
        /**
        * <p>Attached by an event handler to the load event. Internal use.</p>
        * @private
        */
        _sarissa_XMLDocument_onload = function(){
            Sarissa.__handleLoad__(this);
        };
        /**
         * <p>Sets the readyState property of the given DOM Document object.
         * Internal use.</p>
         * @private
         * @argument oDoc the DOM Document object to fire the
         *          readystatechange event
         * @argument iReadyState the number to change the readystate property to
         */
        Sarissa.__setReadyState__ = function(oDoc, iReadyState){
            oDoc.readyState = iReadyState;
            oDoc.readystate = iReadyState;
            if (oDoc.onreadystatechange != null && typeof oDoc.onreadystatechange == "function")
                oDoc.onreadystatechange();
        };
        Sarissa.getDomDocument = function(sUri, sName){
            var oDoc = document.implementation.createDocument(sUri?sUri:null, sName?sName:null, null);
            if(!oDoc.onreadystatechange){

                /**
                * <p>Emulate IE's onreadystatechange attribute</p>
                */
                oDoc.onreadystatechange = null;
            };
            if(!oDoc.readyState){
                /**
                * <p>Emulates IE's readyState property, which always gives an integer from 0 to 4:</p>
                * <ul><li>1 == LOADING,</li>
                * <li>2 == LOADED,</li>
                * <li>3 == INTERACTIVE,</li>
                * <li>4 == COMPLETED</li></ul>
                */
                oDoc.readyState = 0;
            };
            oDoc.addEventListener("load", _sarissa_XMLDocument_onload, false);
            return oDoc;
        };
        if(window.XMLDocument){

        //if(window.XMLDocument) , now mainly for opera
        }// TODO: check if the new document has content before trying to copynodes, check  for error handling in DOM 3 LS
        else if(document.implementation && document.implementation.hasFeature && document.implementation.hasFeature('LS', '3.0')){

            /**
            * <p>Factory method to obtain a new DOM Document object</p>
            * @argument sUri the namespace of the root node (if any)
            * @argument sUri the local name of the root node (if any)
            * @returns a new DOM Document
            */
            Sarissa.getDomDocument = function(sUri, sName){
                var oDoc = document.implementation.createDocument(sUri?sUri:null, sName?sName:null, null);
                return oDoc;
            };
        }
        else {
            Sarissa.getDomDocument = function(sUri, sName){
                var oDoc = document.implementation.createDocument(sUri?sUri:null, sName?sName:null, null);
                // looks like safari does not create the root element for some unknown reason
                if(oDoc && (sUri || sName) && !oDoc.documentElement){
                    oDoc.appendChild(oDoc.createElementNS(sUri, sName));
                };
                return oDoc;
            };
        };
    };//if(_SARISSA_HAS_DOM_CREATE_DOCUMENT)
};
//==========================================
// Common stuff
//==========================================
if(!window.DOMParser){
    if(_SARISSA_IS_SAFARI){
        /*
         * DOMParser is a utility class, used to construct DOMDocuments from XML strings
         * @constructor
         */
        DOMParser = function() { };
        /**
        * Construct a new DOM Document from the given XMLstring
        * @param sXml the given XML string
        * @param contentType the content type of the document the given string represents (one of text/xml, application/xml, application/xhtml+xml).
        * @return a new DOM Document from the given XML string
        */
        DOMParser.prototype.parseFromString = function(sXml, contentType){
            var xmlhttp = new XMLHttpRequest();
            xmlhttp.open("GET", "data:text/xml;charset=utf-8," + encodeURIComponent(sXml), false);
            xmlhttp.send(null);
            return xmlhttp.responseXML;
        };
    }else if(Sarissa.getDomDocument && Sarissa.getDomDocument() && Sarissa.getDomDocument(null, "bar").xml){
        DOMParser = function() { };
        DOMParser.prototype.parseFromString = function(sXml, contentType){
            var doc = Sarissa.getDomDocument();
            doc.loadXML(sXml);
            return doc;
        };
    };
};

if(!document.importNode && _SARISSA_IS_IE){
    try{
        /**
        * Implementation of importNode for the context window document in IE
        * @param oNode the Node to import
        * @param bChildren whether to include the children of oNode
        * @returns the imported node for further use
        */
        document.importNode = function(oNode, bChildren){
            var tmp = document.createElement("div");
            if(bChildren){
                tmp.innerHTML = oNode.xml ? oNode.xml : oNode.innerHTML;
            }else{
                tmp.innerHTML = oNode.xml ? oNode.cloneNode(false).xml : oNode.cloneNode(false).innerHTML;
            };
            return tmp.getElementsByTagName("*")[0];
        };
    }catch(e){ };
};
if(!Sarissa.getParseErrorText){
    /**
     * <p>Returns a human readable description of the parsing error. Usefull
     * for debugging. Tip: append the returned error string in a &lt;pre&gt;
     * element if you want to render it.</p>
     * <p>Many thanks to Christian Stocker for the initial patch.</p>
     * @argument oDoc The target DOM document
     * @returns The parsing error description of the target Document in
     *          human readable form (preformated text)
     */
    Sarissa.getParseErrorText = function (oDoc){
        var parseErrorText = Sarissa.PARSED_OK;
        if(!oDoc.documentElement){
            parseErrorText = Sarissa.PARSED_EMPTY;
        } else if(oDoc.documentElement.tagName == "parsererror"){
            parseErrorText = oDoc.documentElement.firstChild.data;
            parseErrorText += "\n" +  oDoc.documentElement.firstChild.nextSibling.firstChild.data;
        } else if(oDoc.getElementsByTagName("parsererror").length > 0){
            var parsererror = oDoc.getElementsByTagName("parsererror")[0];
            parseErrorText = Sarissa.getText(parsererror, true)+"\n";
        } else if(oDoc.parseError && oDoc.parseError.errorCode != 0){
            parseErrorText = Sarissa.PARSED_UNKNOWN_ERROR;
        };
        return parseErrorText;
    };
};
Sarissa.getText = function(oNode, deep){
    var s = "";
    var nodes = oNode.childNodes;
    for(var i=0; i < nodes.length; i++){
        var node = nodes[i];
        var nodeType = node.nodeType;
        if(nodeType == Node.TEXT_NODE || nodeType == Node.CDATA_SECTION_NODE){
            s += node.data;
        } else if(deep == true
                    && (nodeType == Node.ELEMENT_NODE
                        || nodeType == Node.DOCUMENT_NODE
                        || nodeType == Node.DOCUMENT_FRAGMENT_NODE)){
            s += Sarissa.getText(node, true);
        };
    };
    return s;
};
if(!window.XMLSerializer
    && Sarissa.getDomDocument
    && Sarissa.getDomDocument("","foo", null).xml){
    /**
     * Utility class to serialize DOM Node objects to XML strings
     * @constructor
     */
    XMLSerializer = function(){};
    /**
     * Serialize the given DOM Node to an XML string
     * @param oNode the DOM Node to serialize
     */
    XMLSerializer.prototype.serializeToString = function(oNode) {
        return oNode.xml;
    };
};

/**
 * strips tags from a markup string
 */
Sarissa.stripTags = function (s) {
    return s.replace(/<[^>]+>/g,"");
};
/**
 * <p>Deletes all child nodes of the given node</p>
 * @argument oNode the Node to empty
 */
Sarissa.clearChildNodes = function(oNode) {
    // need to check for firstChild due to opera 8 bug with hasChildNodes
    while(oNode.firstChild) {
        oNode.removeChild(oNode.firstChild);
    };
};
/**
 * <p> Copies the childNodes of nodeFrom to nodeTo</p>
 * <p> <b>Note:</b> The second object's original content is deleted before
 * the copy operation, unless you supply a true third parameter</p>
 * @argument nodeFrom the Node to copy the childNodes from
 * @argument nodeTo the Node to copy the childNodes to
 * @argument bPreserveExisting whether to preserve the original content of nodeTo, default is false
 */
Sarissa.copyChildNodes = function(nodeFrom, nodeTo, bPreserveExisting) {
    if((!nodeFrom) || (!nodeTo)){
        throw "Both source and destination nodes must be provided";
    };
    if(!bPreserveExisting){
        Sarissa.clearChildNodes(nodeTo);
    };
    var ownerDoc = nodeTo.nodeType == Node.DOCUMENT_NODE ? nodeTo : nodeTo.ownerDocument;
    var nodes = nodeFrom.childNodes;
    if(ownerDoc.importNode)  {
        for(var i=0;i < nodes.length;i++) {
            nodeTo.appendChild(ownerDoc.importNode(nodes[i], true));
        };
    } else {
        for(var i=0;i < nodes.length;i++) {
            nodeTo.appendChild(nodes[i].cloneNode(true));
        };
    };
};

/**
 * <p> Moves the childNodes of nodeFrom to nodeTo</p>
 * <p> <b>Note:</b> The second object's original content is deleted before
 * the move operation, unless you supply a true third parameter</p>
 * @argument nodeFrom the Node to copy the childNodes from
 * @argument nodeTo the Node to copy the childNodes to
 * @argument bPreserveExisting whether to preserve the original content of nodeTo, default is
 */
Sarissa.moveChildNodes = function(nodeFrom, nodeTo, bPreserveExisting) {
    if((!nodeFrom) || (!nodeTo)){
        throw "Both source and destination nodes must be provided";
    };
    if(!bPreserveExisting){
        Sarissa.clearChildNodes(nodeTo);
    };
    var nodes = nodeFrom.childNodes;
    // if within the same doc, just move, else copy and delete
    if(nodeFrom.ownerDocument == nodeTo.ownerDocument){
        while(nodeFrom.firstChild){
            nodeTo.appendChild(nodeFrom.firstChild);
        };
    } else {
        var ownerDoc = nodeTo.nodeType == Node.DOCUMENT_NODE ? nodeTo : nodeTo.ownerDocument;
        if(ownerDoc.importNode) {
           for(var i=0;i < nodes.length;i++) {
               nodeTo.appendChild(ownerDoc.importNode(nodes[i], true));
           };
        }else{
           for(var i=0;i < nodes.length;i++) {
               nodeTo.appendChild(nodes[i].cloneNode(true));
           };
        };
        Sarissa.clearChildNodes(nodeFrom);
    };
};

/**
 * <p>Serialize any object to an XML string. All properties are serialized using the property name
 * as the XML element name. Array elements are rendered as <code>array-item</code> elements,
 * using their index/key as the value of the <code>key</code> attribute.</p>
 * @argument anyObject the object to serialize
 * @argument objectName a name for that object
 * @return the XML serializationj of the given object as a string
 */
Sarissa.xmlize = function(anyObject, objectName, indentSpace){
    indentSpace = indentSpace?indentSpace:'';
    var s = indentSpace  + '<' + objectName + '>';
    var isLeaf = false;
    if(!(anyObject instanceof Object) || anyObject instanceof Number || anyObject instanceof String
        || anyObject instanceof Boolean || anyObject instanceof Date){
        s += Sarissa.escape(""+anyObject);
        isLeaf = true;
    }else{
        s += "\n";
        var itemKey = '';
        var isArrayItem = anyObject instanceof Array;
        for(var name in anyObject){
            s += Sarissa.xmlize(anyObject[name], (isArrayItem?"array-item key=\""+name+"\"":name), indentSpace + "   ");
        };
        s += indentSpace;
    };
    return s += (objectName.indexOf(' ')!=-1?"</array-item>\n":"</" + objectName + ">\n");
};

/**
 * Escape the given string chacters that correspond to the five predefined XML entities
 * @param sXml the string to escape
 */
Sarissa.escape = function(sXml){
    return sXml.replace(/&/g, "&amp;")
        .replace(/</g, "&lt;")
        .replace(/>/g, "&gt;")
        .replace(/"/g, "&quot;")
        .replace(/'/g, "&apos;");
};

/**
 * Unescape the given string. This turns the occurences of the predefined XML
 * entities to become the characters they represent correspond to the five predefined XML entities
 * @param sXml the string to unescape
 */
Sarissa.unescape = function(sXml){
    return sXml.replace(/&apos;/g,"'")
        .replace(/&quot;/g,"\"")
        .replace(/&gt;/g,">")
        .replace(/&lt;/g,"<")
        .replace(/&amp;/g,"&");
};
 /***********************************************
 * flashobject_nurun.js
 ***********************************************/
 //RAJOUT pour gestion appel JS FlashExpressInstall hors du *.AS
function flashExpressInstalled(){
	if(navigator.appName.indexOf("Microsoft") >= 0){
		top.window.opener = self;
		top.close();
	}
	else{
		regalInterv = setInterval("closeFirefox()", 1000);
		//top.window.open('','_parent','');
	}

}
function closeFirefox(){
	top.window.open('','_parent','');
	top.close();
	clearInterval(regalInterv);
}
function flashExpressInstallCanceled(){
	alert('This content requires a more recent version of the Macromedia Flash Player.');
}
function flashExpressInstallFailed(){
	alert('There was an error downloading the Flash Player update. Please try again later, or visit macromedia.com to download the latest version of the Flash plugin.');
}
/**
 * FlashObject v1.3c: Flash detection and embed - http://blog.deconcept.com/flashobject/
 *
 * FlashObject is (c) 2006 Geoff Stearns and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 */
if(typeof com == "undefined") var com = new Object();
if(typeof com.deconcept == "undefined") com.deconcept = new Object();
if(typeof com.deconcept.util == "undefined") com.deconcept.util = new Object();
if(typeof com.deconcept.FlashObjectUtil == "undefined") com.deconcept.FlashObjectUtil = new Object();
com.deconcept.FlashObject = function(swf, id, w, h, ver, c, useExpressInstall, quality, xiRedirectUrl, redirectUrl, detectKey, noFlashMessage){
  if (!document.createElement || !document.getElementById) return;
  this.DETECT_KEY = detectKey ? detectKey : 'detectflash';
  this.skipDetect = com.deconcept.util.getRequestParameter(this.DETECT_KEY);
  this.params = new Object();
  this.variables = new Object();
  this.attributes = new Array();
  this.useExpressInstall = useExpressInstall;
  this.setAttribute('noFlashMessage', '');
  if(noFlashMessage) this.setAttribute('noFlashMessage',noFlashMessage);
  if(swf) this.setAttribute('swf', swf);
  if(id) this.setAttribute('id', id);
  if(w) this.setAttribute('width', w);
  if(h) this.setAttribute('height', h);
  if(ver) this.setAttribute('version', new com.deconcept.PlayerVersion(ver.toString().split(".")));
  this.installedVer = com.deconcept.FlashObjectUtil.getPlayerVersion(this.getAttribute('version'), useExpressInstall);
  if(c) this.addParam('bgcolor', c);
  var q = quality ? quality : 'high';
  this.addParam('quality', q);
  var xir = (xiRedirectUrl) ? xiRedirectUrl : top.window.location;
  this.setAttribute('xiRedirectUrl', xir);
  this.setAttribute('redirectUrl', '');
  if(redirectUrl) this.setAttribute('redirectUrl', redirectUrl);
}
com.deconcept.FlashObject.prototype = {
  setAttribute: function(name, value){
    this.attributes[name] = value;
  },
  getAttribute: function(name){
    return this.attributes[name];
  },
  addParam: function(name, value){
    this.params[name] = value;
  },
  getParams: function(){
    return this.params;
  },
  addVariable: function(name, value){
    this.variables[name] = value;
  },
  getVariable: function(name){
    return this.variables[name];
  },
  getVariables: function(){
    return this.variables;
  },
  createParamTag: function(n, v){
    var p = document.createElement('param');
    p.setAttribute('name', n);
    p.setAttribute('value', v);
    return p;
  },
  getVariablePairs: function(){
    var variablePairs = new Array();
    var key;
    var variables = this.getVariables();
    for(key in variables){
      variablePairs.push(key +"="+ variables[key]);
    }
    return variablePairs;
  },
  getFlashHTML: function() {
    var flashNode = "";
    if (navigator.plugins && navigator.mimeTypes && navigator.mimeTypes.length) { // netscape plugin architecture
      if (this.getAttribute("doExpressInstall")) this.addVariable("MMplayerType", "PlugIn");
      flashNode = '<embed type="application/x-shockwave-flash" src="'+ this.getAttribute('swf') +'" width="'+ this.getAttribute('width') +'" height="'+ this.getAttribute('height') +'"';
      flashNode += ' id="'+ this.getAttribute('id') +'" name="'+ this.getAttribute('id') +'" ';
      var params = this.getParams();
       for(var key in params){ flashNode += [key] +'="'+ params[key] +'" '; }
      var pairs = this.getVariablePairs().join("&");
       if (pairs.length > 0){ flashNode += 'flashvars="'+ pairs +'"'; }
      flashNode += '/>';
    } else { // PC IE
      if (this.getAttribute("doExpressInstall")) this.addVariable("MMplayerType", "ActiveX");
      flashNode = '<object id="'+ this.getAttribute('id') +'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+ this.getAttribute('width') +'" height="'+ this.getAttribute('height') +'">';
      flashNode += '<param name="movie" value="'+ this.getAttribute('swf') +'" />';
      var params = this.getParams();
       for(var key in params) {
        flashNode += '<param name="'+ key +'" value="'+ params[key] +'" />';
       }
      var pairs = this.getVariablePairs().join("&");
       if(pairs.length > 0) flashNode += '<param name="flashvars" value="'+ pairs +'" />';
      flashNode += "</object>";
    }
    return flashNode;
  },
  write: function(elementId){
    if(this.useExpressInstall) {
      // check to see if we need to do an express install
      var expressInstallReqVer = new com.deconcept.PlayerVersion([6,0,65]);
      if (this.installedVer.versionIsValid(expressInstallReqVer) && !this.installedVer.versionIsValid(this.getAttribute('version'))) {
        this.setAttribute('doExpressInstall', true);
        this.addVariable("MMredirectURL", escape(this.getAttribute('xiRedirectUrl')));
        document.title = document.title.slice(0, 47) + " - Flash Player Installation";
        this.addVariable("MMdoctitle", document.title);
      }
    } else {
      this.setAttribute('doExpressInstall', false);
    }
    if(this.skipDetect || this.getAttribute('doExpressInstall') || this.installedVer.versionIsValid(this.getAttribute('version'))){
      var n = (typeof elementId == 'string') ? document.getElementById(elementId) : elementId;
      n.innerHTML = this.getFlashHTML();
    }else{
      if(this.getAttribute('redirectUrl') != "") {
	if(this.getAttribute('noFlashMessage') != "") {
          var check = window.confirm(this.getAttribute('noFlashMessage'));
	  if(check == true) window.open(this.getAttribute('redirectUrl'));//document.location.replace(this.getAttribute('redirectUrl'));
	}else{
	  document.location.replace(this.getAttribute('redirectUrl'));
	}
      }
    }
  }
}

/* ---- detection functions ---- */
com.deconcept.FlashObjectUtil.getPlayerVersion = function(reqVer, xiInstall){
  var PlayerVersion = new com.deconcept.PlayerVersion(0,0,0);
  if(navigator.plugins && navigator.mimeTypes.length){
    var x = navigator.plugins["Shockwave Flash"];
    if(x && x.description) {
      PlayerVersion = new com.deconcept.PlayerVersion(x.description.replace(/([a-z]|[A-Z]|\s)+/, "").replace(/(\s+r|\s+b[0-9]+)/, ".").split("."));
    }
  }else{
    try{
      var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
      for (var i=3; axo!=null; i++) {
        axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+i);
        PlayerVersion = new com.deconcept.PlayerVersion([i,0,0]);
      }
    }catch(e){}
    if (reqVer && PlayerVersion.major > reqVer.major) return PlayerVersion; // version is ok, skip minor detection
    // this only does the minor rev lookup if the user's major version
    // is not 6 or we are checking for a specific minor or revision number
    // see http://blog.deconcept.com/2006/01/11/getvariable-setvariable-crash-internet-explorer-flash-6/
    if (!reqVer || ((reqVer.minor != 0 || reqVer.rev != 0) && PlayerVersion.major == reqVer.major) || PlayerVersion.major != 6 || xiInstall) {
      try{
        PlayerVersion = new com.deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));
      }catch(e){}
    }
  }
  return PlayerVersion;
}
com.deconcept.PlayerVersion = function(arrVersion){
  this.major = parseInt(arrVersion[0]) || 0;
  this.minor = parseInt(arrVersion[1]) || 0;
  this.rev = parseInt(arrVersion[2]) || 0;
}
com.deconcept.PlayerVersion.prototype.versionIsValid = function(fv){
  if(this.major < fv.major) return false;
  if(this.major > fv.major) return true;
  if(this.minor < fv.minor) return false;
  if(this.minor > fv.minor) return true;
  if(this.rev < fv.rev) return false;
  return true;
}
/* ---- get value of query string param ---- */
com.deconcept.util = {
  getRequestParameter: function(param){
    var q = document.location.search || document.location.href.hash;
    if(q){
      var startIndex = q.indexOf(param +"=");
      var endIndex = (q.indexOf("&", startIndex) > -1) ? q.indexOf("&", startIndex) : q.length;
      if (q.length > 1 && startIndex > -1) {
        return q.substring(q.indexOf("=", startIndex)+1, endIndex);
      }
    }
    return "";
  },
  removeChildren: function(n){
    while (n.hasChildNodes()) n.removeChild(n.firstChild);
  }
}

/* add Array.push if needed (ie5) */
if (Array.prototype.push == null) { Array.prototype.push = function(item) { this[this.length] = item; return this.length; }}

/* add some aliases for ease of use/backwards compatibility */
var getQueryParamValue = com.deconcept.util.getRequestParameter;
var FlashObject = com.deconcept.FlashObject;


 /***********************************************
 * swfobject.js
 ***********************************************/
 if(typeof deconcept=="undefined"){var deconcept=new Object();}if(typeof deconcept.util=="undefined"){deconcept.util=new Object();}if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object();}deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a){if(!document.getElementById){return;}this.DETECT_KEY=_a?_a:"detectflash";this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);this.params=new Object();this.variables=new Object();this.attributes=new Array();if(_1){this.setAttribute("swf",_1);}if(id){this.setAttribute("id",id);}if(w){this.setAttribute("width",w);}if(h){this.setAttribute("height",h);}if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));}this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion();if(!window.opera&&document.all&&this.installedVer.major>7){deconcept.SWFObject.doPrepUnload=true;}if(c){this.addParam("bgcolor",c);}var q=_7?_7:"high";this.addParam("quality",q);this.setAttribute("useExpressInstall",false);this.setAttribute("doExpressInstall",false);var _c=(_8)?_8:window.location;this.setAttribute("xiRedirectUrl",_c);this.setAttribute("redirectUrl","");if(_9){this.setAttribute("redirectUrl",_9);}};deconcept.SWFObject.prototype={useExpressInstall:function(_d){this.xiSWFPath=!_d?"expressinstall.swf":_d;this.setAttribute("useExpressInstall",true);},setAttribute:function(_e,_f){this.attributes[_e]=_f;},getAttribute:function(_10){return this.attributes[_10];},addParam:function(_11,_12){this.params[_11]=_12;},getParams:function(){return this.params;},addVariable:function(_13,_14){this.variables[_13]=_14;},getVariable:function(_15){return this.variables[_15];},getVariables:function(){return this.variables;},getVariablePairs:function(){var _16=new Array();var key;var _18=this.getVariables();for(key in _18){_16.push(key+"="+_18[key]);}return _16;},getSWFHTML:function(){var _19="";if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","PlugIn");this.setAttribute("swf",this.xiSWFPath);}_19="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\"";_19+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";var _1a=this.getParams();for(var key in _1a){_19+=[key]+"=\""+_1a[key]+"\" ";}var _1c=this.getVariablePairs().join("&");if(_1c.length>0){_19+="flashvars=\""+_1c+"\"";}_19+="/>";}else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");this.setAttribute("swf",this.xiSWFPath);}_19="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\">";_19+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";var _1d=this.getParams();for(var key in _1d){_19+="<param name=\""+key+"\" value=\""+_1d[key]+"\" />";}var _1f=this.getVariablePairs().join("&");if(_1f.length>0){_19+="<param name=\"flashvars\" value=\""+_1f+"\" />";}_19+="</object>";}return _19;},write:function(_20){if(this.getAttribute("useExpressInstall")){var _21=new deconcept.PlayerVersion([6,0,65]);if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){this.setAttribute("doExpressInstall",true);this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));document.title=document.title.slice(0,47)+" - Flash Player Installation";this.addVariable("MMdoctitle",document.title);}}if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){var n=(typeof _20=="string")?document.getElementById(_20):_20;n.innerHTML=this.getSWFHTML();return true;}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}return false;}};deconcept.SWFObjectUtil.getPlayerVersion=function(){var _23=new deconcept.PlayerVersion([0,0,0]);if(navigator.plugins&&navigator.mimeTypes.length){var x=navigator.plugins["Shockwave Flash"];if(x&&x.description){_23=new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}}else{try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}catch(e){try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");_23=new deconcept.PlayerVersion([6,0,21]);axo.AllowScriptAccess="always";}catch(e){if(_23.major==6){return _23;}}try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}catch(e){}}if(axo!=null){_23=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}}return _23;};deconcept.PlayerVersion=function(_27){this.major=_27[0]!=null?parseInt(_27[0]):0;this.minor=_27[1]!=null?parseInt(_27[1]):0;this.rev=_27[2]!=null?parseInt(_27[2]):0;};deconcept.PlayerVersion.prototype.versionIsValid=function(fv){if(this.major<fv.major){return false;}if(this.major>fv.major){return true;}if(this.minor<fv.minor){return false;}if(this.minor>fv.minor){return true;}if(this.rev<fv.rev){return false;}return true;};deconcept.util={getRequestParameter:function(_29){var q=document.location.search||document.location.hash;if(q){var _2b=q.substring(1).split("&");for(var i=0;i<_2b.length;i++){if(_2b[i].substring(0,_2b[i].indexOf("="))==_29){return _2b[i].substring((_2b[i].indexOf("=")+1));}}}return "";}};deconcept.SWFObjectUtil.cleanupSWFs=function(){var _2d=document.getElementsByTagName("OBJECT");for(var i=_2d.length;i>0;i--){_2d[i].style.display="none";for(var x in _2d[i]){if(typeof _2d[i][x]=="function"){_2d[i][x]=function(){};}}}};if(deconcept.SWFObject.doPrepUnload){deconcept.SWFObjectUtil.prepUnload=function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){};window.attachEvent("onunload",deconcept.SWFObjectUtil.cleanupSWFs);};window.attachEvent("onbeforeunload",deconcept.SWFObjectUtil.prepUnload);}if(Array.prototype.push==null){Array.prototype.push=function(_30){this[this.length]=_30;return this.length;};}var getQueryParamValue=deconcept.util.getRequestParameter;var FlashObject=deconcept.SWFObject;var SWFObject=deconcept.SWFObject;

 /***********************************************
 * functions.js
 ***********************************************/
 function dispatch() {
	//----
	var mere = this.creator;
	var dispatchURL = 'index.html';
	//----
	// Detecte si popup ou dispatch : site minimise



	if (mere) {
		// Redirection de la dispatch et Fermeture de la popup
		mere.location = dispatchURL;
		mere.focus();
		//
		this.close();
	} else {
		// Popup
		this.location = dispatchURL;
	}
	//-----
}
//----
/*
Execute la fonction showMe
*/
//----
function showMeJS () {
	if (thisMovie("JMWeston")) {
	     thisMovie("JMWeston").showMe();
	 }
}

function thisMovie (movieName) {
     if (navigator.appName.indexOf("Microsoft") != -1) {
          return window[movieName]
     } else {
          return document[movieName]
     }
}
//----
/*
R?cup?ration des param de l'url
*/
//----
function recupFlashVars(so) {
	//----
	var url = location.href;
	var start = url.lastIndexOf('#') + 1;
	//----
	if (start > 5) {
		var nReq = url.substring(start, url.length);
		nReqT = nReq.split("/");
		var nb = nReqT.length;
		//----
		switch (true) {
			case (nb > 0 && nReqT[0].length > 1):
				so.addVariable('lang', nReqT[0]);
			case (nb > 1):
				//so.addVariable('directLink', nReq.splice(1, nb));
				so.addVariable('directLink', nReq);
				break;
		}
	}
	//----
}
//----
/*
Indique si fullscreen ou non
*/
//----
function isFullScreen() {
	var mere = this.creator;
	if (mere) {
		thisMovie("JMWeston").isFullScreen(true);
	} else {
		thisMovie("JMWeston").isFullScreen(false);
	}
}
//----
/*
Lance le site en popup
ou
Ferme le site en popup et change la dispatch
*/
//----
function fullScreen(url) {
	//----
	var mere = this.creator;
	var homeURL = 'home.html';
	var homeParam = 'width='+ self.screen.width + ', height='+ self.screen.height +', type=fullWindow, fullscreen, scrollbars=yes, resizable=yes';
	//----
	// r??criture de l'url
	if (url != 'null' && url) {
		homeURL += '#' + url;
	}
	//----
	// D?tecte si popup ou dispatch (site minimise)



	if (mere) {
		// Redirection de la dispatch et Fermeture de la popup
		mere.location = homeURL;
		mere.focus();
		//
		this.close();
	} else {
		// Popup
		var fille = window.open(homeURL, 'HOME', homeParam);
		fille.creator = this;
		fille.focus();
		// Retour ? la dispatch
		location.href = 'index.html'
	}
	//-----
}
//----

function loadVideo(videoName)
	{
	//-----
	fo = new SWFObject("/rsc/player-flash/videoplayer.swf", "videoPlayer", "508", "315", "8.0.0.0", "#FFFFFF", true);
	fo.addParam("scale", "noScale");
	fo.addParam("allowScriptAccess", "always");
	fo.addVariable("var_video","/rsc/player-flash/video/"+videoName+".flv");
	//----
	recupFlashVars(fo);
	//----
	fo.write("flash-content");
	}
 /***********************************************
 * fonctions_accueil.js
 ***********************************************/
 function detailPanel(hurle, cible,message)
		{
		/* action AJAX qui cr?? le contenu de la div "detail_produit"
		en utilisant l'identifiant produit (ou toute variable qu'il semblerait utile d'utiliser */

		// Affichage de la div detail produit
		document.getElementById("detail_produit").style.display = "block";
		//appel AJAX
		makeRequest(hurle, cible,'',message);

		}



 /***********************************************
 * fonctions_general.js
 ***********************************************/
 var mBuildDataForDetailPanel = new Array();
//variables de chemins
gPathCss = "/rsc/css/";
gPathPagesRoot = "/yves-rocher/";
//init global nbSsMenu
var nbSsMenu;
//AJAX
//to detect if browser understands AJAX
var isAjax = false;
if (window.XMLHttpRequest) { // Mozilla, Safari,...
	isAjax = new XMLHttpRequest();
}
else if (window.ActiveXObject) { // IE
	try {
	    isAjax = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
	    try {
	        isAjax = new ActiveXObject("Microsoft.XMLHTTP");
	    } catch (e) {}
	}
}

function getElementsByClassName (oElm, strTagName, oClassNames) {
	var arrElements = (strTagName == "*" && document.all)? document.all : oElm.getElementsByTagName(strTagName);
	var arrReturnElements = new Array();
	var arrRegExpClassNames = new Array();
	if(typeof oClassNames == "object") {
		for(var i=0; i<oClassNames.length; i++) {
			arrRegExpClassNames.push(new RegExp("(^|\\s)" + oClassNames[i].replace(/\-/g, "\\-") + "(\\s|$)"));
		}
	}
	else {
		arrRegExpClassNames.push(new RegExp("(^|\\s)" + oClassNames.replace(/\-/g, "\\-") + "(\\s|$)"));
	}
	var oElement;
	var bMatchesAll;
	for(var j=0; j<arrElements.length; j++) {
		oElement = arrElements[j];
		bMatchesAll = true;
		for(var k=0; k<arrRegExpClassNames.length; k++) {
			if(!arrRegExpClassNames[k].test(oElement.className)) {
				bMatchesAll = false;
				break;
			}
		}
		if(bMatchesAll) {
			arrReturnElements.push(oElement);
		}
	}
	return (arrReturnElements)
}

function LoadScrollV() {
	if (document.getElementById("stretcherContainer")) {
  		TabDivs = getElementsByClassName(document.getElementById("stretcherContainer"), "div", "stretcher");
	  	var myScroll;
	  	myScroll = new ScrollObj(6,40,130,"track1","up1","down1","drag1","contentMaskTab1","contentTab1");
	}
}

//appel pour retour HTML: makeRequest("URL?params", "ID_du_DIV_cible");
//appel pour retour XML: makeRequest("URL?params", "ID_du_DIV_cible", "XML");
function makeRequest(hurle, container, typ, message,move2pos, centrer) {
	//affichage loading ////revoir INNERHTML
	if (message == null) message = "";
	document.getElementById(container).innerHTML = message;
	var http_request = false;
	if (window.XMLHttpRequest) { // Mozilla, Safari,...
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) {
		    if (typ == "XML") http_request.overrideMimeType('text/xml');
		}
	}
	else if (window.ActiveXObject) { // IE
		try {
		    http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
		    try {
		        http_request = new ActiveXObject("Microsoft.XMLHTTP");
		    } catch (e) {}
		}
	}
	if (!http_request) {
		alert('Abandon :( Impossible de creer une instance XMLHTTP');
		return false;
	}
	http_request.onreadystatechange = function() {
		if (http_request.readyState == 4) {
			if (typ == "XML"){
				parseContents(http_request, container);
				if(isIE){
					document.getElementById("detail_popin_shim").style.height = document.getElementById(container).clientHeight+ "px";
					centerDiv("detail_popin_shim");
				}
			} else {
				postContents(http_request, container);
				if(isIE){
					document.getElementById("detail_popin_shim").style.height = document.getElementById(container).clientHeight+ "px";
					centerDiv("detail_popin_shim");
				}
			}
			if(centrer){
				centerDiv(container);	
			}
		}
	}
	if( hurle.indexOf("http") >= 0 ) {
		slashInHurle = hurle.split("/");
		cleanHurle = "";
		for(var i = 0 ; i < slashInHurle.length ; i++){
			if(i > 2)
				cleanHurle += "/" + slashInHurle[i];
		}
		hurle = cleanHurle;
	}
	
	http_request.open('GET', hurle, true);

	http_request.setRequestHeader('Expires', '0');
	http_request.setRequestHeader('Pragma', 'no-cache');
	http_request.setRequestHeader('Cache-Control', 'no-cache');

	if(move2pos){
		//position div
		var posX = mouse_x;
		var posY = mouse_y;
		if(posX > 480) posX = 480;
		//augmentation of the popin Y position if the mouse is in the window bottom
		var posY_Window = window.outerHeight;
		var high = (posY - posY_Window);
		document.getElementById(container).style.left = (posX - 100) + "px";
		document.getElementById(container).style.top = (posY - 200) + "px";
		if(isIE){
			document.getElementById("detail_popin_shim").style.display="block";
			document.getElementById("detail_popin_shim").style.left = (posX - 100) + "px";
			document.getElementById("detail_popin_shim").style.top = (posY - 200) + "px";
		}
	}
	http_request.send(null);
}

function postContents(http_request, div) {
	if (http_request.status == 200) {
		document.getElementById(div).innerHTML = http_request.responseText;
		document.getElementById(div).style.display = "block";

		try{
			if(mErrorMessage != null){
				em = new String(unescape(mErrorMessage));
				em = em.replace(/\+/g," ");
				document.getElementById("with-or-without-errors").innerHTML = "<font color='red'>"+em+"</font>";
			}
			if(mAddToCartErrorMessage != null){
				em = new String(unescape(mAddToCartErrorMessage));
				em = em.replace(/\+/g," ");
				document.getElementById("with-or-without-errors").innerHTML = "<font color='red'>"+em+"</font>";
			}
		}catch(e){
			//IE error, we might want to do something in the future.
		}
	}
	else {
		alert('A problem occurred with the request.');
	}
}
//FIN AJAX

/***** DISPLAY MANAGEMENT *****/
//generic fonction to display or not an element
function displayElement(elmt, disp){
	document.getElementById(elmt).style.display=disp;
	}
function displayMainFlashPopin(params,message){
	if(params && params != '' && params != 'intro') {
		params = "/~flash_param=" + params;
		makeRequest('/control/mainflashpopin'+params,'main_flash_popin', '',message);
	}
	if(document.getElementById("dim") && document.getElementById("main_flash_popin")){
		document.getElementById("dim").style.display="block";
		document.getElementById("main_flash_popin").style.display="block";
	}
	//alert(params);

	}
function hideMainFlashPopin(){
	if(document.getElementById("dim") && document.getElementById("main_flash_popin")){
		document.getElementById("dim").style.display="none";
		document.getElementById("main_flash_popin").style.display="none";
	}
}
function closeCiel() {
	// Only if it is not a JWebUnit Test
	if (navigator.userAgent != "ProsodieJWebUnit") {
	if(document.getElementById("ciel")) {
		if(document.getElementById("ciel").style.display != "none") {
			document.getElementById("ciel").style.display = "none";
		}
	}
	}
}
//function to change a CSS an make an ajax call
function changeContent(cibleCSS,urlCSS,cibleDIV,urlDIV){
	document.getElementById(cibleCSS).href = gPathCss + urlCSS;
	makeRequest(urlDIV,cibleDIV);
}
//function to display products specification in different page position
function affichDetail(hurle,cible,message,makedraggable){
	/* action AJAX qui cr???? le contenu de la div "detail_produit"
	en utilisant l'identifiant produit (ou toute variable qu'il semblerait utile d'utiliser */
	if(isAjax){

		if(cible==undefined || cible==''){
			cible = "detail_popin";
		}
		var shim = "detail_popin_shim";
		if(cible.match("zoom") == "zoom") {
			shim = cible + "_shim";
		}
		// Affichage de la div detail
		document.getElementById(cible).style.display = "block";
		//position div
		var posX = mouse_x;
		var posY = mouse_y;
		if(posX > 480) posX = 480;
		//augmentation of the popin Y position if the mouse is in the window bottom
		var posY_Window = window.outerHeight;
		var high = (posY - posY_Window);
		//if(high> 600) {posY = (posY_Window+500);}
		//alert("posX = " + posX + " & posY = " + posY);
		document.getElementById(cible).style.left = posX + "px";
		document.getElementById(cible).style.top = (posY - 150) + "px";
		if(isIE && (cible.match("zoom") == "zoom" || cible == "detail_popin")){
			//alert("detect IE");
			document.getElementById(shim).style.display="block";
			document.getElementById(shim).style.left = posX + "px";
			document.getElementById(shim).style.top = (posY - 150) + "px";
		}
		
		//appel AJAX
		makeRequest(hurle, cible,'',message);
		if(makedraggable)
			document.getElementById(cible).makeDraggable({onStart:function(){ this.el.setOpacity(.8);},onComplete:function(){this.el.setOpacity(1);}});
		//to avoid the href call
		return false;
	}
}
/*****DEBUT TEST JMT ***********/

function affichDetailOpenSet(hurle,cible,message,makedraggable){
	/* action AJAX qui cr???? le contenu de la div "detail_produit"
	en utilisant l'identifiant produit (ou toute variable qu'il semblerait utile d'utiliser */
	if(isAjax){

		if(cible==undefined || cible==''){
			cible = "detail_popin";
		}
		var shim = "detail_popin_shim";
		if(cible.match("zoom") == "zoom") {
			shim = cible + "_shim";
		}
		document.getElementById(cible).style.display = "block";
		centerDiv(cible);
		//appel AJAX
		makeRequest(hurle, cible,'',message,'', true);
		if(makedraggable)
			document.getElementById(cible).makeDraggable({onStart:function(){ this.el.setOpacity(.8);},onComplete:function(){this.el.setOpacity(1);}});
		//to avoid the href call
		return false;
	}
}

/*****FIN TEST JMT ***********/

//function to display products specification in different page position
function affichDetailPopinProduct(hurle,cible,message,pProductId,pFeatureType,isvirtual,makedraggable){
 //Grey background : same as store locator
// alert(cible);
   visibleSelects = jQuery("select:visible");
   visibleSelects.hide();
   divId = "storeLocator";
   Overlay = true;
   var positionCss = "fixed";
   if (jQuery.browser.msie) positionCss = "absolute";
   jQuery('#' + "popin-produit").prependTo("body");
   var zindex = jQuery('#' + "popin-produit").css('z-index');
   var overLayZIndex = zindex - 1;
   jQuery('#' + "popin-produit").show();
    if (Overlay==true){
	var overLay = jQuery('<div id="'+divId+'Overlay"></div>').css({'background-color':'#888888', height:'2500px',width:'100%',position: positionCss,left:0,top:0, 'z-index':overLayZIndex,opacity:0.5});
   	}
   else  {
           var overLay = jQuery('<div id="'+divId+'Overlay"></div>').css({'display':'none'});
   }
   jQuery('body').append(overLay);

   /* action AJAX qui cree le contenu de la div "popin_produit" */
   if (isvirtual=="virtual")
           buildDataForDetailPanel(pProductId, pFeatureType);
   if(isAjax){
       if(cible==undefined || cible==''){
               cible = "popin-produit";
       }
       // Affichage de la div detail
      // alert(cible);
       document.getElementById(cible).style.display = "block";
       //Relative position
       var posY = mouse_y;
       document.getElementById(cible).style.top = (posY - 220) + "px";
       //position div
       //appel AJAX
       makeRequest(hurle, cible,'',message);
       if(makedraggable)
               document.getElementById(cible).makeDraggable({onStart:function(){ this.el.setOpacity(.8);},onComplete:function(){this.el.setOpacity(1);}});

       //to avoid the href call
       return false;
   }
}

function closePopinProduit() {
	closeDivPopin('storeLocator');
	visibleSelects.show();
}

// eme 20091210 nouvelle methode de popin pour le tunnel d'achat

function hauteur_fenetre()
{
 if (window.innerHeight) return window.innerHeight  ;
 else if (document.body && document.body.offsetHeight) return document.body.offsetHeight;
 else return 0;
}

function largeur_fenetre()
{
 if (window.innerWidth) return window.innerWidth;
 else if (document.body && document.body.offsetWidth) return document.body.offsetWidth;
 else return 0;
}

function centerPopup(element) {
	var height=document.getElementById(element).offsetHeight;//hauteur de l'�l�ment � positionner
	var width=document.getElementById(element).offsetWidth;//largeur de l'�l�ment � positionner
	myParent=document.getElementById(element).parentNode;
	var pHeight=hauteur_fenetre();
	var pWidth=largeur_fenetre();//Largeur de l'�l�ment parent
	var sTop=myParent.scrollTop;//Hauteur de d�filement de l'�l�ment parent
	var sLeft=myParent.scrollLeft;//Longueur de d�filement de l'�l�ment parent
	var posY=(pHeight/2)-(height/2)+sTop;//Calcul de la position en Y
	var posX=(pWidth/2)-(width/2)+sLeft;//Calcul de la position en X
	document.getElementById(element).style.top=posY+"px";
	document.getElementById(element).style.left=posX+"px";
}


function affichPopinCheckout(hurle,cible,message,xx,yy){
 //Grey background : same as store locator
// alert(cible);
   visibleSelects = jQuery("select:visible");
   visibleSelects.hide();
   divId = "storeLocator";
   Overlay = true;
   var positionCss = "fixed";
   if (jQuery.browser.msie) positionCss = "absolute";
   jQuery('#' + cible).prependTo("body");
   var zindex = jQuery('#' + cible).css('z-index');
   var overLayZIndex = zindex - 1;
   jQuery('#' + cible).show();
    if (Overlay==true){
	var overLay = jQuery('<div id="'+divId+'Overlay"></div>').css({'background-color':'#888888', height:'2500px',width:'100%',position: positionCss,left:0,top:0, 'z-index':overLayZIndex,opacity:0.5});
   	}
   else  {
           var overLay = jQuery('<div id="'+divId+'Overlay"></div>').css({'display':'none'});
   }
   jQuery('body').append(overLay);

   /* action AJAX qui cree le contenu de la div "popin_produit" */
   
   
   
       // Affichage de la div detail
      // alert(cible);
       document.getElementById(cible).style.display = "block";
       try{
       document.getElementById("type_tel").style.display = "block";
       }catch(e){}
       try{
       document.getElementById("adresse_choix").style.display = "block";
       }catch(e){}
        try{
        	if(document.getElementById("countryGeoId").value=='RUS' || document.getElementById("countryGeoId").value=='UKR')
				document.getElementById("streetNumber").style.display = "block";	
		}catch(e){}
       try{
       document.getElementById("city").style.display = "block";
       }catch(e){}
       try{
       document.getElementById("stateProvinceGeoId").style.display = "block";
       }catch(e){}
       try{
       document.getElementById("locality").style.display = "block";
       }catch(e){}
       try{
       document.getElementById("phone_type").style.display = "block";
       }catch(e){}
        try{
       document.getElementById("contactMechIdold").style.display = "block";
       }catch(e){}
       
       var height=document.getElementById(cible).offsetHeight;//hauteur de l'�l�ment � positionner
		var width=document.getElementById(cible).offsetWidth;//largeur de l'�l�ment � positionner
				
       	//position div
		var posX;
		var posY;
		if (window.outerWidth) {
			posX = (window.outerWidth+xx)/2 + window.pageXOffset - xx;
			//posX = ((window.outerWidth + xx)/2) + window.pageXOffset - xx;
			posY = ((window.outerHeight + yy)/2) + window.pageYOffset - yy - 100;
		} else {
			posX = (document.documentElement.clientWidth+xx)/2 + document.documentElement.scrollLeft - xx;
			//posX = ((document.documentElement.clientWidth + xx)/2) + document.documentElement.scrollLeft - xx;
			posY = ((document.documentElement.clientHeight + yy)/2) + document.documentElement.scrollTop - yy;
		}
		//alert(document.documentElement.clientHeight);
		
		if (posX < 50) { posX = 50; }
		if (posY < 50) { posY = 50; }
		document.getElementById(cible).style.left = posX + "px";
		document.getElementById(cible).style.top = posY + "px";
		//position div
       //appel AJAX
       //makeRequest(hurle, cible,'',message);
      // if(makedraggable)
        //       document.getElementById(cible).makeDraggable({onStart:function(){ this.el.setOpacity(.8);},onComplete:function(){this.el.setOpacity(1);}});

       //to avoid the href call
       return false;
}

function centerDiv(target) {
	centerDivX(target);
	centerDivY(target)
}

function centerDivX(target) {
    var width = document.getElementById(target).offsetWidth; //width of the target
	var posX;	
	if (window.outerWidth) {
		posX = ((window.outerWidth + width)/2) + window.pageXOffset - width;
	} else {
		posX = ((document.documentElement.clientWidth + width)/2) + document.documentElement.scrollLeft - width;
	}
	if (posX < 50) { posX = 50; }
	document.getElementById(target).style.left = posX + "px";
}

function centerDivY(target) {	
	//hauteur de l'élément à positionner
	var height = document.getElementById(target).offsetHeight;
	var posY;
	if (window.outerWidth) {
		posY = ((window.outerHeight + height)/2) + window.pageYOffset - height - 100;
	} else {	
		posY = ((document.documentElement.clientHeight + height)/2) + document.documentElement.scrollTop - height;
	}	
	document.getElementById(target).style.top = posY + "px";
}

/* Specific function for Fact-Finder */
function detailPanelFF(hurle,cible, pProductId, pFeatureType, yOffset,message){
	mErrorMessage = null;
	buildDataForDetailPanel(pProductId, pFeatureType);
	/* action AJAX qui cr???? le contenu de la div "detail_produit"
	en utilisant l'identifiant produit (ou toute variable qu'il semblerait utile d'utiliser */
	if(isAjax){
		if(cible==undefined || cible==''){
			cible = "detail_popin";
		}
		// Affichage de la div detail
		document.getElementById(cible).style.display = "block";
		//position div
		var posX;
		var posY;
		if (window.outerWidth) {
			posX = (window.outerWidth/2) + window.pageXOffset - 200;
			posY = (window.outerHeight/2) + window.pageYOffset - 200;
		} else {
			posX = (document.documentElement.clientWidth/2) + document.documentElement.scrollLeft - 200;
			posY = (document.documentElement.clientHeight/2) + document.documentElement.scrollTop - 150;
		}
		if (posX < 50) { posX = 50; }
		if (posY < 50) { posY = 50; }
		document.getElementById(cible).style.left = posX + "px";
		document.getElementById(cible).style.top = posY + "px";
		if(isIE){
			//alert("detect IE");
			document.getElementById("detail_popin_shim").style.display="block";
			document.getElementById("detail_popin_shim").style.left = posX + "px";
			document.getElementById("detail_popin_shim").style.top = posY + "px";
		}

		//appel AJAX
		makeRequest(hurle, cible,'', message);
		return false;
	}
}

function detailPanel(hurle,cible, pProductId, pFeatureType, yOffset,message){
	mErrorMessage = null;
	buildDataForDetailPanel(pProductId, pFeatureType);
	/* action AJAX qui cr???? le contenu de la div "detail_produit"
	en utilisant l'identifiant produit (ou toute variable qu'il semblerait utile d'utiliser */
	if(isAjax){
		if(yOffset==undefined || yOffset==''){
			yOffset = 150;
		}

		if(cible==undefined || cible==''){
			cible = "detail_popin";
		}
		// Affichage de la div detail
		document.getElementById(cible).style.display = "block";
		//position div
		var posX = mouse_x;
		var posY = mouse_y;
		//alert("mouse_x "+ mouse_x +" mouse_y "+ mouse_y +" scroll_x "+ scroll_x +" scroll_y "+ scroll_y);
		if(posX > 480) posX = 480;
		//augmentation of the popin Y position if the mouse is in the window bottom
		//var posY_Window = window.outerHeight;
		//var high = (posY - posY_Window);
		//if(high> 600) {posY = (posY_Window+500);}
		//alert("x "+ posX + " Y "+ posY);
		//alert("posX = " + posX + " & posY = " + posY);
		document.getElementById(cible).style.left = posX + "px";
		document.getElementById(cible).style.top = (posY - yOffset) + "px";
		if(isIE){
			//alert("detect IE");
			document.getElementById("detail_popin_shim").style.display="block";
			document.getElementById("detail_popin_shim").style.left = posX + "px";
			document.getElementById("detail_popin_shim").style.top = (posY - yOffset) + "px";
		}

		//appel AJAX
		makeRequest(hurle, cible,'', message, '', true);
		return false;
	}
}

// eme 20091210 nouvelle methode de popin pour le tunnel d'achat
function detailCheckoutPanel(hurle,cible, pProductId, pFeatureType, yOffset,message){
	mErrorMessage = null;
	//buildDataForDetailPanel(pProductId, pFeatureType);
	/* action AJAX qui cr???? le contenu de la div "detail_produit"
	en utilisant l'identifiant produit (ou toute variable qu'il semblerait utile d'utiliser */
	if(isAjax){
		if(yOffset==undefined || yOffset==''){
			yOffset = 150;
		}

		if(cible==undefined || cible==''){
			cible = "detail_popin";
		}
		// Affichage de la div detail
		document.getElementById(cible).style.display = "block";
		//position div
		var posX = mouse_x;
		var posY = mouse_y;
		//alert("mouse_x "+ mouse_x +" mouse_y "+ mouse_y +" scroll_x "+ scroll_x +" scroll_y "+ scroll_y);
		if(posX > 480) posX = 480;
		//augmentation of the popin Y position if the mouse is in the window bottom
		//var posY_Window = window.outerHeight;
		//var high = (posY - posY_Window);
		//if(high> 600) {posY = (posY_Window+500);}
		//alert("x "+ posX + " Y "+ posY);
		//alert("posX = " + posX + " & posY = " + posY);
		document.getElementById(cible).style.left = posX + "px";
		document.getElementById(cible).style.top = (posY - yOffset) + "px";
		if(isIE){
			//alert("detect IE");
			document.getElementById("detail_popin_shim").style.display="block";
			document.getElementById("detail_popin_shim").style.left = posX + "px";
			document.getElementById("detail_popin_shim").style.top = (posY - yOffset) + "px";
		}

		//appel AJAX
		makeRequest(hurle, cible,'', message);
		return false;
	}
}

function buildDataForDetailPanel(pProductId, pFeatureType){
	if(pProductId != null && pProductId != undefined &&
	   pFeatureType != null && pFeatureType != undefined){
		var params = "productId=" + pProductId + "&featureType="+ pFeatureType;
		//alert("params : "+params);
		return new AJAXRequest("post", "/control/servlet/ajaxBuildDataForDetailPanel", params, processBuildDataForDetailPanel);
	}
}

function processBuildDataForDetailPanel( myAJAX ) {
    if (myAJAX.readyState == 4) {
        if (myAJAX.status == 200) {
        //alert("processBuildDataForDetailPanel myAJAX.status == 200");
        	mBuildDataForDetailPanel = new Array();
        	var myHTML = null;
        	var textDocument = myAJAX.responseText;
        	//alert("processBuildDataForDetailPanel myAJAX.responseText : "+textDocument);
            var xmlDocument =  Sarissa.getDomDocument();
		    xmlDocument = (new DOMParser()).parseFromString(textDocument, "text/xml");
        	var thePayload = xmlDocument.getElementsByTagName("Payload");
			var theFeatures = thePayload[0].getElementsByTagName("Features");
        	for(var i=0; i< theFeatures.length; i++) {
				aFeature = theFeatures[i].getElementsByTagName("OneFeature");
				for(var j=0; j< aFeature.length; j++) {
					theFeatureAttributes = aFeature[j].attributes;
					productId = theFeatureAttributes.getNamedItem("productId").nodeValue;
					featureType = theFeatureAttributes.getNamedItem("featureType").nodeValue;

					auxiliaryImageUrl = theFeatureAttributes.getNamedItem("auxiliaryImageUrl").nodeValue;
					swatchImageUrl = theFeatureAttributes.getNamedItem("swatchImageUrl").nodeValue;
					smallSwatchImageUrl = theFeatureAttributes.getNamedItem("smallSwatchImageUrl").nodeValue;
					largeSwatchImageUrl = theFeatureAttributes.getNamedItem("largeSwatchImageUrl").nodeValue;
					smallImageUrl = theFeatureAttributes.getNamedItem("smallImageUrl").nodeValue;
					mediumImageUrl = theFeatureAttributes.getNamedItem("mediumImageUrl").nodeValue;
					largeImageUrl = theFeatureAttributes.getNamedItem("largeImageUrl").nodeValue;
					detailImageUrl = theFeatureAttributes.getNamedItem("detailImageUrl").nodeValue;
					podiumImageUrl = theFeatureAttributes.getNamedItem("podiumImageUrl").nodeValue;
					pushImageUrl = theFeatureAttributes.getNamedItem("pushImageUrl").nodeValue;

					//These are member variables of the container page "categorydetail.ftl"
					aProduct = new Array(3);
					aProduct[0] = productId;
					aProduct[1] = mediumImageUrl;
					aProduct[2] = largeSwatchImageUrl;
					aProduct[3] = detailImageUrl;
					mBuildDataForDetailPanel[j] = aProduct;
				}
			}
        }
   	}
}

function findBuildDataForDetailPanel(pProductId){

	//alert("mBuildDataForDetailPanel : "+mBuildDataForDetailPanel);
	for(var i=0; i< mBuildDataForDetailPanel.length; i++) {
		aProduct = mBuildDataForDetailPanel[i];
		productId = aProduct[0];
		if(productId == pProductId){
			return aProduct; //Exit
		}
	}
}


function clearSelectedBox(){
	for (var i = 0; i < mBuildDataForDetailPanel.length; i++){
		try{
			aProduct = mBuildDataForDetailPanel[i];
			productId = aProduct[0];
			if(document.getElementById("productLittleBox"+productId) != null)
				document.getElementById("productLittleBox"+productId).className = "white";
			if(document.getElementById("product"+productId) != null)
				document.getElementById("product"+productId).className = "white";
		}catch(e){
			alert(e);
		}
	}
}
//function to move popin if select obstruct its display
function movePopin(dir,moveX,moveY){
	//recuperation of the x & y value of the div position
	var x = document.getElementById("detail_popin").style.left;
	var y = document.getElementById("detail_popin").style.top;
	x = parseInt(x.substr(0,((x.length) - 2)));
	y = parseInt(y.substr(0,((y.length) - 2)));
	//adding values indicated int the function call
	x = (x + parseInt(moveX)) + "px";
	y = (y + parseInt(moveY)) + "px";
	//moving the div
	document.getElementById("detail_popin").style.left = x;
	document.getElementById("detail_popin").style.top = y;
	}

//function for display management of different menus
function displayMenu(prefixe,puce,tot,n){
	//initialisation
	var nomPuceMarqueur = puce + n + "_vert";
	var nomSsMenu = "";
	var nomPuceHor = "";/* triangle horizontal*/
	var nomPuceVer = "";/*triangle vertical*/
	var etat = document.getElementById(nomPuceMarqueur).style.display;
	//close all objects
	for(i=0;i<tot;i++){
		nomPuceHor = puce + i + "_hor";
		nomPuceVer = puce + i + "_vert";
		nomSsMenu = prefixe + i ;
		document.getElementById(nomPuceHor).style.display = "block";
		document.getElementById(nomPuceVer).style.display = "none";
		document.getElementById(nomSsMenu).style.display = "none";
	}
	//open target div, if not open before
	nomPuceHor = puce + n + "_hor";
	nomPuceVer = puce + n + "_vert";
	nomSsMenu = prefixe + n;
	if(etat != "block"){
		document.getElementById(nomPuceHor).style.display = "none";
		document.getElementById(nomPuceVer).style.display = "block";
		document.getElementById(nomSsMenu).style.display = "block";
	}
}
//function to change colors in detail popin
function affichColoris(n,nbCouleur, listIndex){
	//initialisation
	var couleur = "";
	nomClass = "";
	if(n == undefined){
		n = document.getElementById('coloris').value;
		couleur = "couleur_" + n;
	}
	else{
		n = parseInt(n);
	}
		//gestion du contour des ??chantillons
	for(i=0;i<nbCouleur;i++){
		if(listIndex == undefined) {
			couleur = "couleur_" + i;
		}else {
			couleur = "couleur_"+listIndex+"_" + i;
		}
		nomClass = "white";
		document.getElementById(couleur).className = nomClass;
	}
	if(listIndex == undefined) {
		couleur = "couleur_" + n;
	}else {
		couleur = "couleur_"+listIndex+"_" + n;
	}
	nomClass = "grey";
	document.getElementById(couleur).className = nomClass;
	//gestion de la couleur du gros plan
	//affectation de la bonne image par le biais d'AJAX
	//gestion de la position de l'element select
}

//fonction pour r??v??ler ou cacher une div parmi une suite de div
function affichDiv(n,nameRoot,nbDiv,imgName){
	var divName = nameRoot + n;
	var etat = document.getElementById(divName).style.display;
	for(i=0;i<nbDiv;i++){
		//hidding all divs
		document.getElementById(nameRoot + i).style.display = "none";
		//if an image indicate open status of the div
		if(imgName != "" && imgName != undefined){
			document.getElementById(imgName + "_closed_" + i).style.display = "inline";
			document.getElementById(imgName + "_opened_" + i).style.display = "inline";
		}
	}
	//display target div
	if(etat != "block"){
		document.getElementById(nameRoot + n).style.display = "block";
		if(imgName != "" && imgName != undefined){
			document.getElementById("fiche_puce_hor_" + n).className = "off fleft";
			document.getElementById("fiche_puce_vert_" + n).className = "on fleft";
		}
	}
}
/***** END OF DISPLAY MANAGEMENT *****/

// BIBLIO
var ns4=(document.layers);var ie4=(document.all&&!document.getElementById);var ie5=(document.all&&document.getElementById);var ns6=(!document.all&&document.getElementById);var mac=(navigator.appVersion.indexOf("Mac")>=0)?1:0;var dom=(document.getElementById)?1:0;var ie=(ie4||ie5)?1:0;
function layer(lyr){if(ns4){obj=document.layers[lyr]}else if(ie4){obj=document.all[lyr].style}else if(dom){obj=document.getElementById(lyr).style}return obj;}
function left(lyr){if(!ns4&&!mac){obj=parseInt(layer(lyr).left.substring(0,layer(lyr).left.indexOf("p")));}else if(dom&&mac&&!ie){obj=parseInt(layer(lyr).left.substring(0,layer(lyr).left.indexOf("p")));}else{obj=parseInt(layer(lyr).left);}return obj}
function pot(lyr){if(!ns4&&!mac)obj=parseInt(layer(lyr).top.substring(0,layer(lyr).top.indexOf("p")));else if(dom&&mac&&!ie)obj=parseInt(layer(lyr).top.substring(0,layer(lyr).top.indexOf("p")));else{obj=parseInt(layer(lyr).top)}return obj;}
function showHide(lyr,what){layer(lyr).visibility=what;}
function setDisplay(lyr,what){layer(lyr).display=what;}
function posLeft(lyr,x){layer(lyr).left=x;}
function posTop(lyr,y){layer(lyr).top=y;}
function setWidth(DivId,w){layer(DivId).width=w;}
function setHeight(DivId,h){layer(DivId).height=h;}
function setZ(lyr,z){layer(lyr).zIndex=z;}
// MyClip = [top,right,bottom,left]
function setClip(DivId,MyClip){if(!ns4){layer(DivId).clip="rect(" + MyClip[0] + "px " + MyClip[1] + "px " + MyClip[2] + "px " + MyClip[3] + "px)";}else{document.layers[DivId].clip.top=MyClip[0];document.layers[DivId].clip.right=MyClip[1];document.layers[DivId].clip.bottom=MyClip[2];document.layers[DivId].clip.left=MyClip[3];}}
function getHeight(DivId){if((ie5&&!mac)||ns6)return(document.getElementById(DivId).offsetHeight);else if(ie4)return(document.all[DivId].clientHeight);else if(ns4)return(document.layers[DivId].document.height);else if(ie5&&mac)return(document.all[DivId].offsetHeight);else return(document.getElementById(DivId).offsetHeight);}
function getWidth(DivId){if((ie5&&!mac)||ns6)return(document.getElementById(DivId).offsetWidth);else if(ie4)return(document.all[DivId].clientWidth);else if(ns4)return(document.layers[DivId].document.width);else if(ie5&&mac)return(document.all[DivId].offsetWidth);else return(document.getElementById(DivId).offsetWidth);}
//setToAnchor
function aleft(MyObject){if(dom||ie4){if(MyObject.offsetParent){return(MyObject.offsetLeft + aleft(MyObject.offsetParent));}else{return(MyObject.offsetLeft);}}if(ns4){return(MyObject.x);}}
function atop(MyObject){if(dom||ie4){if(MyObject.offsetParent){return(MyObject.offsetTop + atop(MyObject.offsetParent));}else{return(MyObject.offsetTop);}}if(ns4){return(MyObject.y);}}
function setToAnchor(AnchorName,lyr){var MyAnchor;if(dom){MyAnchor=document.getElementById(AnchorName);}else if(ie4){MyAnchor=document.all[AnchorName];}else if(ns4){MyAnchor=document.anchors[AnchorName];}if(arguments.length==2){posLeft(lyr,aleft(MyAnchor));posTop(lyr,atop(MyAnchor));}else{if(arguments[2]=="x"){posLeft(lyr,aleft(MyAnchor));}else{posTop(lyr,atop(MyAnchor));}}}
// fin setToAnchor
// FIN BIBLIO

//detection position souris
var mouse_x = 0;
var mouse_y = 0;
var scroll_x = 0;
var scroll_y = 0;
function positionSouris(evt){
    if( !evt ) evt = window.event;
    if (evt.pageX || evt.pageY){
		mouse_x = evt.pageX;
		mouse_y = evt.pageY;
	}
	else if (evt.clientX || evt.clientY) 	{
	    if(document.documentElement) {
	    	scroll_x = document.documentElement.scrollLeft;
	    	scroll_y = document.documentElement.scrollTop;
	    }else if(document.body) {
			scroll_x = document.body.scrollLeft;
			scroll_y = document.body.scrollTop;
	    }
	    mouse_x = evt.clientX + scroll_x;
	    mouse_y = evt.clientY + scroll_y;
    }
    //window.status = "Souris X:"+x+" / Y:"+y;
}
document.onmousemove = positionSouris;

/***** PISSENLIT *****/
function togglePissenlit(){
	(document.getElementById("container").style.visibility == "hidden")? closePissenlit():openPissenlit();
}
function openPissenlit(){
	//alert("openPissenlit()");
	//modif clipping container
	//setClip("pissenlit",[top,right,bottom,left]);
	setClip("pissenlit", [0,1065,950,0]);
	//cacher les clips du centre et de la droite de la page
	if(document.getElementById("push_right")) showHide("push_right", "hidden");
	if(document.getElementById("mes_services")) showHide("mes_services", "hidden");
	if(document.getElementById("container")) showHide("container", "hidden");
	//to close left menu
	if(nbSsMenu){
		for(i=0;i<nbSsMenu;i++){
			nomPuce = "puce_bas"+i;
			nomSsMenu = "ssmenu_"+i;
			document.getElementById(nomPuce).style.visibility = "hidden";
			document.getElementById(nomSsMenu).style.display = "none";
		}
	}
}
function closePissenlit(){
//alert("closePissenlit()");
	//modif clipping container
	setClip("pissenlit", [0,1065,194,765]);
	//montrer les clips du centre et de la droite de la page
	if(document.getElementById("push_right")) showHide("push_right", "visible");
	if(document.getElementById("mes_services")) showHide("mes_services", "visible");
	if(document.getElementById("container")) showHide("container", "visible");
}
/***** END OF PISSENLIT *****/
/***** FUNCTIONS FOR THE RAVELLING TEXT IN THE SERVICES DIV *****/
// Pour utiliser la fonction "setTimeout" avec les anciens navigateurs, on utilise des variables globales
var msg="MESSAGE";
var index=0;
var delay=200
function defil() {
	// Fonction r??cursive pour le d??calage du texte du message
	var nb_char=msg.length;
	index++;
	if (index>nb_char) index=0;
	document.getElementById("message_container").value=msg.substring(index)+msg;
	setTimeout("defil()",delay);
}

function defiler(txt,tps){
	//Cette fonction est appel??e pour d??clencher le d??filement.
	msg=txt + "   -   ";
	delay=tps;
	defil();
}
/***** END OF FUNCTIONS FOR THE RAVELLING TEXT IN THE SERVICES DIV *****/
/***** CUSTOM SELECT *****/
function affichMySelect(act,val,elmt){
	var etat = document.getElementById(elmt + "_liste").style.display;
	if(val=="" || val == undefined) val = document.getElementById(elmt).value;
	if(act=="open" && etat !="block"){
		document.getElementById(elmt + "_liste").style.display = "block";
		document.getElementById(elmt + "_select").style.zIndex = 999;
		document.getElementById(elmt + "_liste").style.zIndex = 999;
		}
	else{
		document.getElementById(elmt).value=val;
		document.getElementById(elmt + "_liste").style.display = "none";
		document.getElementById(elmt + "_select").style.zIndex = 1;
		document.getElementById(elmt + "_liste").style.zIndex = 1;
	}
}
/***** END OF CUSTOM SELECT *****/

 /***********************************************
 * fonctions_catalogue.js
 ***********************************************/

//fonction pour r?v?ler ou cacher les fiches de renseignement relatives au produit
function affichFiche(n,listIndex){
	var nbFiche = 6; //initialisation du nombre de fiche
	var nomFiche = "";
	var etat = "none";
	if(listIndex == undefined) {
		etat = document.getElementById("fiche_texte_" + n).style.display;
	} else {
		etat = document.getElementById("fiche_texte_" + listIndex + "_" + n).style.display;
	}

	for(i=0;i<nbFiche;i++){
		//masquage de tous les textes fiches
		try{
			if(listIndex == undefined) {
				document.getElementById("fiche_texte_" + i).style.display = "none";
				document.getElementById("fiche_puce_hor_" + i).className = "on fleft bg_couleur_gamme";
				document.getElementById("fiche_puce_vert_" + i).className = "off fleft bg_couleur_gamme";
			} else  {
				document.getElementById("fiche_texte_" + listIndex + "_" + i).style.display = "none";
				document.getElementById("fiche_puce_hor_" + listIndex + "_" + i).className = "on fleft bg_couleur_gamme";
				document.getElementById("fiche_puce_vert_" + listIndex + "_" + i).className = "off fleft bg_couleur_gamme";
			}
		}catch(e){}
	}
	//affichage du texte fiche cible

	if(etat != "block"){
		try{
			if(listIndex == undefined) {
				document.getElementById("fiche_texte_" + n).style.display = "block";
				document.getElementById("fiche_puce_hor_" + n).className = "off fleft bg_couleur_gamme";
				document.getElementById("fiche_puce_vert_" + n).className = "on fleft bg_couleur_gamme";
			} else {
				document.getElementById("fiche_texte_" + listIndex + "_" + n).style.display = "block";
				document.getElementById("fiche_puce_hor_" + listIndex + "_" + n).className = "off fleft bg_couleur_gamme";
				document.getElementById("fiche_puce_vert_" + listIndex + "_" + n).className = "on fleft bg_couleur_gamme";
			}
		}catch(e){}
	}

	//changement de contenu de la div cible par action AJAX
	}
//fonction pour initialiser la fermeture des div de contenus du menu gauche
//afin qu'en cas d'inactivation du javascript, tout le menu soit ouvert
function fermeMG(n){
	var nomSsMenu = "";
	for(i=0;i<nbSsMenu;i++){
		if(i != n){
			nomSsMenu = "ssmenu_"+i;
			document.getElementById(nomSsMenu).style.display = "none";
		}
	}
}
//fonction pour afficher/masquer les contenus du Menu Gauche
function gestionMG(n){
	//initialisation
	var nomPuce = "puce_bas"+n;
	var nomSsMenu = "";
	var etat = document.getElementById(nomPuce).style.visibility;
	//fermeture de tous les menus
	for(i=0;i<nbSsMenu;i++)
		{
		nomPuce = "puce_bas"+i;
		nomSsMenu = "ssmenu_"+i;
		document.getElementById(nomPuce).style.visibility = "hidden";
		document.getElementById(nomSsMenu).style.display = "none";
		}
	//gestion du menu cliqu?
	nomPuce = "puce_bas"+n;
	nomSsMenu = "ssmenu_"+n;
	if(etat == "hidden" || etat == "")
		{
		document.getElementById(nomPuce).style.visibility = "visible";
		document.getElementById(nomSsMenu).style.display = "block";
		}
	}

// Fonction pour augmenter le nombre de produit ? ajouter au panier
function ajout_quant(n)
	{
	var idQuant = "quantite_" + n;
	var quant = parseInt(document.getElementById(idQuant).value);
	quant = quant + 1;
	document.getElementById(idQuant).value = quant;
	}

// Fonction pour diminuer le nombre de produit ? ajouter au panier
function baisse_quant(n)
	{
	var idQuant = "quantite_" + n;
	var quant = parseInt(document.getElementById(idQuant).value);
	if(quant > 1) quant = quant - 1;
	document.getElementById(idQuant).value = quant;
	}


//function to hide or show select element in produit.html when display popin
function selectVisibility(etat)
	{
	if(document.getElementById("coloris"))
		document.getElementById("coloris").style.visibility = etat;
	if(document.getElementById("quantite"))
		document.getElementById("quantite").style.visibility = etat;
	if(document.getElementById("contactMechId"))
		document.getElementById("contactMechId").style.visibility = etat;
	}


 /***********************************************
 * scroll_v.js
 ***********************************************/
 // ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
//
// Coded by Travis Beckham
// http://www.squidfingers.com | http://www.podlob.com
// If want to use this code, feel free to do so, but please leave this message intact.
//
// ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// --- version date: 01/24/03 ---------------------------------------------------------

// ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// Cross-Browser Functions

var dom = document.getElementById;
var iex = document.all;
var ns4 = document.layers;

function addEventScroll(event,method){
	this[event] = method;
	if(ns4) this.captureEvents(Event[event.substr(2,event.length).toUpperCase()]);
}
function removeEventScroll(event){
	this[event] = null;
	if(ns4) this.releaseEvents(Event[event.substr(2,event.length).toUpperCase()]);
}
function getElementScroll(name,nest){
	nest = nest ? "document."+nest+"." : "";
	var el = dom ? document.getElementById(name) : iex ? document.all[name] : ns4 ? eval(nest+"document."+name) : false;
	el.css = ns4 ? el : el.style;
	el.getTop = function(){return parseInt(el.css.top) || 0};
	el.setTop = function(y){el.css.top = ns4 ? y: y+"px"};
	el.getHeight = function(){return ns4 ? el.document.height : el.offsetHeight};
	el.getClipHeight = function(){return ns4 ? el.clip.height : el.offsetHeight};
	el.hideVis = function(){el.css.visibility="hidden"};
	el.addEventScroll = addEventScroll;
	el.removeEventScroll = removeEventScroll;
	return el;
}
function getYMouse(e){
	return iex ? event.clientY : e.pageY;
}

document.addEventScroll = addEventScroll;
document.removeEventScroll = removeEventScroll;

// ||||||||||||||||||||||||||||||||||||||||||||||||||
// Scroller Class

ScrollObj = function(speed, dragHeight, trackHeight, trackObj, upObj, downObj, dragObj, contentMaskObj, contentObj){
	this.speed = speed;
	this.dragHeight = dragHeight;
	this.trackHeight = trackHeight;
	this.trackObj = getElementScroll(trackObj);
	this.upObj = getElementScroll(upObj);
	this.downObj = getElementScroll(downObj);
	this.dragObj = getElementScroll(dragObj);
	this.contentMaskObj = getElementScroll(contentMaskObj);
	this.contentObj = getElementScroll(contentObj,contentMaskObj);
	this.obj = contentObj+"Object";
	eval(this.obj+"=this");

	this.trackTop = this.dragObj.getTop();
	this.trackLength = this.trackHeight-this.dragHeight;
	this.trackBottom = this.trackTop+this.trackLength;
	this.contentMaskHeight = this.contentMaskObj.getClipHeight();
	this.contentHeight = this.contentObj.getHeight();
	this.contentLength = this.contentHeight-this.contentMaskHeight;
	this.scrollLength = this.trackLength/this.contentLength;
	this.scrollTimer = null;

	if(this.contentHeight <= this.contentMaskHeight){
		this.dragObj.hideVis();
		this.upObj.hideVis();
		this.downObj.hideVis();
		this.trackObj.hideVis();
	}else{
		var self = this;
		this.trackObj.addEventScroll("onmousedown", function(e){self.scrollJump(e);return false});
		this.upObj.addEventScroll("onmousedown", function(){self.scroll(self.speed);return false});
		this.upObj.addEventScroll("onmouseup", function(){self.stopScroll()});
		this.upObj.addEventScroll("onmouseout", function(){self.stopScroll()});
		this.downObj.addEventScroll("onmousedown", function(){self.scroll(-self.speed);return false});
		this.downObj.addEventScroll("onmouseup", function(){self.stopScroll()});
		this.downObj.addEventScroll("onmouseout", function(){self.stopScroll()});
		this.dragObj.addEventScroll("onmousedown", function(e){self.startDrag(e);return false});
		if(iex) this.dragObj.addEventScroll("ondragstart", function(){return false});
	}
}
ScrollObj.prototype.startDrag = function(e){
	this.dragStartMouse = getYMouse(e);
	this.dragStartOffset = this.dragObj.getTop();
	var self = this;
	document.addEventScroll("onmousemove", function(e){self.drag(e)});
	document.addEventScroll("onmouseup", function(){self.stopDrag()});
}
ScrollObj.prototype.stopDrag = function(){
	document.removeEventScroll("onmousemove");
	document.removeEventScroll("onmouseup");
}
ScrollObj.prototype.drag = function(e){
	var currentMouse = getYMouse(e);
	var mouseDifference = currentMouse-this.dragStartMouse;
	var dragDistance = this.dragStartOffset+mouseDifference;
	var dragMovement = (dragDistance<this.trackTop) ? this.trackTop : (dragDistance>this.trackBottom) ? this.trackBottom : dragDistance;
	this.dragObj.setTop(dragMovement);
	var contentMovement = -(dragMovement-this.trackTop)*(1/this.scrollLength);
	this.contentObj.setTop(contentMovement);
}
ScrollObj.prototype.scroll = function(speed){
	var contentMovement = this.contentObj.getTop()+speed;
	var dragMovement = this.trackTop-Math.round(this.contentObj.getTop()*(this.trackLength/this.contentLength));
	if(contentMovement > 0){
		contentMovement = 0;
	}else if(contentMovement < -this.contentLength){
		contentMovement = -this.contentLength;
	}
	if(dragMovement < this.trackTop){
		dragMovement = this.trackTop;
	}else if(dragMovement > this.trackBottom){
		dragMovement = this.trackBottom;
	}
	this.contentObj.setTop(contentMovement);
	this.dragObj.setTop(dragMovement);
	this.scrollTimer = window.setTimeout(this.obj+".scroll("+speed+")",25);
}
ScrollObj.prototype.stopScroll = function(){
	if(this.scrollTimer){
		window.clearTimeout(this.scrollTimer);
		this.scrollTimer = null;
	}
}
ScrollObj.prototype.scrollJump = function(e){
	var currentMouse = getYMouse(e);
	var dragDistance = currentMouse-(this.dragHeight/2);
	var dragMovement = (dragDistance<this.trackTop) ? this.trackTop : (dragDistance>this.trackBottom) ? this.trackBottom : dragDistance;
	this.dragObj.setTop(dragMovement);
	var contentMovement = -(dragMovement-this.trackTop)*(1/this.scrollLength);
	this.contentObj.setTop(contentMovement);
}

// ||||||||||||||||||||||||||||||||||||||||||||||||||
// Misc Functions

function fixNetscape4(){
	if(ns4origWidth != window.innerWidth || ns4origHeight != window.innerHeight){
		window.location.reload();
	}
}
if(document.layers){
	ns4origWidth = window.innerWidth;
	ns4origHeight = window.innerHeight;
	window.onresize = fixNetscape4;
}

 /***********************************************
 * addToCart.js
 ***********************************************/
 var mAddtoCartErrorMessage = null;

function addErrorMesseging(pErrorMessage){
	mAddtoCartErrorMessage = pErrorMessage;
}

// 20092010 - ppo ajout multiple au panier pour pages tutoriel
function addMultipleToCart(productId) {
    var productsParamString = ""; // initialize list  
    var separator = "_";
    var productVar = "productId";  
    var quantityVar = "quantity";  
    var nbOfItems = arguments.length-2;
    var cmSrc = arguments[0]; // recuperation de la valeur 'TutorialProductPage' pour coremetrics
    var category = arguments[1]; // recuperation de la categorie � transmettre au tag Shop5 pour coremetrics
    // iterate through arguments except the first one wich is for the coremetrics tag  (nb of arguments is unknown !). 
    // Quantity is allways equals to 1 for tutoriel products.
    for (var i = 2; i <= nbOfItems+1; i++) {  
       	productsParamString += productVar + separator + (i-2) + "=" + arguments[i] + "&" + quantityVar + separator + (i-2) + "=1" ;  
       	if (i < nbOfItems+1){	
       		productsParamString += "&";
       	}
    }  
    return addMultipleToCartComplete(cmSrc,category, productsParamString, nbOfItems, null, null, null); 
}

function addMultipleToCartForFavorites(productId) {
    var productsParamString = ""; // initialize list  
    var separator = "_";
    var productVar = "productId";  
    var quantityVar = "quantity";  

    var cmSrc = arguments[0]; // recuperation de la valeur 'TutorialProductPage' pour coremetrics
    var category = arguments[1]; // recuperation de la categorie � transmettre au tag Shop5 pour coremetrics
    // iterate through arguments except the first one wich is for the coremetrics tag  (nb of arguments is unknown !). 
    // Quantity is allways equals to 1 for tutoriel products.
    var productTab = arguments[2];

    var nbOfItems = productTab.length;
    var tab;
    for(var i=0; i<productTab.length; i++){
    	tab = productTab[i].split("/");
        productsParamString += productVar + separator + (i) + "=" + tab[0] + "&" + quantityVar + separator + (i) + "=" + tab[1] ;  
        if (i < productTab.length - 1 ){	
        	productsParamString += "&";
        }	
    }

    return addMultipleToCartComplete(cmSrc,category, productsParamString, nbOfItems, null, null, null); 
}

function addMultipleToCartComplete(cmSrc, category, productsParamString, nbOfItems, productName, shoppingListId, shoppingListItemSeqId) {
	mAddToCartErrorMessage = null;
	if(/*productsParamString. == "000" ||*/ productsParamString == null || productsParamString == ""){
		try{
			mAddToCartErrorMessage = mAddtoCartErrorMessage;
		}catch(e){
			//A ridiculous IE error.
		}
	}else{
		mErrorMessage = null;
		// desactivation de l'envoie du tag hitbox pour l'instant ainsi que des infos de shoppingList
		// sinon, il faut boucler sur la liste des products
		//_hbAddCart(productId, productName, price, qty, timezone, hbxAccountNo, hbxCategory);
		var params = productsParamString + "&numberOfItems=" + nbOfItems;
		/*
		if(shoppingListId != null && shoppingListItemSeqId != null) {
			params = productsParamString + "&shoppingListId="+ shoppingListId+"&shoppingListItemSeqId="+shoppingListItemSeqId;
		}
		if (hbxCategory != null) {
		    params = productsParamString + "&hbxCategory="+hbxCategory;
		}
		*/
		
		//coremetrics ajout du cmSrc
		params += "&cmSrc=" + cmSrc;
		
		if(category != null){
			params += "&category_id=" + category;
		}
		
		params += "&action=addToCart"; // indispensable pour l'ajout au panier par le addMultiItem
    	//alert(" params finaux = " + params);
		
		return new AJAXRequest("post", "/control/servlet/ajaxAddMultipleToCart", params, processAddMultipleToCart);
	}
}

function processAddMultipleToCart( myAJAX ) {
    if (myAJAX.readyState == 4) {
        if (myAJAX.status == 200) {
        	var response = myAJAX.responseText;
            var xmlDocument =  Sarissa.getDomDocument();
		    xmlDocument = (new DOMParser()).parseFromString(response, "text/xml");
		    var shoppingCartData  = xmlDocument.getElementsByTagName("shoppingCartData");
		    var numberOfItems = null;
		    var numberOfProductsExceptGifts = null;
		    var grandTotal = null;
		    var numberAdjustments = null;
		    var numberOfPromos = null;
		    var currency = null;
		    
		    var cartTotalLabel = null;
		    var productInMyCart = null;
		    var productsInMyCart = null;
		    var emptyCart = null;
		    var errorMsg = null;

		    /* GDU  New vars for redesign 08 - Free Shipping */
			var ajaxAmountForFree = null;
			var freeShippingText = null;
			var giftLabel = null;
			var giftsLabel = null;

			/* JMA Coremetrics */
			var cmProdId = null;
        	var cmProdName = null;
        	var cmProdQt = null;
        	var cmProdUnitPrice = null;
        	var cmProdCatId = null;
        	var cmProdAtt= null;
        	
	        for(var i=0; i< shoppingCartData.length; i++) {
	        	
		        shoppingCartDataAttrs = shoppingCartData[i].attributes;
		        
		        tmpNumberOfItems = shoppingCartDataAttrs.getNamedItem("numberOfItems").nodeValue;
		        tmpnumberOfProductsExceptGifts = shoppingCartDataAttrs.getNamedItem("numberOfProductsExceptGifts").nodeValue;
		        tmpNumberOfPromos = shoppingCartDataAttrs.getNamedItem("numberOfPromos").nodeValue;
		        tmpGrandTotal = shoppingCartDataAttrs.getNamedItem("grandTotal").nodeValue;
		        tmpNumberAdjustments = shoppingCartDataAttrs.getNamedItem("numberAdjustments").nodeValue;
		        tmpCurrency = shoppingCartDataAttrs.getNamedItem("currency").nodeValue;
		        tmpcartTotalLabel = shoppingCartDataAttrs.getNamedItem("cartTotalLabel").nodeValue;
		        tmpproductInMyCart = shoppingCartDataAttrs.getNamedItem("productInMyCart").nodeValue;
		        tmpproductsInMyCart = shoppingCartDataAttrs.getNamedItem("productsInMyCart").nodeValue;
		        tmpemptyCart = shoppingCartDataAttrs.getNamedItem("emptyCart").nodeValue;
		        tmperrorMsg = shoppingCartDataAttrs.getNamedItem("errorMsg").nodeValue;
		        
		        /* GDU New vars for YR Redesign 08 - Free Shipping */
				tmpFreeShippingTxt = shoppingCartDataAttrs.getNamedItem("freeShippingText").nodeValue;
				tmpAjaxAmountForFree = shoppingCartDataAttrs.getNamedItem("amountForFree").nodeValue;
				tmpGiftLabel = shoppingCartDataAttrs.getNamedItem("giftLabel").nodeValue;
				tmpGiftsLabel = shoppingCartDataAttrs.getNamedItem("giftsLabel").nodeValue;

				/* Coremetrics */				
		        for(var i=1; i<= tmpnumberOfProductsExceptGifts; i++) {
			        tmpNode = shoppingCartDataAttrs.getNamedItem("cmProdId"+i)
			        if(tmpNode != null){
			        	cmProdId = tmpNode.nodeValue;
			        }
			        tmpNode = shoppingCartDataAttrs.getNamedItem("cmProdName"+i)
			        if(tmpNode != null){
			        	cmProdName = tmpNode.nodeValue;
			        }
			        tmpNode = shoppingCartDataAttrs.getNamedItem("cmProdQt"+i)
			        if(tmpNode != null){
			        	cmProdQt = tmpNode.nodeValue;
			        }
			        tmpNode = shoppingCartDataAttrs.getNamedItem("cmProdUnitPrice"+i)
			        if(tmpNode != null){
			        	cmProdUnitPrice = tmpNode.nodeValue;
			        }
			        tmpNode = shoppingCartDataAttrs.getNamedItem("cmProdCatId"+i)
			        if(tmpNode != null){
			        	cmProdCatId = tmpNode.nodeValue;
			        }
			        tmpNode = shoppingCartDataAttrs.getNamedItem("cmProdAtt"+i)
			        if(tmpNode != null){
			        	cmProdAtt = tmpNode.nodeValue;
			        }			        
			        if(cmProdId != null && cmProdName != null && cmProdQt != null && cmProdUnitPrice != null && cmProdCatId != null && cmProdAtt != null){
			        	//alert(' generation coremetrics ' + cmProdId);
		 				coremetricsGenerateShopAction5(cmProdId, cmProdName, cmProdQt, cmProdUnitPrice, cmProdCatId, cmProdAtt);
		 			}
		        }
		       	//Fin Coremetrics				
				
		        if(tmpNumberOfItems != null){
		        	numberOfItems = tmpNumberOfItems;
		        }
		        if(tmpnumberOfProductsExceptGifts != null){
		        	numberOfProductsExceptGifts = tmpnumberOfProductsExceptGifts; 
		        }		        
		 		if(tmpNumberOfPromos != null){
		        	numberOfPromos = tmpNumberOfPromos;
		        }
		        if(tmpGrandTotal != null){
		        	grandTotal = tmpGrandTotal;
		        }
		        if(tmpNumberAdjustments != null){
		        	numberAdjustments = tmpNumberAdjustments;
		        }
		        if(tmpCurrency != null){
		        	currency = tmpCurrency;
		        }
		        if(tmpcartTotalLabel!= null){
		        	cartTotalLabel = tmpcartTotalLabel;
		        }
		        if(tmpproductInMyCart!= null){
		        	productInMyCart = tmpproductInMyCart;
		        }
		        if(tmpproductsInMyCart!= null){
		        	productsInMyCart = tmpproductsInMyCart;
		        }
		        if(tmpemptyCart!= null){
		        	emptyCart = tmpemptyCart;
		        }
		        if(tmperrorMsg != null){
		        	errorMsg = tmperrorMsg;
		        }
		        
		        /* GDU Free Shipping For Redesign */
				if (tmpFreeShippingTxt!=null)
		        {
		        	freeShippingText = tmpFreeShippingTxt;
		        }

		        if (tmpAjaxAmountForFree!=null)
		        {
			        ajaxAmountForFree = tmpAjaxAmountForFree;
		        }

		        if (tmpGiftLabel!=null)
		        {
			        giftLabel = tmpGiftLabel;
		        }

		        if (tmpGiftsLabel!=null)
		        {
			        giftsLabel = tmpGiftsLabel;
		        }
		    };

			if(errorMsg == null || errorMsg == 'null'){
		 		makeMicroCartHTML(numberOfItems, numberOfPromos, grandTotal, productInMyCart, productsInMyCart, emptyCart, freeShippingText, giftLabel, giftsLabel);
		 		//makeMiniCartHTML(numberOfItems, numberOfPromos, grandTotal, itemId1, itemId2, itemId3, itemCatId1, itemCatId2, itemCatId3, itemImage1, itemImage2, itemImage3, itemLinkTitle, itemLinkLabel, cartTotalLabel);
		 		// open popin with ajax
		 		openTutorielModalCartPopin(numberOfProductsExceptGifts,''); 		
			}else{
					mErrorMessage = errorMsg;
				try{
					errorMsg = "<font color='red'>"+URLDecode(errorMsg)+"</font>";
					document.getElementById("with-or-without-errors").innerHTML = errorMsg;
				}catch(e){
				//IE error, we might want to do something in the future.
				}

		 		makeMicroCartHTML(numberOfItems, numberOfPromos, grandTotal, productInMyCart, productsInMyCart, emptyCart, freeShippingText, giftLabel, giftsLabel);
		 		// open popin with ajax
		 		openTutorielModalCartPopin(numberOfProductsExceptGifts,mErrorMessage); 
			}
        } else {
            alert("There was a problem retrieving the XML data:\n" + myAJAX.statusText);
        }
    }
}
// end ppo ajout multiple au panier

function addToCart(productId, qty, price, timezone, hbxAccountNo, hbxCategory, shoppingListId, shoppingListItemSeqId) {
	return addToCart(productId, qty, price, timezone, hbxAccountNo, hbxCategory, null, shoppingListId, shoppingListItemSeqId, null);
}

function addToCartModal(productId, qty, price, timezone, hbxAccountNo, hbxCategory, productName, tradload, url, cmSrc, categoryId) {
	return openModalCartPopin(productId, qty, price, timezone, hbxAccountNo, hbxCategory, productName,'addCart', tradload, url, cmSrc, categoryId);
}

function addToCart(productId, qty, price, timezone, hbxAccountNo, hbxCategory, productName, shoppingListId, shoppingListItemSeqId, cmSrc, categoryId) {
	mAddToCartErrorMessage = null;
	if(productId == "000" || productId == null || productId == ""){
		try{
			mAddToCartErrorMessage = mAddtoCartErrorMessage;
		}catch(e){
			//A ridiculous IE error.
		}
	}else{
		mErrorMessage = null;
		//_hbAddCart(productId, productName, price, qty, timezone, hbxAccountNo, hbxCategory);
		var params = "productId=" + productId + "&quantity=" + qty;
		if(shoppingListId != null && shoppingListItemSeqId != null) {
			params = params + "&shoppingListId="+ shoppingListId+"&shoppingListItemSeqId="+shoppingListItemSeqId;
		}
		if (hbxCategory != null) {
		    params = params + "&hbxCategory="+hbxCategory;
		}

		// GDU : redesign 08 - Free Shipping text
		params += "&amountForFree=" + amountForFree;

		//JMA : coremetrics ajout du cmSrc
		params += "&cmSrc=" + cmSrc;
		if(categoryId != null){
			params += "&category_id=" + categoryId;
		}
		return new AJAXRequest("post", "/control/servlet/ajaxAddToCartNew", params, processAddToCart);
		// Added by Abdel for Bird 2.8
		//return new Ajax("post", "/control/ajaxAddToCart", params, processAddToCartNew).ajaxRequestNew();
	}
}

function processAddToCart( myAJAX ) {
    if (myAJAX.readyState == 4) {
        if (myAJAX.status == 200) {
        	var response = myAJAX.responseText;
            var xmlDocument =  Sarissa.getDomDocument();
		    xmlDocument = (new DOMParser()).parseFromString(response, "text/xml");
		    var shoppingCartData  = xmlDocument.getElementsByTagName("shoppingCartData");
		    var numberOfItems = null;
		    var grandTotal = null;
		    var numberAdjustments = null;
		    var numberOfPromos = null;
		    var currency = null;
		    var cartTotalLabel = null;
		    var productInMyCart = null;
		    var productsInMyCart = null;
		    var emptyCart = null;
		    var errorMsg = null;

		    /* GDU  New vars for redesign 08 - Free Shipping */
			var ajaxAmountForFree = null;
			var freeShippingText = null;
			var giftLabel = null;
			var giftsLabel = null;

			/* JMA Coremetrics */
			var cmProdId = null;
        	var cmProdName = null;
        	var cmProdQt = null;
        	var cmProdUnitPrice = null;
        	var cmProdCatId = null;
        	var cmProdAtt= null;
			
	        for(var i=0; i< shoppingCartData.length; i++) {
		        shoppingCartDataAttrs = shoppingCartData[i].attributes;
		        tmpNumberOfItems = shoppingCartDataAttrs.getNamedItem("numberOfItems").nodeValue;
		        tmpNumberOfPromos = shoppingCartDataAttrs.getNamedItem("numberOfPromos").nodeValue;
		        tmpGrandTotal = shoppingCartDataAttrs.getNamedItem("grandTotal").nodeValue;
		        tmpNumberAdjustments = shoppingCartDataAttrs.getNamedItem("numberAdjustments").nodeValue;
		        tmpCurrency = shoppingCartDataAttrs.getNamedItem("currency").nodeValue;
		        tmpcartTotalLabel = shoppingCartDataAttrs.getNamedItem("cartTotalLabel").nodeValue;
		        tmpproductInMyCart = shoppingCartDataAttrs.getNamedItem("productInMyCart").nodeValue;
		        tmpproductsInMyCart = shoppingCartDataAttrs.getNamedItem("productsInMyCart").nodeValue;
		        tmpemptyCart = shoppingCartDataAttrs.getNamedItem("emptyCart").nodeValue;
		        tmperrorMsg = shoppingCartDataAttrs.getNamedItem("errorMsg").nodeValue;

		        /* GDU New vars for YR Redesign 08 - Free Shipping */
				tmpFreeShippingTxt = shoppingCartDataAttrs.getNamedItem("freeShippingText").nodeValue;
				tmpAjaxAmountForFree = shoppingCartDataAttrs.getNamedItem("amountForFree").nodeValue;
				tmpGiftLabel = shoppingCartDataAttrs.getNamedItem("giftLabel").nodeValue;
				tmpGiftsLabel = shoppingCartDataAttrs.getNamedItem("giftsLabel").nodeValue;

				/* Coremetrics */
				tmpNode = shoppingCartDataAttrs.getNamedItem("cmProdId");
				if(tmpNode != null){
					cmProdId = tmpNode.nodeValue;
				}

				tmpNode = shoppingCartDataAttrs.getNamedItem("cmProdName");
				if(tmpNode != null){
					cmProdName = tmpNode.nodeValue;
				}
				
				tmpNode = shoppingCartDataAttrs.getNamedItem("cmProdQt");
				if(tmpNode != null){
					cmProdQt = tmpNode.nodeValue;
				}
				
				tmpNode = shoppingCartDataAttrs.getNamedItem("cmProdUnitPrice");
				if(tmpNode != null){
					cmProdUnitPrice = tmpNode.nodeValue;
				}

				tmpNode = shoppingCartDataAttrs.getNamedItem("cmProdCatId");
				if(tmpNode != null){
					cmProdCatId = tmpNode.nodeValue;
				}

				tmpNode = shoppingCartDataAttrs.getNamedItem("cmProdAtt");
				if(tmpNode != null){
					cmProdAtt = tmpNode.nodeValue;
				}
				/* Fin Coremetrics*/

		        if(tmpNumberOfItems != null){
		        	numberOfItems = tmpNumberOfItems;
		        }
		 		if(tmpNumberOfPromos != null){
		        	numberOfPromos = tmpNumberOfPromos;
		        }
		        if(tmpGrandTotal != null){
		        	grandTotal = tmpGrandTotal;
		        }
		        if(tmpNumberAdjustments != null){
		        	numberAdjustments = tmpNumberAdjustments;
		        }
		        if(tmpCurrency != null){
		        	currency = tmpCurrency;
		        }
		        if(tmpcartTotalLabel!= null){
		        	cartTotalLabel = tmpcartTotalLabel;
		        }
		        if(tmpproductInMyCart!= null){
		        	productInMyCart = tmpproductInMyCart;
		        }
		        if(tmpproductsInMyCart!= null){
		        	productsInMyCart = tmpproductsInMyCart;
		        }
		        if(tmpemptyCart!= null){
		        	emptyCart = tmpemptyCart;
		        }
		        if(tmperrorMsg != null){
		        	errorMsg = tmperrorMsg;
		        }

		        /* GDU Free Shipping For Redesign */
				if (tmpFreeShippingTxt!=null)
		        {
		        	freeShippingText = tmpFreeShippingTxt;
		        }

		        if (tmpAjaxAmountForFree!=null)
		        {
			        ajaxAmountForFree = tmpAjaxAmountForFree;
		        }

		        if (tmpGiftLabel!=null)
		        {
			        giftLabel = tmpGiftLabel;
		        }

		        if (tmpGiftsLabel!=null)
		        {
			        giftsLabel = tmpGiftsLabel;
		        }
		    };

			if(errorMsg == null || errorMsg == 'null'){
		 		makeMicroCartHTML(numberOfItems, numberOfPromos, grandTotal, productInMyCart, productsInMyCart, emptyCart, freeShippingText, giftLabel, giftsLabel);
		 		//makeMiniCartHTML(numberOfItems, numberOfPromos, grandTotal, itemId1, itemId2, itemId3, itemCatId1, itemCatId2, itemCatId3, itemImage1, itemImage2, itemImage3, itemLinkTitle, itemLinkLabel, cartTotalLabel);
			}else{

					mErrorMessage = errorMsg;
				try{
					errorMsg = "<font color='red'>"+URLDecode(errorMsg)+"</font>";
					document.getElementById("with-or-without-errors").innerHTML = errorMsg;
				}catch(e){
				//IE error, we might want to do something in the future.
				}

		 		makeMicroCartHTML(numberOfItems, numberOfPromos, grandTotal, productInMyCart, productsInMyCart, emptyCart, freeShippingText, giftLabel, giftsLabel);
		 		//makeMiniCartHTML(numberOfItems, numberOfPromos, grandTotal, itemId1, itemId2, itemId3, itemCatId1, itemCatId2, itemCatId3, itemImage1, itemImage2, itemImage3, itemLinkTitle, itemLinkLabel, cartTotalLabel);
			}
			if(cmProdId != null && cmProdName != null && cmProdQt != null && cmProdUnitPrice != null && cmProdCatId != null && cmProdAtt != null){
		 		coremetricsGenerateShopAction5(cmProdId, cmProdName, cmProdQt, cmProdUnitPrice, cmProdCatId, cmProdAtt);
		 	}
        } else {
            alert("There was a problem retrieving the XML data:\n" + myAJAX.statusText);
        }
    }
}

function coremetricsGenerateShopAction5(cmProdId, cmProdName, cmProdQt, cmProdUnitPrice, cmProdCatId, cmProdAtt){
	cmCreateShopAction5Tag(cmProdId,cmProdName,cmProdQt,cmProdUnitPrice,cmProdCatId, cmProdAtt);
	cmDisplayShop5s();
}

function makeMiniCartHTML( numberOfItems, numberOfPromos, grandTotal, itemId1, itemId2, itemId3, itemCatId1, itemCatId2, itemCatId3, itemImage1, itemImage2, itemImage3, itemLinkTitle, itemLinkLabel, cartTotalLabel) {
	var myHTML = "";
	var tmpValue = (numberOfItems - numberOfPromos);
	if(document.getElementById("ajaxAddToCart2") != null)  {
		if(tmpValue > 0){
			myHTML += '<div id="products">';
		if(itemId1 != null && itemId1 != ""){
		myHTML += '<div class="product_box">' +
			'<span><img src="'+itemImage1+'" width="48" height="48" alt=""/></span> ' +
			'<a href="/control/product/~category_id='+itemCatId1+'/~product_id='+itemId1+'" title="'+itemLinkTitle+'">'+itemLinkLabel+'</a>' +
		'</div> ';
		} else {
		myHTML += '<div class="product_box">' +
			'<span><img src="/images/espaceur.gif" width="48" height="48" alt=""/></span> ' +
			'<a href="#" title="'+itemLinkTitle+'" class="underline">'+itemLinkLabel+'</a>' +
			'</div> ';
		}
		if(itemId2 != null && itemId2 != ""){
		myHTML += '<div class="product_box central">' +
			'<span><img src="'+itemImage2+'" width="48" height="48" alt=""/></span> ' +
			'<a href="/control/product/~category_id='+itemCatId2+'/~product_id='+itemId2+'" title="'+itemLinkTitle+'">'+itemLinkLabel+'</a>' +
		'</div> ';
		} else {
		myHTML += '<div class="product_box central">' +
			'<span><img src="/images/espaceur.gif" width="48" height="48" alt=""/></span> ' +
			'<a href="#" title="Voir plus d\'info sur le produit" class="underline">'+itemLinkLabel+'</a>' +
			'</div> ';
		}
		if(itemId3 != null && itemId3 != ""){
		myHTML += '<div class="product_box">' +
			'<span><img src="'+itemImage3+'" width="48" height="48" alt=""/></span> ' +
			'<a href="/control/product/~category_id='+itemCatId3+'/~product_id='+itemId3+'" title="'+itemLinkTitle+'">'+itemLinkLabel+'</a>' +
		'</div> ';
		} else {
		myHTML += '<div class="product_box">' +
			'<span><img src="/images/espaceur.gif" width="48" height="48" alt=""/></span> ' +
			'<a href="#" title="'+itemLinkTitle+'">'+itemLinkLabel+'</a>' +
			'</div> ';
		}
		myHTML += '</div>';
	}
	myHTML += '<div id="both-panier"><p class="detail">' +
		'<span class="nbre-ref">'+tmpValue+' '+cartTotalLabel+'</span>' +
		'<span class="prix">'+grandTotal+'</span>' +
	'</p></div>';
	document.getElementById("ajaxAddToCart2").innerHTML = myHTML;
	}
}


function makeMicroCartHTML( numberOfItems, numberOfPromos, grandTotal, productInMyCart, productsInMyCart, emptyCart, freeShippingText, giftLabel, giftsLabel) {
	
	// debug alert
	/*
	alert('makeMicroCartHTML' 
	+ ' \n' + 'numberOfItems = ' + numberOfItems
	+ ' \n' + 'numberOfPromos = ' + numberOfPromos
	+ ' \n' + 'grandTotal = ' + grandTotal
	+ ' \n' + 'productInMyCart = ' + productInMyCart
	+ ' \n' + 'productsInMyCart = ' + productsInMyCart
	+ ' \n' + 'emptyCart = ' + emptyCart
	+ ' \n' + 'freeShippingText = ' + freeShippingText
	+ ' \n' + 'giftLabel = ' + giftLabel
	+ ' \n' + 'giftsLabel = ' + giftsLabel
	);
	*/

		var reg = new RegExp(" ", "g");
		if (grandTotal != null){
			grandTotal = grandTotal.replace(reg, "&nbsp;");
		}else{
			grandTotal = 0;
		}
		if(numberOfItems > 0 ){

			tmpValue = (numberOfItems - numberOfPromos);
			if(numberOfItems - numberOfPromos > 0){
				tmpValue = tmpValue + " " + productsInMyCart + " (" + grandTotal + ")";
				if (numberOfPromos > 1)
					tmpValue = tmpValue + " <b> + " + numberOfPromos + " " + giftsLabel + "</b>";
				else
				{
					if (numberOfPromos == 1)
						tmpValue = tmpValue + " <b> + " + numberOfPromos + " " + giftLabel + "</b>";
				}

			}else {
			    tmpValue = tmpValue + " " + productInMyCart;
			}
		}else{
			tmpValue = ' ' + emptyCart;
		}

        document.getElementById("ajaxAddToCart").innerHTML = tmpValue;
        document.getElementById("microCartFreeShippingText").innerHTML = freeShippingText;

        var minishopper = document.getElementById("minishopper");
        minishopper.className = "minishopper";
}

function buildWindow(message1, message2, message3, message4, url) {
	return '<div id="theContinueShoppingWindow" style="border:2px solid #ccc;background:#fff;width:150px;height:100px;color:#333;text-align:left;padding:5px">' +
						     '<b style="font-size:14px;">'+message1+'</b><br/>' +
						     '<div style="padding:4px 0;">'+message2+'</div> <div style="padding:4px 0;">' +
						     '<a style="color:#007856" href="#" onclick="document.getElementById(\'theContinueShoppingWindow\').style.visibility=\'hidden\';">' +
						     message3 + '</a></div><div style="padding:4px 0;">' +
						     '<a style="color:#007856" href="'+url+'">' +
						     message4 + '</a></div></div>';
}

function _hbAddCart(HBXPRODUCTID, HBXPRODUCTNAME, HBXPRODUCTPRICE, HBXPRODUCTQTY, HBXTIMEZONE, HBXACCTNO, HBXCATEGORY){
	try{
		if (HBXCATEGORY == null || HBXCATEGORY == ""){
			HBXCATEGORY='YRCATEGORY';  //default category value
		}
		if (HBXPRODUCTNAME == null || HBXPRODUCTNAME == ""){
			HBXPRODUCTNAME=HBXPRODUCTID;
		}
	    _hbSet('epg', 'n');
	    _hbSet('cam', '0');
	    _hbSet('pv', '0');
	    _hbSet('abd_type', 'cart_add');
	    _hbSet('product', HBXPRODUCTNAME);
	    _hbSet('price', HBXPRODUCTPRICE);
	    _hbSet('quantity', HBXPRODUCTQTY);
	    _hbSet('brand', 'YRBRAND');  //default brand value
	    _hbSet('category', HBXCATEGORY);
	    _hbSet('store', '1'); //default store value
	    _hbSet('tz', HBXTIMEZONE);
		_hbSet('aid', HBXACCTNO);
	    _hbPageView("AddCartPage", "/commerce"); //content category and page name
	}catch(e){}
}

function ajaxGetZipCodeShipping(postalCode,shipType,cartTotal){
	params = "postalCode="+postalCode.replace(/^\s+|\s+$/g,"")+"&shipType="+shipType+"&cartTotal="+cartTotal;
	return new AJAXRequest("post", "/control/servlet/ajaxGetShippingCost", params, ajaxGetZipCodeShippingCallback);
}

function ajaxGetZipCodeShippingCallback( myAJAX ){
    if (myAJAX.readyState == 4) {
    	if (myAJAX.status == 200) {
        	var response = myAJAX.responseText;
        	//alert(response);
            var xmlDocument =  Sarissa.getDomDocument();
		    xmlDocument = (new DOMParser()).parseFromString(response, "text/xml");
		    var shippingCosts  = xmlDocument.getElementsByTagName("threshold");
			var root = xmlDocument.getElementsByTagName("shipcosts");
			var cartTotalNode = root[0].attributes;
			var cartTotal = cartTotalNode.getNamedItem("cartTotal").nodeValue;

			var popupHtml = textPopinSorry;
			if(shippingCosts.length > 0){
				popupHtml = textPopinIntro+"<br/>";
				for(var i=0; i< shippingCosts.length; i++) {
		        	var thresholdAttr = shippingCosts[i].attributes;
		        	from = thresholdAttr.getNamedItem("from").nodeValue;
		        	to = thresholdAttr.getNamedItem("to").nodeValue;
		        	cost = (thresholdAttr.getNamedItem("cost").nodeValue != "0") ? thresholdAttr.getNamedItem("cost").nodeValue+" "+textPopinCurrency : textPopinFree;
		        	delta = parseInt(from)-parseInt(cartTotal);
		        	fromtoText = (to=="0") ? textPopinHigher+" <b>"+from+textPopinCurrency : textPopinBetween+" <b>"+from+textPopinCurrency+" "+textPopinAnd+" "+to+textPopinCurrency;
		        	popupHtml += textPopinFor+" "+fromtoText+" : "+cost+"</b><br/>";
					if((parseInt(cartTotal) < parseInt(from))&&(productStoreId != "14000-RU"))
						popupHtml += textPopinOnly+" "+delta+textPopinCurrency+" "+textPopinBenefit+" "+cost+" <br/>";
		        }
			}
	        document.getElementById("pop_content").innerHTML = popupHtml;
	    } else {
        	alert("There was a problem retrieving the XML data:\n" + myAJAX.statusText);
	    }
    }
}

 /***********************************************
 * addToFavorites.js
 ***********************************************/
 var mAddtoFavoritesErrorMessage = null;
function addFavoritesErrorMesseging(pErrorMessage){
	mAddtoFavoritesErrorMessage = pErrorMessage;
}

function addToFavorites(productId, qty, price, timezone, hbxAccountNo, shoppingListId, userLoginId) {
	mAddToCartErrorMessage = null;
	if(productId == "000" || productId == null || productId == ""){
		try{
			mAddToCartErrorMessage = mAddtoCartErrorMessage;
		}catch(e){
			//A ridiculous IE error.
		}
	}else{
		mErrorMessage = null;
		var params = "productId=" + productId + "&quantity=" + qty+ "&userLoginId=" + userLoginId;
		if(shoppingListId != null) {
			params = params + "&shoppingListId="+ shoppingListId;
		}
		return new AJAXRequest("post", "/control/servlet/ajaxAddToFavorites", params, processAddToFavorites);
	}
}

function processAddToFavorites( myAJAX ) {
    if (myAJAX.readyState == 4) {
        if (myAJAX.status == 200) {

        } else {
            alert("There was a problem retrieving the XML data:\n" + myAJAX.statusText);
        }
    }
}

function MultiAddToRecomendList(productIdT, shoppingListId, userLoginId, surveyId, profileId) {
	mAddToCartErrorMessage = null;

	productIds = "";
	for(var ix = 0 ; ix < productIdT.length ; ix++)
	{
		productIds += productIdT[ix];
		if(ix < productIdT.length-1)
			productIds += ",";
	}

	if(productIds == "000" || productIds == null || productIds == ""){
		try{
			mAddToCartErrorMessage = mAddtoCartErrorMessage;
		}catch(e){
			//A ridiculous IE error.
		}
	}else{
		mErrorMessage = null;
		var params = "productId="+productIds+"&quantity=1&userLoginId=" + userLoginId+"&shoppingListTypeId=RECOMENDED_LIST&surveyId="+surveyId+"&profileId="+profileId;
		if(shoppingListId != null) {
			params = params + "&shoppingListId="+ shoppingListId;
		}
		var xhr_object = new AJAXRequest("post", "/control/servlet/ajaxAddToFavorites", params, processAddToReco);
	}
}
function processAddToReco( myAJAX ) {
    if (myAJAX.readyState == 4) {
        if (myAJAX.status == 200) {

			document.getElementById("detail_popin_rec").style.display="block";
			var posX = mouse_x;
			var posY = mouse_y;
			if(posX > 480) posX = 480;
			document.getElementById("detail_popin_rec").style.left = posX + "px";
			document.getElementById("detail_popin_rec").style.top = (posY - 150) + "px";
        } else {
            alert("There was a problem retrieving the XML data:\n" + myAJAX.statusText);
        }
    }
}

 /***********************************************
 * yvesrocher.js
 ***********************************************/
 function popup(url, name, w, h)
{
    var win;
	var winl = (screen.width - w) / 2;
    var wint = (screen.height - h) / 2;
    winprops = 'height=' + h + ',width=' + w + ',top=' + wint + ',left=' + winl + ',toolbar=0,location=0,statusbar=0,menubar=0,';
    win = window.open(url, name, winprops);
  	win.focus();
}
/*************************************************
 *  si_commons.js
 * **********************************************/
/*
 * Opens a div element as popin.
 * Also adds a transparent layer right under it.
 */
function openDivPopin(divId){
	openDivPopinOverlay(divId, true);
}

function openDivPopinOverlay(divId, Overlay)
{
	var positionCss = "fixed";
	if (jQuery.browser.msie) positionCss = "absolute";

	jQuery('#' + divId).prependTo("body");

	var zindex = jQuery('#' + divId).css('z-index');
	var overLayZIndex = zindex - 1;
	jQuery('#' + divId).show();
	if (Overlay==true)
	{
		var overLay = jQuery('<div id="'+divId+'Overlay"></div>').css({'background-color':'#888888', height:'2500px',width:'100%',position: positionCss,left:0,top:0, 'z-index':overLayZIndex,opacity:0.5});
	}
	else
	{
		var overLay = jQuery('<div id="'+divId+'Overlay"></div>').css({'display':'none'});
	}
	jQuery('body').append(overLay);
}

/*
 * Closes a div element opened with openDivPopin function.
 */
function closeDivPopin(divId){
	jQuery('#' + divId).hide();
	jQuery('#' + divId + 'Overlay').remove();
}

/*
 * Show a div element.
 */
function showDiv(divId){
	jQuery('#' + divId).show();
}

/*
 * Hide a div element.
 */
function hideDiv(divId){
	jQuery('#' + divId).hide();
}

/*
 * ppo 31082009 : tell a friend 
 */
function valideEmailFormat(email) 
{
	var exprReg = /^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*$/ ;
	return exprReg.test(email);
}

/* BazaarVoice : display reviews */
function displayReviews(rating_reviews_Id) {
	document.getElementById(rating_reviews_Id).style.visibility = "visible";
}

function hideReviews(rating_reviews_Id) {
	document.getElementById(rating_reviews_Id).style.visibility = "hidden";
}


/* Methodes de choix des couleurs pour un variant */
function addToWishlist(name, productId){
    if(document.forms["addform"].elements[name].selectedIndex==0) {
			document.addToShoppingList.product_id.value=productId;
			document.addToShoppingList.productId.value=productId;
			document.addToShoppingList.submit();
	} else {
    	var indexSelected = document.forms["addform"].elements[name].selectedIndex;
        // using the selected index locate the sku
        var sku = document.forms["addform"].elements[name].options[indexSelected].value;
   
   		document.addToShoppingList.product_id.value = sku;
   		document.addToShoppingList.productId.value = sku;
   		document.addToShoppingList.submit();
    }
}

function getList(pProductId) {
	try{
		clearSelectedBox();
		var productLittleBox = "productLittleBox"+pProductId;
		document.getElementById(productLittleBox).className = "grey";
		setPulldown(pProductId);
		theProduct = findBuildDataForDetailPanel(pProductId);
		document.getElementById("largeImageInDetailPanel").innerHTML = "<img src='"+
			theProduct[1]+"' width='95' height='100'/>";
		document.getElementById("mediumImageInDetailPanel").innerHTML = "<img src='"+
			theProduct[2]+"' width='38' height='38'/>";
		document.getElementById("variantProductId").innerHTML = pProductId;
	}catch(e){
		//Useless IE bug
	}
}

function setPulldown(pProductId){
	try{
		document.addform.add_product_id.value=pProductId;
	}catch(e){}
	for (var i = 0; i < document.addform.productId.options.length; i++){
		if (document.addform.productId.options[i].value == pProductId){
			document.addform.productId.options[i].selected = true;
		}
	}
}

function clearSelectedBox(){
	for (var i = 0; i < mBuildDataForDetailPanel.length; i++){
		try{
			aProduct = mBuildDataForDetailPanel[i];
			productId = aProduct[0];
			document.getElementById("productLittleBox"+productId).className = "white";
		}catch(e){}
	}
}
	
/*
 * Displays green tick and border around the field 'fieldName'
 */
function setOk(formName, hiddenField, fieldName){

	document.getElementById(hiddenField).style.display = "inline";
	document.getElementById(hiddenField).innerHTML = "<img src='/images/customer/ok.gif' alt='' />";
	document.forms[formName].elements[fieldName].style.backgroundColor = "white";
	document.forms[formName].elements[fieldName].style.borderColor = "#7B8F38";
	
	var errorField = "error_"+hiddenField;
	document.getElementById(errorField).style.display = "none";
}

/*
 * Displays red cross, background and border around the field 'fieldName' 
 */
function setKo(formName, hiddenField, fieldName, propertyName, key, checkNum){
	
	resetTick(formName, hiddenField, fieldName);
	document.getElementById(hiddenField).style.display = "inline";
	document.getElementById(hiddenField).innerHTML = "<img src='/images/customer/ko.gif' alt='' />";
	document.forms[formName].elements[fieldName].style.backgroundColor = "#F5CBCC";
	document.forms[formName].elements[fieldName].style.borderColor = "red";

  	//appel � la fonction ajax pour le message d'erreur
  	getErrorMessage(hiddenField, propertyName, key, checkNum);
}

function resetTick(formName, hiddenField, fieldName){
	document.getElementById(hiddenField).innerHTML = "";
	document.forms[formName].elements[fieldName].style.backgroundColor = "";
	document.forms[formName].elements[fieldName].style.borderColor = "";
}

function checkEmailFormat(formName, hiddenField, fieldName1){	
	var champ = document.forms[formName].elements[fieldName1].value;	
	var reg= /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.[a-zA-Z]{2,6})+$/;// \.([a-z]{2,6})
	if (champ != ''){
	  	if(reg.test(champ) == true) {
	  		setOk(formName, hiddenField, fieldName1);
	  	}else{
	  		var propertyName = "EcommerceUiLabels";
	  		var key = "EmailErrorEmailAddress";
	       	setKo(formName, hiddenField, fieldName1, propertyName, key, ""); 
		}
	}else{
		//alert ajax => le champ obligatoire est vide
		var propertyName = "EcommerceUiLabels";
		var key = "PartyEmailAddressMissingError";
	    setKo(formName, hiddenField, fieldName1, propertyName, key, "");
	}
}
	
function controlFieldsValues(formName, hiddenField, fieldName1 , fieldName2){
	var champ1 = document.forms[formName].elements[fieldName1].value;
	var champ2 = document.forms[formName].elements[fieldName2].value;
	if (champ2 != ''){
		if (champ1 == champ2){
			setOk(formName, hiddenField, fieldName2);
			checkEmailFormat(formName, hiddenField, fieldName2);
		}else{
			//alert ajax => les emails saisis ne sont pas les m�mes
			var propertyName = "EcommerceUiLabels";
			var key = "PartyEmailMatchError";
	       	setKo(formName, hiddenField, fieldName2, propertyName, key, "");
		}
	}else{
		//alert ajax => le champ obligatoire est vide
		var propertyName = "EcommerceUiLabels";
		var key = "CommonFieldsMarkedAreRequired";
	    setKo(formName, hiddenField, fieldName2, propertyName, key, "");
	}
}

function checkSizeField(formName, hiddenField, fieldName1){
	var champ = document.forms[formName].elements[fieldName1].value;
	if (champ != ''){
		if (champ.length > 4 || champ.length == 4){
			setOk(formName, hiddenField, fieldName1);
		}else{
			//alert ajax => la taille est inf�rieure � 4
			var propertyName = "SecurityextUiLabels";
			var key = "loginservices.password_must_be_least_characters_long";
	       	setKo(formName, hiddenField, fieldName1, propertyName, key, "doCheckNum");
		}
	}else{
		//alert ajax => le champ obligatoire est vide
		var propertyName = "EcommerceUiLabels";
		var key = "PartyPasswordMissing";
	    setKo(formName, hiddenField, fieldName1, propertyName, key, "");
	}
}

function controlPwdFieldsValues(formName, hiddenField, fieldName1 , fieldName2){
	var champ1 = document.forms[formName].elements[fieldName1].value;
	var champ2 = document.forms[formName].elements[fieldName2].value;
	if (champ2 != ''){
		if (champ1 == champ2){
			setOk(formName, hiddenField, fieldName2);
			checkSizeField(formName, hiddenField, fieldName2);
		}else{
			//alert ajax => les mots de passe ne sont pas les m�mes
			var propertyName = "EcommerceUiLabels";
			var key = "PartyPasswordMatchError";
       		setKo(formName, hiddenField, fieldName2, propertyName, key, "");
		}
	}else{
		//alert ajax => le champ obligatoire est vide
		var propertyName = "SecurityextUiLabels";
		var key = "loginservices.password_or_verify_missing";
	    setKo(formName, hiddenField, fieldName2, propertyName, key, "");
	}
}

function getErrorMessage(hiddenField, propertyName, key, checkNum){
		params = "hiddenField="+hiddenField+"&propertyName="+propertyName+"&messageKey="+key+"&checkNum="+checkNum;
		createXMLHttpRequest();
		xmlHttp.open("POST", "/control/servlet/AjaxGetMessageError", true);
	    xmlHttp.setRequestHeader("Connection", "close");
	    xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	    xmlHttp.setRequestHeader("Method", "POST " + "/control/servlet/AjaxGetMessageError" + "HTTP/1.1");
	    xmlHttp.setRequestHeader("X-Requested-With", "XMLHttpRequest");
		xmlHttp.onreadystatechange = callBackGetMessageError;
		xmlHttp.send(params);
}

function callBackGetMessageError() {
    if (xmlHttp.readyState == 4) {
        if (xmlHttp.status && xmlHttp.status == 200) {
        	var response = xmlHttp.responseText;
            var xmlDocument =  Sarissa.getDomDocument();
		    xmlDocument = (new DOMParser()).parseFromString(response, "text/xml");
		    var ResponseData  = xmlDocument.getElementsByTagName("Response");
	        for(var i=0; i< ResponseData.length; i++) {
		        ResponseDataAttrs = ResponseData[i].attributes;
		        ResponseStatus = ResponseDataAttrs.getNamedItem("status").nodeValue;
		        ResponseError = ResponseDataAttrs.getNamedItem("ErrorMessage").nodeValue;
		        if(ResponseStatus == "OK"){
		        	errorField = ResponseDataAttrs.getNamedItem("errorField").nodeValue;
		        	document.getElementById(errorField).style.display = "block";
		        	document.getElementById(errorField).innerHTML = '<span class="error"><ul><li class="errorMessage">'+ResponseError+'</li></ul></span>'
		        }
	        }
        }
    }
}

function _hbLink(a,b,c){}

function changePicture(urlZoom){
    newHtml="<a href='#'onClick=\"javascript:document.getElementById('popinZoom').style.display='none'; return false;\"><img src='"+urlZoom+"'/></a>";
    //newHtml="<a href='#'onClick=\"javascript:saveMyPopinPicture('"+url+"'); return false;\"><img src='"+url+"'/></a>";
    document.getElementById("popinZoom").innerHTML=newHtml;
}

function selectActivePicture(nameImg){
	var tables=document.getElementsByTagName("a");
	for(var i = 0;i < tables.length;i++){
        if(tables[i].className == "selected"){
        	document.getElementById(tables[i].id).className="";
        }
	}    	
	document.getElementById(nameImg).className="selected";
}

function hideValidePictureProfile(){
	document.getElementById("submitPictureProfile").style.display="none";
	document.getElementById("hidePictureProfile").style.display="block";
}

var waitingMsg;
var addToNewFavorites_url;
function addToNewFavorites(productId, qty, isLogged, currentProductId) {
	if(productId == "000" || productId == null || productId == ""){
		try{
			mAddToCartErrorMessage = mAddtoCartErrorMessage;
		}catch(e){
			//A ridiculous IE error.
		}
	}
		
	if (isLogged){
		//alert("url = " + addToNewFavorites_url);
		$.ajax({
			type: "POST",
			url: addToNewFavorites_url,
			data: "productId="+productId+"&quantity="+qty,
			dataType: "html",
			error: function(XMLHttpRequest, textStatus, errorThrown){
				alert("addToNewFavorites = " + textStatus);
			},
			success: function(data, textStatus){
				waitingFunction();
				showPopinFavorites(productId, qty);
			}
		});
	}else{
		var form_name="addToMyFavorites_"+currentProductId;
		var search_field ="fav_search_string_"+currentProductId;
		if (document.getElementById('new_keyword')){
			document.forms[form_name].elements[search_field].value = document.getElementById('new_keyword').value;
		}
		//alert(document.forms[form_name].elements[search_field].value);
		document.forms[form_name].submit();
	}
}	

function waitingFunction(){
	var yOffset = 150;
	var cible = "detail_popin";
	var shim = "detail_popin_shim";
	if(cible.match("zoom") == "zoom") {
		shim = cible + "_shim";
	}
	// Affichage de la div detail
	document.getElementById(cible).style.display = "block";
	//position div
	var posX;
	if (mouse_x == 0){
		posX = '950';
	}else{
		posX = mouse_x;
	}
	
	var posY;
	if (mouse_y == 0){
		posY = '650';
	}else{
		posY = mouse_y;
	}
	
	if(posX > 480) posX = 480;
	document.getElementById(cible).style.left = posX + "px";
	document.getElementById(cible).style.top = (posY - yOffset) + "px";
	if(isIE){
		//alert("detect IE");
		document.getElementById("detail_popin_shim").style.display="block";
		document.getElementById("detail_popin_shim").style.left = posX + "px";
		document.getElementById("detail_popin_shim").style.top = (posY - yOffset) + "px";
	}

	document.getElementById(cible).innerHTML = waitingMsg;
}

var popinFavorites_url;
function showPopinFavorites(productId, qty){
	
	$.ajax({
		type: "POST",
		url: popinFavorites_url,
		data: "productId="+productId+"&quantity="+qty,
		dataType: "html",
		error: function(XMLHttpRequest, textStatus, errorThrown){
			alert("showPopinFavorites = " + textStatus);
		},
		success: function(data, textStatus){
			if(isIE){
				//$("#detail_popin_shim").html(data);
				$("#detail_popin").html(data);
			}else{
				$("#detail_popin").html(data);
			}
		}
	});
}

var myspace_fav_url;
function showMySpaceFavTab(){
	
	$.ajax({
		type: "POST",
		url: myspace_fav_url,
		data: "type=favoris",
		dataType: "xml",
		error: function(XMLHttpRequest, textStatus, errorThrown){
			alert("showMySpaceFavTab = " + textStatus);
		},
		success: function(data, textStatus){
			//alert("showMySpaceFavTab = " + textStatus);
		}
	});
}

