function choixPage(nPage){



  sLocation = window.location.href;



  if (sLocation.match(/.*(page=\d+).*/g)!=null){



    sLocation = sLocation.replace(/page=\d+/g,"page="+nPage);



  } else {



    if (sLocation.match(/.*\?.*/g)!=null){



      sLocation = sLocation +"&page="+nPage;





    } else {



      sLocation = sLocation +"?page="+nPage;





    } // if



  } // if



  if (window.location.href != sLocation){



    window.location = sLocation;



  } // if



} // function



function ValideForm(){

var obj = document.forms[0];

captVerif(obj);

}



function validateForm(){



    if (document.getElementById('nom_cli').value==''){



        alert ('Il faut bien remplir le champ "Nom"');



        return false;



    }

    if (document.getElementById('prenom_cli').value==''){



        alert ('Il faut bien remplir le champ "Prenom"');



        return false;



    }

    if (document.getElementById('mail_cli').value==''){



        alert ('Il faut bien remplir le champ "Mail"');



        return false;



    }

    if (document.getElementById('tel_cli').value==''){



        alert ('Il faut bien remplir le champ "Téléphone"');



        return false;



    }

    if (document.getElementById('adresse_cli').value==''){



        alert ('Il faut bien remplir le champ "Adresse"');



        return false;



    }

    if (document.getElementById('postal_cli').value==''){



        alert ('Il faut bien remplir le champ "Code"');



        return false;



    }



    if (document.getElementById('ville_cli').value==''){



        alert ('Il faut bien remplir le champ "Ville"');



        return false;



    }



    if (document.getElementById('pass_cli').value==''){



        alert ('Il faut bien remplir le champ "Mot de passe"');



        return false;



    }



    if (document.getElementById('pass_cli').value!=document.getElementById('password_retype').value){



        alert ('Il faut repetez mot de passe');



        return false;



    }



return true;



}



function addEvent(obj, evType, fn, useCapture){

  if (obj && obj.addEventListener){

    obj.addEventListener(evType, fn, useCapture);

    return true;

  } else if (obj && obj.attachEvent){

    var r = obj.attachEvent("on"+evType, fn);

    return r;

  } else {

   alert("Handler could not be attached");

  }

}



function addToBasket(oLink, $nId){



    if (document.getElementById('iCurrDecl') && document.getElementById('iCurrDecl').value){



        $sDecl = document.getElementById('iCurrDecl').value;



    } else {



        $sDecl = '0';



    }



    $sLink = 'produit.php?ajoutpanier=1&idprod='+$nId+'.'+$sDecl;



    oLink.setAttribute('href',$sLink);





}



function getValue(nId, sFrom){



    aValues = document.getElementById(sFrom).value.split(',');



    for (i=0; i<aValues.length; i++){



        aCurrent = aValues[i].split(':');



        if (aCurrent[0] == nId){



            return aCurrent[1];



        }



    }



    return 0;





}



function fca(){





 var oS2 = document.getElementById('iS');



 var nSelectedValue = oS2.options[oS2.selectedIndex].getAttribute('id_proddec');



 document.getElementById('iPriceHolder').innerHTML = getValue(nSelectedValue, 'prix');

 document.getElementById('iWeightHolder').innerHTML = getValue(nSelectedValue, 'dPoidsLot');

 document.getElementById('iRefHolder').innerHTML = getValue(nSelectedValue, 'dReference');



 nLot = getValue(nSelectedValue, 'dLot');



 if (nLot == 0 || nLot == undefined || nLot == null){nLot = 1}







 document.getElementById('iStockHolder').innerHTML = nLot;

 document.getElementById('iCurrDecl').value = nSelectedValue;



 // filterCorelates('iS1','iS2');



}





function init_fca(){



if (document.getElementById('iS')){



document.getElementById('iS').onchange = 'fca();';



addEvent(document.getElementById('iS'), 'change', fca,  false);



fca();



}



}

function addColor(sId){



	 aVal = new Array();

	 i = 0;



	 $('#'+sId+" option:selected").each(function() {



                aVal[i] = $(this).val();

                i++;

     });



	sVal = aVal.join('-');



	if (sVal == undefined || sVal == ''){



		alert('Choissiez coleur');

		return false;



	} else {



		href=($('#href_'+sId).attr('href'))+'.'+sVal;

		href=$('#href_'+sId).attr('href',href)

		return true;

	}





}


