// JavaScript Document
var agt='';
if (navigator) {
    if (navigator.userAgent) {
        agt = navigator.userAgent.toLowerCase();
    }
}

var is_opera = (agt.indexOf("opera") != -1);
var is_mac = (agt.indexOf("mac")!=-1);
var is_konq = (agt.indexOf('konqueror') != -1);
var is_safari = ((agt.indexOf('safari')!=-1)
    &&(agt.indexOf('mac')!=-1))?true:false;
var is_khtml  = (is_safari || is_konq);
var is_gecko = ((!is_khtml)&&(navigator.product)
    &&(navigator.product.toLowerCase()=="gecko"));
var is_fb = ((agt.indexOf('mozilla/5')!=-1) && (agt.indexOf('spoofer')==-1) &&
             (agt.indexOf('compatible')==-1) && (agt.indexOf('opera')==-1)  &&
             (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1)     &&
             (is_gecko) && (navigator.vendor=="Firebird"));
var is_fx = ((agt.indexOf('mozilla/5')!=-1) && (agt.indexOf('spoofer')==-1) &&
             (agt.indexOf('compatible')==-1) && (agt.indexOf('opera')==-1)  &&
             (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1)     &&
             (is_gecko) && ((navigator.vendor=="Firefox")||(agt.indexOf('firefox')!=-1)));
var is_moz   = ((agt.indexOf('mozilla/5')!=-1) && (agt.indexOf('spoofer')==-1) &&
                (agt.indexOf('compatible')==-1) && (agt.indexOf('opera')==-1)  &&
                (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1)     &&
                (is_gecko) && (!is_fb) && (!is_fx) &&
                ((navigator.vendor=="")||(navigator.vendor=="Mozilla")||(navigator.vendor=="Debian")));
var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
            && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
            && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1)
            && (!is_khtml) && (!(is_moz)) && (!is_fb) && (!is_fx));
var is_chrome = /chrome/.test(agt);
                     
/*if (appVer) {
    var is_ie   = ((appVer.indexOf('msie') != -1) && (!is_opera) && (!is_khtml));
} else {
    var is_ie   = false;
}*/

var referer_js=0;
var return_order_id=0;

function MM_swapImgRestore() { //v3.0
    var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
    var d=document; 
    if (d.images) { 
        if(!d.MM_p) d.MM_p=new Array();
        if (MM_preloadImages && d.MM_p) {
            var i,j=d.MM_p.length,a=MM_preloadImages.arguments; 
            for(i=0; i<a.length; i++) {
                if (a[i].indexOf("#")!=0) { 
                    d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];
                }
            }
        }
    }
}

function MM_findObj(n, d) { //v4.01
    var p,i,x;
    if (!d) d=document; 
    if ((p=n.indexOf("?"))>0&&parent.frames.length) {
        d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);
    }
    if (!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
    for (i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
    if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
    if (MM_swapImage) {
        var i,j=0,x,a=MM_swapImage.arguments; 
        document.MM_sr=new Array; 
        for(i=0;i<(a.length-2);i+=3) {
            if ((x=MM_findObj(a[i]))!=null) {
                document.MM_sr[j++]=x; 
                if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];
            }
        }
    }
}


function show(n) {
    if (n) {
        n.style.display = 'block';
    }
}
function hide(n) {
    if (n) {
        n.style.display = 'none';
    }
}

function check(n) {
    if (document.getElementById(n)) {
        document.getElementById(n).checked=true;
    }
}
function uncheck(n) {
    if (document.getElementById(n)) {
        document.getElementById(n).checked=false;
    }
}


function expand(nodeName,nodeName2, classe, pasClasse) {
    var n = document.getElementById(nodeName);
    var n2 = document.getElementById(nodeName2);
    
    if (n.style.display=='block') {
        n.style.display='none';
    } else {
        n.style.display='block';
    }
    if (n2.className==classe) {
        n2.className = pasClasse;
    } else {
        n2.className = classe;
    }
}


function expandPayment(n) {
    var node = n;
    var p = "";
    var s = "";
    var i=0;
    node.style.display = 'block';
    while (document.getElementById('pay'+i)) {
        if (document.getElementById('pay'+i).checked) {
            p = document.getElementById('pay'+i).value;
        }
        i++;
    }
    i=0;
    while (document.getElementById('sh'+i)) {
        if (document.getElementById('sh'+i).checked) {
            s = document.getElementById('sh'+i).value;
        }
        i++;
    }

    if (document.getElementById("adress_link") && document.getElementById("adress_link")!=undefined) {
        document.getElementById("adress_link").href="checkout_payment_address.php?pay=" + p + "&ship=" + s;
    }
    if (document.getElementById('paye4')) {
        document.getElementById('paye4').style.display = 'none';
    }
    document.getElementById('kialaSelection').style.display = 'none';

}

function expandPaymentKiala(n) {
    var node = n;
    var p = "";
    var s = "";
    var i=0;
    //node.style.display = 'block';
    while (document.getElementById('pay'+i)) {
        if (document.getElementById('pay'+i).checked) {
            p = document.getElementById('pay'+i).value;
        }
        i++;
    }
    i=0;
    while (document.getElementById('sh'+i)) {
        if (document.getElementById('sh'+i).checked) {
            s = document.getElementById('sh'+i).value;
        }
        i++;
    }

    if (document.getElementById("adress_link") && document.getElementById("adress_link")!=undefined) {
        document.getElementById("adress_link").href="checkout_payment_address.php?pay=" + p + "&ship=" + s;
    }
    if (document.getElementById('paye4')) {
        document.getElementById('paye4').style.display = 'none';
    }
    document.getElementById('kialaSelection').style.display = 'block';
    sendDataSync('kialaSelection','null','kiala_choice_point_ajax.php', 'POST');
}

var zoomTime4Zoom ;
var zoomProductSizeCache;
var zoomProductDivList;
var zoomProductDivParentList;
var zoomWindow;
var zoomProductImage;
var zoomOffsetX1, zoomOffsetX2, zoomOffsetY1, zoomOffsetY21;
var cursorX,cursorY;
var zoomTime4ZoomProduct ;

var zoomScreenX;
var zoomScreenY;
var zoomDiv2Fade;
var zoomFadingValue;

var zoomOldDate;
 

function getCursor(evenement) {
    
    cursorX = (evenement ? evenement.clientX : window.event.clientX) + (document.body.scrollLeft || document.documentElement.scrollLeft);
    cursorY = (evenement ? evenement.clientY : window.event.clientY) + (document.body.scrollTop || document.documentElement.scrollTop);
}

function GetDomOffset( Obj, Prop ) {
	var iVal = 0;
	while (Obj && Obj.tagName != 'BODY') {
		eval('iVal += Obj.' + Prop + ';');
		Obj = Obj.offsetParent;
	}
	return iVal;
}

function getPageSize() {
    
    if (document.body) {
        zoomScreenX = (document.documentElement.clientWidth);
        zoomScreenY = (document.documentElement.clientHeight);
    } else {
        zoomScreenX = (window.innerWidth);
        zoomScreenY = (window.innerHeight);
    }
    //alert('toto'+zoomScreenY);
}


function intersectTest(div) {
    var x1 = GetDomOffset(div,"offsetLeft");
    var y1 = GetDomOffset(div,"offsetTop");
    var x2 = x1 + div.offsetWidth; 
    var y2 = y1 + div.offsetHeight;
    
    //alert('cursorX '+cursorX+' cursorY '+cursorY+' x1 '+x1+' x2 '+x2+' y1 '+y1+' y2 '+y2);
    if (cursorX>x1 && cursorX<x2 && cursorY>y1 && cursorY<y2) {
        return true;
    } else {
        return false;
    }
}

function displayAllZoom(evt) {
    if (!evt) evt = window.event;
    getCursor(evt);
    clearTimeout(zoomTime4Zoom);
    
    for(i=0;i<zoomProductDivList.length;i++) {
        if (intersectTest(zoomProductDivParentList[i])) {
            zoomTime4Zoom = window.setTimeout("displayZoomGo()",250);
        } else {
            hide(zoomProductDivList[i]);
        }
    }
}

if(!document.getElementById) document.getElementById=function (id) {
    return eval("document.all."+id);
}
function getElementsByNameIE(name) {
    var el=document.all,result=new Array(),j=0;
    for(var i=0;i<el.length;i++) {
        if (el[i].name) {
            if(el[i].name==name) {
                result[j++]=el[i];
            }
        }
    }
    return result;
}


function initZoom() {
    var i;
    
    var rslt = navigator.appVersion.match(/MSIE (\d+\.\d+)/, '');
	var itsAllGood = (rslt != null && Number(rslt[1]) >= 5.5 );
    
    zoomProductDivParentList = new Array();
    if (itsAllGood) {
        zoomProductDivParentList = getElementsByNameIE("global_products");
    } else {
        zoomProductDivParentList = document.getElementsByName("global_products");
    }
    
    zoomProductDivList = new Array();
    zoomProductSizeCache = new Array();

    if (itsAllGood) {
        zoomProductDivList = getElementsByNameIE("zoomIcoDiv");
    } else {
        zoomProductDivList = document.getElementsByName("zoomIcoDiv");
    }
    
    zoomWindow = document.getElementById('zoomProduit');
    zoomProductImage = document.getElementById('zoomProductImage');
    
    getPageSize();
    
    var droiteDiv = document.getElementById('droite');
    
    if (droiteDiv) {
        if (droiteDiv.addEventListener) {
            droiteDiv.addEventListener('mousemove', displayAllZoom, false);
            droiteDiv.addEventListener('mouseout', displayAllZoom, false); 
        } else if (droiteDiv.attachEvent) {
            droiteDiv.attachEvent('onmousemove', displayAllZoom);
            droiteDiv.attachEvent('onmouseout', displayAllZoom);
        } else if (navigator.appName.substring(0,3) == "Net") {
            droiteDiv.captureEvents(Event.MOUSEMOVE);
            droiteDiv.onmousemove = displayAllZoom;
            droiteDiv.captureEvents(Event.MOUSEOUT);
            droiteDiv.onmouseout = displayAllZoom;
        } else {
            droiteDiv.onmousemove = displayAllZoom;
            droiteDiv.onmouseout = displayAllZoom;
        }
    }
}

function displayZoomGo() {
    var i;
    
    for(i=0;i<zoomProductDivList.length;i++) {
        if (intersectTest(zoomProductDivParentList[i])) {
            show(zoomProductDivList[i]);
        } else {
            hide(zoomProductDivList[i]);
        }
    }
    
}

function setOpacity(div, amout) {

    if (div) {  
        if (document.all) {
            div.filters.alpha.opacity = amout;
        } else {
            is_khtml  = (is_safari || is_konq);
            is_moz   = ((agt.indexOf('mozilla/5')!=-1) && (agt.indexOf('spoofer')==-1) &&
                (agt.indexOf('compatible')==-1) && (agt.indexOf('opera')==-1)  &&
                (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1)     &&
                (is_gecko) && (!is_fb) && (!is_fx) &&
                ((navigator.vendor=="")||(navigator.vendor=="Mozilla")||(navigator.vendor=="Debian")));
            var i=parseFloat(amout/100);
            div.style.opacity = i;
            if (is_khtml) {
                div.style.KhtmlOpacity = i;
            }
        }
    }
}


function rollInZoom(evt, img, id, photo, parent) {
    
    // Fred devra changer ça en fonction du positionnement et de la taille du div
    var zoomOffsetX = 0, zoomOffsetY = 0, zoomWindowSizeX = 400,  zoomWindowSizeY = 400; 
    
    if (!evt) evt = window.event;
    
    if (evt.stopPropagation) {
        evt.stopPropagation();
    }
    evt.cancelBubble = true;
    
    id.src=img;
    
    var theParent = document.getElementById('zoomIco'+parent);
    
    var x1 = GetDomOffset(theParent,"offsetLeft");
    
    var y1 = GetDomOffset(theParent,"offsetTop");
    var x2 = x1 + theParent.offsetWidth; 
    var y2 = y1 + theParent.offsetHeight;
    
    var x1Relative = x1;
    var y1Relative = y1;
    var x2Relative = x2; 
    var y2Relative = y2;
    
    var windowX;
    var windowY;
    
    getPageSize();
    
    var offsetMiddleX, offsetMiddleY;
    if (document.all && !window.opera) {
        offsetMiddleX=document.documentElement.scrollLeft  + (zoomScreenX/2);
        offsetMiddleY=document.documentElement.scrollTop  + (zoomScreenY/2);
    } else {
        offsetMiddleX=window.pageXOffset + (zoomScreenX/2);
        offsetMiddleY=window.pageYOffset + (zoomScreenY/2);
    }
    
    
    if (((x1+x2)/2) <= (offsetMiddleX)) {
        windowX = x2Relative + zoomOffsetX;
        
    } else {
        windowX = x1Relative - zoomOffsetX - zoomWindowSizeX; 
    }
    if (((y1+y2)/2) <= (offsetMiddleY) ) {
        windowY = y2Relative + zoomOffsetY; 
    } else {
        windowY = y1Relative - zoomOffsetY - zoomWindowSizeY; 
    }
    
    var zoomWindowBottom, zoomWindowTop;
    if (document.all && !window.opera) {
        zoomWindowBottom=document.documentElement.scrollTop + document.documentElement.clientHeight ;
        zoomWindowTop=document.documentElement.scrollTop ;
    } else {
        zoomWindowBottom=window.pageYOffset+window.innerHeight;
        zoomWindowTop=window.pageYOffset;
    }
    
    if ((windowY+zoomWindowSizeY)>zoomWindowBottom) {
        windowY -= ((windowY+zoomWindowSizeY)-zoomWindowBottom);
    } else if (windowY<zoomWindowTop) {
        windowY += (zoomWindowTop-windowY);
    }
    
    //alert('test windowX '+windowX+' - ' + x1Relative);
    zoomWindow.style.left = windowX+'px';
    zoomWindow.style.top = windowY+'px';
    
    zoomProductImage.src=photo;
    
    zoomFadingValue = 0;
    setOpacity(zoomWindow,zoomFadingValue);
    show(zoomWindow);
    clearTimeout(zoomTime4ZoomProduct);
    zoomDiv2Fade = zoomWindow;
    zoomOldDate = new Date();
    
    document.getElementById('zoom_size_list').innerHTML = '';
    zoomTime4ZoomProduct = window.setTimeout("fadeInDiv()",1);
    
    sendDataWithCache('zoom_size_list', 'products_id='+parent, 'zoom_ajax.php', 'GET', zoomProductSizeCache, parent);
    
}

function sendDataWithCache(div, data, page, method, cachedElements, parent) {
    var content = document.getElementById(div);
    
    var use_cache = 0;
    if (typeof cachedElements == 'object') {
        if (cachedElements[parent]!=null) {
            
            use_cache = 1;
        }
    }
    if (use_cache) {
        if (content) {
            content.innerHTML = cachedElements[parent];
        }
    } else {
        if (document.all && !window.opera) {
            var XhrObj = new ActiveXObject("Microsoft.XMLHTTP") ;
        } else {
            var XhrObj = new XMLHttpRequest();
        }
        
        if (method == "GET") {
            if (data == 'null') {                        
                XhrObj.open("GET", page);
            } else {
            XhrObj.open("GET", page+"?"+data);
            }
        } else if (method == "POST") {                   
            XhrObj.open("POST", page);
        }
    
        XhrObj.onreadystatechange = function() {
        if (XhrObj.readyState == 4 && XhrObj.status == 200)
            if (XhrObj.responseText=='NO_CUSTOMER') {
                window.parent.location='securelogin.php';
            } else {
                if (content) {
                    content.innerHTML = XhrObj.responseText ;
                }
                cachedElements[parent] = XhrObj.responseText ;
            }
        }
    
        if (method == "GET") {
            XhrObj.send(null);
        } else if (method == "POST") {
            XhrObj.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
            XhrObj.send(data);
        }
    }
}

function fadeInDiv() {
    // Fred peut changer ça pour la durée du fading
    var zoomFadeInSpeed=0.13;
    
    
    clearTimeout(zoomTime4ZoomProduct);
    if (zoomFadingValue>=100) {
        setOpacity(zoomDiv2Fade,zoomFadingValue);
        return;
    }
    var zoomNewDate = new Date();
    var delta = zoomNewDate.getTime() - zoomOldDate.getTime();
    zoomOldDate = zoomNewDate;
    zoomFadingValue += 1*delta*zoomFadeInSpeed;
    setOpacity(zoomDiv2Fade,zoomFadingValue);
    zoomTime4ZoomProduct = window.setTimeout("fadeInDiv()",1);
}

function rollOutZoom(evt, img, id) {
    if (!evt) evt = window.event;

    if (evt.stopPropagation) {
        evt.stopPropagation();
    }
    if (evt.cancelBubble) {
        evt.cancelBubble = true;
    }
    id.src=img;
    
    setOpacity(zoomDiv2Fade,0);
    
    zoomProductImage.src='images/loader_zoom.gif';
    
    
    hide(zoomWindow);
    
}


var time4kiala ;

function changeCodeKiala() {
    clearTimeout(time4kiala);
    if ((document.getElementById('postcode').value.length >= 4)) {
           document.getElementById("listeRelais").innerHTML = 
                "<span>"+changeCodeKiala_search_cp+"</span><br />"; 
    } else {
        if ((document.getElementById('town').value.length >= 2)) {
            document.getElementById("listeRelais").innerHTML = 
                "<span>"+changeCodeKiala_search_ville+"</span><br />"; 
        } else {
            document.getElementById("listeRelais").innerHTML = 
                "<span>"+changeCodeKiala_search_error+"</span><br />";
        }
    }
    time4kiala = window.setTimeout("changeCodeKialaGo()",1000);
}

function changeCodeKialaGo() {
    var country = "";
    if(document.getElementById('country')) {
        country = document.getElementById('country').value;
    }
    if ((document.getElementById('postcode').value.length >= 4)){
        sendDataSync('kialaSelection','zip='
            +document.getElementById('postcode').value
            +'&town='
            +'&country='+country,'kiala_choice_point_ajax.php', 'POST');
        document.getElementById('postcode').focus();
            
    } else {
        if ((document.getElementById('town').value.length >= 2)){
            sendDataSync('kialaSelection','town='
                +document.getElementById('town').value
                +'&zip='
                +'&country='+country,'kiala_choice_point_ajax.php', 'POST');
         document.getElementById('town').focus();
            
        } else {
            document.getElementById("listeRelais").innerHTML = 
                "<span>"+changeCodeKialaGo_error+"</span>";
        }
    }
}


function popupCentree(page,largeur,hauteur,options) {
    var top=(screen.height-hauteur)/2;
    var left=(screen.width-largeur)/2;
    window.open(page,"","top="+top+",left="+left+",width="+largeur+",height="+hauteur+","+options); 
} 

// popup jeux greg
function popupGreg_DoFSCommand(Email,Name,Prenom,Sexe) {
    var hauteur =400;
    var largeur =400;
    var top=(screen.height-hauteur)/2;
    var left=(screen.width-largeur)/2;
    window.open("opeWeek.php?email="+Email+"&nom="+Name+"&prenom="+Prenom+"&civilite="+Sexe+"&","toto","scrollbars=yes,width="+largeur+",height="+hauteur+",top="+top+",left="+left+"");
    adidays_DoFSCommand('closeAdidays','yo');
 
} 

// blocage et comptage des caractères restants
function twCompteur_Texte(nTexte, nCompteur, nLimite) {
    if (nTexte.value.length > nLimite)
        nTexte.value = nTexte.value.substring(0, nLimite);
    else 
        nCompteur.value = nLimite - nTexte.value.length;
}


// retourne la valeur de l'ensemble de bouton radio
function getValRadio(radio) {
    if(radio) {
        if (radio.length==undefined) {
            return radio.value;
        }
        var test = 0;
        test = radio.length;
        if(!test){
            if(radio.checked){
                radio.value;
            } else {
                return "aucun";
            }
        } else {
            for (i=0;i<radio.length;i++)
                if (radio[i].checked) return radio[i].value;
                    return "aucun";
        }
    }
    else return 0;
}

// retourne la valeur de l'iban complet
function getValRib(type) {
    if(type == 'iban' && document.getElementById('iban1')) {
        return document.ask.iban1.value+document.ask.iban2.value+document.ask.iban3.value+document.ask.iban4.value+document.ask.iban5.value+document.ask.iban6.value+document.ask.iban7.value;
    }
    else if(type == 'iban' && document.getElementById('rib1')) {
        return document.ask.rib1.value+document.ask.rib2.value+document.ask.rib3.value+document.ask.rib4.value;
    }
    else if(type == 'swift' && document.getElementById('swift')) {
        return document.ask.swift.value;
    }
    else return "0";
}


// test le bouton radio
function getTest(radio) {
    if(radio==true){
        return "1";
    } else {
        return "0";
    }
}


// fonction ajax
function getHTTPObject() {
    var xmlhttp;

    if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
        try {
            xmlhttp = new XMLHttpRequest();
        } catch (e) {
            xmlhttp = false;
        }
    }
    return xmlhttp;
}

function sendData(div, data, page, method) {
    if (document.all && !window.opera) {
        var XhrObj = new ActiveXObject("Microsoft.XMLHTTP");
    } else {
        var XhrObj = new XMLHttpRequest();
    }

    var content = document.getElementById(div);
    
    if (method == "GET") {
        if (data == 'null') {                        
            XhrObj.open("GET", page);
        } else {
        XhrObj.open("GET", page+"?"+data);
        }
    } else if (method == "POST") {                   
        XhrObj.open("POST", page);
    }

    XhrObj.onreadystatechange = function(){
    if (XhrObj.readyState == 4 && XhrObj.status == 200)
        if (XhrObj.responseText=='NO_CUSTOMER') {
            window.parent.location='securelogin.php';
        } else {
            if (content) {
                content.innerHTML = XhrObj.responseText ;
            }
        }
    }

    if (method == "GET") {
        XhrObj.send(null);
    } else if (method == "POST") {
        XhrObj.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
        XhrObj.send(data);
    }
}
  
function sendDataWithoutReturn(n, display, page, method) {
  
    if (display) {
        n.style.display = 'block';
    } else {
        n.style.display = 'none';
    }
    var data = 'sban=' + display;
    if (document.all && !window.opera) {
        var XhrObj = new ActiveXObject("Microsoft.XMLHTTP") ;
    } else {
        var XhrObj = new XMLHttpRequest();
    }
    
    if (method == "GET") {
        if (data == 'null') {                        
            XhrObj.open("GET", page);
        } else {                        
            XhrObj.open("GET", page+"?"+data);
        }
    } else if (method == "POST") {                   
        XhrObj.open("POST", page);
    }
    
    if (method == "GET") {
        XhrObj.send(null);
    } else if (method == "POST") {
        XhrObj.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
        XhrObj.send(data);
    }
}//fin fonction Ajax
  

function sendDataToPaypal(data, page, method) {
    if (document.all && !window.opera) {
        var XhrObj = new ActiveXObject("Microsoft.XMLHTTP") ;
    } else {
        var XhrObj = new XMLHttpRequest();
    }
    
    if (method == "GET") {
        if (data == 'null') {                        
            XhrObj.open("GET", page, true);
        } else {                        
            XhrObj.open("GET", page+"?"+data, true);
        }
    } else if (method == "POST") {                   
        XhrObj.open("POST", page, true);
    }
    
    XhrObj.onreadystatechange = function()
    {
	    if (XhrObj.readyState == 4 && XhrObj.status == 200) 
	    {
	    	controleurResponsePaypal(XhrObj.responseText);
	    }
    }

    if (method == "GET") {
        XhrObj.send(null);
    } else if (method == "POST") {
        XhrObj.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
        XhrObj.send(data);
    }
    
    
}
  
function sendDataSync(div, data, page, method) {
    if (document.all && !window.opera) {
        var XhrObj = new ActiveXObject("Microsoft.XMLHTTP") ;
    } else {
        var XhrObj = new XMLHttpRequest();
    }
    
    var content = document.getElementById(div);
    
    if (method == "GET") {
        if (data == 'null') {                        
            XhrObj.open("GET", page, false);
        } else {                        
            XhrObj.open("GET", page+"?"+data, false);
        }
    } else if(method == "POST") {                   
        XhrObj.open("POST", page, false);
    }
    
    if (method == "GET") {
        XhrObj.send(null);
    } else if(method == "POST") {
        XhrObj.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
        XhrObj.send(data);
    }
    if (XhrObj.responseText=='NO_CUSTOMER') {
        window.parent.location='securelogin2.php';
    } else {
        if (content) {
            content.innerHTML = XhrObj.responseText ;
        }
    }

}

function sendDataSimple(data, page, method) {
    if (document.all && !window.opera) {
        var XhrObj = new ActiveXObject("Microsoft.XMLHTTP") ;
    } else {
        var XhrObj = new XMLHttpRequest();
    }
    
    if (method == "GET") {
        if (data == 'null') {                        
            XhrObj.open("GET", page);
        } else {                        
            XhrObj.open("GET", page+"?"+data);
        }
    } else if (method == "POST") {                   
        XhrObj.open("POST", page);
    }
    
    if (method == "GET") {
        XhrObj.send(null);
    } else if (method == "POST") {
        XhrObj.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
        XhrObj.send(data);
    }
    
}

function sendDataSimpleSync(data, page, method) {
    if (document.all && !window.opera) {
        var XhrObj = new ActiveXObject("Microsoft.XMLHTTP") ;
    } else {
        var XhrObj = new XMLHttpRequest();
    }
    
    if (method == "GET") {
        if (data == 'null') {                        
            XhrObj.open("GET", page, false);
        } else {                        
            XhrObj.open("GET", page+"?"+data, false);
        }
    } else if (method == "POST") {                   
        XhrObj.open("POST", page, false);
    }
    
    
    if (method == "GET") {
        XhrObj.send(null);
    } else if (method == "POST") {
        XhrObj.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
        XhrObj.send(data);
    }
    
}
  

// sert à savoir pour la redirection si la variable de session n'existe pas
function verifSession(){
	getXhr();
	
    post_data='';
    var res;

	xhr.open("POST",'ajax_verifSession.php',false);
	xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
    xhr.send(post_data);
    res = xhr.responseText;

    if (res=='1') return true;
    else return false;
}

  
// modif du formulaire de demande de retour  
function modif() {
    if (document.getElementById("selectreason")) {
        document.getElementById("selectreason").value = "a";
    }
    if (document.getElementById("taille")) {
        document.getElementById("taille").innerHTML= "";
    }
}
 
  
// affichage popup disponibilité d'un produit  
function mysize(val) {
    url = 'my_size.php?id='+val;
    window.open(url,"newFenetre","toolbar=no, location=no, directories=no, status=no,menubar=no, scrollbars=no, resizable=no, width=290, height=350, top=100, left=100");
}

// affichage popup disponibilité d'un produit avec sexe selectionné
function mysize2(val1, val2) {
    url = 'my_size.php?id='+val1+'&sexe='+val2;
    window.open(url,"newFenetre","toolbar=no, location=no, directories=no, status=no,menubar=no, scrollbars=no, resizable=no, width=290, height=350, top=100, left=100");
}
  
// affichage popup disponibilité d'un produit avec style et sexe selectionnés 
function mysize3(val1, val2, val3) {
    url = 'my_size.php?id='+val1+'&style='+val2+'&sexe='+val3;
    window.open(url,"newFenetre","toolbar=no, location=no, directories=no, status=no,menubar=no, scrollbars=no, resizable=no, width=290, height=350, top=100, left=100");
}

// affichage popup disponibilité d'un produit avec style selectionné
function mysize4(val1, val2) {
    url = 'my_size.php?id='+val1+'&style='+val2;
    window.open(url,"newFenetre","toolbar=no, location=no, directories=no, status=no,menubar=no, scrollbars=no, resizable=no, width=290, height=350, top=100, left=100");
}
  

// affichage popup decouverte à un ami  
function myfriend(val) {
    url = 'my_friend.php?id='+val;
    window.open(url,"newFenetre","toolbar=no, location=no, directories=no, status=no,menubar=no, scrollbars=no, resizable=no, width=550, height=500, top=100, left=100");
}
  
// affichage popup decouverte à un ami  cas market viral jerem
function myfriend_special(val) {
    url = 'my_friend_special.php?id='+val;
    window.open(url,"newFenetre","toolbar=no, location=no, directories=no, status=no,menubar=no, scrollbars=no, resizable=no, width=550, height=500, top=100, left=100");
}
// affichage popup Kiala infos 
function popupKiala() {
    url = 'kiala_info.php';
    window.open(url,"newFenetre","toolbar=no, location=no, directories=no, status=no,menubar=no, scrollbars=no, resizable=no, width=320, height=320, top=100, left=100");
}
function popupPoints() {
    url = 'points_info.php';
    window.open(url,"newFenetre","toolbar=no, location=no, directories=no, status=no,menubar=no, scrollbars=no, resizable=no, width=600, height=350, top=100, left=100");
}
// affichage popup FAQ 
function faq_popup(val) {
    url = 'faq_popup.php#'+val;
    window.open(url,"newFenetre","toolbar=no, location=no, directories=no, status=no,menubar=no, scrollbars=yes, resizable=no, width=975, height=500, top=100, left=100");
}

// affichage popup questionnaire 
function questionnaire_sport_popup(track_id) {
    url = 'questionnaire_sport.php?track_id='+track_id;
    window.open(url,"newFenetre");
}
    // affichage popup printemps 
function printemps_popup() {
    url = 'jeuPrintemps.html';
    window.open(url,"newFenetre","toolbar=no, location=no, directories=no, status=no,menubar=no, scrollbars=no, resizable=no, width=570, height=420, top=100, left=100");
}
// affichage popup Parrainage Ventes Privées 
function vpInvit_popup() {
    url = 'parrainage_ventes_privees.php';
    window.open(url,"newFenetre","toolbar=no, location=no, directories=no, status=no,menubar=no, scrollbars=yes, resizable=no, width=800, height=830, top=50, left=100");
}
// affichage popup adidays 
function adidays_popup() {
    url = 'adidays/';
    window.open(url,"newFenetre","toolbar=no, location=no, directories=no, status=no,menubar=no, scrollbars=no, resizable=no, width=600, height=600, top=50, left=100");
}

// affichage popup get your vans 
function vans_popup() {
    url = 'vans/';
    window.open(url,"newFenetre","toolbar=no, location=no, directories=no, status=no,menubar=no, scrollbars=no, resizable=no, width=600, height=600, top=50, left=100");
}
// affichage popup cofinoga 
function cofinoga_popup() {
    url = 'http://www.cofinoga.fr/ouvrir-carte-cofinoga-spartoo.do?idgroupe=R3SPA';
    window.open(url,"newFenetre","toolbar=no, location=no, directories=no, status=no,menubar=no, scrollbars=no, resizable=no, width=800, height=600, top=0, left=0");
}
// affichage popup Générique prodcard 
function generique_prodcard_popup(url) {
    window.open(url,"newFenetre","toolbar=no, location=no, directories=no, status=no,menubar=no, scrollbars=no, resizable=no, width=800, height=600, top=0, left=0");
}
// affichage popup paiement 3 fois 
function paiement3x_popup() {
    url = 'paiement3x_popup.php';
    window.open(url,"newFenetre","toolbar=no, location=no, directories=no, status=no,menubar=no, scrollbars=no, resizable=no, width=550, height=480, top=0, left=0");
}
// affichage popup paypal 
function paypal_popup() {
    window.open('https://www.paypal.com/fr/cgi-bin/webscr?cmd=xpt/Marketing/popup/OLCWhatIsPayPal-outside','olcwhatispaypal','toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, width=400, height=350');
}
// affichage popup CDGP 
function cdgp_popup() {
    url = 'cdgp_popup.php';
    window.open(url,"newFenetre","toolbar=no, location=no, directories=no, status=no,menubar=no, scrollbars=no, resizable=no, width=500, height=550, top=0, left=0");
}
function mp_info_popup(partner) {
    url = 'market_place_info.php?partner_id='+partner;
    window.open(url,"newFenetre","toolbar=no, location=no, directories=no, status=no,menubar=no, scrollbars=no, resizable=no, width=500, height=300, top=0, left=0");
}

// affichage popup opeNOEL by gregorette 
function popupNoel_DoFSCommand(infos) {
  // alert(infos);
    var hauteur =500;
    var largeur =500;
    var top=(screen.height-hauteur)/2;
    var left=(screen.width-largeur)/2;
    var url = "noelPOP/popNoel.php?ope="+infos+"";
    window.open(url,"toto","toolbar=no, location=no, directories=no, status=no,menubar=no, scrollbars=no, resizable=no,width="+largeur+",height="+hauteur+",top="+top+",left="+left+"");
 
} 

// affichage popup cofinoga 
function parrainVP_popup() {
    url = 'getParrainageVP.php';
    window.open(url,"newFenetre","toolbar=no, location=no, directories=no, status=no,menubar=no, scrollbars=no, resizable=no, width=400, height=600, top=0, left=0");
}

// affichage popup cnil 
function cnil_popup() {
    url = 'cnil_popup.php';
    window.open(url,"newFenetre","toolbar=no, location=no, directories=no, status=no,menubar=no, scrollbars=yes, resizable=no, width=800, height=600, top=0, left=0");
}

// affichage popup description
function pop_description(productID){
	url = 'popup_description.php';
	window.open(url+"?pID="+productID,"newFenetre","toolbar=no, location=no, directories=no, status=no,menubar=no, scrollbars=yes, resizable=no, width=600, height=450, top=0, left=0");
}

// vérification formulaire du smartsize  
function verif_form_smartsize(){
    var error = false;
    var message = verif_form_smartsize_header;
    if (document.smart_size.foot_width.value.length < 1) {
        error = true;
        message = message + verif_form_smartsize_largeur;
    }
    if (document.smart_size.foot_length.value.length < 1) {
        error = true;
        message = message + verif_form_smartsize_longueur;
    }
    if (error == true) {
        window.alert(message);
        return false;
    } else {
        return true;
    }	
}
  
function checkFormMySmartSize(){
    var error = false;
    var message = checkFormMySmartSize_header;
    if  (document.account_smartsize.smartsize_length.value.length < 1) {
        error = true;
        message = message + checkFormMySmartSize_largeur;
    }
    if (document.account_smartsize.smartsize_width.value.length < 1) {
        error = true;
        message = message + checkFormMySmartSize_longueur;
    }
    if (error == true) {
        window.alert(message);
        return false;
    } else {
        return true;
    }	
}


// vérification formulaire de demande de retour 
function verif_form_return() {
    var error = false;
    var message = verif_form_return_header;
    if (document.ask.order.value == 'a') {
        error = true;
        message = message + verif_form_return_commande;
    }
    if (document.ask.id_product.value == 'a') {
        error = true;
        message = message + verif_form_return_produit;
    }
    if (document.ask.reason.value == 'a') {
        error = true;
        message = message + verif_form_return_raison;
    }
    if (getValRadio(document.ask.shippingType)=='aucun') {
        error = true;
        message = message + verif_form_return_mode;
    }
    if (document.ask.reason.value == 'size') {
        if (document.ask.new_size.value == 'a') {
            error = true;
            message = message + verif_form_return_pointure;
        }
        if (document.ask.reason.value == 'size') {
            if (document.ask.confirmation_size.checked==false) {
                error = true;
                message = message + verif_form_return_confirmation;
            }
        }
    }
    // on verifie au moins 25 car. si le div est affiché
    if (document.getElementsByName('div_com')[0].style.display=='block' && document.ask.com.value.length < 5) {
        error = true;
        message = message + verif_form_return_commentaire;
    }
    // on verifie la saisie de l'iban
    if(document.ask.iban1) {
        if (document.getElementsByName('saisie_rib')[0].innerHTML.length>10 && (document.ask.iban1.value.length < 4
            || document.ask.iban2.value.length < 4 || document.ask.iban3.value.length < 4 || document.ask.iban4.value.length < 4)) {
            error = true;
            message = message + verif_form_return_iban;
        }
    }  
    //on verifie la saisie du RIB (FR)
    if(document.ask.rib1) {
        if (document.getElementsByName('saisie_rib')[0].innerHTML.length>10 && (document.ask.rib1.value.length < 5
            || document.ask.rib2.value.length < 5 || document.ask.rib3.value.length < 11 || document.ask.rib4.value.length < 2)) {
            error = true;
            message = message + verif_form_return_iban;
        }
    }       
    // on verifie la saisie du swift
    if (document.getElementsByName('saisie_rib')[0].innerHTML.length>10 && document.ask.swift.value.length < 8) {
        error = true;
        message = message + verif_form_return_swift;
    }
    if (error == true) {
        window.alert(message);
        return false;
    } else {
        return true;
    }
}


// vérification formulaire d'avis
function verif_form_reviews(){
    var error = false;
    var message = verif_form_reviews_header;
    if (document.reviews.review.value.length < 30) {
        error = true;
        message = message + verif_form_reviews_commentaire;
    }
    if (error) {
        window.alert(message);
        return false;
    } else {
        return true;
    }
}


// vérification formulaire du ticket
function verif_form_ticket() {
    var error = false;
    var message = verif_form_ticket_header;
    if (document.ticketview.com.value.length < 25) {
        error = true;
        message = message + verif_form_ticket_commentaire;
    }
    if (error == true){
        window.alert(message);
        return false;
    } else {
        return true;
    }	
}

// FRED PNG
function alphaBackgrounds(){
	var rslt = navigator.appVersion.match(/MSIE (\d+\.\d+)/, '');
	var itsAllGood = (rslt != null && Number(rslt[1]) >= 5.5 && Number(rslt[1])<7);
	for (i=0; i<document.all.length; i++){
		var bg = document.all[i].currentStyle.backgroundImage;
		if (itsAllGood && bg){
			if (bg.match(/\.png/i) != null){
				var mypng = bg.substring(5,bg.length-2);
				if (document.all) {
				    //alert(document.all[i].id);
				    document.all[i].style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+mypng+"', sizingMethod='crop');background-position: center bottom;";
				}
                document.all[i].style.backgroundImage = "none";
			}
		}
	}
}

if (navigator.platform == "Win32" && navigator.appName == "Microsoft Internet Explorer" && window.attachEvent) {

	var arVersion = navigator.appVersion.split("MSIE");
    var version = parseFloat(arVersion[1]);
    
    if (version >= 7){
    	window.attachEvent("onload", chargePage);
    }else{
        window.attachEvent("onload", alphaBackgrounds);
        window.attachEvent("onload", fnLoadPngs);
        
    }
	window.attachEvent("onscroll", scrollHeightTest);
} else {
    window.addEventListener('load',chargePage,true);
    window.addEventListener('scroll',scrollHeightTest,true);
}
function scrollHeightTest() {
    
    getScrollHeight();
}
function getScrollWidth()
{
   var w = window.pageXOffset ||
           document.body.scrollLeft ||
           document.documentElement.scrollLeft;
           
   return w ? w : 0;
}
function deplaceKialaReturn(){
    getScrollHeight4Kiala();
}
function getScrollHeight4Kiala()
{
    if (document.getElementById('windowKialaShippingReturnAddress')) {
        var h = window.pageYOffset ||
           document.body.scrollTop ||
           document.documentElement.scrollTop;
        document.getElementById('windowKialaShippingReturnAddress').style.top = h+'px';
        h2 = h+100;
        document.getElementById('windowKialaShippingReturnAddress').style.top = h2+'px';
    }
   return h ? h : 0;

}
function getScrollHeight()
{
    if (document.getElementById('adidaysLink1')) {
        var h = window.pageYOffset ||
           document.body.scrollTop ||
           document.documentElement.scrollTop;
        document.getElementById('adidaysLink1').style.top = h+'px';
        h2 = h+400;
        document.getElementById('adidaysLink2').style.top = h2+'px';
    }
   return h ? h : 0;

}

function fnLoadPngs()
{
	var rslt = navigator.appVersion.match(/MSIE (\d+\.\d+)/, '');
	var itsAllGood = (rslt != null && Number(rslt[1]) >= 5.5 && Number(rslt[1]) < 7);
	

    chargePage();
    
	for (var i = document.images.length-1, img = null; img = document.images[i]; i--) {
	    if (document.all) {
            if (itsAllGood && img.src.match(/\.png$/i) != null) {
                var imgID = (img.id) ? "id='" + img.id + "' " : "";
                var imgClass = (img.className) ? "class='" + img.className + "' " : "";
                var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' ";
                var imgStyle = "display:inline-block;" + img.style.cssText; 
                if (img.align == "left") imgStyle = "float:left;" + imgStyle;
                if (img.align == "right") imgStyle = "float:right;" + imgStyle;
                if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle;
                var strNewHTML = "<span " + imgID + imgClass + imgTitle
                + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
                + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
                + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" ;
                img.outerHTML = strNewHTML;
            }
		}
	}
	
	
}

// END FRED PNG

function BackToTheHtml(node) {
	if (node == null)
		this.node = document; 
	else
		this.node = node; 
};
BackToTheHtml.prototype.node = null;

BackToTheHtml.prototype.execute = function() {
	this.activateObject();
}

BackToTheHtml.prototype.activateObject = function(domObject) {
	var aDomObject = this.node.getElementsByTagName('object');
	var activationObject;
	for(var i=0; i<aDomObject.length; i++)
		if
		(
			aDomObject[i].getAttributeNode('BackToTheHtml') == null
			&&
			(activationObject = this.getActivationObject(aDomObject[i])) != null
		)
			activationObject.execute();
};

BackToTheHtml.prototype.getActivationObject = function(domObject) {
	var classid = domObject.classid.toUpperCase().substr('clsid:'.length);
	var mimeType = domObject.type.toLowerCase();

	switch(true) {
		case 
			classid == 'D27CDB6E-AE6D-11CF-96B8-444553540000' 
			||
			mimeType == 'application/x-shockwave-flash'
		:
			return new ActivateObjectFlash(domObject);

		default :
			return null;
	}
};

BackToTheHtml.uniqueID = function(prefix) {
	var sPrefix;
	if (prefix == null)
		sPrefix = 'uniqueId';
	else
		sPrefix = prefix;
		
	var i=0;
	while(document.getElementById(sPrefix + (i++)))
		;
	return sPrefix + (i-1);
};

BackToTheHtml.isParentOf = function(parent,child) {
	var found = false;
	for (var i=0; i<parent.childNodes.length; i++)
		if (parent.childNodes[i] == child)
			return true;
		else
			found = arguments.callee(parent.childNodes[i],child);

	return found;
}

/*****************************************************************************
* ActivateObject Command
*///**************************************************************************
/*function ActivateObject(domObject) {
	this.domObject = domObject;
}

ActivateObject.prototype.domObject = null;
ActivateObject.prototype.classid = null;
ActivateObject.prototype.aHtmlAttribute = ['accessKey','align','alt','archive','border','code','codeBase','codeType','declare','dir','height','hideFocus','hspace','lang','language','name','standby','tabIndex','title','useMap','vspace','width'];
ActivateObject.prototype.aObjectProperty = null;

ActivateObject.prototype.execute = function() {
	this.xndObjectId = BackToTheHtml.uniqueID();
	this.setTextHtml();
	this.writeObject();

	this.xndObject = document.getElementById(this.xndObjectId);
	this.setSpecialProperties();
	this.removeOriginalObject();
}

ActivateObject.prototype.setTextHtml = function() {
	var str = '';
	str += '<object BackToTheHtml ' + '\n';
	str += ' classid="clsid:' + this.classid + '" ' + '\n';

	//Add HTML attributes to the <object> tag
	for (var i=0; i<this.aHtmlAttribute.length; i++) {
		var name = this.aHtmlAttribute[i];
		if (typeof this.domObject[name] != 'undefined' && this.domObject[name].toString() != '')
			str += '\t' + name + '="' + this.domObject[name].toString() + '" ' + '\n';
	}

	str += 'id="' + this.xndObjectId + '" ' + '\n';
	str += '>';

	for (var i=0; i<this.aObjectProperty.length; i++) {
		var name = this.aObjectProperty[i];
		if (typeof this.domObject[name] != 'undefined' && this.domObject[name].toString() != '' )
			str += '\t<param name="' + name + '" value="' + this.domObject[name].toString() + '"></param>' + '\n';
	}
	str += '</object>';

	this.textHtml = str;
};

ActivateObject.prototype.writeObject = function() {
	this.domObject.insertAdjacentHTML("afterEnd",this.textHtml);
};

ActivateObject.prototype.setSpecialProperties = function() {
	if (typeof this.domObject.className != 'undefined' && this.domObject.className.toString() != '')
		this.xndObject.className = this.domObject.className;

	if (typeof this.domObject.style.cssText != 'undefined' && this.domObject.style.cssText.toString() != '')
		this.xndObject.style.cssText = this.domObject.style.cssText;

	if (typeof this.domObject.SWRemote != 'undefined' && this.domObject.SWRemote.toString() != '')
		this.xndObject.FlashVars = this.domObject.SWRemote;

	if (typeof this.domObject.codebase == 'undefined' || this.domObject.codebase.toString() == '')
		this.xndObject.codebase = 'http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,24,0';

	if (typeof this.domObject.id != 'undefined' && this.domObject.id.toString() != '')
		this.xndObject.id = this.domObject.id;

};

ActivateObject.prototype.removeOriginalObject = function() {
	this.domObject.parentNode.removeChild(this.domObject);
};*/

/*****************************************************************************
* ActivateObjectFlash Command
*///**************************************************************************
/*function ActivateObjectFlash(domObject) {
	ActivateObject.call(this,domObject);
}
ActivateObjectFlash.prototype = new ActivateObject;
ActivateObjectFlash.prototype.aObjectProperty = ['FrameNum','Playing','Quality','Quality2','Scalemode','Scale','AlignMode','SAlign','BackgroundColor','BGColor','Loop','Movie','WMode','Base','DeviceFont','EmbedMovie','SWRemote','FlashVars','AllowScriptAccess'];
ActivateObjectFlash.prototype.classid = 'D27CDB6E-AE6D-11CF-96B8-444553540000';*/


/*****************************************************************************
* Script initialisation
*///**************************************************************************
/*if (typeof ActiveXObject != 'undefined' && typeof Function.call != 'undefined') {
	var styleId = BackToTheHtml.uniqueID();
	document.write('<style id="' + styleId + '" ></style>');
	var domStyle = document.getElementById(styleId);

	var isHead = false;
	var aHead = document.getElementsByTagName('head');
	for (var i=0; i<aHead.length; i++)
		if (BackToTheHtml.isParentOf(aHead[i],domStyle))
			isHead = true;

	if (isHead) {
		document.write('<style type="text/css">OBJECT{visibility:hidden;}</style>');
		document.onreadystatechange = function()
		{
			if(document.readyState == 'complete')
			{
				new BackToTheHtml().execute();
				document.styleSheets[document.styleSheets.length-1].addRule("OBJECT","visibility:visible;");
				//alert('head');
				//alert(document.body.innerHTML);
			}
		}
	} else {
		new BackToTheHtml().execute();
		//alert('body');
		//alert(document.body.innerHTML);
	}
	
	domStyle.parentNode.removeChild(domStyle);
}*/


//Ajout Fred HomePage ALPHA
function invisible(image){
//     vitesseIE=20;
//     vitesseFF=60;
    if (image) {  
        if (document.all){
            image.filters.alpha.opacity = 80;
        } else{
        
            //i=parseFloat(image.style.getPropertyValue("-moz-opacity"));
            i=parseFloat(0.8);
            if (!is_moz) {
                
                image.style.setProperty("-moz-opacity", i, "");
                image.style.opacity = i;
            }
            if (is_khtml) {
                image.style.KhtmlOpacity = i;
            }
        }
    }
 }

function visible(image){
//     vitesseIE=20;
//     vitesseFF=60;
    if (image) {  
        if(document.all) {
            image.filters.alpha.opacity = 100;
        } else {
            //i=parseFloat(image.style.getPropertyValue("-moz-opacity"));
            i=parseFloat(1);
            if (!is_moz) {
                
                image.style.setProperty("-moz-opacity", i, "");
                image.style.opacity = i;
            
            }
            if (is_khtml) {
                image.style.KhtmlOpacity = i;
            }
        }
    }
 }
 
var clientSizeH;
var actualOffsetH = 100;

function getVar(nomVariable){
    var infos = location.href.substring(location.href.indexOf("?")+1, location.href.length)+"&";
    if (infos.indexOf("#")!=-1)
        infos = infos.substring(0,infos.indexOf("#"))+"&";
    var variable=0;
    nomVariable = nomVariable + "="
    var taille = nomVariable.length;
    if (infos.indexOf(nomVariable)!=-1)
        variable = infos.substring(infos.indexOf(nomVariable)+taille,infos.length).substring(0,infos.substring(infos.indexOf(nomVariable)+taille,infos.length).indexOf("&"));
    return variable;
}

function centrage(){
	if(document.body.clientWidth){
        var largeur = document.body.clientWidth;
        var position = ((largeur-670)/2);
        if (document.getElementById("formFlouVP")) {
    	   document.getElementById("formFlouVP").style.left = position+"px";
        }
    }
}

function departForm(){

    document.getElementById("formVP").style.visibility="hidden";
    document.getElementById("formVP").style.display="none";
    document.getElementById("fond").echo_1();
}
    
function url(){
    window.location.reload();
}
  
function chargePage(){
    resolTest();
    if (document.getElementById("MaskFlou")) {
        clientSizeH = document.body.clientHeight;
        
        if (is_opera) {
            clientSizeH = document.body.scrollHeight;        
        }
       
        document.getElementById('MaskFlou').style.height = clientSizeH+'px';
       
    }
    var test = getVar("product");
    if (test > 0 && document.getElementById('prodcard2')) {
        prechargement();
    }
    
    if(!document.cookie){
        if(document.getElementById("nocookie")) {
            if(document.getElementById("nocookie").style) {
                document.getElementById("nocookie").style.display='block';
            }
        }
    }
    
       
    if (navigator.platform == "Win32" && navigator.appName == "Microsoft Internet Explorer") {
	
        var arVersion = navigator.appVersion.split("MSIE");
        var version = parseFloat(arVersion[1]);
    
        if (version >= 7) {
    	
        } else {
            if (document.getElementById("MaskFlou")) {
                if (document.getElementById("MaskFlou").style) {          
                    document.getElementById("MaskFlou").style.filter = "";
                    document.getElementById("MaskFlou").style.backgroundImage = 'url(images/trameFlou.gif)';
                }
            }
            for(i=1;i<11;i++) {
                if (document.getElementById("stylesList"+i)) {
                    if (document.getElementById("stylesList"+i).style) {
                        document.getElementById("stylesList"+i).style.filter = "";
                        if(i>=9){
                            document.getElementById("stylesList"+i).style.backgroundImage = 'url(includes/languages/'+JS_LANGUAGE+'/images/home_univ_menuStyles.gif)';
                        }else {
                            document.getElementById("stylesList"+i).style.backgroundImage = 'url(includes/languages/'+JS_LANGUAGE+'/images/home_univ_menuStyles_'+i+'.gif)';
                        }
                    }
                }
            }
        }
    }
    
    if(document.getElementById("infoDescription")){
        showOnglet("infoDescription","onglet1","arrow1");    
    }
    
    var tag_loading_timer = window.setTimeout("load_tag()",1);
    
}

function load_tag() {
    
    if (is_fx || is_chrome) {
        if (document.getElementById("tag_src") && document.getElementById("tag_object")) {
            document.getElementById("tag_object").data = document.getElementById("tag_src").value;
            //alert(document.getElementById("tag_object").data);
        }
    } else {
        if (document.getElementById("tag_src") && document.getElementById("tag_iframe")) {
            document.getElementById("tag_iframe").src = document.getElementById("tag_src").value;
        }
    }
        
    //alert('debug '+document.getElementById("tag_iframe").src);
    
}


function fadeOutPage() {
    if (actualOffsetH<clientSizeH) {
        actualOffsetH +=100;
       
        
        document.getElementById("MaskFlou").style.height="" + actualOffsetH + "px";
        document.getElementById("fond").height="" + actualOffsetH + "px";
       
        timeoutID = window.setTimeout("window.fadeOutPage()",1);
        
    } else {
        clearTimeout(timeoutID);
    }
}

var emailTyped=0;
var genderTyped=0;
var lastnameTyped=0;
var firstnameTyped=0;
var password1Typed=0;
var password2Typed=0;
var dobTyped=0;
var phoneTyped=0;
var adressTyped=0;
var postcodeTyped=0;
var cityTyped=0;
var countryTyped=0;
var password1TypedOld=0;

var emailEverSent = 0;

// functions for account creation
function checkSecureLogin() {
    testEmailSecureLogin = false;
    testGenderSecureLogin = false;
    testLastnameSecureLogin = false;
    testFirstnameSecureLogin = false;
    testPassword1SecureLogin = false;
    testPassword2SecureLogin = false;
    testDobSecureLogin = true;
    testPhoneSecureLogin = false;
    testAdressSecureLogin = false;
    testPostcodeSecureLogin = false;
    testCitySecureLogin = false;
    testCountrySecureLogin = false;
    
    testEmailSecureLogin = isEmailAdress(document.getElementById("emailSecureLogin").value,
                                        document.getElementById("emailStateImage"));
    
    testGenderSecureLogin = isGender(document.getElementById("genderHSecureLogin"),
                                    document.getElementById("genderFSecureLogin"),
                                    document.getElementById("genderStateImage"));
    
    testLastnameSecureLogin = isLastname(document.getElementById("lastnameSecureLogin").value,
                                         document.getElementById("lastnameStateImage"));
    testFirstnameSecureLogin = isFirstname(document.getElementById("firstnameSecureLogin").value,
                                            document.getElementById("firstnameStateImage"));
    
    testPassword1SecureLogin = isPassword1(document.getElementById("password1SecureLogin").value,
                                            document.getElementById("password1StateImage"));
    testPassword2SecureLogin = isPassword2(document.getElementById("password1SecureLogin").value,
                                            document.getElementById("password2SecureLogin").value,
                                            document.getElementById("password2StateImage"));
                                            
    if (testEmailSecureLogin && testPassword1SecureLogin && testPassword2SecureLogin) {
        document.getElementById("creaCompteSuite").style.display = "block";
        document.getElementById("createAccountBegining").style.display = "none";
        //document.getElementById("login").style.display = "none";
        if (!emailEverSent) {
            emailEverSent = 1;
            sendDataSimple('email='+document.getElementById("emailSecureLogin").value,'save_mail_ajax.php','POST');
        }
    }
    
    /*testDobSecureLogin = isDob(document.getElementById("dobSecureLogin").value,
                                document.getElementById("dobStateImage"));*/
    
    testPhoneSecureLogin = isPhone(document.getElementById("phoneSecureLogin").value,
                                    document.getElementById("phoneStateImage"));
    testAdressSecureLogin = isAdress(document.getElementById("adressSecureLogin").value,
                                    document.getElementById("adressStateImage"));
    
    testPostcodeSecureLogin = isPostcode(document.getElementById("postcodeSecureLogin").value,
                                        document.getElementById("postcodeStateImage"));
    testCitySecureLogin = isCity(document.getElementById("citySecureLogin").value,
                                document.getElementById("cityStateImage"));
    testCountrySecureLogin = isCountry(document.getElementById("countrySecureLogin"),
                                        document.getElementById("countryStateImage"),
                                        document.getElementById("postcodeSecureLogin").value, false);
    
    ret =  (   testEmailSecureLogin 
            && testGenderSecureLogin 
            && testLastnameSecureLogin 
            && testFirstnameSecureLogin
            && testPassword1SecureLogin 
            && testPassword2SecureLogin
            && testDobSecureLogin
            && testPhoneSecureLogin
            && testAdressSecureLogin
            && testPostcodeSecureLogin
            && testCitySecureLogin
            && testCountrySecureLogin);
    strsrc_button_continue2 = document.getElementById("button_continue2").src;
    if (ret) {
         pos = strsrc_button_continue2.lastIndexOf("_disabled.gif");
         if (pos!=-1) {
            document.getElementById("button_continue2").src = strsrc_button_continue2.substring(0,pos)+".gif";
         }
    } else {
        pos = strsrc_button_continue2.lastIndexOf("_disabled.gif");
         if (pos==-1) {
            pos = strsrc_button_continue2.lastIndexOf(".gif");
            if (pos!=-1) {
                document.getElementById("button_continue2").src = strsrc_button_continue2.substring(0,pos)+"_disabled.gif";
            }
         }
    }
    return ret;
}
// functions for account creation
function checkSecureLogin2() {
    testEmailSecureLogin = false;
    testGenderSecureLogin = false;
    testLastnameSecureLogin = false;
    testFirstnameSecureLogin = false;
    testPassword1SecureLogin = false;
    testPassword2SecureLogin = false;
    testDobSecureLogin = true;
    testPhoneSecureLogin = false;
    testAdressSecureLogin = false;
    testPostcodeSecureLogin = false;
    testCitySecureLogin = false;
    testProvinceSecureLogin = false;
    testCountrySecureLogin = false;
    
    testEmailSecureLogin = isEmailAdress(document.getElementById("emailSecureLogin").value,
                                        document.getElementById("emailStateImage"));
    
    testGenderSecureLogin = isGender(document.getElementById("genderHSecureLogin"),
                                    document.getElementById("genderFSecureLogin"),
                                    document.getElementById("genderStateImage"));
    
    testLastnameSecureLogin = isLastname(document.getElementById("lastnameSecureLogin").value,
                                         document.getElementById("lastnameStateImage"));
    testFirstnameSecureLogin = isFirstname(document.getElementById("firstnameSecureLogin").value,
                                            document.getElementById("firstnameStateImage"));
    
    testPassword1SecureLogin = isPassword1(document.getElementById("password1SecureLogin").value,
                                            document.getElementById("password1StateImage"));
    testPassword2SecureLogin = isPassword2(document.getElementById("password1SecureLogin").value,
                                            document.getElementById("password2SecureLogin").value,
                                            document.getElementById("password2StateImage"));
                                            
    if (testEmailSecureLogin) {
        document.getElementById("creaCompteSuite").style.display = "block";
        
        document.getElementById("createAccountBegining").style.display = "none";
        
        if (!emailEverSent) {
            emailEverSent = 1;
            sendDataSimple('email='+document.getElementById("emailSecureLogin").value,'save_mail_ajax.php','POST');
        }
    }
    /*
    testDobSecureLogin = isDob(document.getElementById("dobSecureLogin").value,
                                document.getElementById("dobStateImage"));
    */
    
    testPhoneSecureLogin = isPhone(document.getElementById("phoneSecureLogin").value,
                                    document.getElementById("phoneStateImage"));
    testAdressSecureLogin = isAdress(document.getElementById("adressSecureLogin").value,
                                    document.getElementById("adressStateImage"));
    
    testPostcodeSecureLogin = isPostcode(document.getElementById("postcodeSecureLogin").value,
                                        document.getElementById("postcodeStateImage"));
    testCitySecureLogin = isCity(document.getElementById("citySecureLogin").value,
                                document.getElementById("cityStateImage"));
    testProvinceSecureLogin = true;
    document.getElementById("provinceStateImage").src = "images/greenTrue.gif";
    testCountrySecureLogin = isCountry(document.getElementById("countrySecureLogin"),
                                        document.getElementById("countryStateImage"),
                                        document.getElementById("postcodeSecureLogin").value, false);
    
    ret =  (   testEmailSecureLogin 
            && testGenderSecureLogin 
            && testLastnameSecureLogin 
            && testFirstnameSecureLogin
            && testPassword1SecureLogin 
            && testPassword2SecureLogin
            /*&& testDobSecureLogin*/
            && testPhoneSecureLogin
            && testAdressSecureLogin
            && testPostcodeSecureLogin
            && testCitySecureLogin
            && testCountrySecureLogin);
            
    return ret;
}
function checkSecureLoginAlert() {
    
    testEmailSecureLogin = false;
    testGenderSecureLogin = false;
    testLastnameSecureLogin = false;
    testFirstnameSecureLogin = false;
    testPassword1SecureLogin = false;
    testPassword2SecureLogin = false;
    testDobSecureLogin = true;
    testPhoneSecureLogin = false;
    testAdressSecureLogin = false;
    testPostcodeSecureLogin = false;
    testCitySecureLogin = false;
    testProvinceSecureLogin = false;
    testCountrySecureLogin = false;
    
    testEmailSecureLogin = isEmailAdress(document.getElementById("emailSecureLogin").value,
                                        document.getElementById("emailStateImage"));
    
    testGenderSecureLogin = isGender(document.getElementById("genderHSecureLogin"),
                                    document.getElementById("genderFSecureLogin"),
                                    document.getElementById("genderStateImage"));
    
    testLastnameSecureLogin = isLastname(document.getElementById("lastnameSecureLogin").value,
                                         document.getElementById("lastnameStateImage"));
    testFirstnameSecureLogin = isFirstname(document.getElementById("firstnameSecureLogin").value,
                                            document.getElementById("firstnameStateImage"));
    
    testPassword1SecureLogin = isPassword1(document.getElementById("password1SecureLogin").value,
                                            document.getElementById("password1StateImage"));
    testPassword2SecureLogin = isPassword2(document.getElementById("password1SecureLogin").value,
                                            document.getElementById("password2SecureLogin").value,
                                            document.getElementById("password2StateImage"));
                                            
    if (testEmailSecureLogin) {
        document.getElementById("creaCompteSuite").style.display = "block";
        
        document.getElementById("createAccountBegining").style.display = "none";
        
        if (!emailEverSent) {
            emailEverSent = 1;
            sendDataSimple('email='+document.getElementById("emailSecureLogin").value,'save_mail_ajax.php','POST');
        }
    }
    /*
    testDobSecureLogin = isDob(document.getElementById("dobSecureLogin").value,
                                document.getElementById("dobStateImage"));
    */
    
    testPhoneSecureLogin = isPhone(document.getElementById("phoneSecureLogin").value,
                                    document.getElementById("phoneStateImage"));
    testAdressSecureLogin = isAdress(document.getElementById("adressSecureLogin").value,
                                    document.getElementById("adressStateImage"));
    
    testPostcodeSecureLogin = isPostcode(document.getElementById("postcodeSecureLogin").value,
                                        document.getElementById("postcodeStateImage"));
    testCitySecureLogin = isCity(document.getElementById("citySecureLogin").value,
                                document.getElementById("cityStateImage"));
    testProvinceSecureLogin = true;
    document.getElementById("provinceStateImage").src = "images/greenTrue.gif";
    testCountrySecureLogin = isCountry(document.getElementById("countrySecureLogin"),
                                        document.getElementById("countryStateImage"),
                                        document.getElementById("postcodeSecureLogin").value, true);
    
    var error = false;
    var message = verif_formFlou_header;
    if(!testLastnameSecureLogin) {
        error = true;
        message = message + verif_formFlou_nom;
    }
    if(!testFirstnameSecureLogin) {
        error = true;
        message = message + verif_formFlou_prenom;
    }
    if(!testEmailSecureLogin) {
        error = true;
        message = message + verif_formFlou_email;
    }
    if(!testGenderSecureLogin) {
        error = true;
        message = message + verif_formFlou_genre;
    }
    if(!testPassword1SecureLogin ) {
        error = true;
        message = message + verif_formFlou_password;
    }
    if(!testPassword2SecureLogin) {
        error = true;
        message = message + verif_formFlou_pwd_confirmation;
    }
    if(!testAdressSecureLogin) {
        error = true;
        message = message + verif_formFlou_adresse;
    }
    if(!testPostcodeSecureLogin) {
        error = true;
        message = message + verif_formFlou_cp;
    }
    if(!testCitySecureLogin) {
        error = true;
        message = message + verif_formFlou_ville;
    }
    if(!testCountrySecureLogin) {
        error = true;
        message = message + verif_formFlou_pays;
    }
    if(!testPhoneSecureLogin) {
        error = true;
        message = message + verif_formFlou_telephone;
    }
    if (error) {
        
        window.alert(message);
        
        return false;
    } else {
        return true;
    }	
}
function checkSecureAddress() {
    testGenderSecureLogin = false;
    testLastnameSecureLogin = false;
    testFirstnameSecureLogin = false;
    testAdressSecureLogin = false;
    testPostcodeSecureLogin = false;
    testCitySecureLogin = false;
    testCountrySecureLogin = false;
    
    testGenderSecureLogin = isGenderAddress(document.getElementById("genderHSecureLogin"),
                                    document.getElementById("genderFSecureLogin"),
                                    document.getElementById("genderStateImage"));
    
    testLastnameSecureLogin = isLastnameAddress(document.getElementById("lastnameSecureLogin").value,
                                         document.getElementById("lastnameStateImage"));
    testFirstnameSecureLogin = isFirstnameAddress(document.getElementById("firstnameSecureLogin").value,
                                            document.getElementById("firstnameStateImage"));
        
    testAdressSecureLogin = isAdressAddress(document.getElementById("adressSecureLogin").value,
                                    document.getElementById("adressStateImage"));
    
    testPostcodeSecureLogin = isPostcodeAddress(document.getElementById("postcodeSecureLogin").value,
                                        document.getElementById("postcodeStateImage"));
    testCitySecureLogin = isCityAddress(document.getElementById("citySecureLogin").value,
                                document.getElementById("cityStateImage"));
    testCountrySecureLogin = isCountryAddress(document.getElementById("countrySecureLogin"),
                                        document.getElementById("countryStateImage"),
                                        document.getElementById("postcodeSecureLogin").value, false);
    
    ret =  (   testGenderSecureLogin 
            && testLastnameSecureLogin 
            && testFirstnameSecureLogin
            && testAdressSecureLogin
            && testPostcodeSecureLogin
            && testCitySecureLogin
            && testCountrySecureLogin);
    strsrc_button_valid_securezone = document.getElementById("valid_securezone").src;
    if (ret) {
         pos = strsrc_button_valid_securezone.lastIndexOf("_disabled.png");
         if (pos!=-1) {
            document.getElementById("valid_securezone").src = strsrc_button_valid_securezone.substring(0,pos)+".png";
         }
    } else {
        pos = strsrc_button_valid_securezone.lastIndexOf("_disabled.png");
         if (pos==-1) {
            pos = strsrc_button_valid_securezone.lastIndexOf(".png");
            if (pos!=-1) {
                document.getElementById("valid_securezone").src = strsrc_button_valid_securezone.substring(0,pos)+"_disabled.png";
            }
         }
    }
    return ret;
}



function isEmailAdress(email, image) {
   var re = /^([a-zA-Z0-9_\.\-\+])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
   ret = re.test(email);
   
    if (ret) {
        image.src = "images/greenTrue.gif";
    } else {
        if (emailTyped) {
            image.src = "images/redCross.gif";
        } else {
            image.src = "images/bluePoint.gif";
        }
    }
   
   return ret;
}


function isDob(dob, image) {
   var re = /^\d{2}\/\d{2}\/\d{4}$/;
   ret = re.test(dob);
   
    if (ret) {
        image.src = "images/greenTrue.gif";
    } else {
        if (dobTyped) {
            image.src = "images/redCross.gif";
        } else {
            image.src = "images/bluePoint.gif";
        }
    }
   
   return ret;
}

function isGender(c1,c2, image) {
    ret = (c1.checked || c2.checked);
      
    if (ret) {
        image.src = "images/greenTrue.gif";
    } else {
        if (genderTyped) {
            image.src = "images/redCross.gif";
        } else {
            image.src = "images/bluePoint.gif";
        }
    }
   
    return ret;
}

function isGenderAddress(c1,c2, image) {
    ret = (c1.checked || c2.checked);
      
    if (ret) {
        image.src = "images/greenTrue.gif";
    } else {
        if (genderTyped) {
            image.src = "images/redCross.gif";
        } else {
            image.src = "images/bluePoint.gif";
        }
    }
   
    return ret;
}

function isLastname(lastname, image) {
    ret = (lastname.length >= 2);
   
    if (ret) {
        image.src = "images/greenTrue.gif";
    } else {
        if (lastnameTyped) {
            image.src = "images/redCross.gif";
         } else {
            image.src = "images/bluePoint.gif";
        }
    }
  
    return ret;
}

function isLastnameAddress(lastname, image) {
    ret = (lastname.length >= 2);
   
    if (ret) {
        image.src = "images/greenTrue.gif";
    } else {
        if (lastnameTyped) {
            image.src = "images/redCross.gif";
         } else {
            image.src = "images/bluePoint.gif";
        }
    }
  
    return ret;
}


function isFirstname(firstname, image) {
    ret = (firstname.length >= 2);
   
    if (ret) {
        image.src = "images/greenTrue.gif";
    } else {
        if (firstnameTyped) {
            image.src = "images/redCross.gif";
        } else {
            image.src = "images/bluePoint.gif";
        }
    }
   
    return ret;
}

function isFirstnameAddress(firstname, image) {
    ret = (firstname.length >= 2);
   
    if (ret) {
        image.src = "images/greenTrue.gif";
    } else {
        if (firstnameTyped) {
            image.src = "images/redCross.gif";
        } else {
            image.src = "images/bluePoint.gif";
        }
    }
   
    return ret;
}

function isPhone(phone, image) {
    ret = (phone.length >= 3);
   
    if (ret) {
        image.src = "images/greenTrue.gif";
    } else {
        if (phoneTyped) {
            image.src = "images/redCross.gif";
        } else {
            image.src = "images/bluePoint.gif";
        }
    }
   
    return ret;
}

function isAdress(adress, image) {
    ret = (adress.length >= 5);
   
    if (ret) {
        image.src = "images/greenTrue.gif";
    } else {
        if (adressTyped) {
            image.src = "images/redCross.gif";
         } else {
            image.src = "images/bluePoint.gif";
        }
    }
  
    return ret;
}

function isAdressAddress(adress, image) {
    ret = (adress.length >= 5);
   
    if (ret) {
        image.src = "images/greenTrue.gif";
    } else {
        if (adressTyped) {
            image.src = "images/redCross.gif";
         } else {
            image.src = "images/bluePoint.gif";
        }
    }
  
    return ret;
}

function isPostcode(postcode, image) {
    ret = (postcode.length >= 3 && postcode.length <= 8);
   
    if (ret) {
        image.src = "images/greenTrue.gif";
    } else {
        if (postcodeTyped) {
            image.src = "images/redCross.gif";
        } else {
            image.src = "images/bluePoint.gif";
        }
    }
   
    return ret;
}

function isPostcodeAddress(postcode, image) {
   ret = (postcode.length >= 3 && postcode.length <= 8);
   
    if (ret) {
        image.src = "images/greenTrue.gif";
    } else {
        if (postcodeTyped) {
            image.src = "images/redCross.gif";
        } else {
            image.src = "images/bluePoint.gif";
        }
    }
   
    return ret;
}

function isCity(city, image) {
    ret = (city.length >= 2);
    
    if (ret) {
        image.src = "images/greenTrue.gif";
    } else {
        if (cityTyped) {
            image.src = "images/redCross.gif";
        } else {
            image.src = "images/bluePoint.gif";
        }
    }
   
    return ret;
}

function isCity(city, image) {
    ret = (city.length >= 3);
    
    if (ret) {
        image.src = "images/greenTrue.gif";
    } else {
        if (cityTyped) {
            image.src = "images/redCross.gif";
        } else {
            image.src = "images/bluePoint.gif";
        }
    }
   
    return ret;
}

function isCityAddress(city, image) {
    ret = (city.length >= 3);
    
    if (ret) {
        image.src = "images/greenTrue.gif";
    } else {
        if (cityTyped) {
            image.src = "images/redCross.gif";
        } else {
            image.src = "images/bluePoint.gif";
        }
    }
   
    return ret;
}

function isCountry(country, image, postcode, displayAlert) {
    ret = (country.selectedIndex > 0);
    
    if (ret) {
        switch (country.value) {
            case "73":
                if (postcode.length!=5 || (postcode.substr(0, 2)>"96" && postcode !="98000") ) {
                    image.src = "images/redCross.gif";
                    if (displayAlert) {
                        alert(isCountry_cp);
                    }
                    return false;
                }
                break;
            case "21":
                if (postcode.length!=4) {
                    image.src = "images/redCross.gif";
                    if (displayAlert) {
                        alert(isCountry_cp);
                    }
                    return false;
                }
                break;
            case "75":
            case "134":
            case "87":
            case "137":
            case "174":
            case "198":
                if (postcode.substr(0, 2)!="97" || (postcode.length!=5 && postcode.length!=3) ) {
                    image.src = "images/redCross.gif";
                    if (displayAlert) {
                        alert(isCountry_cp);
                    }
                    return false;
                }
                break;
            case "76":
            case "77":
            case "233":
                
                if (postcode.substr(0, 2)!="98" || (postcode.length!=5 && postcode.length!=3) ) {
                    image.src = "images/redCross.gif";
                    if (displayAlert) {
                        alert(isCountry_cp);
                    }
                    return false;
                }
                break;
            case "124":
                if (postcode.length<4) {
                    image.src = "images/redCross.gif";
                    if (displayAlert) {
                        alert(isCountry_cp);
                    }
                    return false;
                }
                break;
            case "222":
                if (postcode.length<=5 || postcode.length>8) {
                    image.src = "images/redCross.gif";
                    if (displayAlert) {
                        alert(isCountry_cp);
                    }
                    return false;
                }
                break;
            default:
                break;
        }
        image.src = "images/greenTrue.gif";
    } else {
        if (countryTyped) {
            image.src = "images/redCross.gif";
         } else {
            if(country.options.length == 1 ){
                image.src = "images/greenTrue.gif";
                ret = 1
            } else {
                image.src = "images/bluePoint.gif";
            }
        }
    }
  
    return ret;
}

function isCountryAddress(country, image, postcode) {
    ret = (country.selectedIndex > 0);
    if (ret) {        
        switch (country.value) {
            case "73":
                if (postcode.length!=5 || ( postcode.substr(0, 2)>"96" && postcode!="98000") ) {
                    image.src = "images/redCross.gif";
                    if (displayAlert) {
                        alert(isCountryAddress_cp);
                    }
                    return false;
                }
                break;
            case "21":
                if (postcode.length!=4) {
                    image.src = "images/redCross.gif";
                    if (displayAlert) {
                        alert(isCountryAddress_cp);
                    }
                    return false;
                }
                break;
            case "75":
            case "134":
            case "87":
            case "137":
            case "174":
            case "198":
                if (postcode.substr(0, 2)!="97" || (postcode.length!=5 && postcode.length!=3) ) {
                    image.src = "images/redCross.gif";
                    if (displayAlert) {
                        alert(isCountryAddress_cp);
                    }
                    return false;
                }
                break;
            case "76":
            case "77":
            case "233":
                
                if (postcode.substr(0, 2)!="98" || (postcode.length!=5 && postcode.length!=3) ) {
                    image.src = "images/redCross.gif";
                    if (displayAlert) {
                        alert(isCountryAddress_cp);
                    }
                    return false;
                }
                break;
            case "124":
                if (postcode.length<4) {
                    image.src = "images/redCross.gif";
                    if (displayAlert) {
                        alert(isCountryAddress_cp);
                    }
                    return false;
                }
                break;
            case "222":
                if (postcode.length<5 || postcode.length>8) {
                    image.src = "images/redCross.gif";
                    if (displayAlert) {
                        alert(isCountry_cp);
                    }
                    return false;
                }
                break;
            default:
                break;
        }
        image.src = "images/greenTrue.gif";
    } else {
        if (countryTyped) {
            image.src = "images/redCross.gif";
         } else {
            if(country.options.length == 1 ){
                image.src = "images/greenTrue.gif";
                ret = 1
            } else {
                image.src = "images/bluePoint.gif";
            }
        }
    }
  
    return ret;
}

function isPassword1(password, image) {
    ret = (password.length >= 5);
   
    if (ret) {
        image.src = "images/greenTrue.gif";
        document.getElementById("password_warning").style.display = "none";
    } else {
        if (password1Typed) {
            image.src = "images/redCross.gif";
            document.getElementById("password_warning").style.display = "block";
        } else {
            image.src = "images/bluePoint.gif";
        }
    }
   
    return ret;
}

function isPassword2(password1, password2, image) {
    ret = ((password1 == password2) && (password1.length >= 5));
      
    if (ret) {
        image.src = "images/greenTrue.gif";
    } else {
        if (password2Typed) {
            image.src = "images/redCross.gif";
        } else {
            image.src = "images/bluePoint.gif";
        }
    }
   
    return ret;
}

var time4Check ;
var time2DisplayCoupon ;


function loginOldCompte(){
    testEmailSecureLogin2 = false;
    document.getElementById('creaCompte2').style.display = 'none';
    validTypeDelayed2();
    document.getElementById("password1StateImageOld").src = "images/bluePoint.gif";
    testEmailSecureLogin2 = isEmailAdress(document.getElementById("emailSecureLogin").value,
                                          document.getElementById("emailStateImage"));
}


function loginNewCompte(){
    testEmailSecureLogin2 = false;
    document.getElementById('creaCompte2').style.display = 'block';
    validTypeDelayed2();
    document.getElementById("password1StateImageOld").src = "images/trans.gif";
    testEmailSecureLogin2 = isEmailAdress(document.getElementById("emailSecureLogin").value,
                                          document.getElementById("emailStateImage"));
}

function isPassword1Old(password, image) {
    ret = (password.length >= 5);

    if (ret) {
        image.src = "images/greenTrue.gif";
        document.getElementById("password_warning").style.display = "none";
    } else {
        if (password1TypedOld) {
            image.src = "images/redCross.gif";
            document.getElementById("password_warning").style.display = "block";
        } else {
            image.src = "images/bluePoint.gif";
        }
    }

    return ret;
}

function validTypeDelayed2() {
    clearTimeout(time4Check);
    time4Check = window.setTimeout("checkSecureLogin2()",1000);
}

function validTypeDelayed3() {
    clearTimeout(time4Check);
    time4Check = window.setTimeout("checkSecureLogin2()",2000);
}


function validTypeDelayed() {
    clearTimeout(time4Check);
    time4Check = window.setTimeout("checkSecureLogin()",1000);
}

function validTypeDelayedAddress() {
    clearTimeout(time4Check);
    time4Check = window.setTimeout("checkSecureAddress()",1000);
}

// ced changes for smoother loading - 080109
var paymentTypeJS = 0;

var secureZoneTimer;
function secureZoneLoadAllAjaxModules() {
    document.getElementById("windowPayment").style.display="none";
    document.getElementById("windowShipping").style.display="none";
    document.getElementById("windowShippingAddress").style.display="none";
    sendDataSync("coupon",null,"securecouponajax.php","POST");
    secureZoneTimer = window.setTimeout("secureZoneLoadAllAjaxModulePaymentMode()",1);
}
function secureZoneLoadAllAjaxModulePaymentMode() {
    var pay_collection = document.getElementsByName('payment_id[]');
    clearTimeout(secureZoneTimer);
    sendDataSync("paymentMode",null,"securepaymentajax.php","POST");
    for (i=0;i<pay_collection.length;i++) {
        if (pay_collection[i].checked) {
            paymentTypeJS = i;
            break;
        }
    }
    secureZoneTimer = window.setTimeout("secureZoneLoadAllAjaxModuleShippingMode()",1);
}
function secureZoneLoadAllAjaxModuleShippingMode() {
    clearTimeout(secureZoneTimer);
    sendDataSync("shippingMode",null,"secureshippingtypeajax.php","POST");
    secureZoneTimer = window.setTimeout("secureZoneLoadAllAjaxModuleShippingAddress()",1);
}
function secureZoneLoadAllAjaxModuleShippingAddress() {
    clearTimeout(secureZoneTimer);
    sendDataSync("shippingAddress",null,"secureshippingaddressajax.php","POST");
    if(document.getElementById('no_address_available') != null)
        secureZoneLoadShippingAddressAjaxWindow();
    secureZoneTimer = window.setTimeout("secureZoneLoadAllAjaxModuleConfirmation()",1);
}
function secureZoneLoadAllAjaxModuleConfirmation() {
    clearTimeout(secureZoneTimer);
    sendDataSync("confirmation",null,"securecartajax.php","POST");   
}
function check_auth_code(code) {
    clearTimeout(secureZoneTimer);
    sendDataSync("confirmation",'payment_shipping_auth_code_post='+code,"securecartajax.php","POST");
}

function check_auth_code_2(code) {
    clearTimeout(secureZoneTimer);
    sendDataSync("confirmation",'payment_3fois_auth_code_post='+code,"securecartajax.php","POST");
}

function check_auth_phone(phone) {
    clearTimeout(secureZoneTimer);
    
    phone = phone.replace('+','00');
    //alert(escape(phone) + ' '+phone.replace('+','00'));
    sendDataSync("confirmation",'payment_shipping_auth_phone_post='+escape(phone),"securecartajax.php","POST");
}

function check_auth_phone_2(phone) {
    clearTimeout(secureZoneTimer);
    
    phone = phone.replace('+','00');
   
    sendDataSync("confirmation",'payment_3fois_auth_phone_post='+escape(phone),"securecartajax.php","POST");
}

function secureZoneLoadCouponAjaxModuleWithDelay() {
    clearTimeout(time2DisplayCoupon);
    if (document.getElementById("gv_code")) {
        time2DisplayCoupon = window.setTimeout("secureZoneLoadCouponAjaxModule()",5000);
    }
}

function secureZoneLoadCouponAjaxModule() {
    clearTimeout(time2DisplayCoupon);
    if (    (document.getElementById("windowPayment").style.display=="block")
        ||  (document.getElementById("windowShipping").style.display=="block")
        ||  (document.getElementById("windowBank").style.display=="block")
        ||  (document.getElementById("windowShippingAddress").style.display=="block")) {
        return false;
    }
    sendDataSync("coupon","gv_redeem_code="+document.getElementById("gv_code").value,"securecouponajax.php","POST");
    secureZoneTimer = window.setTimeout("secureZoneLoadCouponAjaxModuleConfirmation()",1);
    
}
function secureZoneLoadCouponAjaxModuleConfirmation() {
    clearTimeout(secureZoneTimer);
    sendDataSync("confirmation",null,"securecartajax.php","POST");
}


function secureZoneLoadChequeAjaxModule() {
    if (document.getElementById("chequecadeau").value == "a") {
        alert(TEXT_DID_NOT_SELECT_VOUNCHER);
    } else {
      if (    (document.getElementById("windowPayment").style.display=="block")
          ||  (document.getElementById("windowShipping").style.display=="block")
          ||  (document.getElementById("windowBank").style.display=="block")
          ||  (document.getElementById("windowShippingAddress").style.display=="block")) {
          return false;
      }
      sendDataSync("coupon","chequecadeau_code="+document.getElementById("chequecadeau").value,"securecouponajax.php","POST");
      secureZoneTimer = window.setTimeout("secureZoneLoadCouponAjaxModuleConfirmation()",1); // réutilise celui plus haut
    }
}



function secureZoneLoadPaymentAjaxWindow() {
    if (    (document.getElementById("windowPayment").style.display=="block")
        ||  (document.getElementById("windowShipping").style.display=="block")
        ||  (document.getElementById("windowBank").style.display=="block")
        ||  (document.getElementById("windowShippingAddress").style.display=="block")) {
        return false;
    }
   
    sendDataSync("windowPayment",null,"securepaymentwindowajax.php","POST");
    document.getElementById("windowPayment").style.display="block";    
}


function secureZoneLoadShippingTypeAjaxWindow() {
    if (    (document.getElementById("windowPayment").style.display=="block")
        ||  (document.getElementById("windowShipping").style.display=="block")
        ||  (document.getElementById("windowBank").style.display=="block")
        ||  (document.getElementById("windowShippingAddress").style.display=="block")) {
        return false;
    }
    sendDataSync("windowShipping",null,"secureshippingtypewindowajax.php","POST");
    document.getElementById("windowShipping").style.display="block";
}

function secureZoneLoadShippingAddressAjaxWindow() {
    if (    (document.getElementById("windowPayment").style.display=="block")
        ||  (document.getElementById("windowShipping").style.display=="block")
        ||  (document.getElementById("windowBank").style.display=="block")
        ||  (document.getElementById("windowShippingAddress").style.display=="block")) {
        return false;
    }
    sendDataSync("windowShippingAddress",null,"secureshippingaddresswindowajax.php","POST");
    document.getElementById("windowShippingAddress").style.display="block";
    //secureShippingAddressIE();
}

function secureZoneLoadShippingAddressKialaAjaxWindow() {
    if (    (document.getElementById("windowPayment").style.display=="block")
        ||  (document.getElementById("windowShipping").style.display=="block")
        ||  (document.getElementById("windowBank").style.display=="block")
        ||  (document.getElementById("windowShippingAddress").style.display=="block") ) {
        return false;
    }
    sendDataSync("windowShippingAddress",null,"secureshippingaddresswindowajax.php","POST");
    document.getElementById("windowShippingAddress").style.display="block";
    //secureShippingAddressIE();
}

function secureZoneLoadNewAddress() {
    sendDataSync("windowShipping",null,"secureshippingtypewindowajax.php?new_adress=1","POST");
    document.getElementById("windowShipping").style.display="block";
    
}

function secureZoneLoadShippingTypeCancel() {
    document.getElementById("windowShipping").style.display="none";
}

function secureZoneLoadShippingAddressCancel() {
    document.getElementById("windowShippingAddress").style.display="none";
}


function secureZoneLoadShippingTypeOk() {
    var ship_collection = document.getElementsByName('shipping_id[]'); 
    
    for (i=0;i<ship_collection.length;i++) {
        if (ship_collection[i].checked) {
            sendDataSync("shippingMode","shipping_id="+ship_collection[i].value,"secureshippingtypeajax.php","POST");
            sendDataSync("confirmation","","securecartajax.php","POST");
            document.getElementById("windowShipping").style.display="none";
            sendDataSync("shippingAddress",null,"secureshippingaddressajax.php","POST");
            sendDataSync("paymentMode",null,"securepaymentajax.php","POST");
            if (ship_collection[i].value==4) {
                secureZoneLoadShippingAddressKialaAjaxWindow();  
            }
            return;
        }
    } 
}


function secureZoneLoadShippingAddressNewOk() {
    var genderSecureAddress;
    var lastnameSecureAddress;
    var firstnameSecureAddress;
    var adressSecureAddress;
    var postcodeSecureAddress;
    var citySecureAddress;
    var countrySecureAddress;
    var company;
    var suburb;
    
    var postStr;
    
    if (!checkSecureAddress()) {
        return false;
    }
    
    lastnameSecureAddress = document.getElementById("lastnameSecureLogin").value;
    firstnameSecureAddress = document.getElementById("firstnameSecureLogin").value;
    adressSecureAddress = document.getElementById("adressSecureLogin").value;
    postcodeSecureAddress = document.getElementById("postcodeSecureLogin").value;
    citySecureAddress = document.getElementById("citySecureLogin").value;
    provinceSecureAddress = document.getElementById("provinceSecureLogin").value;
    countrySecureAddress = document.getElementById("countrySecureLogin").value;
    if (document.getElementById("genderFSecureLogin").checked) {
        genderSecureAddress = 'f';
    }
    if (document.getElementById("genderHSecureLogin").checked) {
        genderSecureAddress = 'm';
    }
    
    suburb = document.getElementById("suburbSecureLogin").value;
    company = document.getElementById("companySecureLogin").value;
    
    postStr = "gender="+genderSecureAddress
                                        +"&firstname="+firstnameSecureAddress
                                        +"&lastname="+lastnameSecureAddress
                                        +"&postcode="+postcodeSecureAddress
                                        +"&city="+citySecureAddress
                                        +"&province="+provinceSecureAddress
                                        +"&country="+countrySecureAddress
                                        +"&suburb="+suburb
                                        +"&street_address="+adressSecureAddress
                                        +"&company="+company;
    
    sendDataSync("windowShippingAddress",postStr,"secureshippingaddresswindowajax.php?new_address_valid=1","POST");
    if(document.getElementById('errorKO') == null)
    {
        secureZoneTimer = window.setTimeout("secureZoneLoadShippingAddressNewOkShippingAddress()",1);
    }    
}
function secureZoneLoadShippingAddressNewOkShippingAddress() {
    clearTimeout(secureZoneTimer);
    sendDataSync("shippingAddress","","secureshippingaddressajax.php","GET");
    document.getElementById("windowShippingAddress").style.display="none";
    secureZoneTimer = window.setTimeout("secureZoneLoadShippingAddressNewOkShippingMode()",1);
}
function secureZoneLoadShippingAddressNewOkShippingMode() {
    clearTimeout(secureZoneTimer);
    sendDataSync("shippingMode","","secureshippingtypeajax.php","POST");
    secureZoneTimer = window.setTimeout("secureZoneLoadPayment()",1); // réutilise celui plus haut
    
}

function secureZoneLoadShippingAddressOk() {
    var ship_collection = document.getElementsByName('address_id[]'); 
    
    for (i=0;i<ship_collection.length;i++) {
        if (ship_collection[i].checked) {
            sendDataSync("shippingAddress","shipping_address_id="+ship_collection[i].value,"secureshippingaddressajax.php","POST");
            break;
        }
    }
    document.getElementById("windowShippingAddress").style.display="none";
    secureZoneTimer = window.setTimeout("secureZoneLoadShippingAddressNewOkShippingMode()",1);
}



function secureZoneLoadShippingAddressKialaOk() {
    sendDataSync("shippingAddress","","secureshippingaddressajax.php","POST");
    document.getElementById("windowShippingAddress").style.display="none";
    secureZoneTimer = window.setTimeout("secureZoneLoadShippingAddressNewOkShippingMode()",1);
}


function secureZoneNewAddress() {
    sendDataSync("windowShippingAddress","","secureshippingaddresswindowajax.php?new_address=1","POST");
    document.getElementById("windowShippingAddress").style.display="block";
    //secureShippingAddressIE();
}

function secureZoneLoadPaymentCancel() {
    var pay_collection = document.getElementsByName('payment_id[]');
    document.getElementById("windowPayment").style.display="none";
    pay_collection[paymentTypeJS].checked="checked";
}

function secureZoneLoadPayment() {
    sendDataSync("paymentMode","","securepaymentajax.php","POST");
    secureZoneTimer = window.setTimeout("secureZoneLoadCouponAjaxModuleConfirmation()",1); // réutilise celui plus haut
}

function secureZoneLoadPaymentOk() {
    var pay_collection = document.getElementsByName('payment_id[]'); 
    for (i=0;i<pay_collection.length;i++) {
        if (pay_collection[i].checked) {
            paymentTypeJS = i;
            sendDataSync("paymentMode","payment_id="+pay_collection[i].value,"securepaymentajax.php","POST");
            break;
        }
    }
    document.getElementById("windowPayment").style.display="none";
    secureZoneTimer = window.setTimeout("secureZoneLoadCouponAjaxModuleConfirmation()",1); // réutilise celui plus haut
}

function secureZoneLoadPaymentChange() {
    var pay_collection = document.getElementsByName('payment_id_direct[]'); 
    for (i=0;i<pay_collection.length;i++) {
        if (pay_collection[i].checked) {
            paymentTypeJS = i;
            sendDataSync("paymentMode","payment_id="+pay_collection[i].value,"securepaymentajax.php","POST");
            if (document.getElementById("payment_id_"+pay_collection[i].value)) {
                document.getElementById("payment_id_"+pay_collection[i].value).checked="checked";
            }
            break;
        }
    }
    secureZoneTimer = window.setTimeout("secureZoneLoadCouponAjaxModuleConfirmation()",1); // réutilise celui plus haut
}

function secureZoneDeleteMaxiCheque() {
    sendDataSync("confirmation","deleteMaxiCheque=1","securecartajax.php","POST");
}

function secureZoneDeleteMaxiCheque1() {
    var pay_collection = document.getElementsByName('payment_id[]'); 
    for (i=0;i<pay_collection.length;i++) {
        if (pay_collection[i].checked && pay_collection[i].value!='1' && pay_collection[i].value!='12') {
            sendDataSync("confirmation","deleteMaxiCheque=1","securecartajax.php","POST");
            break;
        }
    }
}

/*
 * Controleur de reponse paypal
 * Types de reponse: erreur à afficher, url à rediriger.
 */

function controleurResponsePaypal(response){
	if (response.indexOf('http') != -1) {
		// si response est une adresse url
		window.location.href=response;
	} else alert(response);
}


function removeSpaces(string) {
    var tstring = "";
    string = '' + string;
    splitstring = string.split(" ");
    for(i = 0; i < splitstring.length; i++)
        tstring += splitstring[i];
    return tstring;
}

function setBankMessage() {
    document.getElementById("windowBank").style.display="block";
}


function isBissextileJS(year) {
    if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0) {
        return true;
    } 
    else {
        return false;
    }
}


function card_check_test() {
    if (    (document.getElementById("windowPayment").style.display=="block")
        ||  (document.getElementById("windowShipping").style.display=="block")
        ||  (document.getElementById("windowBank").style.display=="block")
        ||  (document.getElementById("windowShippingAddress").style.display=="block")) {
        return false;
    }
    setBankMessage();
    return true;
}

function card_check_test2() {
    if (    (document.getElementById("windowPayment").style.display=="block")
        ||  (document.getElementById("windowShipping").style.display=="block")
        ||  (document.getElementById("windowBank").style.display=="block")
        ||  (document.getElementById("windowShippingAddress").style.display=="block")) {
        return false;
    }
    
    var mois = document.checkout_confirmation.mois_validite.value;
    var annee = document.checkout_confirmation.annee_validite.value;

    switch(mois){
        case '1':
        case '3':
        case '5':
        case '7':
        case '8':
        case '10':
        case '12':
            var nbJourMois = 31;
        break;
        
        case '4':
        case '6':
        case '9':
        case '11':
            var nbJourMois = 30;
        break;
        
        case '2':
            var nbJourMois = 28;
            if(isBissextileJS(annee))
                nbJourMois = 29;
        break;
    }
    
    var nowDate = new Date();
    var dateOrder = new Date(nowDate.getFullYear(),nowDate.getMonth()+2,nbJourMois);
    var dateCard = new Date(annee,(mois-1),nbJourMois);
    if(dateCard<dateOrder){
        alert(cardPaiement3TimesExpire);
        return false;
    }
    
    setBankMessage();
    return true;
}

function card_check(theform) {
    var numero = document.checkout_confirmation.numero_carte.value;
    numero=removeSpaces(numero);
    var totalcarte=0;
    var dnum=0;
    var test=0;
    if (    (document.getElementById("windowPayment").style.display=="block")
        ||  (document.getElementById("windowShipping").style.display=="block")
        ||  (document.getElementById("windowBank").style.display=="block")
        ||  (document.getElementById("windowShippingAddress").style.display=="block")) {
        return false;
    }
    if (numero.length < 13) {
        alert (card_check_error);
        document.checkout_confirmation.numero_carte.focus();
        return (false);
    } else {
        for ( i = numero.length; i >= 1 ;  i--) {
            test=test+1;
            num = numero.charAt(i-1);
            if ((test % 2) != 0)
               totalcarte=totalcarte+parseInt(num)
            else {
               dnum=parseInt(num)*2;
               if (dnum >= 10)
                  totalcarte=totalcarte+1+dnum-10
               else
                  totalcarte=totalcarte+dnum;
            }

        }
        if ((totalcarte % 10) != 0){
            
            alert(card_check_error);

            document.checkout_confirmation.numero_carte.focus();

            return (false);
        } else {
            if (document.all || document.getElementById) {
                for (i = 0; i < theform.length; i++) {
                    var tempobj = theform.elements[i];
                    if (tempobj.type.toLowerCase() == "submit" || tempobj.type.toLowerCase() == "reset")
                        tempobj.disabled = true;
                }
                setBankMessage();
                return true;
            }
            setBankMessage();
            return(true);
        }
    }
}


function card_check2(theform) {
    var numero = document.checkout_confirmation.numero_carte.value;

    numero=removeSpaces(numero);
    var totalcarte=0;
    var dnum=0;
    var test=0;
    if (    (document.getElementById("windowPayment").style.display=="block")
        ||  (document.getElementById("windowShipping").style.display=="block")
        ||  (document.getElementById("windowBank").style.display=="block")
        ||  (document.getElementById("windowShippingAddress").style.display=="block")) {
        return false;
    }
    
    var mois = document.checkout_confirmation.mois_validite.value;
    var annee = document.checkout_confirmation.annee_validite.value;    
    
    switch(mois){
        case '1':
        case '3':
        case '5':
        case '7':
        case '8':
        case '10':
        case '12':
            var nbJourMois = 31;
        break;
        
        case '4':
        case '6':
        case '9':
        case '11':
            var nbJourMois = 30;
        break;
        
        case '2':
            var nbJourMois = 28;
            if(isBissextileJS(annee))
                nbJourMois = 29;
        break;
    }
    
    var nowDate = new Date();
    var dateOrder = new Date(nowDate.getFullYear(),nowDate.getMonth()+2,nbJourMois);
    var dateCard = new Date(annee,(mois-1),nbJourMois);
    if(dateCard<dateOrder){
        alert(cardPaiement3TimesExpire);
        return false;
    }
    
    
    if (numero.length < 13) {
        alert (card_check_error);
        document.checkout_confirmation.numero_carte.focus();
        return (false);
    } else {
        for ( i = numero.length; i >= 1 ;  i--) {
            test=test+1;
            num = numero.charAt(i-1);
            if ((test % 2) != 0)
               totalcarte=totalcarte+parseInt(num)
            else {
               dnum=parseInt(num)*2;
               if (dnum >= 10)
                  totalcarte=totalcarte+1+dnum-10
               else
                  totalcarte=totalcarte+dnum;
            }

        }
        
        if ((totalcarte % 10) != 0){
            alert(card_check_error);

            document.checkout_confirmation.numero_carte.focus();

            return (false);
        } else {
            if (document.all || document.getElementById) {
                for (i = 0; i < theform.length; i++) {
                    var tempobj = theform.elements[i];
                    if (tempobj.type.toLowerCase() == "submit" || tempobj.type.toLowerCase() == "reset")
                        tempobj.disabled = true;
                }
                setBankMessage();
                return true;
            }
            setBankMessage();
            return(true);
        }
    }
}

    
function helpcvxwindow () {
    url = 'cvx.php';
    window.open(url,"newFenetre",
                    "toolbar=no, location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=502,height=218,top=100,left=100");
}

function returnShippingAddressKialaIE(order_id)
{
	
	//alert(order_id);
	sendDataSync('kialaSelection','order_id='+order_id,'return_kiala_choice_point_ajax.php','POST');
	document.getElementById("windowKialaShippingReturnAddress").style.display="block";
    var scrollH = window.pageYOffset || document.body.scrollTop || document.documentElement.scrollTop;
    scrollH += 50;
    document.getElementById("windowKialaShippingReturnAddress").style.top = scrollH+'px';

}


function EcrireCookie(nom, valeur){
    var argv=EcrireCookie.arguments;
    var argc=EcrireCookie.arguments.length;
    var expires=(argc > 2) ? argv[2] : null;
    var path=(argc > 3) ? argv[3] : null;
    var domain=(argc > 4) ? argv[4] : null;
    var secure=(argc > 5) ? argv[5] : false;
    document.cookie=nom+"="+escape(valeur)+
    ((expires==null) ? "" : ("; expires="+expires.toGMTString()))+
    ((path==null) ? "" : ("; path="+path))+
    ((domain==null) ? "" : ("; domain="+domain))+
    ((secure==true) ? "; secure" : "");
}

function getCookieVal(offset){
    var endstr=document.cookie.indexOf (";", offset);
    if (endstr==-1) endstr=document.cookie.length;
    return unescape(document.cookie.substring(offset, endstr));
}

function LireCookie(nom){
    var arg=nom+"=";
    var alen=arg.length;
    var clen=document.cookie.length;
    var i=0;
    while (i<clen){
        var j=i+alen;
        if (document.cookie.substring(i, j)==arg) return getCookieVal(j);
        i=document.cookie.indexOf(" ",i)+1;
        if (i==0) break;
    }
    return null;
}

function ScrollAutomatique(){
    var test=document.location.href;
    var result = test.substring( test.lastIndexOf('#') );
    if(result == test){
        LireCookieScroll();
    }
}

var timeWriteCookieDelay = 0; ;
var offsetY4Filters = 0;

function timeWriteCookieDelayGo() {
    if (document.all && !window.opera) {
        offsetY4Filters=document.documentElement.scrollTop;
    } else {
        offsetY4Filters=window.pageYOffset;
    }
    EcrireCookie('hauteurscroll', offsetY4Filters);
}



function EcrireCookieScroll() {
    clearTimeout(timeWriteCookieDelay);
    timeWriteCookieDelay = window.setTimeout("timeWriteCookieDelayGo()",500);
}

function LireCookieScroll() {
    value= LireCookie("hauteurscroll");
    window.scrollBy(0,value);
}

function EcrireCookieProductDetail() {
    if(document.getElementById('products_viewed_detail')) {
        expiration=new Date;
        expiration.setMonth(expiration.getMonth()+1);
        EcrireCookie('products_viewed_detail',document.getElementById('products_viewed_detail').value,expiration);
    }
}


function helpcvx () {
    url = 'cvx.php';
    window.open(url,"newFenetre","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=502,height=218,top=100,left=100");
}

function help_amex_cvx () {
    url = 'cvx_amex.php';
    window.open(url,"newFenetre","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=502,height=218,top=100,left=100");
}


function panierAjax(params) {
    if (params.length > 0) {
        if (confirm(panierAjax_confirmation)) {
            window.location.href = 'panier.php?'+params;
        }
    } else {
        if (confirm(panierAjax_confirmation)) {
            window.location.href = 'panier.php';
        }

    }
    return false;
}
function panierAjax_mb(params) {
    if (params.length > 0) {
        if (confirm(panierAjax_confirmation)) {
            window.location.href = 'panier_mb.php?'+params;
        }
    } else {
        if (confirm(panierAjax_confirmation)) {
            window.location.href = 'panier_mb.php';
        }

    }
    return false;
}

function panierOffreBienvenue(params){
    sendDataSync('cartajax','operation=welcome','panierAjax.php', 'POST');
    return false;
}

function panierOperationRemove() {
    sendDataSync('cartajax','operation=','panierAjax.php', 'POST');
    return false;
}

window.onerror = function (msg, err_url, line) {
    var post_data = 'msg=' + msg + '&err_url=' + err_url + '&line=' + line + '&browser=' + navigator.userAgent;
    sendDataSimple(post_data,'save_javascript_error.php','POST');
}

function changeCodeKiala2(order_id) {
    
    clearTimeout(time4kiala);
    if ((document.getElementById('postcode').value.length >= 4)){
           document.getElementById("listeRelais").innerHTML =
                "<span>"+changeCodeKiala2_search_cp+"</span><br />";
    } else {
        if ((document.getElementById('town').value.length >= 2)){
            document.getElementById("listeRelais").innerHTML =
                "<span>"+changeCodeKiala2_search_ville+"</span><br />";
        } else {
            document.getElementById("listeRelais").innerHTML =
                "<span>"+changeCodeKiala2_search_error+"</span><br />";
        }
    }
    
    return_order_id = order_id;
    time4kiala = window.setTimeout("changeCodeKialaGo2()",1000);
}

function changeCodeKialaGo2() {
    var order_id = return_order_id;
    if ((document.getElementById('postcode').value.length >= 4)){
        sendDataSync('kialaSelection','zip='
            +document.getElementById('postcode').value
            +'&town=','return_kiala_choice_point_ajax.php', 'POST');
        document.getElementById('postcode').focus();

    } else {
        if ((document.getElementById('town').value.length >= 2)){
            sendDataSync('kialaSelection','town='
                +document.getElementById('town').value
                +'&zip=','return_kiala_choice_point_ajax.php', 'POST');
         document.getElementById('town').focus();

        } else {
            document.getElementById("listeRelais").innerHTML =
                "<span>"+changeCodeKialaGo2_error+"</span>";
        }
    }
}

function returnAddressKialaCancel() {
    sendDataSimpleSync('confirm=0','return_kiala_valid.php','POST');
    if (document.getElementById("relaisChoose")) {
        document.getElementById("relaisChoose").innerHTML =
                "<font color=\"red\"><b>"+returnAddressKialaCancel_text+"<br /><br /></b></font>";
    }
    if (document.getElementById("relaisChoose2")) {
        document.getElementById("relaisChoose2").innerHTML =
                "<font color=\"red\"><b>"+returnAddressKialaCancel_text+"<br /><br /></b></font>";
    }
    if (document.getElementById("windowKialaShippingReturnAddress")) {
        document.getElementById("windowKialaShippingReturnAddress").style.display="none";
    }
    if (document.getElementById("relaisChoose")) {
        document.getElementById("relaisChoose").style.display="block";
    }
    if (document.getElementById("relaisChoose2")) {
        document.getElementById("relaisChoose2").style.display="block";
    }
    sendDataSync('kialaPointRelaisSelect','','return_kiala_selected_point_ajax.php?confirm=0', 'POST');
    sendDataSync('kialaPointRelaisSelect2','','return_kiala_selected_point_ajax.php?confirm=0', 'POST');
}

function returnAddressKialaOk() {
    sendDataSimpleSync('confirm=1','return_kiala_valid.php','POST');
    if (document.getElementById("windowKialaShippingReturnAddress")) {
        document.getElementById("windowKialaShippingReturnAddress").style.display="none";
    }
    if((document.getElementById("colissimoradio") && document.getElementById("colissimoradio").checked==false)
    ||  (!document.getElementById("colissimoradio"))) {
        if (document.getElementById("relaisChoose")) {
            document.getElementById("relaisChoose").style.display="block";
        }
        if (document.getElementById("relaisChoose")) {
            document.getElementById("relaisChoose").innerHTML = "<font color=\"green\"><b>"+returnAddressKialaOk_text+"</b></font>";
        }
        sendDataSync('kialaPointRelaisSelect','','return_kiala_selected_point_ajax.php?confirm=1', 'POST');
    }    
    if (document.getElementById("relaisChoose2")) {
        document.getElementById("relaisChoose2").innerHTML = "<font color=\"green\"><b>"+returnAddressKialaOk_text+"</b></font>";
    }
    sendDataSync('kialaPointRelaisSelect2','','return_kiala_selected_point_ajax.php?confirm=1', 'POST');
}

function clearReturnKialaRelais() {
    if (document.getElementById("relaisChoose")) {
        document.getElementById("relaisChoose").style.display="none";
    }
    if (document.getElementById("relaisChoose2")) {
        document.getElementById("relaisChoose2").style.display="none";
    }
    if (document.getElementById("kialaPointRelaisSelect")) {
        document.getElementById("kialaPointRelaisSelect").innerHTML = "";
    }
    if (document.getElementById("kialaPointRelaisSelect2")) {
        document.getElementById("kialaPointRelaisSelect2").innerHTML = "";
    }
}

function loadReturnType() {
    sendDataSimpleSync('confirm=0','return_kiala_valid.php','POST');
    sendDataSync('shippingTypeSelection','order_id='+document.getElementById('orderID').value,'return_type_choice.php', 'POST');
}

function showProdcard(monId) {
    if (document.getElementById('windowProdcard')) {
        document.getElementById('windowProdcard').style.display = 'block';
    }
    sendDataSync('windowProdcard','null','windowProdcard.php?productId='+monId, 'GET');
    if (navigator.platform == "Win32" && navigator.appName == "Microsoft Internet Explorer" && window.attachEvent) {
        fnLoadPngs();
    }
    scrollProdCard();
}

function scrollProdCard() {
    var offsetY;
    if(document.all && !window.opera){
        offsetY=document.documentElement.scrollTop;
    }
    else {
        offsetY=window.pageYOffset;
    }
    document.getElementById('windowProdcard').style.top = ""+(offsetY+200)+"px";
}
function happyDays2_DoFSCommand(command,args) {
    if (command == "closeHappyDays") {
        document.getElementById("pub").style.display = "none";
    }
    if (command == "pub"){
        document.getElementById("pub").style.display = "none";
    }
    if (command == "million"){
        document.getElementById("million").style.display = "none";
    }
}
function closeHappyDays(){
	document.getElementById("pub").style.display = "none";
}
function adidays_DoFSCommand(command,args) {
    if (command == "closeAdidays") {
        document.getElementById("divAdidays").style.display = "none";
    }
    if (command == "pub"){
        document.getElementById("pub").style.display = "none";
    }
}
function sorel_DoFSCommand(command,args) {
    if (command == "close") {
        document.getElementById("sorel").style.display = "none";
    }
}
function salomon() {
    document.getElementById("sis").style.display = "none";
}

function OFFRE_DoFSCommand(command,args) {
    if (command == "closeAdidays") {
        document.getElementById("divAdidays").style.display = "none";
    }
    if (command == "pub"){
        document.getElementById("pub").style.display = "none";
    }
}

function verif_form_operation() {
    var error = false;
    var message = verif_form_operation_header;
    if (document.operation.nom.value.length == 0) {
        error = true;
        message = message + verif_form_operation_nom;
    }
    if (document.operation.prenom.value.length == 0) {
        error = true;
        message = message + verif_form_operation_prenom;
    }
    if (document.operation.dob.value.length < 5) {
        error = true;
        message = message + verif_form_operation_dob;
    }
    if (document.operation.dob.value== 'jj/mm/aaaa') {
        error = true;
        message = message + verif_form_operation_dob;
    }
    if (document.operation.email.value.length == 0) {
        error = true;
        message = message + verif_form_operation_email;
    }
    if (getValRadio(document.operation.sexe)=='aucun'){
        error = true;
        message = message + verif_form_operation_genre;
    }
    if (document.operation.email.value.length > '0') {
      var a = document.operation.email.value;
      test = true;
      for (var j=1 ; j<(a.length) ; j++) {
        if (a.charAt(j)=='@') {
           if (j<(a.length-4)) {
              for (var k=j ; k<(a.length-2) ; k++) {
                 if (a.charAt(k)=='.') {
                    test = false;
                 }
              }
           }
        }
      }
      if (test == true) {
        error = true;
        message = message + verif_form_operation_adresse;
      }
    }
    if (error == true) {
        window.alert(message);
        return false;
    } else {
        return true;
    }
 }


function expliWrite(value) {
    if(value =='size'){
        document.getElementById("explication").innerHTML = expliWrite_text1;
    }else if(value =='com'){
        document.getElementById("explication").innerHTML = expliWrite_text2;
    }else if(value =='defaut'){
        document.getElementById("explication").innerHTML = expliWrite_text3;
    }else if(value =='modele'){
        document.getElementById("explication").innerHTML = expliWrite_text4;
    }
}

function expliWrite2(value) {
    if(value =='size'){
        document.getElementById("explication").innerHTML = expliWrite2_text1;
    }else if(value =='com'){
        document.getElementById("explication").innerHTML = expliWrite_text2;
    }else if(value =='defaut'){
        document.getElementById("explication").innerHTML = expliWrite2_text1;
    }else if(value =='modele'){
        document.getElementById("explication").innerHTML = expliWrite_text4;
    }
}

// fonction utilisé dans retour_add.php qui permet d'afficher ou non le textearea "com" que si la raison choisi est defaut.
function displayOrNotCom(value) {
	if(value =='defaut' || value =='com'){
		 document.getElementsByName("div_com")[0].style.display='block';
	} else document.getElementsByName("div_com")[0].style.display='none';
}

// fonction appellée au onChange de la droplist reasons dans retour_add.php
function onChangeReason(value) {
	sendDataSync('taille','null','list_size.php?reason='+value+'&product='+document.ask.id_product.value ,'GET');
	displayOrNotCom(value);
	document.getElementsByName("saisie_rib")[0].style.display='block';
	document.getElementsByName("info_rib")[0].style.display='block';
	document.getElementsByName("info_rib_size")[0].style.display='none';
	if(value == 'size') {
	  document.getElementsByName("info_rib")[0].style.display='none';
    document.getElementsByName("info_rib_size")[0].style.display='block';
  }
	expliWrite(value);
}

function onChangeReason2(value) {
    if(value.substring(0,4)=="size") value="size";
    if(value.substring(0,6)=="modele") value="modele";
    if(value.substring(0,6)=="defaut") value="defaut";
	sendDataSync('taille','null','list_size2.php?reason='+value+'&product='+document.ask.id_product.value+'&order='+document.ask.order.value ,'GET');
	displayOrNotCom(value);
	document.getElementsByName("saisie_rib")[0].style.display='block';
	document.getElementsByName("info_rib")[0].style.display='block';
	document.getElementsByName("info_rib_size")[0].style.display='none';
	if(value == 'size') {
	  document.getElementsByName("info_rib")[0].style.display='none';
      document.getElementsByName("info_rib_size")[0].style.display='block';
    }
	expliWrite2(value);
    document.getElementById("question3").style.display='block';
}

function confirmPromoNoel(promo) {
    sendDataSync('promoNoel','confirm='+promo,'panier_promo_noel.php', 'POST');
}

// sert à savoir pour la redirection si la variable de session n'existe pas
function verifSessionPromoNoel(){

    if (document.all && !window.opera) {
        var xhr = new ActiveXObject("Microsoft.XMLHTTP") ;
    } else {
        var xhr = new XMLHttpRequest();
    }

    post_data='';
    var res;

	xhr.open("POST",'panier_Noel_Verif_Session.php',false);
	xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
    xhr.send(post_data);
    res = xhr.responseText;

    if (res=='1') return true;
    else return false;
}

function verifPromoSelected(){

    if ( !verifSessionPromoNoel() ){
        return confirm(verifPromoSelected);
    } else {
        return true;
    }

}

function verifCGVSelected(){
    if ( document.getElementById("cgv_confirmation").checked == false ){
        alert(verifCGVSelected_text);
        return false;
    } else {
        return true;
    }
}
function refererRecup() {
    var referer = '';
    referer = document.referrer;
    return referer;
}
/* formulaire création compte */
var submitcount=0;

function checkSubmit(){
    if (submitcount == 0){
        submitcount++;
        return true;
    } else {
        alert(checkSubmit_text);
        return false;
    }
}

// affichage popup témoignage client
function myTestimony() {
    url = 'myTestimony.php';
    window.open(url,"newFenetre","toolbar=no, location=no, directories=no, status=no,menubar=no, scrollbars=no, resizable=no, width=400, height=400, top=100, left=100");
}

// affichage popup assurance serenite
function popupAssurance(identifiant) {
    url = 'assuranceDetail.php?id='+identifiant;
    window.open(url,"newFenetre","toolbar=no, location=no, directories=no, status=no,menubar=no, scrollbars=no, resizable=no, width=400, height=400, top=100, left=100");
}

function removeAssurance(identifiant) {
    sendDataSync('cartajax','assuranceRemoved='+identifiant,'panierAjax.php', 'POST');
    return false;
}

function loadFormReturn(orderID) {
    sendDataSync('marketplace','order_id='+orderID,'returnForm.php', 'POST');
}

function loadFormReturn2(orderID) {
    sendDataSync('marketplace','order_id='+orderID,'returnForm2.php', 'POST');
}

// vérification formulaire de demande de retour
function verif_form_return_marketplace() {
    var error = false;
    var message = verif_form_return_marketplace_header;
    if (document.ask.order.value == 'a') {
        error = true;
        message = message + verif_form_return_marketplace_commande;
    }
    if (document.ask.id_product.value == 'a') {
        error = true;
        message = message + verif_form_return_marketplace_produit;
    }
    if (error == true) {
        window.alert(message);
        return false;
    } else {
        return true;
    }
}

var trendTimer;
var decal;
var offsetTrend;

var trendDiv;
var oldDate = new Date();
var moving = false;

function moveTrend() {
    clearTimeout(trendTimer);
    var DivLong = eval(trendDiv.style.marginLeft.substr(0,trendDiv.style.marginLeft.length -2));
    var newDate = new Date();
    var delta = newDate.getTime() - oldDate.getTime();
    oldDate = newDate;
    var offsetT = offsetTrend*delta/2.0;
    if (offsetT>9.99) {
        offsetT = 10;
    }
    if (offsetT<-9.99) {
        offsetT = -10;
    }
    
    if (Math.abs(DivLong-decal)<=10) {
        trendDiv.style.marginLeft = decal+'px';
        moving = false;
    } else {
        var dest = DivLong + offsetT;
        trendDiv.style.marginLeft = dest+'px';
        trendTimer = window.setTimeout("moveTrend()",1);
    }
}



function scrollThumbsLeft(monDiv){
    if (moving) {
        return;
    }

    oldDate = new Date();
    trendDiv = monDiv;
   
    if (875 - eval(trendDiv.style.marginLeft.substr(0,trendDiv.style.marginLeft.length -2)) < 
        eval(trendDiv.style.width.substr(0,trendDiv.style.width.length -2))){
        var DivLong = eval(trendDiv.style.marginLeft.substr(0,trendDiv.style.marginLeft.length -2)); 
        
        decal = DivLong - 106;
        offsetTrend = -1;
        moving = true;
        moveTrend();
        
    }
}
function scrollThumbsLeftCarrousel(monDiv){
    if (moving) {
        return;
    }

    oldDate = new Date();
    trendDiv = monDiv;
    
    if (636 - eval(trendDiv.style.marginLeft.substr(0,trendDiv.style.marginLeft.length -2)) < 
        eval(trendDiv.style.width.substr(0,trendDiv.style.width.length -2))){
        var DivLong = eval(trendDiv.style.marginLeft.substr(0,trendDiv.style.marginLeft.length -2)); 
        
        decal = DivLong - 106;
        offsetTrend = -1;
        moving = true;
        moveTrend();
       
    }
}
function scrollBrandLeft(monDiv){
    if (moving) {
        return;
    }
    oldDate = new Date();
    trendDiv = monDiv;
    if (816 - eval(trendDiv.style.marginLeft.substr(0,trendDiv.style.marginLeft.length -2)) <  eval(trendDiv.style.width.substr(0,trendDiv.style.width.length -2))){
        var DivLong = eval(trendDiv.style.marginLeft.substr(0,trendDiv.style.marginLeft.length -2)); 
        decal = DivLong - 102;
        offsetTrend = -1;
        moving = true;
        moveTrend();
        
    }else{
    
    }
}
function scrollBrandRight(monDiv){
    if (moving) {
        return;
    }
    
    oldDate = new Date();
    trendDiv = monDiv;
    if (eval(trendDiv.style.marginLeft.substr(0,trendDiv.style.marginLeft.length -2)) < 0){
        var DivLong = eval(trendDiv.style.marginLeft.substr(0,trendDiv.style.marginLeft.length -2)); 
       
        decal = DivLong - DivLong;
        offsetTrend = +1;
        moving = true;
        moveTrend();
        
    }
}

function scrollThumbsLeft2(monDiv){
    if (moving) {
        return;
    }

    oldDate = new Date();
    trendDiv = monDiv;
    if (848 - eval(trendDiv.style.marginLeft.substr(0,trendDiv.style.marginLeft.length -2)) <
        eval(trendDiv.style.width.substr(0,trendDiv.style.width.length -2))){
        var DivLong = eval(trendDiv.style.marginLeft.substr(0,trendDiv.style.marginLeft.length -2));

        decal = DivLong - 106;
        offsetTrend = -1;
        moving = true;
        moveTrend();
        
    }
}

function scrollThumbsRight(monDiv){
    if (moving) {
        return;
    }
    
    oldDate = new Date();
    trendDiv = monDiv;
    //alert(trendDiv.style.marginLeft);
    if (eval(trendDiv.style.marginLeft.substr(0,trendDiv.style.marginLeft.length -2)) < 0){
        var DivLong = eval(trendDiv.style.marginLeft.substr(0,trendDiv.style.marginLeft.length -2)); 
        
        decal = DivLong + 106;
        offsetTrend = +1;
        moving = true;
        moveTrend();
        
    }
    
}
     
function verif_formFlou() {
    var error = false;
    var message = verif_formFlou_header;
    if(document.create_account.lastname.value.length == 0) {
        error = true;
        message = message + verif_formFlou_nom;
    }
    if(document.create_account.firstname.value.length == 0) {
        error = true;
        message = message + verif_formFlou_prenom;
    }
    if(document.create_account.email_address.value.length == 0) {
        error = true;
        message = message + verif_formFlou_email;
    }
    
    if(document.getElementById('homme').checked==false && document.getElementById('femme').checked==false) {
        error = true;
        message = message + verif_formFlou_genre;
    }
    if(document.create_account.password.value.length == 0) {
        error = true;
        message = message + verif_formFlou_password;
    }
    if(document.create_account.confirmation.value != document.create_account.password.value) {
        error = true;
        message = message + verif_formFlou_pwd_confirmation;
    }
    if(document.create_account.street_address.value.length == 0) {
        error = true;
        message = message + verif_formFlou_adresse;
    }
    if(document.create_account.postcode.value.length == 0) {
        error = true;
        message = message + verif_formFlou_cp;
    }
    if(document.create_account.city.value.length == 0) {
        error = true;
        message = message + verif_formFlou_ville;
    }
    if(document.create_account.country.value.length == 0) {
        error = true;
        message = message + verif_formFlou_pays;
    }
    if(document.create_account.telephone.value.length == 0) {
        error = true;
        message = message + verif_formFlou_telephone;
    }
    if(document.create_account.email_address.value.length > '0') {
      var a = document.create_account.email_address.value;
      test = true;
      for (var j=1 ; j<(a.length) ; j++) {
        if (a.charAt(j)=='@') {
           if (j<(a.length-4)){
              for (var k=j ; k<(a.length-2) ; k++) {
                 if (a.charAt(k)=='.') {
                    test = false;
                 }
              }
           }
        }
      }
        if(test == true){   
            error = true;
            message = message + verif_formFlou_email_format;
        }
    }
    if (error == true){
        window.alert(message);
        return false;
    } else {
        return true;
    }	
} 

function resolTest(){
    if(document.getElementById('opeLeft')){
        u = location.href.substring(location.href.length - 8 , location.href.length);
        
        if(screen.width >= 1280 && u != "noel.php"){
            document.getElementById('opeRight').style.display = "block";
            document.getElementById('opeLeft').style.display = "block";
        }else{
            document.getElementById('opeRight').style.display = "none";
            document.getElementById('opeLeft').style.display = "none";
        }
    }
}
function showLanguage(myLanguageString) {
    document.getElementById('myLanguage').innerHTML = myLanguageString;
}
// vérification formulaire ticket_satisfaction  
function verif_form_satisfaction(){
    var error = false;
    var numero = 0;
    if (document.getElementsByName('radio')) {
        if (document.getElementsByName('radio')[0]
            && document.getElementsByName('radio')[1]
            && document.getElementsByName('radio')[2]
            && document.getElementsByName('radio')[3]) {
            
            if (document.getElementsByName('radio')[0].checked == false 
                && document.getElementsByName('radio')[1].checked == false 
                && document.getElementsByName('radio')[2].checked == false 
                && document.getElementsByName('radio')[3].checked == false) {
                error = true;
                numero = 1;
            }
        }
    }
    
    
    if (document.getElementsByName('radio2')) {
        if (document.getElementsByName('radio2')[0]
            && document.getElementsByName('radio2')[1]
            && document.getElementsByName('radio2')[2]) {
            
            if (document.getElementsByName('radio2')[0].checked == false 
                && document.getElementsByName('radio2')[1].checked == false 
                && document.getElementsByName('radio2')[2].checked == false) {
                error = true;
                numero = 2;
            }
        }
    }
    
    if (document.getElementsByName('radio3')) {
        if (document.getElementsByName('radio3')[0]
            && document.getElementsByName('radio3')[1]
            && document.getElementsByName('radio3')[2]) {
    
            if (document.getElementsByName('radio3')[0].checked == false 
                && document.getElementsByName('radio3')[1].checked == false 
                && document.getElementsByName('radio3')[2].checked == false) {
                error = true;
                numero = 3;
            }
        }
    }
    
    if (document.getElementsByName('voteA') && document.getElementsByName('voteB') && document.getElementsByName('voteC')) {
        if(!document.getElementById('voteA').value) {error=true;numero=3;} 
        if(!document.getElementById('voteB').value) {error=true;numero=2;}   
        if(!document.getElementById('voteC').value) {error=true;numero=1;}    
    }
    
    
    
    if (error == true) {
        alert(c_you_did_not_answer+numero);
        return false;
    } else {
        return true;
    }	
}

// ZONE GREGORETTE

/* ----------------------------- spot TV ----------------- */

function spotTV(target,action)
{
	switch(action)
	{
		case 'open':
		var video = '<div style="border:1px solid #535353;"><object width="360" height="286"><param name="movie" value="http://www.dailymotion.com/swf/x8xde8_spartooontv_creation&related=1"></param><param name="allowFullScreen" value="true"></param><param name="allowScriptAccess" value="always"></param><embed src="http://www.dailymotion.com/swf/x8xde8_spartooontv_creation&related=1" type="application/x-shockwave-flash" width="360" height="286" allowFullScreen="true" allowScriptAccess="always"></embed></object><div class="closespot"><a href="#" onclick="spotTV(\'spottv\',\'close\');" alt="Fermer"><img src="../images/close_spot_tv.png" /></a></div></div>';
		//document.getElementById(target).style.display = "block";
		document.getElementById(target).innerHTML = video;
		document.getElementById(target).style.display = "block";
			break;
		case 'close':
		var video = "";
		document.getElementById(target).innerHTML = video;
		document.getElementById(target).style.display = "none";
			break;

    }
				
}

/* ----------------------------- Salomon popup ----------------- */

function onClickStart()
{
	var so = new SWFObject("http://origin.salomonsports.com/sis/spartoo/salomon/main.swf", "Salomon Shop", "688", "474", "9", "#FFFFFF");
    so.addParam("scale", "noscale");
    so.addParam("allowscriptaccess", "always");
    so.addParam("base", "salomon");
    so.write("flashzone");
}
			
function salomon()
{ 
	document.getElementById('flashzone').className= "invisible"; 
}	
	
// FIN GREGORETTE
    
function getContactMessagerie()
{
    var contacts = document.getElementsByName('contact');
    var contacts_name = new Array();
    var contacts_email = new Array();    
    for(var i = 0 ; i< contacts.length ; i++)
    {
        if(contacts[i] . checked == true)
        {
            contacts_name.push(document.getElementById('contact_name'+i).innerHTML);
            contacts_email.push(document.getElementById('contact_email'+i).innerHTML);
        }
    }
    
    var contact_parrain = document.getElementById('user').value;
    
    var javascript_function = document.getElementById('javascriptFunction').innerHTML;
    var tab =  new Array(contacts_name, contacts_email);
    document.getElementById('getContactsMessagerie').style.display = 'none';
    
    eval(javascript_function + '( new Array(contacts_name, contacts_email, contact_parrain))');
}

function toutCocher()
{
    var contacts = document.getElementsByName('contact');

    for(var i = 0 ; i< contacts.length ; i++)
    {
        contacts[i] . checked = !contacts[i] . checked;
    }
}

function save_prefs_newsletter()
{
    var retour ='';

    if(document.getElementById('prix').checked == true)     retour += '&prix=1';
    else                                                    retour += '&prix=0';
    if(document.getElementById('homme').checked == true)    retour += '&homme=1';
    else                                                    retour += '&homme=0';
    if(document.getElementById('femme').checked == true)    retour += '&femme=1';
    else                                                    retour += '&femme=0';
    if(document.getElementById('enfant').checked == true)   retour += '&enfant=1';
    else                                                    retour += '&enfant=0';
    if(document.getElementById('marques').checked == true)  retour += '&marques=1';
    else                                                    retour += '&marques=0';
    if(document.getElementById('soldes').checked == true)   retour += '&soldes=1';
    else                                                    retour += '&soldes=0';
    if(document.getElementById('optin').checked == true)    retour += '&optin=1';
    else                                                    retour += '&optin=0';
    retour += '&cause='+document.getElementById('cause').value;
    retour += '&cause_txt='+document.getElementById('cause_txt').value;
    retour += '&concurrent='+document.getElementById('concurrent').value;
    retour += '&email='+document.getElementById('email').value;

    sendData('affiche','null','compte_newsletters.php?action=process'+retour,'GET');
    return false;
}

function goLastPageFromProdCard(url) {
    if (referer_js) {

        history.back();
        return false;
    } else {
        window.location=url;

        return false;
    }
    
}

function alertNewsBrand(gender, email, marque) {
   var re = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
   ret = re.test(email);
   
    if (ret) {
        sendData('form_NewsAlert','null','compte_newsBrand.php?action=process&gender='+gender+'&email='+email+'&marque='+marque,'GET');
    } else {
        alert(NewsBrandAlert_email);
    }

}

function alertNewsBrand2(gender, email, marque) {
   var re = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
   ret = re.test(email);
   
    if (ret) {
        sendData('brandNews','null','compte_newsBrand.php?action=process2&gender='+gender+'&email='+email+'&marque='+marque,'GET');
        alert(NewsBrandAlert_inscription);
        hide(document.getElementById('brandNews'));
    } else {
        alert(NewsBrandAlert_email);
    }

}
// fred prodcard onglets
var active_id_fred;
function showOnglet(id_fred, id2_fred, id_img){
    document.getElementById(id_fred).style.display = "block";
    active_id_fred = id2_fred;
    if(document.getElementById("onglet1"))
        ongletOff ("onglet1", "arrow1");
    if(document.getElementById("onglet2"))
        ongletOff ("onglet2", "arrow2");
    if(document.getElementById("onglet3"))
        ongletOff ("onglet3", "arrow3");
    ongletOn (id2_fred, id_img);
    if(document.getElementById("infoDescription") && id_fred != "infoDescription")
        hideOnglet ("infoDescription");
    if(document.getElementById("infoCompo") && id_fred != "infoCompo")
        hideOnglet ("infoCompo");
    if(document.getElementById("plusProduit") && id_fred != "plusProduit")
        hideOnglet ("plusProduit");
}
function ongletOn (id_fred, id_img){
    document.getElementById(id_fred).parentNode.className= "prodcardOngletOn";
    document.getElementById(id_img).src = "images/arrowDown.gif";
}
function hideOnglet(id_fred){
    document.getElementById(id_fred).style.display = "none";
}
function ongletOff (id_fred,id_img){
    if(id_fred != active_id_fred){
        document.getElementById(id_fred).parentNode.className= "prodcardOngletOff";
        document.getElementById(id_img).src = "images/arrowRight.gif";
    }
}

function go_product(id,supp)
{
    go_product2(id, supp);
}

// Manufacturer History - ced 091019
var manufacturer_history_size = 0;
var manufacturer_history_timer;
var manufacturer_history_div;
var manufacturer_history_old_date;
var manufacturer_history_new_date
var manufacturer_history_current_size = 0;


function open_manufacturer_history_init(div, margin_bottom) {
    manufacturer_history_div = div;
    
    manufacturer_history_div.style.display = 'block';
    if (manufacturer_history_size==0) {
        
        manufacturer_history_size = manufacturer_history_div.offsetHeight;
        /*var rslt = navigator.appVersion.match(/MSIE (\d+\.\d+)/, '');
        var itsAllGood = (rslt != null && Number(rslt[1]) >= 5.5 && Number(rslt[1]) < 7);
        if (itsAllGood) {*/
            manufacturer_history_size += margin_bottom;
        /*}*/
    }
    
    if (manufacturer_history_current_size==0) {
        manufacturer_history_div.style.height = manufacturer_history_current_size+'px';
    }
    manufacturer_history_old_date = new Date();
    open_manufacturer_history();
}
function open_manufacturer_history() {
    clearTimeout(manufacturer_history_timer);
    manufacturer_history_new_date = new Date();
    var delta = manufacturer_history_new_date.getTime() - manufacturer_history_old_date.getTime();
    manufacturer_history_current_size = manufacturer_history_current_size+delta*0.3;
    if (manufacturer_history_current_size<manufacturer_history_size) {

        manufacturer_history_div.style.height = manufacturer_history_current_size+'px';
        
        manufacturer_history_old_date=manufacturer_history_new_date;
        
        manufacturer_history_timer = window.setTimeout("open_manufacturer_history()",1);
    } else {
        manufacturer_history_current_size = manufacturer_history_size;
        manufacturer_history_div.style.height = manufacturer_history_current_size+'px';
    }
}
function close_manufacturer_history_init(div) {
    manufacturer_history_old_date = new Date();
    close_manufacturer_history();
}

function close_manufacturer_history() {
    clearTimeout(manufacturer_history_timer);
    manufacturer_history_new_date = new Date();
    var delta = manufacturer_history_new_date.getTime() - manufacturer_history_old_date.getTime();
    manufacturer_history_current_size = manufacturer_history_current_size-delta*0.4;
    if (manufacturer_history_current_size>0) {
        manufacturer_history_div.style.height = manufacturer_history_current_size+'px';
        
        manufacturer_history_old_date=manufacturer_history_new_date;
        
        manufacturer_history_timer = window.setTimeout("close_manufacturer_history()",1);
    } else {
        manufacturer_history_current_size = 0;
        manufacturer_history_div.style.height = manufacturer_history_current_size+'px';
        manufacturer_history_div.style.display = 'none';
    }
}

// Home univers sous-styles - fred 100119
var home_subStyles_timer;
var home_subStyles_div;
var home_subStyles_old_date;
var home_subStyles_new_date
var home_subStyles_current_y = 0;
var home_subStyles_current_from_y = 0;
var home_subStyles_current_to_y = 0;
var first_step=0;
var last_step=0;


function open_subStyles_init(div, fromY, toY, stepStart, stepStop) {
    
    home_subStyles_div = div;
    first_step = stepStart;
    last_step = stepStop+1;
    
    home_subStyles_current_from_y = fromY;
    home_subStyles_current_to_y = toY;
    if (home_subStyles_current_y==0) {
        if (document.getElementById(div+first_step)) {
            home_subStyles_current_y = document.getElementById(div+first_step).offsetTop;
        }
    }
    //alert('toto' + home_subStyles_current_y);
    
    home_subStyles_old_date = new Date();
    
    open_home_subStyles();
}
function open_home_subStyles() {
    clearTimeout(home_subStyles_timer);
    home_subStyles_new_date = new Date();
    var delta = home_subStyles_new_date.getTime() - home_subStyles_old_date.getTime();
    home_subStyles_current_y = home_subStyles_current_y-delta*0.3;
    if (home_subStyles_current_y>home_subStyles_current_to_y) {
        
        
        home_subStyles_old_date=home_subStyles_new_date;
        
        home_subStyles_timer = window.setTimeout("open_home_subStyles()",1);
        
    } else {
        home_subStyles_current_y = home_subStyles_current_to_y;
        
    }
    for(i=first_step;i<last_step;i++){
        document.getElementById(home_subStyles_div+i).style.top = home_subStyles_current_y+'px';
    }
}
function close_home_subStyles_init() {
    //alert(home_subStyles_current_y);
    home_subStyles_old_date = new Date();
    clearTimeout(home_subStyles_timer);
    close_home_subStyles();
}

function close_home_subStyles() {
    clearTimeout(home_subStyles_timer);
    home_subStyles_new_date = new Date();
    var delta = home_subStyles_new_date.getTime() - home_subStyles_old_date.getTime();
    home_subStyles_current_y = home_subStyles_current_y+delta*0.4;
    //alert(home_subStyles_new_date.getTime() +" "+ home_subStyles_old_date.getTime());
    if (home_subStyles_current_y<home_subStyles_current_from_y) {
    
        home_subStyles_old_date=home_subStyles_new_date;
        
        home_subStyles_timer = window.setTimeout("close_home_subStyles()",1);
    } else {
        home_subStyles_current_y = home_subStyles_current_from_y;
    }
    for(i=first_step;i<last_step;i++){
        document.getElementById(home_subStyles_div+i).style.top = home_subStyles_current_y+'px';
    }
}
// footer texte pour référencement 
function showHide(id) {
    for(i=1;i<5;i++) {
        if(document.getElementById('tab'+i))
        {
            document.getElementById('tab'+i).className = "hide";
        }
    }
    document.getElementById('tab'+id).className = "show";
}

function optout_ads() {
    expiration=new Date;
    expiration.setMonth(expiration.getMonth()+12*50);
    EcrireCookie('OPTOUT',1,expiration);
    alert(TEXT_OPTOUT_OK);
}
