var xmlHttp; var xmlHttp2; var phase; var idInput; var idtype; var redirection; var code_promo; var redirection_valid; var redirection_novalid; function selectDeclinaisonProductInFiche(product_id) { document.getElementById('product_id_selected').value = product_id; product_parent_id = document.getElementById('product_parent_id_selected').value; marge = document.getElementById('product_marge').value; type_px = document.getElementById('product_type_px').value var url="/mkdg_system/onlineshop_select_declinaison_product_in_fiche.php?product_id=" + product_id + "&product_parent_id=" + product_parent_id + "&marge=" + marge + "&type_px=" + type_px; xmlHttp=GetXmlHttpObject(stateSelectDeclinaisonProductInFiche); xmlHttp.open("GET", url , true); xmlHttp.send(null); } function stateSelectDeclinaisonProductInFiche() { if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { /* breakTag = ""; msg = xmlHttp.responseText; nb_chars = msg.length; msg = msg.substr(0,(nb_chars-1)); js = (msg + '').replace(/([^>]?)\n/g, '$1'+ breakTag +''); eval(js); */ eval(xmlHttp.responseText); } } function addCodePromo() { code_promo = document.getElementById('inputCodePromo').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; fp = 0; 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 verifValiditePanier(url_valid,url_novalid) { if (url_valid == "PAYPAL") { message_html = '
Veuillez patientez ........
'; messageAlert('Traitement en cours !',message_html,'400','65'); } /* message_html = '
Veuillez patientez ........
'; messageAlert('Traitement en cours !',message_html,'400','65'); */ redirection_valid = url_valid; redirection_novalid = url_novalid; var url="/mkdg_system/onlineshop_verif_validite_panier.php?url_valid="+ url_valid + "&url_novalid=" + url_novalid; xmlHttp=GetXmlHttpObject(stateVerifValiditePanier); //redirection = link; xmlHttp.open("GET", url , true); xmlHttp.send(null); } function stateVerifValiditePanier() { if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { redirection = xmlHttp.responseText; if (redirection == redirection_novalid ) { document.location.href = redirection; } else { if (redirection_valid == 'PAYPAL') { var url2="/mkdg_system/onlineshop_write_precommande_paypal.php"; xmlHttp2=GetXmlHttpObject(stateWriteCommandForPaypal); //redirection = link; xmlHttp2.open("GET", url2 , true); xmlHttp2.send(null); } else { document.location.href = redirection; } } } } function stateWriteCommandForPaypal() { if (xmlHttp2.readyState==4 || xmlHttp2.readyState=="complete") { document.paypal_form.submit(); } } function productQte(id,type,product_id) { phase = 1; var url="/mkdg_system/onlineshop_qte_line.php?phase="+ phase +"&line=" + id + "&type=" + type + "&product_id=" + product_id; if (phase == "1") { xmlHttp=GetXmlHttpObject(stateChangedPrixTotal); idInput = id; idtype = type; } xmlHttp.open("GET", url , true); xmlHttp.send(null); } function productQteManual(id,product_id) { var qte = document.getElementById('line_qte_'+id).value; if ( (isNaN(qte) == false) && (qte > 0) && (qte.indexOf(".") < 0) ) { var url="/mkdg_system/onlineshop_qte_manual_line.php?line=" + id + "&qte=" + qte + "&product_id=" + product_id; xmlHttp=GetXmlHttpObject(stateChangedPrixTotalManual); idInput = id; xmlHttp.open("GET", url , true); xmlHttp.send(null); } else { message_html = 'Veuillez rentrer un chiffre entier supérieur à 0 !

'; message_html += '
'; message_html += ''; message_html += '
'; messageAlert('Erreur de saisie !',message_html,'400','100'); document.getElementById('line_qte_'+id).value = 1; productQteManual(id,product_id); } } function stateChangedPrixTotal() { if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { if (xmlHttp.responseText != "error") { document.getElementById('line_total_'+idInput).value = xmlHttp.responseText; productQtePhase2(idInput,idtype); changedPrixTotalHt(idInput,idtype); } else { message_html = 'Vous ne pouvez commander cette quantité. Le stock étant insuffisant pour ce produit !

'; message_html += '
'; message_html += ''; message_html += '
'; messageAlert('Information stock !',message_html,'400','130'); } } } function stateChangedPrixTotalManual() { if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { res = xmlHttp.responseText; array_res=res.split('+') if (array_res[0] != "error") { document.getElementById('line_total_'+idInput).value = array_res[0]; productTotalPanier(); changedPrixTotalHt(idInput,idtype); } else { document.getElementById('line_qte_'+idInput).value = array_res[1]; message_html = 'Vous ne pouvez commander cette quantité. Le stock étant insuffisant pour ce produit !

'; message_html += '
'; message_html += ''; message_html += '
'; messageAlert('Information stock !',message_html,'400','130'); } } } function changedPrixTotalHt(id,type) { phase = 2; var url="/mkdg_system/onlineshop_total_line_ht.php?phase="+ phase +"&line=" + id; xmlHttp2=GetXmlHttpObject(stateChangedPrixTotalHt); idInput = id; xmlHttp2.open("GET", url , true); xmlHttp2.send(null); } function stateChangedPrixTotalHt() { if (xmlHttp2.readyState==4 || xmlHttp2.readyState=="complete") { document.getElementById('line_total_ht_'+idInput).innerHTML = xmlHttp2.responseText; } } 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.getElementById('line_qte_'+idInput).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; productTotalPanierHT(); } } function productTotalPanierHT() { var url="/mkdg_system/onlineshop_total_panier_ht.php"; xmlHttp=GetXmlHttpObject(stateChangedTotalPanierHT); xmlHttp.open("GET", url , true); xmlHttp.send(null); } function stateChangedTotalPanierHT() { if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { document.getElementById("totalPanierHT").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; message_html = 'Le produit vient d\'être ajouté à votre panier !

'; message_html += '
'; message_html += '     '; message_html += ''; message_html += '
'; messageAlert('Produit ajouté !',message_html,'400','100'); productTotalPanier(); } } function stateChangedPanierClear() { if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { document.getElementById("nbProductPanier").innerHTML=xmlHttp.responseText; document.location.href='/fr/panier.php'; //document.location.reload(); } } function choicePaiement(el) { if (el == "paiement_cheque") { document.getElementById('paiement_cheque').style.display = "inline"; document.getElementById('paiement_30jours').style.display = "none"; document.getElementById('paiement_paypal').style.display = "none"; } if (el == "paiement_30jours") { document.getElementById('paiement_cheque').style.display = "none"; document.getElementById('paiement_30jours').style.display = "inline"; document.getElementById('paiement_paypal').style.display = "none"; } if (el == "paiement_paypal") { document.getElementById('paiement_cheque').style.display = "none"; document.getElementById('paiement_30jours').style.display = "none"; document.getElementById('paiement_paypal').style.display = "inline"; } } //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"; }