function checkForm() {
	var aRemplir = "";
	if ($("wf_Nom").getValue() == "") {
		aRemplir += "nom, ";
	}
	if ($("wf_societe").getValue() == "") {
		aRemplir += "prénom, ";
	}
	if ($("wf_e-Mail").getValue() == "") {
		aRemplir += "email, ";
	}
	if ($("wf_adresse").getValue() == "") {
		aRemplir += "adresse de facturation, ";
	}
	if ($("wf_cp").getValue() == "") {
		aRemplir += "code postal de facturation, ";
	}
	if ($("wf_ville").getValue() == "") {
		aRemplir += "ville de facturation, ";
	}
	if (aRemplir != "") {
		alert('Veuillez remplir les champs suivants : '+aRemplir.substr(0, aRemplir.length-2));
		return false;
	} else {
		return true;
	}
}

function in_UE(pays){
	var europe=new Array("GB","IO","DE","AT","BE","DK","ES","FR","FX","GR","FI","IE","IT","LU","HU","NL","AN","PT","SE","CY","EE","PL","CZ","SI","LV","LT","SK","MT","RO","BG","VG");
	//alert (europe.length);
	for (var i=0 ; i<europe.length ; i++){
		if(europe[i]==pays){
			return true;
		}
	}
	return false;
}


function refresh_total_amount(){
	
	var total=0;
	
	//alert(document.getElementById(quantite));
	var nb_dvd = parseInt($("quantity").getValue());
	var prix_dvd = parseFloat($("amount_unit").getValue());
	// récupération des adresses 
	var adresse_liv=$("wf_adresse_liv").getValue()+ $("wf_cp_liv").getValue()+ $("wf_ville_liv").getValue() ;
	
	if(  !empty(adresse_liv) ){
		var pays= $("wf_pays_liv").getValue();		
	}else{
		var pays= $("wf_pays").getValue();
	}
	if(in_UE(pays)){
		if(pays=="FR" || pays=="FX"){
			var fdp=1.95;
			$("shipping_detail").innerHTML="France m&eacute;tropolitaine / France: "+(Math.round(fdp*nb_dvd*100))/100+" &euro;";
		}else{
			var fdp=2.95;
			$("shipping_detail").innerHTML="UE: "+(Math.round(fdp*nb_dvd*100))/100+" &euro;";
		}
		
	}else{
		var fdp=3.95;
		$("shipping_detail").innerHTML="Hors UE et DOM TOM / Outside EU: "+(Math.round(fdp*nb_dvd*100))/100+" &euro;";		
	}
	// montant a payer
	var amount=(prix_dvd+fdp)*nb_dvd;
	var total="<strong> "+amount+"&euro;</strong> ";
	
	// determination de l'application de la tva
	var pays_fact=$("wf_pays").getValue();
	if(in_UE(pays_fact)){
		var tva=true;
		var taux_tva=19.6;
		var montant_tva=(Math.round((amount*0.196/1.196)*100))/100;
		total+="<br/> Dont TVA : "+montant_tva+" &euro;";
	}else{
		var tva=false;
		var taux_tva=0;
		var montant_tva=0;
	}
	
	//Mise a jour des valeurs paypal
	$("amount").value=(Math.round(amount*100))/100;
	// mise a jour de l'énoncé de la commande 
	$("item_name").value=nb_dvd+" DVD Early times";
	
	// affichage du total de la commande	
	$("total").innerHTML=total;		
	 
	// mise a jour de la variable custom 
	$("custom").value="('"+ $("wf_adresse").getValue() +"','"+ $("wf_cp").getValue() +"','"+ $("wf_ville").getValue() +"','"+ $("wf_pays").getValue() +"','"+ $("wf_adresse_liv").getValue() +"','"+ $("wf_cp_liv").getValue() +"','"+ $("wf_ville_liv").getValue() +"','"+ $("wf_pays_liv").getValue() +"',"+ nb_dvd +","+ prix_dvd +","+ fdp +","+ tva +","+ taux_tva +","+ montant_tva +")";
	
	// mise à jour des variables d'adresses pour paypal
	if(  !empty(adresse_liv) ){
		$("address1").value = $("wf_adresse_liv").getValue();
		$("zip").value = $("wf_cp_liv").getValue();
		$("city").value = $("wf_ville_liv").getValue();
		$("country").value = $("wf_pays_liv").getValue();
	} else {
		$("address1").value = $("wf_adresse").getValue();
		$("zip").value = $("wf_cp").getValue();
		$("city").value = $("wf_ville").getValue();
		$("country").value = $("wf_pays").getValue();
	}
	
}


function empty( mixed_var ) {
    // http://kevin.vanzonneveld.net
    // +   original by: Philippe Baumann
    // *     example 1: empty(null);
    // *     returns 1: true
	mixed_var=trim(mixed_var);
    return ( mixed_var === "" || mixed_var === 0   || mixed_var === "0" || mixed_var === null  || mixed_var === false   );
}

function trim( str, charlist ) {
    // http://kevin.vanzonneveld.net
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: mdsjack (http://www.mdsjack.bo.it)
    // +   improved by: Alexander Ermolaev (http://snippets.dzone.com/user/AlexanderErmolaev)
    // +      input by: Erkekjetter
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +      input by: DxGx
    // +   improved by: Steven Levithan (http://blog.stevenlevithan.com)
    // *     example 1: trim('    Kevin van Zonneveld    ');
    // *     returns 1: 'Kevin van Zonneveld'
    // *     example 2: trim('Hello World', 'Hdle');
    // *     returns 2: 'o Wor'
 
    var whitespace;
    
    if(!charlist){
        whitespace = ' \n\r\t\f\x0b\xa0\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u200b\u2028\u2029\u3000';
    } else{
        whitespace = charlist.replace(/([\[\]\(\)\.\?\/\*\{\}\+\$\^\:])/g, '\$1');
    }
  
  for (var i = 0; i < str.length; i++) {
    if (whitespace.indexOf(str.charAt(i)) === -1) {
    str = str.substring(i);
    break;
    }
  }
  for (i = str.length - 1; i >= 0; i--) {
    if (whitespace.indexOf(str.charAt(i)) === -1) {
      str = str.substring(0, i + 1);
      break;
      }
  }
  return whitespace.indexOf(str.charAt(0)) === -1 ? str : '';
}

