﻿function nav(goTo,qS)
{
    var titre="",url="";
    switch(goTo)
    {
        case 1:
            window.location.href="LstManifsFormules.aspx?" + rndId() + "&wId=" + document.getElementById("wId").value + (qS ? qS : "");
            break;
        case 2:
            window.location.href="Resa.aspx?" + rndId() + (qS ? qS : "");
            break;  
        case 3:
            window.location.href="Panier.aspx?" + rndId();
            break;
        case 4:
            url = document.getElementById("URLTrtmt_txtURLIdentification").value;
            if (url == "")
                window.location.href = "Identification.aspx?" + rndId() + "&m=i" + (qS ? qS : "");
            else
                window.location.href = url + (qS ? qS : "");
            //{   
            /*if (!URLexists(url))
            window.location.href="Identification.aspx?" + rndId() + "&m=i";
            else
            {*/
            /*      if ($("#TB_window")[0])
            $("#TB_window")[0].innerHTML = "";
            titre=document.getElementById("URLTrtmt_txtTypeClubSalle").value + " - " +
            dspt("fc=web&trslt=true",null,null,"key=web_vente_nav_lbl_BilletterieEnLigne") + " - " +
            document.getElementById("URLTrtmt_txtNomClubSalle").value + " - " +
            dspt("fc=web&trslt=true",null,null,"key=Resa_lbl_Identification");
            tb_show(titre, url + "?TB_iframe=true&height=700&width=900&lng=FR", false);*/
            /*}*/
            //}
            break;        
        case 5:
            url=document.getElementById("URLTrtmt_txtURLIdentification").value;
            if (url=="")
                window.location.href="Client.aspx?" + rndId() + "&i=ins&mf=v&ml=v";
            else            
                window.location.href=url;
            break;
        case 6:
            url=document.getElementById("URLTrtmt_txtURLIdentification").value;
            if (url=="")
                window.location.href="Client.aspx?" + rndId() + "&mf=v&ml=v" + (qS ? qS : "");
            else            
                window.location.href=url;
            break;
        case 7:
            url=document.getElementById("URLTrtmt_txtURLIdentification").value;
            if (url=="")
                window.location.href="Client.aspx?" + rndId() + "&mf=m&ml=v";
            else            
                window.location.href=url;
            break;
        case 8:
            url=document.getElementById("URLTrtmt_txtURLIdentification").value;
            if (url=="")
                window.location.href="Client.aspx?" + rndId() + "&mf=v&ml=m";
            else            
                window.location.href=url;
            break;        
        case 9:                    
            window.location.href="Paiement.aspx?" + rndId();
            break;
        case 10:            
            window.location.href="Confirmation.aspx?" + rndId() + (qS ? qS : "");
            break;
        case 11:
            window.location.href="Expired.aspx?" + rndId();
            break;
        case 12:
            window.location.href="LstCommandes.aspx?" + rndId();
            break;
        case 13:
            window.location.href="Client.aspx?" + rndId() + "&mf=pwd";
            break;
        case 14:
            window.location.href="Client.aspx?" + rndId() + "&mf=clBenef";
            break;
        case 20:
            window.location.href = "LstCommandesClientEspace.aspx?" + rndId() + (qS ? qS : "");
            break;
        case 98:
            window.open("http://www.datasport.fr");
            break; 
        case 99:
            window.open("http://www.datasport.fr");
            break;    
    }
}
function rndId() {
    return "id=" + Math.floor(10000000 * Math.random());
}
function URLexists(url)
{
    try
    {
     if(window.XMLHttpRequest) // FIREFOX
          xhr_object = new XMLHttpRequest();
     else if(window.ActiveXObject) // IE
          xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
     else
          return(false);
     xhr_object.open("GET", url, false);
     xhr_object.send(null);
     if(xhr_object.readyState == 4) return(xhr_object.responseText);
     else return(false);
    }
    catch(err){return false};
}
function res()
{
   dspt("fc=web&res=true",null,null,"res="+screen.width+"x"+screen.height);
   window.location.href=window.location.href;
}
function setTitle(n,onoff)
{
    switch(onoff)
    {
        case "on":
            document.getElementById("nomEtpOff").className="nomEtpOff" + n;
            switch(document.getElementById("lang").value)
            {
                case "":
                case "FR":
                    document.getElementById("nomEtpOff").style.background="url(../images/web/"+document.getElementById("wId").value+"/nomEtp"+n+"_off.gif)";                    
                    break;
                default:
                    document.getElementById("nomEtpOff").style.background="url(../images/web/"+document.getElementById("wId").value+"/nomEtp"+n+"_"+document.getElementById("lang").value+"_off.gif)";
                    break;                    
            }     
            document.getElementById("nomEtpOff").style.backgroundRepeat="no-repeat";               
            break;
        case "off":
            document.getElementById("nomEtpOff").className="";
            document.getElementById("nomEtpOff").style.backgroundImage="";
            break;
    }
}
function setLangue(s,onoff)
{
    switch(onoff)
    {
        case "on":
            document.getElementById("langue_"+s).className="langue_"+s+"_on";
            break;
        case "off":
            if (s != document.getElementById("currentLang").value) {
                document.getElementById("langue_" + s).className = "langue_" + s + "_off";
            }
            break;
    }
}
function detailFormule(f)
{   
    showInfos("divinfos",dspt("fc=web&detailformule=true",null,null,"f="+f),null,-100);        
}
function detailFormulePanier(f)
{   
    showInfos("divinfos",dspt("fc=web&detailformulepanier=true",null,null,"f="+f),10,null);
}
function chkTypePn(from,type,m,s,f,prf){
    var ret=dspt("fc=web&chktypepn=true",null,null,"from="+from+"&type="+type+"&m="+m+"&s="+s+"&f="+f+"&prf="+prf);
    var b;
    switch(ret)
    {
        case "0":
            b=true;
            break;
        case "-1":
            alert(dspt("fc=web&trslt=true",null,null,"key=web_chkTypePn_lbl_VotrePanierContientDesPlaces")+"\n"+
                  dspt("fc=web&trslt=true",null,null,"key=web_chkTypePn_lbl_VousNePouvezPasReserver")+"\n"+
                  dspt("fc=web&trslt=true",null,null,"key=web_chkTypePn_lbl_VeuillezFinaliserVotreCommandeActuelle"));                    
            b=false;
            break;
        default:
            alert(dspt("fc=web&trslt=true",null,null,"key=web_vente_erreur")+"\n"+
                  dspt("fc=web&trslt=true",null,null,"key=web_vente_reserver_VeuillezRenouvelerOperation")+"\n"+
                  dspt("fc=web&trslt=true",null,null,"key=web_vente_reserver_SiLePbPersiste"));                    
            b=false;
            break;
    }
    return b;
}
function disp(type,m,s,f,ap,prf)
{
    var msg = "";
    var ret;
    switch(type)
    {
        case "m":
            if (!chkTypePn("disp",type,m,s,f,prf))
                return;
            ret=dspt("fc=web&disp=true",null,null,"type="+type+"&m="+m+"&s="+s+"&prf="+prf);
            switch(ret)
            {
                case "0":
                    nav(2,"&ap="+ap);
                    break;
                case "-12":
                    msg=dspt("fc=web&trslt=true",null,null,"key=web_vente_disp_resaImpossible")+"\n"+
                        dspt("fc=web&trslt=true",null,null,"key=web_vente_AucunePlaceDispoManif");
                    alert(msg);
                    break;
                default:
                    msg=dspt("fc=web&trslt=true",null,null,"key=web_vente_erreur")+"\n"+
                        dspt("fc=web&trslt=true",null,null,"key=web_vente_reserver_VeuillezRenouvelerOperation")+"\n"+
                        dspt("fc=web&trslt=true",null,null,"key=web_vente_reserver_SiLePbPersiste");
                    alert(msg);
                    nav(1);
                    break;
            }
            break;
        case "s":
            /*s=getSelRb(document.getElementsByName("rbSeances_"+m));
            if (s=="-1"){
                msg=dspt("fc=web&trslt=true",null,null,"key=web_vente_disp_ChoixSeanceObligatoire")+".\n"+
                    dspt("fc=web&trslt=true",null,null,"key=web_vente_disp_VeuillezSelectionnerSeance")+".";        
                alert(msg);        
                return;
            }*/
            if (!chkTypePn("disp","m",m,s,f,prf))
                return;
            ret=dspt("fc=web&disp=true",null,null,"type=m&m="+m+"&s="+s+"&prf="+prf);
            switch(ret)
            {
                case "0":                    
                    nav(2,"&ap="+dspt("fc=web&typeres=true"));
                    break;
                case "-12":
                    msg=dspt("fc=web&trslt=true",null,null,"key=web_vente_disp_resaImpossible")+"\n"+
                        dspt("fc=web&trslt=true",null,null,"key=web_vente_AucunePlaceDispoManif");
                    alert(msg);
                    break;
                default:
                    msg=dspt("fc=web&trslt=true",null,null,"key=web_vente_erreur")+"\n"+
                        dspt("fc=web&trslt=true",null,null,"key=web_vente_reserver_VeuillezRenouvelerOperation")+"\n"+
                        dspt("fc=web&trslt=true",null,null,"key=web_vente_reserver_SiLePbPersiste");
                    alert(msg);
                    nav(1);
                    break;
            }
            break;
        case "f":
            if (!chkTypePn("disp",type,m,s,f,prf))
                return;
            ret=dspt("fc=web&disp=true",null,null,"type="+type+"&f="+f+"&prf="+prf);
            switch (ret)
            {
                case "0":
                    nav(2,"&ap="+ap);
                    break;
                case "-1":
                    msg=dspt("fc=web&trslt=true",null,null,"key=web_vente_disp_aucunTarifDispo");
                    alert(msg);
                    break;
                case "-2":
                case "-12":
                    msg=dspt("fc=web&trslt=true",null,null,"key=web_vente_disp_resaImpossible")+"\n"+
                        dspt("fc=web&trslt=true",null,null,"key=web_vente_AucunePlaceDispoFormule");
                    alert(msg);			        
			        break;
			    default:
			        msg=dspt("fc=web&trslt=true",null,null,"key=web_vente_erreur")+"\n"+
                        dspt("fc=web&trslt=true",null,null,"key=web_vente_reserver_VeuillezRenouvelerOperation")+"\n"+
                        dspt("fc=web&trslt=true",null,null,"key=web_vente_reserver_SiLePbPersiste");
                    alert(msg);
                    nav(1);
                    break;
            } 
            break;
    }
}
function showSeances(m,s,prf)
{    
    dspt("fc=web&resaseance=true",null,null,"m="+m);
    nav(1,"&sce=true&m="+m+"&s="+s+"&prf="+prf);
}
function calSeances(prf,m,s,y,mth)
{
    wait(true);
    document.getElementById("grdManifsFormules").innerHTML=dspt("fc=web&calseances=true",null,null,"prf="+prf+"&m="+m+"&s="+s+"&y="+y+"&mth="+mth);    
    wait(false);
}
function planZone(t,z)
{
    window.open("WebPlanGeneral.aspx?"+rndId()+"&t="+t+"&z="+z,
                "Plan",
                "width=820,height=570,menubar=no,location=no,resizable=yes,scrollbars=yes,status=no");
}
function dispoPlan(t,m,s,f,p)
{
    showInfos("divinfos",dspt("fc=web&dispoplan=true",null,null,
                              "typeResa="+t+"&m="+m+"&s="+s+"&f="+f+"&p="+p),"bulle","bulle");
}
function setInfoZone(cp,cc){
    var z=getSel(document.getElementById("lstzones$"+cp+"$"+cc),"val");
    var i=0;
    if (document.getElementById("imgInfoZone$"+z+"$"+cp+"$"+cc))
        document.getElementById("imgInfoZone$"+z+"$"+cp+"$"+cc).style.display="inline";   
    var lstImg=document.getElementsByName("imgInfoZone$"+cp+"$"+cc);
    if (lstImg.length>0)
    {
        if (lstImg[0]!=null)
	    {
	        for (i=0;i<lstImg.length;i++)
	            if (lstImg[i].id!="imgInfoZone$"+z+"$"+cp+"$"+cc)
		            lstImg[i].style.display="none";   
        }
        else
        {
	        if (lstImg!=null)
	            if (lstImg.id!="imgInfoZone$"+z+"$"+cp+"$"+cc)
			        lstImg.style.display="none";   
        }
    }    
    
    if (document.getElementById("lstnb$"+z+"$"+cp+"$"+cc))
        document.getElementById("lstnb$"+z+"$"+cp+"$"+cc).style.display="inline";   
    var lstNb=document.getElementsByName("lstnb");
    if (lstNb.length>0)
    {
        if (lstNb[0]!=null)
        {
            for (i=0;i<lstNb.length;i++)
                if (lstNb[i].id!="lstnb$"+z+"$"+cp+"$"+cc)
                    if ((lstNb[i].id.split('$')[0]=="lstnb")&&(lstNb[i].id.split('$')[2]==cp)&&(lstNb[i].id.split('$')[3]==cc))
	                {
	                    lstNb[i].style.display="none";
	                    lstNb[i].selectedIndex=0;
	                }
        }
        else
        {
            if (lstNb!=null)
                if (lstNb.id!="lstnb$"+z+"$"+cp+"$"+cc)
                    if ((lstNb.id.split('$')[0]=="lstnb")&&(lstNb.id.split('$')[2]==cp)&&(lstNb.id.split('$')[3]==cc))
		            {
		                lstNb.style.display="none";   
		                lstNb.selectedIndex=0;
                    }
        }
    }
}
function reserver(type,opt,m,s)
{
    if (!chkTypePn("resa",type,null,null,null,null))
        return;
        
    var nbEltsResa=getInfosReservation();
    var nbm=document.getElementById("nbm").value;
    var msg="";
    switch(type)
    {
        case "m":
            if (nbEltsResa == 0) {
                msg = dspt("fc=web&trslt=true", null, null, "key=web_vente_reserver_SelectionnezUneOuPlusieursPlaces");
                alert(msg);
                return;
            }
            if (nbEltsResa == -1) {
                clearResa();
                msg = dspt("fc=web&trslt=true", null, null, "key=web_vente_reserver_DispoManifInsuffisante") + "\n" +
		            dspt("fc=web&trslt=true", null, null, "key=web_vente_reserver_VeuillezModifierResa");
                alert(msg);
                return;
            }
            if (nbEltsResa > nbm) {
                clearResa();
                msg = dspt("fc=web&trslt=true", null, null, "key=web_vente_reserver_VousNePouvezPasReserver") + " " + nbm + " " +
	                dspt("fc=web&trslt=true", null, null, "key=web_vente_reserver_PlacesPourCetteManif");
                alert(msg);
                return;
            }
            break;
	    case "f":
	        if (nbEltsResa==0)
	        {
	            msg=dspt("fc=web&trslt=true",null,null,"key=web_vente_reserver_SelectionnezUneOuPlusieursFormules");
                alert(msg);		        
		        return;
	        }
	        if (nbEltsResa==-1)
	        {
		        clearResa();
		        msg=dspt("fc=web&trslt=true",null,null,"key=web_vente_reserver_DispoFormuleInsuffisante")+"\n"+
		            dspt("fc=web&trslt=true",null,null,"key=web_vente_reserver_VeuillezModifierResa");
                alert(msg);
		        return;
	        }
	        if (nbEltsResa>nbm)
	        {
	            clearResa();
	            msg=dspt("fc=web&trslt=true",null,null,"key=web_vente_reserver_VousNePouvezPasReserver")+" "+nbm+" "+
	                dspt("fc=web&trslt=true",null,null,"key=web_vente_reserver_Formules")+" '"+document.getElementById("nomF").value + "'.";
	            alert(msg);	            
	            return;
	        }
	        break;
    }
    var resa=new Array(tNbPlZCp.length);
    var i,j;
    for (i=0,j=0;i<tNbPlZCp.length;i++)
        if (tNbPlZCp[i]!=0)
        {
            resa[j]=tNbPlZCp[i]+"|"+tIdZCp[i].split('|')[1]+"|"+tIdZCp[i].split('|')[0]+"|"+tResaZCp[i];		
	        j++;			
        }	    
    if (resa==null) return;
    
    var ret=dspt("fc=web&resa=true",null,null,
	             "type="+type+"&resa="+resa+"&nbm="+nbm+"&opt="+opt+"&m="+m+"&s="+s);
    switch (ret)
    {
        case "0":
            switch(opt)
            {
                case "plcmtLibrePlan":
                    nav(2,"&ap=2");
                    break;
                default:
                   nav(parseInt(dspt("fc=web&navresa=true")));
                    break;
            }
	        break;
	    case "1":            
            nav(9);
	        break;   
	    case "-10":
        case "-12":
        case "-13":
        case "-14":
        case "-15":
        case "-16":
        case "-17":
            clearResa();
            msg=dspt("fc=web&trslt=true",null,null,"key=web_vente_reserver_VotreResaNonAboutie")+"\n"+
                dspt("fc=web&trslt=true",null,null,"key=web_vente_reserver_VeuillezRenouvelerOperation")+"\n"+
                dspt("fc=web&trslt=true",null,null,"key=web_vente_reserver_SiLePbPersiste");
	        alert(msg);
	        switch(opt)
            {
                case "plcmtLibrePlan":
                    nav(2,"&ap=2");
                    break;
                default:
                    nav(2);
                    break;
            }	        
	        break;  
	    case "-20":
	        clearResa();
	        msg=dspt("fc=web&trslt=true",null,null,"key=web_vente_reserver_LePanierEnCours")+"\n"+
	            dspt("fc=web&trslt=true",null,null,"key=web_vente_reserver_VeuillezPayerVotreCommande")+"\n\n"+
	            dspt("fc=web&trslt=true",null,null,"key=web_vente_reserver_SiVousSouhaitezAbandonner")+"\n"+
	            dspt("fc=web&trslt=true",null,null,"key=web_vente_reserver_VidezLePanier");
	        alert(msg);
	        switch(opt)
            {
                case "plcmtLibrePlan":
                    nav(2,"&ap=2");
                    break;
                default:
                    nav(2);
                    break;
            }	        
	        break;     
	    default:
            alert(ret);
            switch(opt)
            {
                case "plcmtLibrePlan":
                    nav(2,"&ap=2");
                    break;
                default:
                    nav(parseInt(dspt("fc=web&navresa=true")));
                    break;
            }
	        break;
    }
}
function reserverPlacesSpecif(t)
{
    if (!chkTypePn("resa",t,null,null,null,null))
        return;
        
    var cc="";
    var lstCC="";
    var rbTarifs=document.getElementsByName("rbTarifs");    
    if (rbTarifs)
    {
        for (i = 0; i < rbTarifs.length; i++)
        {
            cc=getSelRb(document.getElementsByName("rbTarifs_" + rbTarifs[i].id));
            if (cc=="-1")
            {
                msg=dspt("fc=web&trslt=true",null,null,"key=web_vente_reserverPlacesSpecif_ChoixTarifObligatoire")+" ";
                switch(t)
                {
                    case "m":
                        msg+=dspt("fc=web&trslt=true",null,null,"key=web_vente_reserverPlacesSpecif_PourChaquePlace")+".\n";
                        break;
                    case "f":
                        msg+=dspt("fc=web&trslt=true",null,null,"key=web_vente_reserverPlacesSpecif_PourChaqueFormule")+".\n";        
                        break;
                }
                msg+=dspt("fc=web&trslt=true",null,null,"key=web_vente_reserverPlacesSpecif_VeuillezSelectionnerTarif")+".";        
                alert(msg);        
                return;
            }
            lstCC+=rbTarifs[i].id+"|"+cc+";";
        }
    }        
    var ret=dspt("fc=web&resaplspecif=true",null,null,"t=" + t + "&lstCC=" + lstCC);
    switch(ret.split('|')[0])
    {
        case "0":       
            nav(parseInt(dspt("fc=web&navresa=true")));
	        break;      
	    case "-50":
	        alert(dspt("fc=web&trslt=true",null,null,"key=DsptWeb_ReservationAutomatique_lbl_ReservationImpossible")+".\n"+
	              dspt("fc=web&trslt=true",null,null,"key=web_vente_reserverPlacesSpecif_lbl_LesPlacesDeVotreFormule"));	        
	        break;  
        default:
            if (ret.split('|')[1])
                alert(ret.split('|')[1]);
            else
                alert(dspt("fc=web&trslt=true",null,null,"key=web_vente_erreur")+"\n"+
                      dspt("fc=web&trslt=true",null,null,"key=web_vente_reserver_VeuillezRenouvelerOperation")+"\n"+
                      dspt("fc=web&trslt=true",null,null,"key=web_vente_reserver_SiLePbPersiste"));
            //nav(parseInt(dspt("fc=web&navresa=true")));
            break;	
    }
}
function getInfosReservation()
{
    var ret=0;
    
    var field=document.getElementsByName("lstnb");    
    
    var z;
    var cp;
    var cc;
    var nb;
    var indZCp;
    var sumNbZCp=0;
    var val;
    var i=0;
    
    if (field[i] != null)
    {
	    for (i=0;i<field.length;i++)
	    {	        
		    val=field[i].value;
		    if (val=="")
			    val="0";			
			nb=parseInt(val);
            if (nb!=0)
            {
                z=field[i].id.split('$')[1];
	            cp=field[i].id.split('$')[2];	            
	            cc=field[i].id.split('$')[3];
	            
	            indZCp=getIndiceZCp(z,cp);                				
                tResaZCp[indZCp]+=cc+";"+nb+";";
                sumNbZCp=parseInt(tNbPlZCp[indZCp])+nb;
				
                if (sumNbZCp>tDispoZCp[indZCp])
                    return -1;
                else
                {
                    tNbPlZCp[indZCp]=sumNbZCp;
                    ret+=nb;
                }
            }
		}
    }
    return ret;
}
function getIndiceZCp(z,cp)
{
	for (var i=0;i<tIdZCp.length;i++)
		if (tIdZCp[i]==z+"|"+cp)
			return i;
}
function clearResa()
{
    for (var i=0;i<tIdZCp.length;i++)
	{
	    tResaZCp[i]="";
		tNbPlZCp[i]="0";
	}	
}
function supprPlacePanier(ref)
{
    highlightLignePanier("m",ref,"on");    
    setTimeout(function () { annuPl(ref); },50);	
}
function annuPl(ref)
{
    var msg=dspt("fc=web&trslt=true",null,null,"key=web_vente_reserver_SouhaitezVousSupprimerCettePlace");
    if (!confirm(msg))
	{
	    highlightLignePanier("m",ref,"off"); 
		return;	
	}
	var ret=dspt("fc=web&deleltpanier=true",null,null,"type=pl&ref="+ref);
	switch (ret)
	{
		case "0":
            nav(3);
			break;
	    default:
		    highlightLignePanier("m",ref,"off");
		    msg=dspt("fc=web&trslt=true",null,null,"key=web_vente_erreur")+"\n"+
                dspt("fc=web&trslt=true",null,null,"key=web_vente_reserver_VeuillezRenouvelerOperation")+"\n"+
                dspt("fc=web&trslt=true",null,null,"key=web_vente_reserver_SiLePbPersiste");
            alert(msg);
			nav(3);
			break;
	}
}
function supprFormulePanier(ref)
{
    highlightLignePanier("f",ref,"on"); 
    setTimeout(function () { annuF(ref); },50);	
}
function annuF(ref)
{
    var msg=dspt("fc=web&trslt=true",null,null,"key=web_vente_reserver_SouhaitezVousSupprimerCetteFormule");
    if (!confirm(msg))
	{	    
	    highlightLignePanier("f",ref,"off");
		return;
    }
    var ret=dspt("fc=web&deleltpanier=true",null,null,"type=f&ref="+ref);
	switch (ret)
	{
		case "0":
            nav(3);
			break;
	    default:
		    highlightLignePanier("f",ref,"off");
			msg=dspt("fc=web&trslt=true",null,null,"key=web_vente_erreur")+"\n"+
                dspt("fc=web&trslt=true",null,null,"key=web_vente_reserver_VeuillezRenouvelerOperation")+"\n"+
                dspt("fc=web&trslt=true",null,null,"key=web_vente_reserver_SiLePbPersiste");
            alert(msg);
			nav(3);
			break;
	}
}
function supprPlFMS(ref)
{
    var msg=dspt("fc=web&trslt=true",null,null,"key=web_supprPlFMS_SouhaitezVousSupprimerCettePlace");
    if (!confirm(msg))
		return;
    var ret=dspt("fc=web&deleltpanier=true",null,null,"type=fplan&ref="+ref);
	switch (ret)
	{
		case "0":
            nav(2,"&ap=2");
			break;
	    default:
		    msg=dspt("fc=web&trslt=true",null,null,"key=web_vente_erreur")+"\n"+
                dspt("fc=web&trslt=true",null,null,"key=web_vente_reserver_VeuillezRenouvelerOperation")+"\n"+
                dspt("fc=web&trslt=true",null,null,"key=web_vente_reserver_SiLePbPersiste");
            alert(msg);
			nav(2,"&ap=2");
			break;
	}
}
function viderPanier()
{    
    highlightPanier("all");  
    setTimeout(function () { annuPn(); },50);
}
function annuPn()
{
    var msg=dspt("fc=web&trslt=true",null,null,"key=web_vente_reserver_SouhaitezVousAnnulerPanier");
    if (!confirm(msg))
	{	    
	    highlightPanier("none");
		return;	
	}
	var ret=dspt("fc=web&viderpanier=true");
	switch (ret)
	{
		case "0":
            nav(3);
			break;
		default:
		    highlightPanier("none");
			msg=dspt("fc=web&trslt=true",null,null,"key=web_vente_erreur")+"\n"+
                dspt("fc=web&trslt=true",null,null,"key=web_vente_reserver_VeuillezRenouvelerOperation")+"\n"+
                dspt("fc=web&trslt=true",null,null,"key=web_vente_reserver_SiLePbPersiste");
            alert(msg);
			nav(3);
			break;
	}
}
function highlightLignePanier(type,ref,onoff)
{
    var t;
    switch(type)
    {
        case "m":
            t="tblplaces";
            break;
        case "f":
            t="tblformules";
            break;
    }
    var c;
    switch (onoff)
    {
        case "on":
            c="trcolor";
            break;
        case "off":
            c="trtbl";
            break;            
    }
    var i;    
    var tbl=document.getElementById(t);
    for (i=0;i<tbl.tBodies[0].rows.length;i++)    
        if (tbl.tBodies[0].rows[i].id=="tr_"+ref)
            tbl.tBodies[0].rows[i].className=c;
}
function highlightPanier(type)
{
    var cOld;
    var cNew;
    switch(type)
    {
        case "all":
            cOld="trtbl";
            cNew="trcolor";
            break;
        case "none":
            cOld="trcolor";
            cNew="trtbl";
            break;
    }
    var i;
    var tblpl;
    if (document.getElementById("tblplaces")!=null)
    {
        tblpl=document.getElementById("tblplaces");        
        for (i=0;i<tblpl.tBodies[0].rows.length;i++)                     
            if (tblpl.tBodies[0].rows[i].className==cOld)            
                tblpl.tBodies[0].rows[i].className=cNew;
    }
    var tblf;
    if (document.getElementById("tblformules")!=null)
    {
        tblf=document.getElementById("tblformules");
        for (i=0;i<tblf.tBodies[0].rows.length;i++)                     
            if (tblf.tBodies[0].rows[i].className==cOld)            
                tblf.tBodies[0].rows[i].className=cNew;
    }
}
function setInfosMD()
{
    var md="";
    var rbMD=document.getElementsByName("rbModeDistrib");
    if (rbMD.length==1)    
        rbMD[0].checked=true;        
    for(var i=0;i<rbMD.length;i++)
        if(rbMD[i].checked)
            md=rbMD[i].value;        
    showInfosModeDistrib(md);
}
function showInfosModeDistrib(tMD)
{
    var infos=dspt("fc=web&infomd=true",null,null,"tMD="+tMD);
    switch(infos)
    {
        default:
            if (infos!="")    
                document.getElementById("detailmodedistrib").style.display="block";
            else
                document.getElementById("detailmodedistrib").style.display="none";
            document.getElementById("detailmodedistrib").innerHTML=infos;    
            break;
    }
}
function validerPanier()
{    
    var i=0;
    var prf="",m="",s="",f="",p="",md="",lstMD_M="",lstMD_F="",
        cplmtId="", nom="",prenom="",email="",lstCli_M="",lstCli_F="";
    
    var cliManifs=document.getElementsByName("txtclientpaniernom_M");
    if (cliManifs)
    {
        for (i = 0; i < cliManifs.length; i++)
        {
            cplmtId=cliManifs[i].id.split('_')[1]+"_"+cliManifs[i].id.split('_')[2]+"_"+cliManifs[i].id.split('_')[3]+"_"+cliManifs[i].id.split('_')[4]+"_"+cliManifs[i].id.split('_')[5];
            nom=trim(document.getElementById("txtclientpaniernom_"+cplmtId).value);
            if (nom=="")
            {
                msgVerif(document.getElementById("txtclientpaniernom_"+cplmtId),
                         dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_LeChamp")+" '"+
                         dspt("fc=web&trslt=true",null,null,"key=Client_lbl_Nom")+"' "+
                         dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_EstObligatoire")+"\n"+
                         dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_VeuillezCorrigerVotreSaisie"));
                return;
            }
            if (!isAlphaNum(nom))
            {
                msgVerif(document.getElementById("txtclientpaniernom_"+cplmtId),
                         dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_LeChamp")+" '"+
                         dspt("fc=web&trslt=true",null,null,"key=Client_lbl_Nom")+"' "+
                         dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_ContientUnCaractereNonAutorise") +
                         " : " + wrongCar + "\n" +
                         dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_VeuillezCorrigerVotreSaisie"));
                return;
            }
            prenom=trim(document.getElementById("txtclientpanierprenom_"+cplmtId).value);
            if (prenom=="")
            {
                msgVerif(document.getElementById("txtclientpanierprenom_"+cplmtId),
                         dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_LeChamp")+" '"+
                         dspt("fc=web&trslt=true",null,null,"key=Client_lbl_Prenom")+"' "+
                         dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_EstObligatoire")+"\n"+
                         dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_VeuillezCorrigerVotreSaisie"));
                return;
            }            
            if (!isAlphaNum(prenom))
            {
                msgVerif(document.getElementById("txtclientpanierprenom_"+cplmtId),
                         dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_LeChamp")+" '"+
                         dspt("fc=web&trslt=true",null,null,"key=Client_lbl_Prenom")+"' "+
                         dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_ContientUnCaractereNonAutorise") +
                         " : " + wrongCar + "\n" +
                         dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_VeuillezCorrigerVotreSaisie"));
                return;
            }
            email=trim(document.getElementById("txtclientpanieremail_"+cplmtId).value);
            if ((email!="")&&!verifMail(email))
            {
                msgVerif(document.getElementById("txtclientpanieremail_"+cplmtId),
                         dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_MailValide")+"\n"+
                         dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_VeuillezCorrigerVotreSaisie"));
                return; 
            }
            lstCli_M+=encodeURIComponent(cliManifs[i].id.split('_')[1]+"|"+
                                         cliManifs[i].id.split('_')[2]+"|"+
                                         cliManifs[i].id.split('_')[3]+"|"+
                                         cliManifs[i].id.split('_')[4]+"|"+
                                         cliManifs[i].id.split('_')[5]+"|"+nom+"|"+prenom+"|"+email+";");
        }
    }
    var cliFormules=document.getElementsByName("txtclientpaniernom_F");
    if (cliFormules)
    {
        for (i = 0; i < cliFormules.length; i++)
        {
            cplmtId=cliFormules[i].id.split('_')[1]+"_"+cliFormules[i].id.split('_')[2]+"_"+cliFormules[i].id.split('_')[3]+"_"+cliFormules[i].id.split('_')[4];
            nom=trim(document.getElementById("txtclientpaniernom_"+cplmtId).value);
            if (nom=="")
            {
                msgVerif(document.getElementById("txtclientpaniernom_"+cplmtId),
                         dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_LeChamp")+" '"+
                         dspt("fc=web&trslt=true",null,null,"key=Client_lbl_Nom")+"' "+
                         dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_EstObligatoire")+"\n"+
                         dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_VeuillezCorrigerVotreSaisie"));
                return;
            }
            if (!isAlphaNum(nom))
            {
                msgVerif(document.getElementById("txtclientpaniernom_"+cplmtId),
                         dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_LeChamp")+" '"+
                         dspt("fc=web&trslt=true",null,null,"key=Client_lbl_Nom")+"' "+
                         dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_ContientUnCaractereNonAutorise") +
                         " : " + wrongCar + "\n" +
                         dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_VeuillezCorrigerVotreSaisie"));
                return;
            }
            prenom=trim(document.getElementById("txtclientpanierprenom_"+cplmtId).value);
            if (prenom=="")
            {
                msgVerif(document.getElementById("txtclientpanierprenom_"+cplmtId),
                         dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_LeChamp")+" '"+
                         dspt("fc=web&trslt=true",null,null,"key=Client_lbl_Prenom")+"' "+
                         dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_EstObligatoire")+"\n"+
                         dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_VeuillezCorrigerVotreSaisie"));
                return;
            }            
            if (!isAlphaNum(prenom))
            {
                msgVerif(document.getElementById("txtclientpanierprenom_"+cplmtId),
                         dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_LeChamp")+" '"+
                         dspt("fc=web&trslt=true",null,null,"key=Client_lbl_Prenom")+"' "+
                         dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_ContientUnCaractereNonAutorise") +
                         " : " + wrongCar + "\n" +
                         dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_VeuillezCorrigerVotreSaisie"));
                return;
            }
            email=trim(document.getElementById("txtclientpanieremail_"+cplmtId).value);
            if ((email!="")&&!verifMail(email))
            {
                msgVerif(document.getElementById("txtclientpanieremail_"+cplmtId),
                         dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_MailValide")+"\n"+
                         dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_VeuillezCorrigerVotreSaisie"));
                return;    
            }
            lstCli_F+=encodeURIComponent(cliFormules[i].id.split('_')[1]+"|"+
                                         cliFormules[i].id.split('_')[2]+"|"+
                                         cliFormules[i].id.split('_')[3]+"|"+
                                         cliFormules[i].id.split('_')[4]+"|"+nom+"|"+prenom+"|"+email+";");
        }
    }

    var ass1 = getSelRb(document.getElementsByName("rbAssur"))
    var testAff = 0;
    testAff = dspt("fc=web&isassurance=", null, null);
    if (ass1 == "-1" && testAff == 1)
    {
        alert(dspt("fc=web&trslt=true", null, null, "key=web_vente_validerPanier_MerciDIndiquerSiVousSouhaitezSouscrire"));
        return;
    }

    switch (taMD)
    {
        case "0":
            md=getSelRb(document.getElementsByName("rbModeDistrib"));
            if (md=="-1"){
                msg=dspt("fc=web&trslt=true",null,null,"key=web_vente_validerPanier_ChoixModeDistribObligatoire")+".\n"+
                    dspt("fc=web&trslt=true",null,null,"key=web_vente_validerPanier_VeuillezSelectionnerModeDistrib")+".";        
                alert(msg);         
                return;
            }
            break;
        case "1":    
            var mdManifs=document.getElementsByName("ModeDistrib_M");    
            if (mdManifs)
            {
                for (i = 0; i < mdManifs.length; i++)
                {
                    md=getSelRb(document.getElementsByName("rbModeDistrib_M_" + mdManifs[i].id));
                    if (md=="-1")
                    {
                        msg=dspt("fc=web&trslt=true",null,null,"key=web_vente_validerPanier_ChoixModeDistribObligatoire")+" "+
                            dspt("fc=web&trslt=true",null,null,"key=web_vente_validerPanier_PourChaqueManifFormule")+".\n"+
                            dspt("fc=web&trslt=true",null,null,"key=web_vente_validerPanier_VeuillezSelectionnerModeDistrib")+".";        
                        alert(msg);        
                        return;
                    }
                    lstMD_M+=mdManifs[i].id.split('_')[0]+"|"+mdManifs[i].id.split('_')[1]+"|"+mdManifs[i].id.split('_')[2]+"|"+md+";";
                }
            }        
            var mdFormules=document.getElementsByName("ModeDistrib_F");
            if (mdFormules)
            {
                for (i = 0; i < mdFormules.length; i++)
                {
                    md=getSelRb(document.getElementsByName("rbModeDistrib_F_" + mdFormules[i].id));
                    if (md=="-1")
                    {
                        msg=dspt("fc=web&trslt=true",null,null,"key=web_vente_validerPanier_ChoixModeDistribObligatoire")+" "+
                            dspt("fc=web&trslt=true",null,null,"key=web_vente_validerPanier_PourChaqueManifFormule")+".\n"+
                            dspt("fc=web&trslt=true",null,null,"key=web_vente_validerPanier_VeuillezSelectionnerModeDistrib")+".";         
                        alert(msg);        
                        return;
                    }
                    lstMD_F+=mdFormules[i].id.split('_')[0]+"|"+mdFormules[i].id.split('_')[1]+"|"+md+";";
                }
            }    
            break;
    }
    
    var ret=dspt("fc=web&validerpanier=true",null,null,"taMD="+taMD+"&md="+md+"&lstMD_M="+lstMD_M+"&lstMD_F="+lstMD_F+
                                                       "&lstCli_M="+lstCli_M+"&lstCli_F="+lstCli_F);
    /*var ret=dspt("fc=web&validerpanier=true",null,null,"taMD="+taMD+"&md="+md+"&lstMD_M="+lstMD_M+"&lstMD_F="+lstMD_F);*/
    switch (ret)
	{
		case "0":
		    nav(4, "&wId=" + document.getElementById("wId").value + "&eId=0");
			break;
		default:
		    msg=dspt("fc=web&trslt=true",null,null,"key=web_vente_erreur")+"\n"+
                dspt("fc=web&trslt=true",null,null,"key=web_vente_reserver_VeuillezRenouvelerOperation")+"\n"+
                dspt("fc=web&trslt=true",null,null,"key=web_vente_reserver_SiLePbPersiste");
            alert(msg);
			nav(3);
			break;
	}    
}
function getSelRb(field)
{
	var i=0;
	if (field[i] != null)
	{
		for (i = 0; i < field.length; i++)
			if (field[i].checked)
				return field[i].value;	
	}
	else
	{
		if (field!=null)
			if (field.checked)
				return field.value;	
	}
	return "-1";
}
function setClientBanque()
{
    switch(document.getElementById("btnvalider_banque_fac").value)
    {
        case dspt("fc=web&trslt=true",null,null,"key=Client_btn_Modifier"):
            document.getElementById("btnvalider_fac").setAttribute("disabled","disabled");
            document.getElementById("lbl24_fac").innerText=dspt("fc=web&trslt=true",null,null,"key=Paiement_lbl_Titulaire") + "* :";
            document.getElementById("txt24_fac").className="txtficheclient";
            document.getElementById("txt24_fac").removeAttribute("readOnly");
            document.getElementById("lbl25_fac").innerText=dspt("fc=web&trslt=true",null,null,"key=Paiement_lbl_Banque") + "* :";
            document.getElementById("txt25_fac").className="txtficheclient";
            document.getElementById("txt25_fac").removeAttribute("readOnly");
            /*document.getElementById("lbl26_fac").innerText=dspt("fc=web&trslt=true",null,null,"key=Paiement_lbl_IBAN") + " (IBAN)* :";
            document.getElementById("txt26_fac").className="txtficheclient";
            document.getElementById("txt26_fac").removeAttribute("readOnly");
            document.getElementById("lbl27_fac").innerText=dspt("fc=web&trslt=true",null,null,"key=Paiement_lbl_BIC") + " (BIC)* :";
            document.getElementById("txt27_fac").className="txtficheclient";
            document.getElementById("txt27_fac").removeAttribute("readOnly");*/
            document.getElementById("lbl26_fac").innerText=dspt("fc=web&trslt=true",null,null,"key=Paiement_lbl_CodeEtablissement") + "* :";
            document.getElementById("txt26_fac").className="txtficheclient";
            document.getElementById("txt26_fac").removeAttribute("readOnly");
            document.getElementById("lbl27_fac").innerText=dspt("fc=web&trslt=true",null,null,"key=Paiement_lbl_CodeGuichet") + "* :";
            document.getElementById("txt27_fac").className="txtficheclient";
            document.getElementById("txt27_fac").removeAttribute("readOnly");            
            document.getElementById("lbl28_fac").innerText=dspt("fc=web&trslt=true",null,null,"key=Paiement_lbl_NumCompte") + "* :";
            document.getElementById("txt28_fac").className="txtficheclient";
            document.getElementById("txt28_fac").removeAttribute("readOnly");            
            document.getElementById("lbl29_fac").innerText=dspt("fc=web&trslt=true",null,null,"key=Paiement_lbl_Cle") + "* :";
            document.getElementById("txt29_fac").className="txtficheclient";
            document.getElementById("txt29_fac").removeAttribute("readOnly");            
            document.getElementById("btnvalider_banque_fac").value=dspt("fc=web&trslt=true",null,null,"key=Client_btn_Valider");
            document.getElementById("lbl19_fac").style.visibility="visible";
            break;
            
        case dspt("fc=web&trslt=true",null,null,"key=Client_btn_Valider"):
            var titulaire=trim(document.getElementById("txt24_fac").value);
            if (titulaire=="")
            {
                msgVerif(document.getElementById("txt24_fac"),
                         dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_LeChamp")+" '"+
                         dspt("fc=web&trslt=true",null,null,"key=Paiement_lbl_Titulaire")+"' "+
                         dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_EstObligatoire")+"\n"+
                         dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_VeuillezCorrigerVotreSaisie"));
                return;
            }
            var banque=trim(document.getElementById("txt25_fac").value);
            if (banque=="")
            {
                msgVerif(document.getElementById("txt25_fac"),
                         dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_LeChamp")+" '"+
                         dspt("fc=web&trslt=true",null,null,"key=Paiement_lbl_Banque")+"' "+
                         dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_EstObligatoire")+"\n"+
                         dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_VeuillezCorrigerVotreSaisie"));
                return;
            }
            /*var IBAN=trim(document.getElementById("txt26_fac").value);
            if (IBAN=="")
            {
                msgVerif(document.getElementById("txt26_fac"),
                         dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_LeChamp")+" '"+
                         dspt("fc=web&trslt=true",null,null,"key=Paiement_lbl_IBAN")+"' "+
                         dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_EstObligatoire")+"\n"+
                         dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_VeuillezCorrigerVotreSaisie"));
                return;
            }            
            var BIC=trim(document.getElementById("txt27_fac").value);            
            if (BIC=="")
            {
                msgVerif(document.getElementById("txt27_fac"),
                         dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_LeChamp")+" '"+
                         dspt("fc=web&trslt=true",null,null,"key=Paiement_lbl_BIC")+"' "+
                         dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_EstObligatoire")+"\n"+
                         dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_VeuillezCorrigerVotreSaisie"));             
                return;
            }
            if (!isIBANvalid(IBAN,"txt26_fac"))
                return;
            if (!isBICvalid(BIC,"txt26_fac"))
                return;            
            var ret=dspt("fc=web&infosprlvmt=true",null,null,"type=IBANBIC&titulaire="+encodeURIComponent(titulaire)+
                                                             "&banque="+encodeURIComponent(banque)+"&IBAN="+IBAN+"&BIC="+BIC);*/
                                                             
            var codeEtabl=trim(document.getElementById("txt26_fac").value);
            if (codeEtabl=="")
            {
                msgVerif(document.getElementById("txt26_fac"),
                         dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_LeChamp")+" '"+
                         dspt("fc=web&trslt=true",null,null,"key=Paiement_lbl_CodeEtablissement")+"' "+
                         dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_EstObligatoire")+"\n"+
                         dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_VeuillezCorrigerVotreSaisie"));
                return;
            }
            var codeGuich=trim(document.getElementById("txt27_fac").value);
            if (codeGuich=="")
            {
                msgVerif(document.getElementById("txt27_fac"),
                         dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_LeChamp")+" '"+
                         dspt("fc=web&trslt=true",null,null,"key=Paiement_lbl_CodeGuichet")+"' "+
                         dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_EstObligatoire")+"\n"+
                         dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_VeuillezCorrigerVotreSaisie"));
                return;
            }
            var numCompte=trim(document.getElementById("txt28_fac").value);
            if (numCompte=="")
            {
                msgVerif(document.getElementById("txt28_fac"),
                         dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_LeChamp")+" '"+
                         dspt("fc=web&trslt=true",null,null,"key=Paiement_lbl_NumCompte")+"' "+
                         dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_EstObligatoire")+"\n"+
                         dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_VeuillezCorrigerVotreSaisie"));
                return;
            }
            var cleRIB=trim(document.getElementById("txt29_fac").value);
            if (cleRIB=="")
            {
                msgVerif(document.getElementById("txt29_fac"),
                         dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_LeChamp")+" '"+
                         dspt("fc=web&trslt=true",null,null,"key=Paiement_lbl_Cle")+"' "+
                         dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_EstObligatoire")+"\n"+
                         dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_VeuillezCorrigerVotreSaisie"));
                return;
            }
            if (!isRIBvalid(codeEtabl, codeGuich, numCompte, cleRIB))
            {
                alert(dspt("fc=web&trslt=true",null,null,"key=web_vente_validerInfosPrlvmt_LesInfosBancaires"));                
                return;
            }
            
            var ret=dspt("fc=web&infosprlvmt=true",null,null,"type=RIB&titulaire="+encodeURIComponent(titulaire)+
                                                             "&banque="+encodeURIComponent(banque)+"&codeEtabl="+codeEtabl+
                                                             "&codeGuich="+codeGuich+"&numCompte="+numCompte+"&cleRIB="+cleRIB);
            
            switch(ret)
            {
                case "0":                                         
                    document.getElementById("btnvalider_fac").removeAttribute("disabled");
                    document.getElementById("lbl24_fac").innerText=dspt("fc=web&trslt=true",null,null,"key=Paiement_lbl_Titulaire") + " :";
                    document.getElementById("txt24_fac").className="txtficheclientdis";
                    document.getElementById("txt24_fac").setAttribute("readOnly","readonly");
                    document.getElementById("lbl25_fac").innerText=dspt("fc=web&trslt=true",null,null,"key=Paiement_lbl_Banque") + " :";
                    document.getElementById("txt25_fac").className="txtficheclientdis";
                    document.getElementById("txt25_fac").setAttribute("readOnly","readonly");                    
                    /*document.getElementById("lbl26_fac").innerText=dspt("fc=web&trslt=true",null,null,"key=Paiement_lbl_IBAN") + " (IBAN) :";
                    document.getElementById("txt26_fac").className="txtficheclientdis";
                    document.getElementById("txt26_fac").setAttribute("readOnly","readonly");
                    document.getElementById("lbl27_fac").innerText=dspt("fc=web&trslt=true",null,null,"key=Paiement_lbl_BIC") + " (BIC) :";
                    document.getElementById("txt27_fac").className="txtficheclientdis";
                    document.getElementById("txt27_fac").setAttribute("readOnly","readonly");*/
                    document.getElementById("lbl26_fac").innerText=dspt("fc=web&trslt=true",null,null,"key=Paiement_lbl_CodeEtablissement") + " :";
                    document.getElementById("txt26_fac").className="txtficheclientdis";
                    document.getElementById("txt26_fac").setAttribute("readOnly","readonly");
                    document.getElementById("lbl27_fac").innerText=dspt("fc=web&trslt=true",null,null,"key=Paiement_lbl_CodeGuichet") + " :";
                    document.getElementById("txt27_fac").className="txtficheclientdis";
                    document.getElementById("txt27_fac").setAttribute("readOnly","readonly");
                    document.getElementById("lbl28_fac").innerText=dspt("fc=web&trslt=true",null,null,"key=Paiement_lbl_NumCompte") + " :";
                    document.getElementById("txt28_fac").className="txtficheclientdis";
                    document.getElementById("txt28_fac").setAttribute("readOnly","readonly");         
                    document.getElementById("lbl29_fac").innerText=dspt("fc=web&trslt=true",null,null,"key=Paiement_lbl_Cle") + " :";
                    document.getElementById("txt29_fac").className="txtficheclientdis";
                    document.getElementById("txt29_fac").setAttribute("readOnly","readonly");
                    document.getElementById("btnvalider_banque_fac").value=dspt("fc=web&trslt=true",null,null,"key=Client_btn_Modifier");
                    document.getElementById("lbl19_fac").style.visibility="hidden";
                    break;
               default:
                    alert(dspt("fc=web&trslt=true",null,null,"key=web_vente_erreur")+"\n"+
                          dspt("fc=web&trslt=true",null,null,"key=web_vente_reserver_VeuillezRenouvelerOperation")+"\n"+
                          dspt("fc=web&trslt=true",null,null,"key=web_vente_reserver_SiLePbPersiste"));            
                    break;
            }
            break;
    }
}
function msgVerif(c,m)
{
    c.style.backgroundColor="#FD9393";
    alert(m);
    c.style.backgroundColor="";
    c.focus();
}
function infosCNIL()
{    
    showInfos("divinfos",dspt("fc=web&infoscnil=true"),50,-100);    
}
//function sendMdp()
//{
//    var msg="";
//    var mail=trim(document.getElementById("txtlogin").value);    
//    if (mail=="")
//    {
//        msgVerif(document.getElementById("txtlogin"),
//                 dspt("fc=web&trslt=true",null,null,"key=web_vente_sendMdp_VeuillezSaisirVotreEMail")+
//                 dspt("fc=web&trslt=true",null,null,"key=web_vente_sendMdp_OuVotreIdentifiant") + ".");
//        return;
//    }
//    if (!verifMail(mail))
//    {
//        msgVerif(document.getElementById("txtlogin"),        
//                 dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_MailValide")+"\n"+
//                 dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_VeuillezCorrigerVotreSaisie"));
//        return;
//    }    
//    var ret=dspt("fc=web&sendmdp=true",null,null,"mail="+mail);
//    switch(ret)
//    {
//        case "0":
//            msg=dspt("fc=web&trslt=true",null,null,"key=web_vente_sendMdp_UnEMailContenantMDP");
//            alert(msg + " " + mail + "."); 
//            nav(4);
//            break;  
//        case "-1":
//            msg=dspt("fc=web&trslt=true",null,null,"key=web_vente_sendMdp_AucunEspacePersoAssocie")+"\n"+
//                dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_VeuillezCorrigerVotreSaisie");
//            alert(msg); 
//            break;            
//        default:
//            msg=dspt("fc=web&trslt=true",null,null,"key=web_vente_erreur")+"\n"+
//                dspt("fc=web&trslt=true",null,null,"key=web_vente_reserver_VeuillezRenouvelerOperation")+"\n"+
//                dspt("fc=web&trslt=true",null,null,"key=web_vente_reserver_SiLePbPersiste");
//	        alert(msg);	
//			window.location.href=window.location.href;
//            break;
//    }
//}

function sendMdp()
{
    var msg = "";
    var login = trim(document.getElementById("txtlogin").value);
    if (login == "")
    {
        msgVerif(document.getElementById("txtlogin"),
                 dspt("fc=web&trslt=true", null, null, "key=web_esp_sendMdp_VeuillezSaisirVotreIdentifiant"));
        return;
    }
    //var ret = dspt("fc=web&sendmdpcliesp=true", null, null, "login=" + login).split('|');
    var ret = dspt("fc=web&sendmdp=true", null, null, "login=" + login).split('|'); ;
    switch (ret[0])
    {
        case "0":
            msg = dspt("fc=web&trslt=true", null, null, "key=web_vente_sendMdp_UnEMailContenantMDP");
            alert(msg);
            nav(4, "&wId=" + document.getElementById("wId").value + "&eId=0");
            //nav(4);
            break;
        default:
            msg = dspt("fc=web&trslt=true", null, null, "key=web_vente_erreur") + "\n" +
                dspt("fc=web&trslt=true", null, null, "key=web_vente_reserver_VeuillezRenouvelerOperation") + "\n" +
                dspt("fc=web&trslt=true", null, null, "key=web_vente_reserver_SiLePbPersiste");
            alert(msg);
            window.location.href = window.location.href;
            break;
    }
}

function authClient(f, qS)
{
    var login = trim(document.getElementById("txtlogin").value);
    var mdp = trim(document.getElementById("txtmdp").value);
    var msg = "";

    if (login == "")
    {
        msgVerif(document.getElementById("txtlogin"),
                 dspt("fc=web&trslt=true", null, null, "key=web_esp_sendMdp_VeuillezSaisirVotreIdentifiant"));
        return;
    }
//    if (login.indexOf('@', 0) != -1)
//    {
//        if (!verifMail(login))
//        {
//            msgVerif(document.getElementById("txtlogin"),
//                     dspt("fc=web&trslt=true", null, null, "key=web_vente_addUpdClient_MailValide") + "\n" +
//                     dspt("fc=web&trslt=true", null, null, "key=web_vente_addUpdClient_VeuillezCorrigerVotreSaisie"));
//            return;
//        }
//    }
    if (mdp.length < 6)
    {
        msgVerif(document.getElementById("txtmdp"),
                 dspt("fc=web&trslt=true", null, null, "key=web_vente_addUpdClient_VotreMotDePasseDoitContenir"));
        return;
    }
    
    //var ret = dspt("fc=web&authclient=true", null, null, "login=" + login + "&mdp=" + mdp);

    var ret = dspt("fc=web&authcliesp=true", null, null, "login=" + login + "&mdp=" + mdp);

    switch (ret)
    {
        case "0":
            switch (f)
            {
                case "2":
                    nav(2, "&ap=" + qS);
                    break;
                case "4":
                    if (qS)
                        nav(6, "&fro=" + qS);
                    else
                        nav(6);
                    break;
            }
            break;
        case "-1":
            msg = dspt("fc=web&trslt=true", null, null, "key=web_vente_authClient_LoginMDPincorrect") + "\n" +
                dspt("fc=web&trslt=true", null, null, "key=web_vente_addUpdClient_VeuillezCorrigerVotreSaisie");
            alert(msg);
            break;
        default:
            msg = dspt("fc=web&trslt=true", null, null, "key=web_vente_erreur") + "\n" +
                dspt("fc=web&trslt=true", null, null, "key=web_vente_reserver_VeuillezRenouvelerOperation") + "\n" +
                dspt("fc=web&trslt=true", null, null, "key=web_vente_reserver_SiLePbPersiste");
            alert(msg);
            window.location.href = window.location.href;
            break;
    }
}

function getSel(l,val)
{
	for (var i=0; i<l.length; i++)
	{				
		if (l.options[i].selected==true)
		{
			if (val=="txt")
				return l.options[i].text;	
			else if (val=="val")
				return l.options[i].value;	
			else if (val=="ind")
				return i;	
		}
	} 
	return "";
}
function verifMail(email)
{  
  var re = new RegExp("([a-z0-9]+([-_]?[a-z0-9]+)*.)*[a-z0-9]+([-_]?[a-z0-9]+)*@([a-z0-9]+([-_]?[a-z0-9]+)*[.])+[a-z]{2,4}","gi");
  return (email.match(re) == email);
  
  /*var re =/^(a-z0-9]+([-_]?[a-z0-9]+)*.)*[a-z0-9]+([-_]?[a-z0-9]+)*@([a-z0-9]+([-_]?[a-z0-9]+)*[.])+[a-z]{2,4}$/gi;
  return (re.test(email));*/
}
var numb = "0123456789";
var lwr = "abcdefghijklmnopqrstuvwxyz";
var upr = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
var specar = " _-'éèêëôöîïûüùàäâçñ&ÉÈÊËÔÖÎÏÛÜÙÀÄÂÑ";
var spepwd="_-#&$£";
var speadr = ",./*#&()";
var spetel = "(+-_.) ";
var wrongCar= "";
function isAlphaNum(s)
{
    return isValid(s,lwr+upr+numb+specar);    
}
function isNum(s)
{
    return isValid(s,numb);    
}
function isPwd(s)
{
    return isValid(s,lwr+upr+numb+spepwd);    
}
function isAdr(s)
{
    return isValid(s,lwr+upr+numb+specar+speadr);    
}
function isTel(s)
{
    return isValid(s,numb+spetel);    
}
function isValid(s,p)
{    
    if (s == "") return true;
    for (var i=0; i<s.length; i++)     
        if (p.indexOf(s.charAt(i),0) == -1) 
        {
            wrongCar=s.charAt(i);
            return false;
        }
    return true;
}
function trim(s) 
{
  while (s.substring(0,1) == ' ') 
  {
    s = s.substring(1,s.length);
  }
  while (s.substring(s.length-1,s.length) == ' ') 
  {
    s = s.substring(0,s.length-1);
  }
   while (s.charCodeAt(s.length-1) == 160) 
  {
    s = s.substring(0,s.length-1);
  }
  return s;
}
function annuCmd()
{
    var msg=dspt("fc=web&trslt=true",null,null,"key=web_vente_annuCmd_SouhaitezVousAnnulerCmd");
    if (!confirm(msg))
		return;	
			
	var ret=dspt("fc=web&annucmd=true");
	switch (ret)
	{
		case "0":
            nav(1);
			break;
		default:		    
			msg=dspt("fc=web&trslt=true",null,null,"key=web_vente_erreur")+"\n"+
                dspt("fc=web&trslt=true",null,null,"key=web_vente_reserver_VeuillezRenouvelerOperation")+"\n"+
                dspt("fc=web&trslt=true",null,null,"key=web_vente_reserver_SiLePbPersiste");
	        alert(msg);	
			window.location.href=window.location.href;
			break;
	}
}

function showPanierProspection ()
{
    var msg="";
    if (document.getElementById("hDo_fac"))
    {
        if (document.getElementById("hDo_fac").value!="")
        {
            if (document.getElementById("hDo_fac").value!="show")
            {
                msg=dspt("fc=web&trslt=true",null,null,"key=web_vente_endCmd_ValidezVosInformations");
                alert(msg);        
                return;
            }
        }
    }
    if (document.getElementById("hDo_liv"))
    {
        if (document.getElementById("hDo_liv").value!="")
        {
            if (document.getElementById("hDo_liv").value!="show")
            {
                msg=dspt("fc=web&trslt=true",null,null,"key=web_vente_endCmd_ValidezVotreAdresseLivr");
                alert(msg);
                return;
            }
        }
    } 
    nav(3);
}

function endCmd()
{
    var msg="";
    if (document.getElementById("hDo_fac"))
    {
        if (document.getElementById("hDo_fac").value!="")
        {
            if (document.getElementById("hDo_fac").value!="show")
            {
                msg=dspt("fc=web&trslt=true",null,null,"key=web_vente_endCmd_ValidezVosInformations");
                alert(msg);        
                return;
            }
        }
    }
    if (document.getElementById("hDo_liv"))
    {
        if (document.getElementById("hDo_liv").value!="")
        {
            if (document.getElementById("hDo_liv").value!="show")
            {
                msg=dspt("fc=web&trslt=true",null,null,"key=web_vente_endCmd_ValidezVotreAdresseLivr");
                alert(msg);
                return;
            }
        }
    }
    /*dspt("fc=web&validerclient=true");
    document.forms["frmValidationClient"].submit();*/
    var f;
    if (document.getElementById("tblBeneficiaire"))
    {
        f="clBenef";
        if (!beneficiaire())
            return;
    }
    else
        f="clFact";
    var ret=dspt("fc=web&validerclient=true",null,null,"f="+f);
    switch(ret)
    {
        case "1":
            nav(14);
            break;
        default:
            document.forms["frmValidationClient"].submit();          
            break;        
    }
}
function CGV()
{
    document.getElementById("chkCGV").checked = true;
    document.getElementById("divmodespaiement").style.display="block";
    if (document.getElementById("lang").value=="FR")
        window.open("/App/Homes/" + document.getElementById("wId").value + "/CGV.htm");
    else
        window.open("/App/Homes/" + document.getElementById("wId").value + "/CGV_"+document.getElementById("lang").value+".htm");
}
function chkModeDistrib()
{   
    alert(dspt("fc=web&trslt=true",null,null,"key=web_vente_validerPanier_ChoixModeDistribObligatoire")+".\n"+
          dspt("fc=web&trslt=true",null,null,"key=web_vente_validerPanier_VeuillezSelectionnerModeDistrib")+"."); 
    nav(3); 
}
function setModalitesDsp(checked)
{    
    if (checked)
        document.getElementById("divCGV").style.display="block";
    else
    {
        document.getElementById("divCGV").style.display="none";
        document.getElementById("divmodespaiement").style.display="none";
        document.getElementById("chkCGV").checked=false;
    }
}
function setInfosPaiement(checked)
{
    if (checked)
        document.getElementById("divmodespaiement").style.display="block";
    else
        document.getElementById("divmodespaiement").style.display="none";
}
function espacePerso()
{
    dspt("fc=web&espaceperso=true",null,null,"href="+window.location.href);
    var wId = document.getElementById("wId").value;
    nav(4, "&wId=" + wId + "&eId=0");
}
function pageClient()
{
    var wId = document.getElementById("wId").value;
    nav(4, "&wId=" + wId + "&eId=0");
}
function logout()
{
    var nbElts=0;
    if(document.getElementById("Panier_Web_nbElts"))
        nbElts=parseInt(document.getElementById("Panier_Web_nbElts").value);
    if (nbElts>0)
    {
        var msg=dspt("fc=web&trslt=true",null,null,"key=web_vente_logout_DecoEntraineAnnulation")+"\n"+
                dspt("fc=web&trslt=true",null,null,"key=Web_vente_logout_SouhaitezVousVousDeco");
        if (!confirm(msg))
            return;
    
    }
    dspt("fc=web&logout=true");
    nav(1);    
}
function Envoi_Eticket(cmd, refext, indice, target)
{
    document.getElementById("cmd").value = cmd;
    document.getElementById("refext").value = refext;
    document.getElementById("indice").value = indice;
    
    document.getElementById("frmCommandes").target= target;
    document.getElementById("frmCommandes").method = "post";
    document.getElementById("frmCommandes").action = "SendETicket.aspx";
    document.getElementById("frmCommandes").submit();
}
function detailCmd(o,p,c,m,s,f,r) 
{
	var detail;
	var img;
    var lstTr;
    var i=0;
    var dsply;
	
	if ((m==null)&&(s==null)&&(f==null)&&(r==null))
    {
        img=document.getElementById("imgdetail_"+c);
        lstTr=document.getElementsByTagName('tr'); 	 
        switch(img.src.substring(img.src.lastIndexOf("/")+1))
        {
            case "plus.gif":
                img.src=img.src.substring(0,img.src.lastIndexOf("/")+1) + "minus.gif";
                //img.src="../images/web/minus.gif";
                //dsply="block";
                //dsply="table-row";
                dsply="";
                break;
            case "minus.gif":
                img.src=img.src.substring(0,img.src.lastIndexOf("/")+1) + "plus.gif";
                //img.src="../images/web/plus.gif";
                dsply="none";
                break;
        }        
        if (lstTr[0]!=null)
        {
            for (i=0; i<lstTr.length; i++)
            {
                if (sStartsWith(lstTr[i].id,"trmanif_" + c + "_")||
                    sStartsWith(lstTr[i].id,"treticket_" + c + "_")||
                    sStartsWith(lstTr[i].id,"trproduit1_" + c + "_")||
                    sStartsWith(lstTr[i].id,"trproduit2_" + c + "_")||
                    sStartsWith(lstTr[i].id,"trsuivi1_" + c + "_")||
                    sStartsWith(lstTr[i].id,"trsuivi2_" + c + "_"))
                {
                    lstTr[i].style.display=dsply;                    
                }                
            }
        }
    }
    else
    {
	    if (f == null)
	        f = '';
    	    
        if (r != "")
	    {
	        img=document.getElementById("imgdetail_"+o+"_"+p+"_"+c+"_"+m+"_"+s+"_"+f+"_"+r);
	        detail=document.getElementById("divdetail_"+o+"_"+p+"_"+c+"_"+m+"_"+s+"_"+f+"_"+r);
	    }
	    else
	    {
	        img=document.getElementById("imgdetail_"+o+"_"+p+"_"+c+"_"+m+"_"+s+"_"+f);
	        detail=document.getElementById("divdetail_"+o+"_"+p+"_"+c+"_"+m+"_"+s+"_"+f);
	    }
	    if (detail.style.display!="none") 
	    {
	        //img.src="../images/web/plus.gif";
	        img.src=img.src.substring(0,img.src.lastIndexOf("/")+1) + "plus.gif";
	        detail.innerHTML="";
		    detail.style.display="none";		
	    }
	    else 
	    {
	        //img.src="../images/web/minus.gif";
	        img.src=img.src.substring(0,img.src.lastIndexOf("/")+1) + "minus.gif";
		    detail.style.display = "";		
		    detail.innerHTML = dspt("fc=web&detailPlCmd=true",null,null,"o="+o+"&p="+p+"&c="+c+"&m="+m+"&s="+s+"&f="+f+"&r="+r);
	    }
	}
}
function showInfo(type, lng, si, m, se, f, z, c, md, prf, sec, typeMD, rglmt, defaultInfo) {
    var ret = "";
    if (defaultInfo) {
        switch (type) {
            case "f":
                ret = "1||||" + dspt("fc=web&detailformule=true", null, null, "f=" + f + "&prf=" + prf) + "||550||150||";
                break;
            case "pnf":
                ret = "1||||" + dspt("fc=web&detailformulepanier=true", null, null, "f=" + f + "&prf=" + prf) + "||900||300||";
                break;
            case "typeMD":
                var infosMD=dspt("fc=web&getinfostypemodedistrib=true", null, null, "typeMD=" + typeMD + "&prf=" + prf + "&m=" + m + "&se=" + se + "&f=" + f);
                ret = "1||" + infosMD.split('|')[0] + "||" + infosMD.split('|')[1] + "||700||300||";
                break;
        }
    }
    else
        ret = dspt("fc=web&getinfo=true", null, null, "type=" + type + "&lng=" + lng + "&si=" + si + "&m=" + m +
                                                      "&se=" + se + "&f=" + f + "&z=" + z + "&c=" +c + "&prf=" + prf + 
                                                      "&md=" + md + "&sec=" + sec + "&typeMD=" + typeMD + "&rglmt=" + rglmt);
    if(ret=="") window.location.href=window.location.href;
    var box = "2";
    var typeInfo = ret.split('||')[0];
    var titre = ret.split('||')[1];
    var info = ret.split('||')[2];
    var w = ret.split('||')[3];
    var h = ret.split('||')[4];    
    switch (box) {
        case "1":
            switch (typeInfo) {
                case "1":
                    Shadowbox.open({
                        player: 'html',
                        title: titre,
                        content: info,
                        height: h,
                        width: w,
                        backgroundColor: bgColor,
                        imgLoadingPath: "/App/Web/GetLogoImg.aspx?type=img&logo_img="+img
                    });
                    break;
                case "2":
                    Shadowbox.Shadowbox.open({
                        player: 'iframe',
                        title: titre,
                        content: info + '?TB_iframe=true',
                        height: h,
                        width: w,
                        backgroundColor: bgColor,
                        imgLoadingPath: "/App/Web/GetLogoImg.aspx?type=img&logo_img=" + img
                    });
                    break;
            }
            break;
        case "2":
            switch (typeInfo) {
                case "1":
                    if ($("#TB_ajaxContent")[0])
                        $("#TB_ajaxContent")[0].innerHTML = "";
                    document.getElementById("msg").innerHTML = info;
                    tb_show(titre, window.location.href.split('?')[0] + "#TB_inline?height=" + h + "&width=" + w + "&inlineId=msg&lng=" + lng, false);
                    break;
                case "2":
                    if ($("#TB_window")[0])
                        $("#TB_window")[0].innerHTML = "";
                    tb_show(titre, info + "?TB_iframe=true&height=" + h + "&width=" + w + "&lng=" + lng, false);
                    break;
            }
            break;
    }
}
function setFraisMD(id){
    var infosMD="";
    var mdM="";
    var mdF="";    
    var totF=0;
    var i=0;
    var md="";
    var frMD="";
    switch(taMD){    
        case "0":
            infosMD=getSelRb(document.getElementsByName("rbModeDistrib_Cmd"));
            if (infosMD=="-1") return;
            totF=dspt("fc=web&montantfraismd=true",null,null,
                      "taMD="+taMD+"&infosMD="+infosMD);            
            document.getElementById("divrecapmanifformulemontantfrais").innerHTML = totF;
            break;
        case "1":
            infosMD=getSelRb(document.getElementsByName("rbModeDistrib_"+id));
            if (infosMD=="-1") return;               
            document.getElementById("divrecapmanifformulemontantfrais_"+id).innerHTML = dspt("fc=web&montantfraismd=true",null,null,
                                                                                             "taMD="+taMD+"&infosMD="+infosMD);
            mdM=document.getElementsByName("ModeDistrib_M");
            if (mdM)
            {
                for (i = 0; i < mdM.length; i++)
                {
                    frMD=sReplace(document.getElementById("divrecapmanifformulemontantfrais_M_"+mdM[i].id).innerHTML,",",".");
                    if (frMD != "" && !isNaN(frMD))
                        totF+=parseFloat(sReplace(document.getElementById("divrecapmanifformulemontantfrais_M_"+mdM[i].id).innerHTML,",","."));
                }
            }
            mdF=document.getElementsByName("ModeDistrib_F");
            if (mdF)
            {
                for (i = 0; i < mdF.length; i++)
                {      
                    frMD=sReplace(document.getElementById("divrecapmanifformulemontantfrais_F_"+mdF[i].id).innerHTML,",",".");
                    if (frMD != "" && !isNaN(frMD))
                        totF+=parseFloat(sReplace(document.getElementById("divrecapmanifformulemontantfrais_F_"+mdF[i].id).innerHTML,",","."));                        
                }   
            }
            break;
    }
    document.getElementById("montantcmd").innerHTML=dspt("fc=web&mntntcmd=true",null,null,"totF="+totF);
}
function sReplace(chaine,oldvalue,newvalue)
{
	var reg=new RegExp("("+oldvalue+")", "g");
	return chaine.replace(reg,newvalue);	
}
function sStartsWith(s, prefix) {
    return s.indexOf(prefix) === 0;
}
function validerRecap(){
    var i=0;
    var md="", mr="", msg="";
    var lstMD="",lstMR="";
    
    var mdC=document.getElementsByName("ModeDistrib_Cmd");
    if (mdC.length>0)
    {
        md=getSelRb(document.getElementsByName("rbModeDistrib_Cmd"));
        if (md=="-1")
        {
            msg=dspt("fc=web&trslt=true",null,null,"key=web_vente_validerPanier_ChoixModeDistribObligatoire")+".\n"+            
                dspt("fc=web&trslt=true",null,null,"key=web_vente_validerPanier_VeuillezSelectionnerModeDistrib")+".";        
            alert(msg);        
            return;
        }   
        lstMD+="C_"+md+";";
    }
    var mdM=document.getElementsByName("ModeDistrib_M");
    if (mdM)
    {
        for (i = 0; i < mdM.length; i++)
        {
            md=getSelRb(document.getElementsByName("rbModeDistrib_M_" + mdM[i].id));
            if (md=="-1")
            {
                msg=dspt("fc=web&trslt=true",null,null,"key=web_vente_validerPanier_ChoixModeDistribObligatoire")+" "+
                    dspt("fc=web&trslt=true",null,null,"key=web_vente_validerPanier_PourChaqueManifFormule")+".\n"+
                    dspt("fc=web&trslt=true",null,null,"key=web_vente_validerPanier_VeuillezSelectionnerModeDistrib")+".";        
                alert(msg);        
                return;
            }
            lstMD+="M_"+mdM[i].id+"_"+md+";";
         }
    }
    var mdF=document.getElementsByName("ModeDistrib_F");
    if (mdF)
    {
        for (i = 0; i < mdF.length; i++)
        {
            md=getSelRb(document.getElementsByName("rbModeDistrib_F_" + mdF[i].id));
            if (md=="-1")
            {
                msg=dspt("fc=web&trslt=true",null,null,"key=web_vente_validerPanier_ChoixModeDistribObligatoire")+" "+
                    dspt("fc=web&trslt=true",null,null,"key=web_vente_validerPanier_PourChaqueManifFormule")+".\n"+
                    dspt("fc=web&trslt=true",null,null,"key=web_vente_validerPanier_VeuillezSelectionnerModeDistrib")+".";        
                alert(msg);        
                return;
            }
            lstMD+="F_"+mdF[i].id+"_"+md+";";
         }
    }
    var mrC=document.getElementsByName("ModeReglement_Cmd");
    if (mrC.length>0)
    {
        mr=getSelRb(document.getElementsByName("rbModeReglement_Cmd"));
        if (mr=="-1")
        {
            msg=dspt("fc=web&trslt=true",null,null,"key=web_vente_validerPanier_ChoixModeReglementObligatoire")+" "+                
                dspt("fc=web&trslt=true",null,null,"key=web_vente_validerPanier_VeuillezSelectionnerModeReglement")+".";        
            alert(msg);        
            return;
        }
        lstMR+="C_"+mr+";";   
    }
    var mrM=document.getElementsByName("ModeReglement_M");
    if (mrM)
    {
        for (i = 0; i < mrM.length; i++)
        {
            mr=getSelRb(document.getElementsByName("rbModeReglement_M_" + mrM[i].id));
            if (mr=="-1")
            {
                msg=dspt("fc=web&trslt=true",null,null,"key=web_vente_validerPanier_ChoixModeReglementObligatoire")+" "+
                    dspt("fc=web&trslt=true",null,null,"key=web_vente_validerPanier_PourChaqueManifFormule")+".\n"+
                    dspt("fc=web&trslt=true",null,null,"key=web_vente_validerPanier_VeuillezSelectionnerModeReglement")+".";        
                alert(msg);        
                return;
            }
            lstMR+="M_"+mrM[i].id+"_"+mr+";";
        }
    }
    var mrF=document.getElementsByName("ModeReglement_F");
    if (mrF)
    {
        for (i = 0; i < mrF.length; i++)
        {
            mr=getSelRb(document.getElementsByName("rbModeReglement_F_" + mrF[i].id));
            if (mr=="-1")
            {
                msg=dspt("fc=web&trslt=true",null,null,"key=web_vente_validerPanier_ChoixModeReglementObligatoire")+" "+
                    dspt("fc=web&trslt=true",null,null,"key=web_vente_validerPanier_PourChaqueManifFormule")+".\n"+
                    dspt("fc=web&trslt=true",null,null,"key=web_vente_validerPanier_VeuillezSelectionnerModeReglement")+".";        
                alert(msg);        
                return;
            }
            lstMR+="F_"+mrF[i].id+"_"+mr+";";
        }
    }
    document.getElementById("mnt").value=document.getElementById("montantcmd").innerHTML;
    var ret=dspt("fc=web&validerrecap=true",null,null,"mnt="+document.getElementById("montantcmd").innerHTML+"&lstMD="+lstMD+"&lstMR="+lstMR);
    switch (ret)
	{
		case "0":
		case "00":
            document.getElementById("frmPmt").submit();
			break;
        case "1":
            nav(10);
			break;
		case "-1":
		    alert(dspt("fc=web&trslt=true",null,null,"key=web_vente_validerRecap_ValiderCoordonneesBancaires"));		    
		    break;
		case "-2":
		    alert(dspt("fc=web&trslt=true",null,null,"key=web_vente_validerRecap_VeuillezSaisirLesInformationsDeChaqueClient"));		    
		    nav(14);
		    break;
		default:
		    msg=dspt("fc=web&trslt=true",null,null,"key=web_vente_erreur")+"\n"+
                dspt("fc=web&trslt=true",null,null,"key=web_vente_reserver_VeuillezRenouvelerOperation")+"\n"+
                dspt("fc=web&trslt=true",null,null,"key=web_vente_reserver_SiLePbPersiste");
            alert(msg);
			nav(9);
			break;
	}
}
function showRecap(){
    dspt("fc=web&clrecap=true");
    nav(9);
}
function wait(w)
{
    if (w)      
        document.getElementById("tblPatience").style.display="block"; 
    else
        document.getElementById("tblPatience").style.display="none";
}   
function showPlan(m,s,p,l,c)
{
    window.open("ResaPlan.aspx?"+rndId()+"&placeManifRef=true&plan=" + p + "&m=" + m + "&se=" + s + "&lg=" + l + "&col=" + c,
                "Plan",
                "width=900,height=600,menubar=no,location=no,resizable=yes,scrollbars=yes,status=no");               
}
function setCodePromo() {

    var txtCodePromo = document.getElementById("txtCodePromo");
    if (txtCodePromo.value == "" || txtCodePromo.value == null || txtCodePromo.value == "undefined")
        return;

    dspt("fc=outils&delvarsess=codepromo");
    dspt("fc=outils&addvarsess=codepromo$" + txtCodePromo.value, "");

    nav(3);
}
function setAssurance(bolReponse)
{
    dspt("fc=outils&delvarsess=assurance");
    switch (bolReponse)
    {
        case 1:
            dspt("fc=outils&addvarsess=assurance$true", "");
            break;
        case 2:
            dspt("fc=outils&addvarsess=assurance$false", "");
            break;
        default:
            //dspt("fc=outils&addvarsess=assurance$false", "");
            break ;            
    }
    nav(3);
}
function infosAssurance(lng)
{
    if ($("#TB_window")[0])
        $("#TB_window")[0].innerHTML = "";
    tb_show(dspt("fc=web&trslt=true",null,null,"key=web_vente_infosAssurance_AssuranceAnnulationFormuleAbo"), "/App/Web/InfoAssurance.aspx?" + rndId() + "&TB_iframe=true&height=300&width=550&lng=" + lng, false);
}
function setCompte()
{
    var rbCompte=getSelRb(document.getElementsByName("rbCompte"));
    if (rbCompte=="-1")
        return;
    switch(rbCompte)
    {
        case "0":
            document.getElementById("divid").style.display="none";
            break;
        case "1":
            document.getElementById("divid").style.display="block";
            break;
    }
}
function chkCompte(qS)
{
    var rbCompte=getSelRb(document.getElementsByName("rbCompte"));
    var msg="";
    if (rbCompte=="-1")        
    {
        alert(dspt("fc=web&trslt=true",null,null,"key=web_vente_setCompte_VeuillezSelectionnerUneOption"));
        return;
    }
    //rbCompte="0"; //pour empêcher les fusions...
    switch(rbCompte)
    {
        case "0":            
            dspt("fc=web&chkcompte=true",null,null,"cpt="+rbCompte);
            nav(2,"&ap="+qS);
            break;
        case "1":
            var login=trim(document.getElementById("txtlogin").value);
            var mdp=trim(document.getElementById("txtmdp").value);            
            if (login=="")
            {
                msgVerif(document.getElementById("txtlogin"),
                         dspt("fc=web&trslt=true",null,null,"key=web_vente_sendMdp_VeuillezSaisirVotreEMail") + ".");
                return;
            }         
            if (mdp.length<6)
            {
                msgVerif(document.getElementById("txtmdp"),
                         dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_VotreMotDePasseDoitContenir"));
                return;
            }             
            var ret=dspt("fc=web&chkcompte=true",null,null,"cpt="+rbCompte+"&login="+login+"&mdp="+mdp);
            switch(ret)
            {
                case "0":
                    msg=dspt("fc=web&trslt=true",null,null,"key=web_vente_chkCompte_LorsDeVosProchainesConnexions")+"\n"+
                        dspt("fc=web&trslt=true",null,null,"key=web_vente_chkCompte_LesIdentifiantsTemporaires");
                    alert(msg);     
                    nav(2,"&ap="+qS);
                    break;
                case "-1":
                    msg=dspt("fc=web&trslt=true",null,null,"key=web_vente_authClient_LoginMDPincorrect")+"\n"+
                        dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_VeuillezCorrigerVotreSaisie");
                    alert(msg);            
                    break;
                case "-21":
                    msg=dspt("fc=web&trslt=true",null,null,"key=web_vente_chkCompte_LeCompteQueVousAvezSaisi")+"\n"+
                        dspt("fc=web&trslt=true",null,null,"key=web_vente_chkCompte_VousNePouvezPasLUtiliserPourUneAutreFusion")+"\n"+
                        dspt("fc=web&trslt=true",null,null,"key=web_vente_chkCompte_ChoisissezLOptionSuivante") + " : « " + dspt("fc=web&trslt=true",null,null,"key=Resa_lbl_NonPremiereVisite") + " ».";
                    alert(msg);            
                    break;
                case "-10":
                default:
                    msg=dspt("fc=web&trslt=true",null,null,"key=web_vente_authClient_LoginMDPincorrect")+"\n"+
                        dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_VeuillezCorrigerVotreSaisie");
                    alert(msg);            
                    break;
            }            
            break;
    }    
}
function validerCmd()
{
    var ret=dspt("fc=web&cmdnocb=true");
    switch(ret.split('|')[0])
    {
        case "00":
            nav(10,"&ref="+ret.split('|')[1]);
            break;
        default:
            msg=dspt("fc=web&trslt=true",null,null,"key=web_vente_erreur")+"\n"+
                dspt("fc=web&trslt=true",null,null,"key=web_vente_reserver_VeuillezRenouvelerOperation")+"\n"+
                dspt("fc=web&trslt=true",null,null,"key=web_vente_reserver_SiLePbPersiste");
            alert(msg);
            break;
    }
}
function validerChgmtPlace()
{
    if (window.frames[0].curNbSel==0)
    {
        alert(dspt("fc=web&trslt=true",null,null,"key=web_vente_ValiderChgmtPlace_SelectionnezUnePlace"));
        return;
    }
    var ret=dspt("fc=web&chgmtplc=true",null,null,"lig="+window.frames[0].oSel.lig+"&col="+window.frames[0].oSel.col+
                                                  "&numPlaceFormule="+window.frames[0].numPlaceFormule);
    switch(ret)
    {
        case "0":
            nav(2);
            break;
        case "-1":
            alert(dspt("fc=web&trslt=true",null,null,"key=ResaPlan_lbl_LaPlaceSelectionnee"));
            break;
        default:
            alert(dspt("fc=web&trslt=true",null,null,"key=web_vente_erreur")+"\n"+
                  dspt("fc=web&trslt=true",null,null,"key=web_vente_reserver_VeuillezRenouvelerOperation")+"\n"+
                  dspt("fc=web&trslt=true",null,null,"key=web_vente_reserver_SiLePbPersiste"));            
            break;
    }
}
function validerPlaceSiteFormuleMS()
{
    if (window.frames[0].curNbSel==0)
    {
        alert(dspt("fc=web&trslt=true",null,null,"key=web_vente_validerPlaceSiteFormuleMS_SelectionnezUneOuPlusieursPlace"));
        return;
    }
    nav(2,"&ap=2");
}
function validerPlFMS()
{
    var ret=dspt("fc=web&validerplfms=true");
    switch(ret)
    {
        case "0":
            nav(3);
            break;
        case "-1":
            alert(dspt("fc=web&trslt=true",null,null,"key=web_vente_validerPlFMS_ReservezVosPlacesPourChaqueSite"));
            break;
        case "-2":
            alert(dspt("fc=web&trslt=true",null,null,"key=web_vente_validerPlFMS_ReservezAuMoinsUnePlaceSurChaqueSite"));
            break;
        case "-3":
            alert(dspt("fc=web&trslt=true",null,null,"key=web_vente_validerPlFMS_LeNombreDePlacesReservees") + "\n" +
                  dspt("fc=web&trslt=true",null,null,"key=web_vente_validerPlFMS_VousDevezReserverLeMemeNombre") + "\n" +
                  dspt("fc=web&trslt=true",null,null,"key=web_vente_validerPlFMS_CorrigezVotreReservationEn"));
            break;
        case "-4":
            alert(dspt("fc=web&trslt=true",null,null,"key=web_vente_validerPlFMS_LesCategoriesDesPlacesReservees") + "\n" +
                  dspt("fc=web&trslt=true",null,null,"key=web_vente_validerPlFMS_VousDevezReserverLeMemeNombreParCat") + "\n" +
                  dspt("fc=web&trslt=true",null,null,"key=web_vente_validerPlFMS_CorrigezVotreReservation"));
            break;
        case "-10":
            alert(dspt("fc=web&trslt=true",null,null,"key=web_vente_erreur")+"\n"+
                  dspt("fc=web&trslt=true",null,null,"key=web_vente_reserver_VeuillezRenouvelerOperation")+"\n"+
                  dspt("fc=web&trslt=true",null,null,"key=web_vente_reserver_SiLePbPersiste"));          
            break;
    }
}
function setInfosPrlvmt()
{
    var rbRIB_IBANBIC=getSelRb(document.getElementsByName("rbRIB_IBANBIC"));
    if (rbRIB_IBANBIC=="-1")        
    {
        alert(dspt("fc=web&trslt=true",null,null,"key=web_vente_setCompte_VeuillezSelectionnerUneOption"));
        return;
    }
    switch(rbRIB_IBANBIC)
    {
        case "0":
            document.getElementById("tblIBANBIC").style.display="block";
            document.getElementById("tblRIB").style.display="none";
            break;
        case "1":
            document.getElementById("tblIBANBIC").style.display="none";
            document.getElementById("tblRIB").style.display="block";
            break;
    }
}
function validerInfosPrlvmt(type)
{
    var titulaire,banque,codeEtabl,codeGuich,numCompte,cleRIB,IBAN,BIC;
    switch(type)
    {
        case "RIB":
            titulaire=trim(document.getElementById("txtTitulaireRIB").value);
            if (titulaire=="")
            {
                msgVerif(document.getElementById("txtTitulaireRIB"),
                         dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_LeChamp")+" '"+
                         dspt("fc=web&trslt=true",null,null,"key=Paiement_lbl_Titulaire")+"' "+
                         dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_EstObligatoire")+"\n"+
                         dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_VeuillezCorrigerVotreSaisie"));
                return;
            }
            banque=trim(document.getElementById("txtBanqueRIB").value);
            if (banque=="")
            {
                msgVerif(document.getElementById("txtBanqueRIB"),
                         dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_LeChamp")+" '"+
                         dspt("fc=web&trslt=true",null,null,"key=Paiement_lbl_Banque")+"' "+
                         dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_EstObligatoire")+"\n"+
                         dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_VeuillezCorrigerVotreSaisie"));
                return;
            }
            codeEtabl=trim(document.getElementById("txtCodeEtablissementRIB").value);
            if (codeEtabl=="")
            {
                msgVerif(document.getElementById("txtCodeEtablissementRIB"),
                         dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_LeChamp")+" '"+
                         dspt("fc=web&trslt=true",null,null,"key=Paiement_lbl_CodeEtablissement")+"' "+
                         dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_EstObligatoire")+"\n"+
                         dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_VeuillezCorrigerVotreSaisie"));
                return;
            }
            codeGuich=trim(document.getElementById("txtCodeGuichetRIB").value);
            if (codeGuich=="")
            {
                msgVerif(document.getElementById("txtCodeGuichetRIB"),
                         dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_LeChamp")+" '"+
                         dspt("fc=web&trslt=true",null,null,"key=Paiement_lbl_CodeGuichet")+"' "+
                         dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_EstObligatoire")+"\n"+
                         dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_VeuillezCorrigerVotreSaisie"));
                return;
            }
            numCompte=trim(document.getElementById("txtNumCompteRIB").value);
            if (numCompte=="")
            {
                msgVerif(document.getElementById("txtNumCompteRIB"),
                         dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_LeChamp")+" '"+
                         dspt("fc=web&trslt=true",null,null,"key=Paiement_lbl_NumCompte")+"' "+
                         dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_EstObligatoire")+"\n"+
                         dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_VeuillezCorrigerVotreSaisie"));
                return;
            }
            cleRIB=trim(document.getElementById("txtCleRIB").value);
            if (cleRIB=="")
            {
                msgVerif(document.getElementById("txtCleRIB"),
                         dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_LeChamp")+" '"+
                         dspt("fc=web&trslt=true",null,null,"key=Paiement_lbl_Cle")+"' "+
                         dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_EstObligatoire")+"\n"+
                         dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_VeuillezCorrigerVotreSaisie"));
                return;
            }
            if (!isRIBvalid(codeEtabl, codeGuich, numCompte, cleRIB))
            {
                alert(dspt("fc=web&trslt=true",null,null,"key=web_vente_validerInfosPrlvmt_LesInfosBancaires"));                
                return;
            }
            break;
        case "IBANBIC":
            titulaire=trim(document.getElementById("txtTitulaireIBANBIC").value);
            if (titulaire=="")
            {
                msgVerif(document.getElementById("txtTitulaireIBANBIC"),
                         dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_LeChamp")+" '"+
                         dspt("fc=web&trslt=true",null,null,"key=Paiement_lbl_Titulaire")+"' "+
                         dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_EstObligatoire")+"\n"+
                         dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_VeuillezCorrigerVotreSaisie"));
                return;
            }
            banque=trim(document.getElementById("txtBanqueIBANBIC").value);
            if (banque=="")
            {
                msgVerif(document.getElementById("txtBanqueIBANBIC"),
                         dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_LeChamp")+" '"+
                         dspt("fc=web&trslt=true",null,null,"key=Paiement_lbl_Banque")+"' "+
                         dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_EstObligatoire")+"\n"+
                         dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_VeuillezCorrigerVotreSaisie"));
                return;
            }
            IBAN=trim(document.getElementById("txtIBAN").value);
            if (IBAN=="")
            {
                msgVerif(document.getElementById("txtIBAN"),
                         dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_LeChamp")+" '"+
                         dspt("fc=web&trslt=true",null,null,"key=Paiement_lbl_IBAN")+"' "+
                         dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_EstObligatoire")+"\n"+
                         dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_VeuillezCorrigerVotreSaisie"));
                return;
            }            
            BIC=trim(document.getElementById("txtBIC").value);            
            if (BIC=="")
            {
                msgVerif(document.getElementById("txtBIC"),
                         dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_LeChamp")+" '"+
                         dspt("fc=web&trslt=true",null,null,"key=Paiement_lbl_BIC")+"' "+
                         dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_EstObligatoire")+"\n"+
                         dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_VeuillezCorrigerVotreSaisie"));             
                return;
            }
            if (!isIBANvalid(IBAN,"txtIBAN"))
                return;
            if (!isBICvalid(BIC,"txtIBAN"))
                return;
            break;
    }
    var ret=dspt("fc=web&infosprlvmt=true",null,null,"type="+type+"&titulaire="+encodeURIComponent(titulaire)+
                                                     "&banque="+encodeURIComponent(banque)+"&codeEtabl="+codeEtabl+
                                                     "&codeGuich="+codeGuich+"&numCompte="+numCompte+"&cleRIB="+cleRIB+"&IBAN="+IBAN+"&BIC="+BIC);
    switch(ret)
    {
        case "0":
            showInfosPrlvmt(type, false);
            switch(type){
                case "IBANBIC":
                    document.getElementById("txtTitulaireRIB").value="";
                    document.getElementById("txtBanqueRIB").value="";
                    document.getElementById("txtCodeEtablissementRIB").value="";
                    document.getElementById("txtCodeGuichetRIB").value="";
                    document.getElementById("txtNumCompteRIB").value="";
                    document.getElementById("txtCleRIB").value="";                    
                    break;
                case "RIB":
                    document.getElementById("txtTitulaireIBANBIC").value="";
                    document.getElementById("txtBanqueIBANBIC").value="";
                    document.getElementById("txtIBAN").value="";
                    document.getElementById("txtBIC").value="";
                    break;
            }
            break;
        default:
            alert(dspt("fc=web&trslt=true",null,null,"key=web_vente_erreur")+"\n"+
                  dspt("fc=web&trslt=true",null,null,"key=web_vente_reserver_VeuillezRenouvelerOperation")+"\n"+
                  dspt("fc=web&trslt=true",null,null,"key=web_vente_reserver_SiLePbPersiste"));            
            break;
    }
}
function showInfosPrlvmt(type,visible){
    var clName=(visible ? "txtprlvmt" : "txtprlvmtdis");
    //document.getElementById("rbRIB_IBANBIC_0").disabled=(visible ? "" : "disabled");
    document.getElementById("rbRIB_IBANBIC_0").disabled="disabled";
    document.getElementById("rbRIB_IBANBIC_1").disabled=(visible ? "" : "disabled");
    document.getElementById("txtTitulaireRIB").className=clName;
    document.getElementById("txtBanqueRIB").className=clName;
    document.getElementById("txtCodeEtablissementRIB").className=clName;
    document.getElementById("txtCodeGuichetRIB").className=clName;
    document.getElementById("txtNumCompteRIB").className=clName;
    document.getElementById("txtCleRIB").className=clName;
    document.getElementById("txtTitulaireIBANBIC").className=clName;
    document.getElementById("txtBanqueIBANBIC").className=clName;
    document.getElementById("txtIBAN").className=clName;
    document.getElementById("txtBIC").className=clName;
    document.getElementById("btnValider_IBANBIC").value=(visible ? dspt("fc=web&trslt=true",null,null,"key=Client_btn_Valider") :
                                                                   dspt("fc=web&trslt=true",null,null,"key=Client_btn_Modifier"));
    document.getElementById("btnValider_IBANBIC").onclick=(visible ? function() { validerInfosPrlvmt('IBANBIC') } : function() { showInfosPrlvmt('IBANBIC', true) });
    document.getElementById("btnValider_RIB").value=(visible ? dspt("fc=web&trslt=true",null,null,"key=Client_btn_Valider") :
                                                               dspt("fc=web&trslt=true",null,null,"key=Client_btn_Modifier"));
    document.getElementById("btnValider_RIB").onclick=(visible ? function() { validerInfosPrlvmt('RIB') } : function() { showInfosPrlvmt('RIB', true) });
}
function isRIBvalid()
{
    if (isRIBvalid.arguments.length>=3)
	{
	    var bqe=isRIBvalid.arguments[0];
	    var gui=isRIBvalid.arguments[1];
	    var cpt=isRIBvalid.arguments[2].toUpperCase();        
	    var tab= "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
	    var tab1="123456789123456789234567890123456789".split("");
    	
                                while (cpt.match(/\D/) != null)
		    cpt=cpt.replace(/\D/, tab1[tab.indexOf(cpt.match(/\D/))]);
	    var cp=parseInt	(cpt, 10);	    
	    a=bqe%97;
	    a=a*100000+parseInt(gui, 10);
	    a=a%97;
	    a=a*Math.pow(10, 11) + cp;
	    a=a%97
	    a=a*100;
	    a=a%97
	    a=97-a;
	    if (isRIBvalid.arguments.length>3)
		    return isRIBvalid.arguments[3]==a;
	    else
		    return a;
	}
    else
    {
        return;
    }
}
function mod97(num) {
  var i = 0;
  var mod = "";
  var lg = num.length;
  while (i != lg) {
    var nb = lg - i;
    if (nb > 4) nb = 4;
    var int = "" + mod + num.substring(i, i + nb);
    mod = int % 97;
    i += nb;
  }
  return mod;
}
function isIBANvalid(str,txtId) {
  
  var num = "";
  var i = str.length;
  while (i > 0) {
    --i;
    var c = str.charAt(i);
    if (c == ' ' || c == '.' || c == '-') continue;
    if (!(c >= 'A' && c <= 'Z') && !(c >= '0' && c <= '9')) {
      msgVerif(document.getElementById(txtId),
               dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_LeChamp")+" '"+
               dspt("fc=web&trslt=true",null,null,"key=Paiement_lbl_IBAN")+"' "+
               dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_ContientUnCaractereNonAutorise") +
               " : " + c + "\n" +
               dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_VeuillezCorrigerVotreSaisie"));     
      return false;      
    }
    num = c + num;
  }
  
  var lg = num.length;
  if (lg < 5 || lg > 34) {
    alert(dspt("fc=web&trslt=true",null,null,"key=web_vente_isIBANvalid_LaLongueurDeLaCleIBAN"));
    return false;
  }
  num = num.substring(4) + num.substring(0, 4);
  
  var num2 = "";
  i = lg;
  while (i > 0) {
    --i;
    var c = num.charAt(i);
    if (c >= 'A' && c <= 'Z') {
      var n = num.charCodeAt(i) - 55;
      num2 = n + num2;
    } else {
      num2 = c + num2;
    }
  }
  num = num2;
  
  var mod = mod97(num);
  if (mod != 1) {
    alert(dspt("fc=web&trslt=true",null,null,"key=web_vente_validerInfosPrlvmt_LesInfosBancaires"));
    return false;
  }
  return true;
}
function isBICvalid(s,txtIdIBAN)
{
    if ((s.length!=8)&&(s.length!=11))
    {
        alert(dspt("fc=web&trslt=true",null,null,"key=web_vente_isBICvalid_LaLongueurDeBIC"));
        return false;
    }
    var IBAN=trim(document.getElementById(txtIdIBAN).value);
    var paysIBAN=IBAN.substring(0,2);
    var paysBIC=s.substring(4,6);
    if (paysIBAN != paysBIC)
    {
        alert(dspt("fc=web&trslt=true",null,null,"key=web_vente_validerInfosPrlvmt_LesInfosBancaires"));
        return false;
    }
    return true;
}
function setModeRglmt(){
    var mrC=document.getElementsByName("ModeReglement_Cmd");
    var mr;
    var prlvmtAuto=false;
    if (mrC.length>0)
    {
        mr=getSelRb(document.getElementsByName("rbModeReglement_Cmd")); 
        if (mr!="-1") 
            if (dspt("fc=web&isprlvmt=true",null,null,"mr="+mr)=="true")
                prlvmtAuto=true;
    }
    var mrM=document.getElementsByName("ModeReglement_M");
    if (mrM)
    {
        for (i = 0; i < mrM.length; i++)
        {
            mr=getSelRb(document.getElementsByName("rbModeReglement_M_" + mrM[i].id));
            if (mr!="-1") 
                if (dspt("fc=web&isprlvmt=true",null,null,"mr="+mr)=="true")
                    prlvmtAuto=true;
        }
    }
    var mrF=document.getElementsByName("ModeReglement_F");
    if (mrF)
    {
        for (i = 0; i < mrF.length; i++)
        {
            mr=getSelRb(document.getElementsByName("rbModeReglement_F_" + mrF[i].id));
            if (mr!="-1") 
                if (dspt("fc=web&isprlvmt=true",null,null,"mr="+mr)=="true")
                    prlvmtAuto=true;
        }
    }
    if (document.getElementById("tblPrlvmt"))
    {
        if (prlvmtAuto)
            document.getElementById("tblPrlvmt").style.display="";
        else
            document.getElementById("tblPrlvmt").style.display="none";
    }
}
function updPwd(){
    var pwd1=document.getElementById("txt1_fac").value;
    var pwd2=document.getElementById("txt2_fac").value;
    var pwd3=document.getElementById("txt3_fac").value;
    
    if (pwd1==""){
        msgVerif(document.getElementById("txt1_fac"),
                 dspt("fc=web&trslt=true",null,null,"key=Client_lbl_SaisissezVotreAncienMotDePasse"));
                return;
    }    
    if (pwd2.length<6){
        msgVerif(document.getElementById("txt2_fac"),
                 dspt("fc=web&trslt=true",null,null,"key=web_part_CoordsPartenaire_VotreNouveauMotDePasseDoitContenir"));
        return;
    }
    if (!isPwd(pwd2)){
        msgVerif(document.getElementById("txt2_fac"),
                 dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_LeChamp")+" '"+
                 dspt("fc=web&trslt=true",null,null,"key=Partenaire_lbl_NouveauMotDePasse")+"' "+
                 dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_ContientUnCaractereNonAutorise") +
                 " : " + wrongCar + "\n" +
                 dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_VeuillezCorrigerVotreSaisie"));                         
        return;
    }
    if (pwd2!=pwd3)
    {
        msgVerif(document.getElementById("txt3_fac"),
                 dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_MotDePasseConfirmNonValide")+"\n"+
                 dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_VeuillezCorrigerVotreSaisie"));                            
        return;
    }  
    var ret=dspt("fc=web&updpwd=true",null,null,
                 "pwd1="+pwd1+"&pwd2="+pwd2+"&pwd3="+pwd3);
    switch(ret){
        case "0":
            alert(dspt("fc=web&trslt=true",null,null,"key=web_esp_modMdp_MotDePasseModifie"));
            nav(6);
            break;
        default:
            alert(dspt("fc=web&trslt=true", null, null, "key=web_vente_erreur") + "\n" +
                  dspt("fc=web&trslt=true", null, null, "key=web_vente_reserver_VeuillezRenouvelerOperation"));
            break;
    }
}
function setAnchor(){
    location.href = location.href+"#container_top";
}
function CGAU()
{
    document.getElementById("chkCGV").checked = true;
    document.getElementById("divmodespaiement").style.display="block";
    if (document.getElementById("lang").value=="FR")
        window.open("/App/Homes/" + document.getElementById("wId").value + "/CGAU.htm");        
    else
        window.open("/App/Homes/" + document.getElementById("wId").value + "/CGAU_"+document.getElementById("lang").value+".htm");        
}
function beneficiaire(previousNext){    
    var nomBeneficiaire=trim(document.getElementById("txtNomBeneficiaire").value);
    var prenomBeneficiaire=trim(document.getElementById("txtPrenomBeneficiaire").value);
    var mailBeneficiaire=trim(document.getElementById("txtEMailBeneficiaire").value);
    var refPlaceBeneficiaire=trim(document.getElementById("txtRefPlaceBeneficiaire").value);
    
    if (nomBeneficiaire=="")
    {
        msgVerif(document.getElementById("txtNomBeneficiaire"),
                 dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_LeChamp")+" '"+
                 dspt("fc=web&trslt=true",null,null,"key=Client_lbl_Nom")+"' "+
                 dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_EstObligatoire")+"\n"+
                 dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_VeuillezCorrigerVotreSaisie"));
        return false;
    }
    if (!isAlphaNum(nomBeneficiaire))
    {
        msgVerif(document.getElementById("txtNomBeneficiaire"),
                 dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_LeChamp")+" '"+
                 dspt("fc=web&trslt=true",null,null,"key=Client_lbl_Nom")+"' "+
                 dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_ContientUnCaractereNonAutorise") +
                 " : " + wrongCar + "\n" +
                 dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_VeuillezCorrigerVotreSaisie"));
        return false;
    }
    if (prenomBeneficiaire=="")
    {
        msgVerif(document.getElementById("txtPrenomBeneficiaire"),
                 dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_LeChamp")+" '"+
                 dspt("fc=web&trslt=true",null,null,"key=Client_lbl_Prenom")+"' "+
                 dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_EstObligatoire")+"\n"+
                 dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_VeuillezCorrigerVotreSaisie"));
        return false;
    }
    if (!isAlphaNum(prenomBeneficiaire))
    {
        msgVerif(document.getElementById("txtPrenomBeneficiaire"),
                 dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_LeChamp")+" '"+
                 dspt("fc=web&trslt=true",null,null,"key=Client_lbl_Prenom")+"' "+
                 dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_ContientUnCaractereNonAutorise") +
                 " : " + wrongCar + "\n" +
                 dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_VeuillezCorrigerVotreSaisie"));
        return false;
    }
    if ((mailBeneficiaire!="")&&!verifMail(mailBeneficiaire))
    {
        msgVerif(document.getElementById("txtEMailBeneficiaire"),
                 dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_MailValide")+"\n"+
                 dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_VeuillezCorrigerVotreSaisie"));
        return false;
    }    
    var numPIdPlaceBeneficiaire="";    
    var typePIdPlaceBeneficiaire="";
    
    if(document.getElementById("txtNumPIdBeneficiaire"))
    {
        numPIdPlaceBeneficiaire=trim(document.getElementById("txtNumPIdBeneficiaire").value);
        if (numPIdPlaceBeneficiaire=="")
        {
            msgVerif(document.getElementById("txtNumPIdBeneficiaire"),
                     dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_LeChamp")+" '"+
                     dspt("fc=web&trslt=true",null,null,"key=Client_lbl_NumPieceId")+"' "+
                     dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_EstObligatoire")+"\n"+
                     dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_VeuillezCorrigerVotreSaisie"));
            return false;
        }
        if (!isAlphaNum(numPIdPlaceBeneficiaire))
        {
            msgVerif(document.getElementById("txtNumPIdBeneficiaire"),
                     dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_LeChamp")+" '"+
                     dspt("fc=web&trslt=true",null,null,"key=Client_lbl_NumPieceId")+"' "+
                     dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_ContientUnCaractereNonAutorise") +
                     " : " + wrongCar + "\n" +
                     dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_VeuillezCorrigerVotreSaisie"));
            return false;
        }
        typePIdPlaceBeneficiaire=getSelRb(document.getElementsByName("rbTypePId"));
        if (typePIdPlaceBeneficiaire=="-1")
        {
            alert(dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_LeChamp")+" '"+
                  dspt("fc=web&trslt=true",null,null,"key=Client_lbl_TypePieceId")+"' "+
                  dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_EstObligatoire")+"\n"+
                  dspt("fc=web&trslt=true",null,null,"key=web_vente_addUpdClient_VeuillezCorrigerVotreSaisie"));
            return;
        }
    }
        
    var ret=dspt("fc=web&beneficiairePlaces=true",null,null,
                 "nom="+nomBeneficiaire+"&prn="+prenomBeneficiaire+"&mail="+mailBeneficiaire+
                 "&refPlace="+refPlaceBeneficiaire+"&numPId="+numPIdPlaceBeneficiaire+"&typePId="+typePIdPlaceBeneficiaire);
    switch(ret){
        case "0":
            if (previousNext)
            {
                var retBenef=dspt("fc=web&previousNextBeneficiaire=true",null,null,
                                  "refPlace="+refPlaceBeneficiaire+"&previousNext="+previousNext);  
                if (retBenef!="")
                {
                    document.getElementById("divTblBeneficiaire").innerHTML=retBenef.split('|')[0];
                    switch(retBenef.split('|')[1])
                    {
                        case "0":
                            document.getElementById("btnAnnulerCmd").style.visibility="hidden";
                            document.getElementById("btnValiderCmd").style.visibility="hidden";
                            break;
                        case "1":
                            document.getElementById("btnAnnulerCmd").style.visibility="visible";
                            document.getElementById("btnValiderCmd").style.visibility="visible";
                            break;
                    }
                    if (document.getElementById("txtNomBeneficiaire"))
                        document.getElementById("txtNomBeneficiaire").focus();
                }
            }
            return true;            
        default:
            alert(dspt("fc=web&trslt=true", null, null, "key=web_vente_erreur") + "\n" +
                  dspt("fc=web&trslt=true", null, null, "key=web_vente_reserver_VeuillezRenouvelerOperation"));
            return false;
    }
}
function docCmd(cmd,typeDoc){
    var retDoc = dspt("fc=web&doccmd=true",null,null,
                      "cmd="+cmd+"&typedoc="+typeDoc);
    switch (retDoc.split('|')[0])
    {
        case "0":            
            window.location.href=retDoc.split('|')[1];
            break;
        default :
            alert(dspt("fc=web&trslt=true", null, null, "key=web_vente_erreur") + "\n" +
                  dspt("fc=web&trslt=true", null, null, "key=web_vente_reserver_VeuillezRenouvelerOperation"));
            break;        
    }
}