function Control_account_express(theForm,idclient) { if(theForm.nom.value=='') { alert("Please enter a name "); theForm.nom.focus(); return (false); } if(theForm.adresse.value=='') { alert("Please enter an address"); theForm.adresse.focus(); return (false); } if(theForm.idpays.value==0) { alert("Please enter a country "); theForm.idpays.focus(); return (false); } if(theForm.city.value==0) { alert("Please enter a city "); theForm.city.focus(); return (false); } if(theForm.idprovince.value==0) { alert("Please enter a state or province name"); theForm.idprovince.focus(); return (false); } if(theForm.zip.value==0) { alert("Please enter a zip or postal code"); theForm.zip.focus(); return (false); } if(theForm.email.value==0) { alert("Please enter an email address"); theForm.email.focus(); return (false); } if(!checkEmail(theForm.email.value)) { alert("Please enter a valid email address"); theForm.email.focus(); return(false); } if(theForm.email.value!=theForm.email2.value) { alert("E-mail error"); theForm.email.focus(); return (false); } if(theForm.phone.value==0) { alert("Please enter a telephone number"); theForm.phone.focus(); return (false); } if(theForm.password.value!=theForm.password2.value) { alert("Password error"); theForm.password.focus(); return (false); } if(idclient==0) { if(theForm.modalite.checked==false) { alert("I agree with the terms and conditions! "); //theForm.password.focus(); return (false); } } return (true); } function charger_province_account() { idpays=document.forms.form1.idpays.value; url="ajax_list_province.php?idpays="+idpays; // alert(url); ajax(url,'listprovinceaccount'); } function liste_date(numpanier,idproduit,idpersonne) { document.getElementById('temp').value = numpanier; url="ajax_list_date.php?idproduit="+idproduit+"&idpersonne="+idpersonne; // alert(url); ajax(url,31); } function charger_list_personnel() { url="ajax_list_compagnie_personnel.php"; ajax(url,21); } function Afficher_form_personne(num) { if(num==-1) { //nouvelle personne document.getElementById('zone_personnel_form').style.display = 'block'; document.getElementById('iframe_form_personnel').src = 'iframe_form_addressbook_personnel.php'; } else { if(document.getElementById('idpersonnel').value==0) { //choisir personne document.getElementById('iframe_form_personnel').src = 'vide.php'; document.getElementById('zone_personnel_form').style.display = 'none'; } else { //une personne document.getElementById('zone_personnel_form').style.display = 'block'; document.getElementById('iframe_form_personnel').src = 'iframe_form_addressbook_personnel.php?idp='+document.getElementById('idpersonnel').value; } } } function copylist(source,destination) { var listes=document.getElementById(source); var listed=document.getElementById(destination); listed.options.length=0; for (var i=0;i<=listes.options.length-2; i++) { nb=listed.options.length; listed.options.length++; listed.options[ nb]=new Option(); listed.options[ nb].value=listes.options[i].value; listed.options[ nb].text=listes.options[i].text; // alert(listes.options[i]); } } function charger_list_personne(idcompagnie) { url="ajax_list_compagnie_personne.php?idcompagnie="+idcompagnie; // alert(url); ajax(url,13); } function Control_account(theForm,idclient) { if(theForm.nom.value=='') { alert("Please enter a name "); theForm.nom.focus(); return (false); } if(theForm.adresse.value=='') { alert("Please enter an address"); theForm.adresse.focus(); return (false); } if(theForm.idpays.value==0) { alert("Please enter a country "); theForm.idpays.focus(); return (false); } if(theForm.city.value==0) { alert("Please enter a city "); theForm.city.focus(); return (false); } if(theForm.idprovince.value==0) { alert("Please enter a state or province name"); theForm.idprovince.focus(); return (false); } if(theForm.zip.value==0) { alert("Please enter a zip or postal code"); theForm.zip.focus(); return (false); } if(theForm.email.value==0) { alert("Please enter an email address"); theForm.email.focus(); return (false); } if(!checkEmail(theForm.email.value)) { alert("Please enter a valid email address"); theForm.email.focus(); return(false); } if(theForm.email.value!=theForm.email2.value) { alert("E-mail error"); theForm.email.focus(); return (false); } if(theForm.phone.value==0) { alert("Please enter a telephone number"); theForm.phone.focus(); return (false); } if(theForm.password.value==0) { alert("Please enter a password "); theForm.password.focus(); return (false); } if(theForm.password.value!=theForm.password2.value) { alert("Password error"); theForm.password.focus(); return (false); } if(idclient==0) { if(theForm.modalite.checked==false) { alert("I agree with the terms and conditions! "); //theForm.password.focus(); return (false); } } return (true); } function charger_province_i() { idpays=document.forms.form1.idpays.value; url="ajax_list_province.php?idpays="+idpays; ajax(url,'listprovince2'); } function charger_provinceform2() { idpays=document.forms.form2.idpays.value; url="ajax_list_province.php?idpays="+idpays; ajax(url,'listprovince'); } function Control_new_account(theForm) { if(theForm.nom.value=='') { alert("Please enter a name "); theForm.nom.focus(); return (false); } if(theForm.adresse.value=='') { alert("Please enter a name "); theForm.adresse.focus(); return (false); } return (true); } function changement_personne(idpersonne) { if(idpersonne==-1) { //nouvelle personne document.getElementById('zone_compagnie_personne_form').style.display = 'block'; document.getElementById('iframe_form_pers').src = 'iframe_form_addressbook_personn.php?idc='+document.getElementById('idcompagnie').value; } else { if(idpersonne==0) { //choisir personne document.getElementById('iframe_form_pers').src = 'vide.php'; document.getElementById('zone_compagnie_personne_form').style.display = 'none'; } else { //une personne document.getElementById('iframe_form_pers').src = 'iframe_form_addressbook_personn.php?idc='+document.getElementById('idcompagnie').value+'&idp='+document.getElementById('idpersonne').value; document.getElementById('zone_compagnie_personne_form').style.display = 'block'; // afficher_liste_personne_compagnie(); } } } function afficher_liste_personne_compagnie() { idcompagniel=document.getElementById('idcompagnie').value; document.getElementById('zone_compagnie_lpersonne').style.display = 'block'; document.getElementById('zone_basket').style.display = 'block'; url="ajax_list_compagnie_personne.php?idcompagnie="+idcompagnie; ajax(url,13); } function masquer_liste_panier() { } function charger_list_compagnie() { url="ajax_list_compagnie.php"; // alert(url); ajax(url,11); } function charger_province(idpro) { idpays=document.forms.formiframe1.idpays.value; url="ajax_list_province.php?idpays="+idpays; ajax(url,10); } function Afficher_etape1_form(num) { if(num==-1) { //nouvelle compagnie document.getElementById('zone_compagnie_form').style.display = 'block'; document.getElementById('zone_compagnie_lpersonne').style.display = 'none'; document.getElementById('iframe_form_comp').src = 'iframe_form_addressbook_compagny.php'; } else { if(document.getElementById('idcompagnie').value==0) { //choisir compagnie document.getElementById('iframe_form_comp').src = 'vide.php'; document.getElementById('zone_compagnie_form').style.display = 'none'; } else { //une compagnie // document.getElementById('iframe_form_comp').src = 'iframe_form_addressbook_compagny.php?idc='+document.getElementById('idcompagnie').value; document.getElementById('iframe_form_comp').src = 'iframe_form_addressbook_info_compagny.php?idc='+document.getElementById('idcompagnie').value; document.getElementById('zone_compagnie_form').style.display = 'block'; afficher_liste_personne_compagnie(); charger_list_personne(document.getElementById('idcompagnie').value); } } } function Afficher_etape1(num) { document.getElementById('zone_basket').style.display = 'none'; document.getElementById('zone_compagnie_form').style.display = 'none'; if(num==2) { document.getElementById('zone_compagnie').style.display = 'block'; document.getElementById('zone_personnel').style.display = 'none'; } if(num==1) { document.getElementById('zone_compagnie').style.display = 'none'; document.getElementById('zone_personnel').style.display = 'block'; charger_list_personnel(); } } function ControlV1(theForm) { total=0; nb_adresse=theForm.nb_adresse.value; for(t=0;t<=nb_adresse-1;t++) { champ='adresse_nom'+(t+1); if(document.getElementById(champ).value=='') { alert("Please enter a name "); document.getElementById(champ).focus(); return (false); } qtyl=document.getElementById('qty'+(t+1)).value*1 total=total+qtyl; } if(theForm.qty.value!=total) { alert("The quantity ordered does not equal the quantity shipped. Please verify "); return (false); } /* if (theForm.prenom.value == "") { } */ return(true); } function change_qty(nb) { if(nb>1) { var i=0; var liste=document.forms.form1.nb_adresse; liste.options.length=0; for(i=0;i<=nb-1;i++) { liste.options.length++; liste.options[i]=new Option(i+1,i+1); } document.getElementById('zonehowmany').style.display = 'block'; } else { document.getElementById('zonehowmany').style.display = 'none'; } } function list_name_shipping(num,name_zone,name_zonel) { if(num==0) { document.getElementById(name_zone).style.display = 'block'; document.getElementById(name_zone).value =""; } else { document.getElementById(name_zone).style.display = 'none'; document.getElementById(name_zone).value = document.getElementById(name_zonel).value; } } function doBlock(srcElement) { if(srcElement.bgColor == "#dddddd") { srcElement.bgColor = ""; }else{ srcElement.bgColor = "#dddddd"; } } function nb_zone_adresse_name(nb,qty) { url="ajax_zone_adresse.php?nb="+nb+"&qty="+qty; rep=ajax(url,3); } function nb_shipping(nb) { if(nb>1) { var i=0; var liste=document.forms.form1.nb_adresse; liste.options.length=0; for(i=0;i<=nb-1;i++) { liste.options.length++; liste.options[i]=new Option(i+1,i+1); } document.getElementById('howmany').style.display = 'block'; } else { document.getElementById('howmany').style.display = 'none'; } } function toggle(){ var a = document.getElementById('shipping') var b = document.getElementById('shippingBT') if(a.style.display == 'none'){ a.style.display = 'block' b.style.display = 'none' }else{ a.style.display = 'none' b.style.display = 'block' } } function popup(pageName, w, h) { //var winl = (screen.width - w) / 2; //var wint = (screen.height - h) / 2; var winl = 10; var wint = 10; window.open(pageName,'','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width='+w+',height='+h+',left='+winl+',top='+wint+''); } function afficher_shipping(idshipping,num) { if(num!=0) { url="ajax_shipping.php?idshipping="+idshipping+"&num="+num; // alert(url); rep=ajax(url,1); } } function calcul_prix_produit() { var prix_g=document.forms.form1.prixgadget.value * 1; //prix gadget var prix_o=document.forms.form1.prixoption.value * 1; //prix option var prix_p=document.forms.form1.prixproduit.value * 1; //prix produit // document.forms.form1.total.value=prix_g+prix_o+prix_p; // valeur=prix_g+prix_o+prix_p document.forms.form1.total.value=prix_g+prix_o; valeur=prix_g+prix_o; document.getElementById("infoprix").innerHTML = valeur.toFixed(2)+" $"; if(prix_g==0) { document.getElementById('showgadget').style.display = 'none'; } else { document.getElementById('showgadget').style.display = 'block'; } } function add_gadget(num,prix) { valeur=document.forms.form1.numgadget.value; var tab=valeur.split(","+num+","); if(tab.length==1) { var prix1=document.forms.form1.prixgadget.value * 1; document.forms.form1.prixgadget.value=prix1+prix; valeur=document.forms.form1.numgadget.value+num+","; document.forms.form1.numgadget.value=valeur; url="ajax_listgadget.php?num="+valeur; // alert(num+"-"+valeur+"-"+url); rep=ajax(url,2); } calcul_prix_produit(); } function delete_gadget(num,prix) { var prix1=document.forms.form1.prixgadget.value * 1; document.forms.form1.prixgadget.value=prix1-prix; var reg=new RegExp(","+num+",", "g"); valeur=document.forms.form1.numgadget.value; valeur=valeur.replace(reg,",0,"); document.forms.form1.numgadget.value=valeur; url="ajax_listgadget.php?num="+valeur; // alert(num+"-"+valeur+"-"+url); rep=ajax(url,2); calcul_prix_produit(); } function ajax(url,numfct) { var req = null; if (window.XMLHttpRequest) { req = new XMLHttpRequest(); if (req.overrideMimeType) { req.overrideMimeType('text/xml'); } } else if (window.ActiveXObject) { try { req = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { req = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {} } } req.onreadystatechange = function() { // document.ajax.dyn.value="Wait server..."; if(req.readyState == 4) { if(req.status == 200) { //document.ajax.dyn.value="Received:" + req.responseText; var response1 = req.responseText; //alert(response1); if(numfct=='listprovince2') { var liste=document.forms.form1.idprovince; if(response1=="") { document.getElementById('zoneprovince').style.display = 'none'; liste.options.length=0; nb=liste.options.length; liste.options.length++; liste.options[ nb]=new Option("Choose","-1"); //document.forms.form1.idprovince=0; } else { document.getElementById('zoneprovince').style.display = 'block'; liste.options.length=0; nb=liste.options.length; liste.options.length++; liste.options[ nb]=new Option("Choose",""); var reg=new RegExp("[;]+", "g"); var tableau=response1.split(reg); for (var i=0;i<=tableau.length-2; i++) { nb=liste.options.length; liste.options.length++; liste.options[ nb]=new Option(tableau[i],tableau[i+1]); i++; } document.forms.form1.idprovince.value=document.forms.form1.idprovince_init.value; } } if(numfct=='listprovince') { var liste=document.forms.form2.idprovince; if(response1=="") { document.getElementById('zoneprovince').style.display = 'none'; liste.options.length=0; nb=liste.options.length; liste.options.length++; liste.options[ nb]=new Option("Choose","0"); document.forms.form1.idprovince=0; } else { document.getElementById('zoneprovince').style.display = 'block'; liste.options.length=0; nb=liste.options.length; liste.options.length++; liste.options[ nb]=new Option("Choose",""); var reg=new RegExp("[;]+", "g"); var tableau=response1.split(reg); for (var i=0;i<=tableau.length-2; i++) { nb=liste.options.length; liste.options.length++; liste.options[ nb]=new Option(tableau[i],tableau[i+1]); i++; } } } if(numfct==10) { var liste=document.forms.formiframe1.idprovince; if(response1=="") { document.getElementById('zoneprovince').style.display = 'none'; liste.options.length=0; nb=liste.options.length; liste.options.length++; liste.options[ nb]=new Option("Choose","0"); document.forms.formiframe1.idprovince=0; } else { document.getElementById('zoneprovince').style.display = 'block'; liste.options.length=0; nb=liste.options.length; liste.options.length++; liste.options[ nb]=new Option("Choose",""); var reg=new RegExp("[;]+", "g"); var tableau=response1.split(reg); for (var i=0;i<=tableau.length-2; i++) { nb=liste.options.length; liste.options.length++; liste.options[ nb]=new Option(tableau[i],tableau[i+1]); i++; } document.forms.formiframe1.idprovince.value=document.forms.formiframe1.idprovince_init.value; } } if(numfct==11) { var liste=document.getElementById('idcompagnie'); if(response1=="") { liste.options.length=0; nb=liste.options.length; liste.options.length++; liste.options[ nb]=new Option("Choose","0"); document.getElementById('idcompagnie').value=0; } else { liste.options.length=0; nb=liste.options.length; liste.options.length++; liste.options[ nb]=new Option("Select a company ",""); var reg=new RegExp("[;]+", "g"); var tableau=response1.split(reg); for (var i=0;i<=tableau.length-2; i++) { nb=liste.options.length; liste.options.length++; liste.options[ nb]=new Option(tableau[i],tableau[i+1]); i++; } } //liste.options.length++; nb=liste.options.length; liste.options[ nb]=new Option("New company","-1"); //afficher_liste_personne_compagnie(); idct=document.getElementById('temp_idcompagnie').value; // alert(idct); if(document.getElementById('temp_idcompagnie').value!=0) { idc=document.getElementById('temp_idcompagnie').value; // alert(idc); document.getElementById('idcompagnie').value=idc; document.getElementById('iframe_form_comp').src = 'iframe_form_addressbook_info_compagny.php?idc='+idc; document.getElementById('zone_compagnie_form').style.display = 'block'; afficher_liste_personne_compagnie(); charger_list_personne(idc); } } //afficher_liste_personne_compagnie if(numfct==13) { var liste=document.getElementById('idpersonne'); if(response1=="") { liste.options.length=0; nb=liste.options.length; liste.options.length++; liste.options[ nb]=new Option("Select a name","0"); document.getElementById('idpersonne').value=0; } else { liste.options.length=0; nb=liste.options.length; liste.options.length++; liste.options[ nb]=new Option("Select a name",""); var reg=new RegExp("[;]+", "g"); var tableau=response1.split(reg); for (var i=0;i<=tableau.length-2; i++) { nb=liste.options.length; liste.options.length++; liste.options[ nb]=new Option(tableau[i],tableau[i+1]); i++; } } //liste.options.length++; nb=liste.options.length; liste.options[ nb]=new Option("New name","-1"); // nbp=document.getElementById("nb_panier").value; nbp=document.forms.panier.nb_panier.value; for (var i=1;i<=nbp; i++) { copylist('idpersonne','idpersonne'+i); } } if(numfct==1) { document.getElementById("zoneshipping").innerHTML = response1; } if(numfct==2) { document.getElementById("zonegadget").innerHTML = response1; } if(numfct==3) { document.getElementById("zone_adresse_name").innerHTML = response1; } if(numfct==21) { var liste=document.getElementById('idpersonnel'); if(response1=="") { liste.options.length=0; nb=liste.options.length; liste.options.length++; liste.options[ nb]=new Option("Select a name","0"); document.getElementById('idpersonne').value=0; } else { liste.options.length=0; nb=liste.options.length; liste.options.length++; liste.options[ nb]=new Option("Select a name",""); var reg=new RegExp("[;]+", "g"); var tableau=response1.split(reg); for (var i=0;i<=tableau.length-2; i++) { nb=liste.options.length; liste.options.length++; liste.options[ nb]=new Option(tableau[i],tableau[i+1]); i++; } } //liste.options.length++; nb=liste.options.length; liste.options[ nb]=new Option("New name","-1"); nbp=document.forms.panier.nb_panier.value; if(nb>0) { document.getElementById('zone_basket').style.display = 'block'; } for (var i=1;i<=nbp; i++) { copylist('idpersonnel','idpersonne'+i); } } if(numfct==31) { num=document.getElementById('temp').value ; var liste=document.getElementById('date'+num); if(response1=="") { } else { liste.options.length=0; nb=liste.options.length; liste.options.length++; liste.options[ nb]=new Option("Choose",""); var reg=new RegExp("[;]+", "g"); var tableau=response1.split(reg); for (var i=0;i<=tableau.length-2; i++) { nb=liste.options.length; liste.options.length++; liste.options[ nb]=new Option(tableau[i],tableau[i+1]); i++; } } } if(numfct=='listprovinceaccount') { var liste=document.forms.form1.idprovince; if(response1=="") { liste.options.length=0; nb=liste.options.length; liste.options.length++; liste.options[ nb]=new Option("Choose","0"); document.forms.form1.idprovince=0; } else { liste.options.length=0; nb=liste.options.length; liste.options.length++; liste.options[ nb]=new Option("Choose",""); var reg=new RegExp("[;]+", "g"); var tableau=response1.split(reg); for (var i=0;i<=tableau.length-2; i++) { nb=liste.options.length; liste.options.length++; liste.options[ nb]=new Option(tableau[i],tableau[i+1]); i++; } } } } else { //document.ajax.dyn.value="Error: returned status code " + req.status + " " + req.statusText; } } }; req.open("GET", url, true); req.send(null); } function checkEmail(em){ var retour=true; if ((em.indexOf("@")==-1)||(em.indexOf(".")==-1)){ retour=false; } return retour; }