var xmlHttp; var phase; var idInput; var idtype; var redirection; var code_promo; function addCodePromo() { code_promo = document.inputform["fields[code-promo]"].value code_promo = code_promo.toUpperCase();; var url="/mkdg_system/onlineshop_affect_code_promo.php?code_promo="+ code_promo; xmlHttp=GetXmlHttpObject(stateCodePromo); xmlHttp.open("GET", url , true); xmlHttp.send(null); } function stateCodePromo() { if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { if (xmlHttp.responseText == "non valide") { document.getElementById('inputCodePromo').style.backgroundColor = "#d39c9c"; } else { document.getElementById("codePromo").innerHTML = "Code Promo (" + code_promo + ") -" + xmlHttp.responseText + " €"; document.getElementById('fraisPort').style.visibility = "hidden"; } } } function validerPanier(link) { fp = document.inputform["fields[frais-port]"].value; var url="/mkdg_system/onlineshop_valider_panier.php?fp="+ fp; xmlHttp=GetXmlHttpObject(stateValiderPanier); redirection = link; xmlHttp.open("GET", url , true); xmlHttp.send(null); } function stateValiderPanier() { if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { document.location.href=redirection; } } function productQte(id,type) { phase = 1; var url="/mkdg_system/onlineshop_qte_line.php?phase="+ phase +"&line=" + id + "&type=" + type; if (phase == "1") { xmlHttp=GetXmlHttpObject(stateChangedPrixTotal); idInput = id; idtype = type; } xmlHttp.open("GET", url , true); xmlHttp.send(null); } function productQteManual(id) { var qte = document.inputform["fields["+id+"][qte]"].value; if ( (isNaN(qte) == false) && (qte > 0) && (qte.indexOf(".") < 0) ) { var url="/mkdg_system/onlineshop_qte_manual_line.php?line=" + id + "&qte=" + qte; xmlHttp=GetXmlHttpObject(stateChangedPrixTotalManual); idInput = id; xmlHttp.open("GET", url , true); xmlHttp.send(null); } else { alert("Veuillez rentrer un chiffre entier supérieur à 0 !"); document.inputform["fields["+id+"][qte]"].value = 1; productQteManual(id); } } function stateChangedPrixTotal() { if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { document.inputform["fields["+idInput+"][total]"].value = xmlHttp.responseText; productQtePhase2(idInput,idtype); } } function stateChangedPrixTotalManual() { if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { document.inputform["fields["+idInput+"][total]"].value = xmlHttp.responseText; productTotalPanier(); } } function productQtePhase2(id,type) { phase = 2; var url="/mkdg_system/onlineshop_qte_line.php?phase="+ phase +"&line=" + id; xmlHttp=GetXmlHttpObject(stateChangedQte); idInput = id; xmlHttp.open("GET", url , true); xmlHttp.send(null); } function stateChangedQte() { if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { document.inputform["fields["+idInput+"][qte]"].value = xmlHttp.responseText; productTotalPanier(); } } function productTotalPanier() { var url="/mkdg_system/onlineshop_total_panier.php"; xmlHttp=GetXmlHttpObject(stateChangedTotalPanier); xmlHttp.open("GET", url , true); xmlHttp.send(null); } function stateChangedTotalPanier() { if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { document.getElementById("totalPanier").innerHTML=xmlHttp.responseText; } } function addProductPanier(id_product) { var tabFields = new Array(); tabFields[0] = "id_product="+id_product; strFields = tabFields.join("&"); var url="/mkdg_system/onlineshop_add_product_panier.php?" + strFields; xmlHttp=GetXmlHttpObject(stateChangedPanier); xmlHttp.open("GET", url , true); xmlHttp.send(null); } function clearProductPanier() { var url="/mkdg_system/onlineshop_clear_panier.php"; xmlHttp=GetXmlHttpObject(stateChangedPanierClear); xmlHttp.open("GET", url , true); xmlHttp.send(null); } function stateChangedPanier() { if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { document.getElementById("nbProductPanier").innerHTML=xmlHttp.responseText; //productTotalPanier(); } } function stateChangedPanierClear() { if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { document.getElementById("nbProductPanier").innerHTML=xmlHttp.responseText; document.location.reload(); } } //Fonction de communication globale function GetXmlHttpObject(handler) { var objXmlHttp=null if (navigator.userAgent.indexOf("Opera")>=0) { alert("This example doesn't work in Opera") return } if (navigator.userAgent.indexOf("MSIE")>=0) { var strName="Msxml2.XMLHTTP" if (navigator.appVersion.indexOf("MSIE 5.5")>=0) { strName="Microsoft.XMLHTTP" } try { objXmlHttp=new ActiveXObject(strName) objXmlHttp.onreadystatechange=handler return objXmlHttp } catch(e) { alert("Error. Scripting for ActiveX might be disabled") return } } if (navigator.userAgent.indexOf("Mozilla")>=0) { objXmlHttp=new XMLHttpRequest() objXmlHttp.onload=handler objXmlHttp.onerror=handler return objXmlHttp } } function viewVignette(product) { document.getElementById("imgContentListNum"+product).style.display = "inline"; document.getElementById("imgContentImgPanier"+product).style.zIndex = "2"; } function viewVignetteNone(product) { document.getElementById("imgContentListNum"+product).style.display = "none"; document.getElementById("imgContentImgPanier"+product).style.zIndex = "1"; }