




	/////////////////////
	// modes de livraison
	/////////////////////

	var modeDeLivraisonSelectionne;

	function displayLivraison(){

		var valeurPaysDepart = $("#expedition").attr("value");

		var valeurPaysArrivee = $("#vers").attr("value");


		effaceApresPaysArr();

		$("#modeDeLivraisonDiv").hide();


		if(valeurPaysDepart!="" && valeurPaysArrivee!=""){

			$.ajax({
			   	type: "POST",
   				url: "modeDeLivraisonStubs.do",
   				data: "paysDepart=" + valeurPaysDepart + "&paysArrivee=" + valeurPaysArrivee,
   				success: function(responseXml){
     				fillLivraison(responseXml);
   				},
   				error: function(responseXml) { fillErreur(responseXml);}
 				});

		}

	}

	function fillLivraison(responseXml){



		var select = $('#mode');

		$("#modeDeLivraisonDiv").show('fast');

		$.scrollTo("#modeDeLivraisonDiv",100, {axis:'y',margin:true,offset:-250});


		select.empty();





		$(responseXml).find("modeDeLivraison").each(function() {

      		var vcode = $(this).find("code").text();

      		var vlibelle = $(this).find("libelle").text();

      		//alert('vcode:'+vcode);
      		//alert('vlibelle:'+vlibelle);

			select.append("<option value='" + vcode + "'>" + vlibelle + "</option>");

		});



		var nbElts = $(responseXml).find("modeDeLivraison").length;


		if(nbElts>2){
			$("#modeDeLivraisonDiv").show('fast');
			$.scrollTo("#modeDeLivraisonDiv",100, {axis:'y',margin:true,offset:-250});

		} else if(nbElts==2){
			modeDeLivraisonSelectionneTemp=$(responseXml).find("modeDeLivraison").eq(1).find("code").text();
			displayOptions(modeDeLivraisonSelectionneTemp);


		$("#modeDeLivraisonDiv").hide();
		$("#modeDeLivraisonDiv").css("display", "none").fadeOut(0);


		} 




	}

	/////////////////////////////
	// options
	/////////////////////////////

	var optionSelectionne;



	function displayOptions(codeModeLivraison){


		if(codeModeLivraison!=''){
			modeDeLivraisonSelectionne=codeModeLivraison;
		} else {

			modeDeLivraisonSelectionne=$("#mode").attr("value");

		}



		var valeurModeDeLivraison = modeDeLivraisonSelectionne;

		var valeurPaysDepart = $("#expedition").attr("value");

		var valeurPaysArrivee = $("#vers").attr("value");

		effaceApresModeLivraison();

		if(valeurPaysDepart!="" && valeurPaysArrivee!="" && valeurModeDeLivraison!=""){

			$.ajax({
			   	type: "POST",
   				url: "optionsStubs.do",
   				data: "paysDepart=" + valeurPaysDepart + "&paysArrivee=" + valeurPaysArrivee + "&modeLivraison=" + valeurModeDeLivraison ,
   				success: function(responseXml){
     				fillOptions(responseXml);
   				},
   				error: function(responseXml) { fillErreur(responseXml);}
 			});

		}

	}

	function fillOptions(responseXml){


		var select = $('#optionSelect');

		select.empty();

		$(responseXml).find("option").each(function() {

      		var vcode = $(this).find("code").text();

      		var vlibelle = $(this).find("libelle").text();

      	//	alert('vcode:'+vcode);
      	//	alert('vlibelle:'+vlibelle);

			select.append("<option value='" + vcode + "'>" + vlibelle + "</option>");

		});


		var nbElts = $(responseXml).find("option").length;


		if(nbElts>2){
			$("#optionsDiv").show('fast');
			$.scrollTo("#optionsDiv",100, {axis:'y',margin:true,offset:-250});

		} else if(nbElts==2){
			optionSelectionneTemp=$(responseXml).find("option").eq(1).find("code").text();
			showProducts(optionSelectionneTemp);
		} 


	}


	/////////////////////
	// les produits !
	/////////////////////

	var codeFicheProduitSelectionne;

	var codeProduitSelectionne;

	var autoriseRechargementEmballage=false;

	var codePaysDest;

	var codePaysDep;

	var codePaysDep;

	var presencePaysInter=false;

	function showProducts(codeOption){

		if(codeOption!=''){
			optionSelectionne=codeOption;
		} else {

			optionSelectionne=$("#optionSelect").attr("value");

		}



		var valeurPaysDepart = $("#expedition").attr("value");

		codePaysDep=valeurPaysDepart;


		var valeurPaysArrivee = $("#vers").attr("value");

		codePaysDest=valeurPaysArrivee;

		var valeurModeDeLivraison = modeDeLivraisonSelectionne;

		var valeurOption = optionSelectionne;

		effaceApresOptions();

		if(valeurPaysDepart!="" && valeurPaysArrivee!="" && valeurModeDeLivraison!="" && valeurOption!=""){

			$.ajax({
			   	type: "POST",
   				url: "trouveProduitsStubs.do",
   				data: "paysDepart=" + valeurPaysDepart + "&paysArrivee=" + valeurPaysArrivee + "&modeLivraison=" + valeurModeDeLivraison + "&option=" + valeurOption,
   				success: function(responseHtml){
     				fillProducts(responseHtml);
   				},
   				error: function(responseXml) { fillErreur(responseXml);}
 			});

		}

	}

	function fillProducts(responseHtml){

		$("#productsDiv").html(responseHtml);

		var num = 0;

		 $(".mea").each(function() {
			 num++;
		 });

		if(num==1){
			$("#productsDiv").css("width","36%");
		} else if (num==2){
			$("#productsDiv").css("width","68%");
		}else if (num==3){
			$("#productsDiv").css("width","110%");
		}


		$("#introProductsDiv").show('fast');

		$("#productsDiv").show('fast');

		//$("#productsDiv").localScroll();
		$.scrollTo("#productsDiv",100, {axis:'y',margin:true,offset:-250});

	}


	////////////////////////
	// formulaire de produit
	///////////////////////


	function showProductForm(codeFamilleProduit, codeOption, codePaysDestChoisi, codePaysDepartChoisi){


		effaceErreurs();

		var valeurOption;

		if(codeOption != ''){

			valeurOption = codeOption;

		} else {

			valeurOption = optionSelectionne;

		}

		if(codePaysDepartChoisi != ''){


			codePaysDep = codePaysDepartChoisi;

		}

		effaceApresProduits();


		if(codePaysDestChoisi != ''){



			codePaysDest = codePaysDestChoisi;



		}


		if(codePaysDestChoisi != 'NULL'){





			showProduitSolutionAffranchissement(codeFamilleProduit, valeurOption );

		} else {



			codeFicheProduitSelectionne = codeFamilleProduit;
			$("#paysDestinationFicheProduit").show('fast');
			$.scrollTo("#paysDestinationFicheProduit",100, {axis:'y',margin:true,offset:-250});


		}




	}

	function preShowProduitSolutionAffranchissement(){

		var codePaysDestChoisi  = $("#paysDestinationFicheProduitSelect").attr("value");

		effaceApresProduits();

		if(codePaysDestChoisi!=""){

			codePaysDest = codePaysDestChoisi;

			showProduitSolutionAffranchissement(codeFicheProduitSelectionne, 'NULL' );

		}

	}

	function showProduitSolutionAffranchissement(codeFamilleProduit, valeurOption ){


		$.ajax({
	   		type: "POST",
				url: "trouveProduitSolutionAffranchissementStubs.do",
				data: "codeFamilleProduit=" + codeFamilleProduit + "&codeTypTax=" + valeurOption,
				success: function(responseXml){
				fillProduitSolutionAffranchissement(responseXml);
				},
   				error: function(responseXml) { fillErreur(responseXml);}
			});

		$("#formProduitDiv").show('fast');

		$.scrollTo("#formProduitDiv",100, {axis:'y',margin:true,offset:-250});

	}

	/////////////////////////////
	// fiche produit - solutions affranchissemens
	/////////////////////////////


	function fillProduitSolutionAffranchissement(responseXml){

		var select = $('#formProduitSolution');

		select.empty();

		$(responseXml).find("solutionAffranchissement").each(function() {

      		var vcode = $(this).find("code").text();

      		var vlibelle = $(this).find("libelle").text();

			select.append("<option value='" + vcode + "'>" + vlibelle + "</option>");

		});


		var nbElts = $(responseXml).find("solutionAffranchissement").length;


		if(nbElts>2){
			$("#solutionAffranchissement").show('fast');
			$.scrollTo("#formProduitDiv",100, {axis:'y',margin:true,offset:-250});
		} else if(nbElts==2){
			var eltSolutionAffranchissement=$(responseXml).find("solutionAffranchissement").eq(1).find("code").text();
			showFormProductPaysDestination(eltSolutionAffranchissement);
		} 

	}




	/////////////////////////////
	// fiche produit - pays de destination
	/////////////////////////////



	function showFormProductPaysDestination(eltSolutionAffranchissement){

		var valeurPaysArrivee = codePaysDest;

		var valeurSolutionAffranchissement;

		if(eltSolutionAffranchissement!=""){
			valeurSolutionAffranchissement = eltSolutionAffranchissement;
		} else {
			valeurSolutionAffranchissement = $("#formProduitSolution").attr("value");
		}

		codeProduitSelectionne = valeurSolutionAffranchissement;


		effaceApresSolutionsAffranchissements();

		if(valeurSolutionAffranchissement!=""){

			$.ajax({
			   	type: "POST",
   				url: "trouveProduitPaysStubs.do",
   				data: "solutionAffranchissement=" + valeurSolutionAffranchissement + "&paysArrivee=" + valeurPaysArrivee,
   				success: function(responseXml){
     				fillFormProductPaysDestination(responseXml,valeurSolutionAffranchissement);
   				},
   				error: function(responseXml) { fillErreur(responseXml);}
 			});

		}

	}



	function fillFormProductPaysDestination(responseXml,valeurSolutionAffranchissement){

		var select = $('#formProduitPays');

		select.empty();

		var nbElts = $(responseXml).find("pays").length;

		if(nbElts>1){

			$(responseXml).find("pays").each(function() {

	      		var vcode = $(this).find("code").text();

	      		var vlibelle = $(this).find("libelle").text();

				select.append("<option value='" + vcode + "'>" + vlibelle + "</option>");

			});

			presencePaysInter=true;

			$("#paysDestination").show('fast');
			$.scrollTo("#paysDestination",100, {axis:'y',margin:true,offset:-250});

		} else {

			presencePaysInter=false;

			showFormProductTxRec();

		}

	}



	///////////////////////////
	// fiche produit - tx rec
	/////////////////////////////

	function showFormProductTxRec(){

		var valeurSolutionAffranchissement = codeProduitSelectionne;

		var valeurCodePaysArrivee = codePaysDest;

		var valeurPaysArrivee2 = $("#formProduitPays").attr("value");

			effaceApresPaysDestination();

			if(presencePaysInter && valeurPaysArrivee2==''){

			} else {

				$.ajax({
				   	type: "POST",
	   				url: "trouveProduitTauxStubs.do",
	   				data: "codeProduit=" + valeurSolutionAffranchissement+"&codePaysArrivee="+valeurCodePaysArrivee+"&codePaysArrivee2="+valeurPaysArrivee2,
	   				success: function(responseXml){
	     				fillProduitTaux(responseXml,valeurSolutionAffranchissement);
	   				},
   				error: function(responseXml) { fillErreur(responseXml);}
	 			});

			}

	}


	function fillProduitTaux(responseXml,valeurSolutionAffranchissement){

		var select = $('#formProduitTaux');

		select.empty();

		var nbElts = $(responseXml).find("taux").length;

		if(nbElts>1){

			$(responseXml).find("taux").each(function() {

	      		var vcode = $(this).find("code").text();

	      		var vlibelle = $(this).find("libelle").text();

				select.append("<option value='" + vcode + "'>" + vlibelle + "</option>");

			});

			$("#txRecommandation").show('fast');
			$.scrollTo("#txRecommandation",100, {axis:'y',margin:true,offset:-250});

		}

		showFormProductPoids(valeurSolutionAffranchissement);

	}




	///////////////////////////
	// fiche produit - poids
	/////////////////////////////

	function showFormProductPoids(valeurSolutionAffranchissement){

		fillProduitPoids(valeurSolutionAffranchissement);

	}


	function fillProduitPoids(valeurSolutionAffranchissement){

		$("#poidline").show('fast');
		$.scrollTo("#poidline",100, {axis:'y',margin:true,offset:-250});


		// attention, on affiche le prochain elt form si ce n est pas un produit emballage

			$.ajax({
			   	type: "POST",
   				url: "determineAffichageProduitFormatEmballageStubs.do",
   				data: "codeProduit=" + valeurSolutionAffranchissement,
   				success: function(responseXml){
     				determineAffichageProduitFormatEmballage(responseXml);
   				},
   				error: function(responseXml) { fillErreur(responseXml);}
 			});


	}




	function determineAffichageProduitFormatEmballage(responseXml){


		var nbElts = $(responseXml).find("autorise").length;

		if(nbElts == 0){

			showFormProductFormatEmballage();

			autoriseRechargementEmballage=false;

			$("#boutonOkPoids").hide();


		} else {


			$("#boutonOkPoids").css("display", "inline").fadeIn(1000);

			autoriseRechargementEmballage=true;

		}

	}


	function showFormProductFormatEmballageACondition(){



		effaceApresPoids();


		if(autoriseRechargementEmballage){

			showFormProductFormatEmballage();

		}

	}



	function fillErreur(rXml){

		effaceErreurs();

		$(rXml.responseXML).find("erreurResponse").children().each(function() {


			var champEnErreur = this.tagName;

			var msgErr = this.firstChild.nodeValue;


			//alert('champEnErreur:'+champEnErreur);

			//alert('msgErr:'+msgErr);

			// div info erreur presente
			$("#erreursDansFicheProduitDiv").show('fast');



			if(champEnErreur=='poids'){

				$("#poidErreurlineMessage").text(msgErr);

				$("#poidErreurline").show('fast');

			} else if(champEnErreur=='natureEnvoi'){

				$("#natureEnvoiErreurlineMessage").text(msgErr);

				$("#natureEnvoiErreurline").show('fast');

			}  else if(champEnErreur=='formatEmballage'){

				$("#formatEmballageErreurlineMessage").text(msgErr);

				$("#formatEmballageErreurline").show('fast');

			} else if(champEnErreur=='valeurDeclare'){

				$("#valeurDeclareeErreurlineMessage").text(msgErr);

				$("#valeurDeclareeErreurline").show('fast');

			} else if(champEnErreur=='assuranceOptionnelle'){

				$("#assuranceOptionnelleErreurlineMessage").text(msgErr);

				$("#assuranceOptionnelleErreurline").show('fast');

			} else if(champEnErreur=='tauxRecommandation'){

				$("#tauxrecommandationErreurlineMessage").text(msgErr);

				$("#tauxrecommandationErreurline").show('fast');

			} else if(champEnErreur=='contreRemboursement'){

				$("#contreRemboursementErreurlineMessage").text(msgErr);

				$("#contreRemboursementErreurline").show('fast');

			} else {

				//$("#templateRechercheDiv").hide();

				//$("#templateRechercheDivErreurLineMessage").text(msgErr);

				//$("#templateRechercheDivErreurLine").show('fast');

				//window.location.href="errorPage.jsp";
				$(location).attr('href',"errorPage.jsp");

			}

		});

	}






	///////////////////////////
	// fiche produit - format emballage
	/////////////////////////////

	function showFormProductFormatEmballage(){

		effaceErreurs();

		var valeurSolutionAffranchissement = codeProduitSelectionne;

		var valeurPoids = $("#poid").attr("value");

		var valeurPaysArrivee = codePaysDest;

		var valeurPaysArrivee2 = $("#formProduitPays").attr("value");

			$.ajax({
			   	type: "POST",
   				url: "trouveProduitFormatEmballageStubs.do",
   				data: "codeProduit=" + valeurSolutionAffranchissement + "&poids=" + valeurPoids + "&codePaysDestination1=" + valeurPaysArrivee + "&codePaysDestination2=" + valeurPaysArrivee2,
   				success: function(responseXml){
     				fillProduitFormatEmballage(responseXml,valeurSolutionAffranchissement);},
   				error: function(responseXml) { fillErreur(responseXml); }
 			});

	}


	function fillProduitFormatEmballage(responseXml,valeurSolutionAffranchissement){



		var select = $('#formProduitFormatEmballage');

		select.empty();

		var nbElts = $(responseXml).find("format").length;

		if(nbElts>0){

			$(responseXml).find("format").each(function() {

	      		var vcode = $(this).find("code").text();

	      		var vlibelle = $(this).find("libelle").text();

				select.append("<option value='" + vcode + "'>" + vlibelle + "</option>");

			});

			$("#Formatline").show('fast');
			$.scrollTo("#Formatline",100, {axis:'y',margin:true,offset:-250});

		}


		showFormProductNatureEnvoi(valeurSolutionAffranchissement);

	}



	///////////////////////////
	// fiche produit - format nature de l envoi
	/////////////////////////////

	function showFormProductNatureEnvoi(valeurSolutionAffranchissement){

		var valeurCodePaysArrivee = codePaysDest;

		var valeurCodePaysArrivee2 = $("#formProduitPays").attr("value");

			$.ajax({
			   	type: "POST",
   				url: "trouveProduitNatureEnvoiStubs.do",
   				data: "codeProduit=" + valeurSolutionAffranchissement + "&codePaysArrivee=" + valeurCodePaysArrivee +  "&codePaysArrivee2=" + valeurCodePaysArrivee2,
   				success: function(responseXml){
     				fillProduitNatureEnvoi(responseXml,valeurSolutionAffranchissement);
   				},
   				error: function(responseXml) { fillErreur(responseXml);}
 			});

	}


	function fillProduitNatureEnvoi(responseXml,valeurSolutionAffranchissement){


		// nature envoi est affichee si le choix emballage n est pas affichee
		if(!autoriseRechargementEmballage){

			var select = $('#formProduitEnvoi');

			select.empty();

			$(responseXml).find("nature").each(function() {

	      		var vcode = $(this).find("code").text();

	      		var vlibelle = $(this).find("libelle").text();

				select.append("<option value='" + vcode + "'>" + vlibelle + "</option>");

			});

			$("#natureEnvoi").show('fast');
			$.scrollTo("#natureEnvoi",100, {axis:'y',margin:true,offset:-250});

		}

		showFormProductAvisReception(valeurSolutionAffranchissement);



	}



	///////////////////////////
	// fiche produit - avis de recpetion
	/////////////////////////////

	function showFormProductAvisReception(valeurSolutionAffranchissement){

		var valeurCodePaysArrivee = codePaysDest;

		var valeurCodePaysArrivee2 = $("#formProduitPays").attr("value");

			$.ajax({
			   	type: "POST",
   				url: "trouveProduitAvisReceptionStubs.do",
   				data: "codeProduit=" + valeurSolutionAffranchissement + "&codePaysArrivee=" + valeurCodePaysArrivee+  "&codePaysArrivee2=" + valeurCodePaysArrivee2,
   				success: function(responseXml){
     				fillProduitAvisReception(responseXml,valeurSolutionAffranchissement);
   				},
   				error: function(responseXml) { fillErreur(responseXml);}
 			});

	}


	function fillProduitAvisReception(responseXml,valeurSolutionAffranchissement){


		var nbElts = $(responseXml).find("presence").length;

		if(nbElts>0){

			$("#divAvisReception").show('fast');
			$.scrollTo("#divAvisReception",100, {axis:'y',margin:true,offset:-250});

		}

		showFormProductContreRemboursement(valeurSolutionAffranchissement);

	}





	///////////////////////////
	// fiche produit - contre remboursement
	/////////////////////////////


	function afficheInputContreRemboursement(){

		//$("#inputContreRemboursement").show('fast');


		if($("#inputContreRemboursement").css("display")=='inline'){
			$("#inputContreRemboursement").css("display", "none").fadeOut(1000);
		} else {
			$("#inputContreRemboursement").css("display", "inline").fadeIn(1000);
		}




	}



	function showFormProductContreRemboursement(valeurSolutionAffranchissement){

		var valeurCodePaysArrivee = codePaysDest;

		var valeurCodePaysArrivee2 = $("#formProduitPays").attr("value");

			$.ajax({
			   	type: "POST",
   				url: "trouveProduitContreRemboursementStubs.do",
   				data: "codeProduit=" + valeurSolutionAffranchissement + "&codePaysArrivee=" + valeurCodePaysArrivee +  "&codePaysArrivee2=" + valeurCodePaysArrivee2,
   				success: function(responseXml){
     				fillProduitContreRemboursement(responseXml,valeurSolutionAffranchissement);
   				},
   				error: function(responseXml) { fillErreur(responseXml);}
 			});

	}


	function fillProduitContreRemboursement(responseXml,valeurSolutionAffranchissement){


		var nbElts = $(responseXml).find("presence").length;

		if(nbElts>0){

			$("#divContreRemboursement").show('fast');
			$.scrollTo("#divContreRemboursement",100, {axis:'y',margin:true,offset:-250});

		}

			showFormProductValeurDeclaree(valeurSolutionAffranchissement);



	}







	///////////////////////////
	// fiche produit - valeur declaree
	/////////////////////////////


	function afficheInputValeurDeclaree(){



	//	$("#inputvaleurdeclaree").show('fast');

		if($("#inputvaleurdeclaree").css("display")=='inline'){
			$("#inputvaleurdeclaree").css("display", "none").fadeOut(1000);
		} else {
			$("#inputvaleurdeclaree").css("display", "inline").fadeIn(1000);
		}


	}



	function showFormProductValeurDeclaree(valeurSolutionAffranchissement){

		var valeurCodePaysArrivee = codePaysDest;

		var valeurCodePaysArrivee2 = $("#formProduitPays").attr("value");

			$.ajax({
			   	type: "POST",
   				url: "trouveProduitValeurDeclareeStubs.do",
   				data: "codeProduit=" + valeurSolutionAffranchissement + "&codePaysArrivee=" + valeurCodePaysArrivee+  "&codePaysArrivee2=" + valeurCodePaysArrivee2,
   				success: function(responseXml){
     				fillProduitValeurDeclaree(responseXml,valeurSolutionAffranchissement);
   				},
   				error: function(responseXml) { fillErreur(responseXml);}
 			});

	}


	function fillProduitValeurDeclaree(responseXml,valeurSolutionAffranchissement){


		var nbElts = $(responseXml).find("presence").length;

		if(nbElts>0){

			$("#divValeurDeclaree").show('fast');
			$.scrollTo("#divValeurDeclaree",100, {axis:'y',margin:true,offset:-250});

		}

		showFormProductAssuranceOptionnelle(valeurSolutionAffranchissement);

	}





	///////////////////////////
	// fiche produit - assurance optionnelle
	/////////////////////////////


	function afficheInputAssuranceOptionnelle(){

		//$("#inputassurance").show('fast');


		if($("#inputassurance").css("display")=='inline'){
			$("#inputassurance").css("display", "none").fadeOut(1000);
		} else {
			$("#inputassurance").css("display", "inline").fadeIn(1000);
		}




	}


	function showFormProductAssuranceOptionnelle(valeurSolutionAffranchissement){

		var valeurCodePaysArrivee = codePaysDest;

		var valeurCodePaysArrivee2 = $("#formProduitPays").attr("value");

			$.ajax({
			   	type: "POST",
   				url: "trouveProduitAssuranceOptionnelleStubs.do",
   				data: "codeProduit=" + valeurSolutionAffranchissement + "&codePaysArrivee=" + valeurCodePaysArrivee+  "&codePaysArrivee2=" + valeurCodePaysArrivee2,
   				success: function(responseXml){
     				fillProduitAssuranceOptionnelle(responseXml);
   				},
   				error: function(responseXml) { fillErreur(responseXml);}
 			});

	}


	function fillProduitAssuranceOptionnelle(responseXml){

		var nbElts = $(responseXml).find("presence").length;



		if(nbElts>0){

			$("#divAssuranceOptionelle").show('fast');
			$.scrollTo("#divAssuranceOptionelle",100, {axis:'y',margin:true,offset:-250});

		}

		$("#bouttonCalcul").show('fast');

	}



	///////////////////////////
	// fiche produit - calcul prix
	/////////////////////////////

	function calculPrixProduit(){

		var valeurPaysDepart = codePaysDep;

		var valeurPaysArrivee = codePaysDest;

		var valeurPaysArrivee2 = $("#formProduitPays").attr("value");

		var valeurPoids = $("#poid").attr("value");

		var valeurCodeEmballage = $("#formProduitFormatEmballage").attr("value");

		var valeurNatureEnvoi = $("#formProduitEnvoi").attr("value");

		var presenceValeurDeclaree = $("#valeurDeclaree").attr("checked");

		var valeurValeurDeclaree = $("#inputvaleurdeclaree").attr("value");

		var valeurTauxRec = $("#formProduitTaux").attr("value");

		var presenceAvisReception = $("#avisReception").attr("checked");

		var presenceAssuranceOptionnelle = $("#assuranceOpt").attr("checked");

		var valeurAssuranceOptionnelle = $("#inputassurance").attr("value");

		var presenceContreRemboursement = $("#contreRemboursement").attr("checked");

		var valeurContreRemboursement = $("#inputContreRemboursement").attr("value");

		effaceErreurs();

		$.ajax({
			   	type: "POST",
   				url: "calculProduitPrixStubs.do",
   				data: 	"codeProduit=" + codeProduitSelectionne +
   				 		"&codePaysDepart=" + valeurPaysDepart +
   				 		"&codePaysArrivee=" + valeurPaysArrivee +
   				 		"&codePaysArrivee2=" + valeurPaysArrivee2 +
   				 		"&poids=" + valeurPoids +
   				 		"&codeEmballage=" + valeurCodeEmballage +
   				 		"&natureEnvoi=" + valeurNatureEnvoi +
   				 		"&presValDec=" + presenceValeurDeclaree +
   				 		"&valValDec=" + valeurValeurDeclaree +
   				 		"&codeTauxRec=" + valeurTauxRec +
   				 		"&presAvisRecep=" + presenceAvisReception +
   				 		"&presAssOpt=" + presenceAssuranceOptionnelle +
   				 		"&valAssOpt=" + valeurAssuranceOptionnelle +
   				 		"&presContRemb=" + presenceContreRemboursement +
   				 		"&valContRemb=" + valeurContreRemboursement,
   				success: function(responseHtml){

     				fillProduitPrix(responseHtml);
   				},
	   			error: function(responseXml) {

		   			fillErreur(responseXml); }
 		});
	}


	function fillProduitPrix(responseHtml){





			$("#divProduitPrix").html(responseHtml);

			$("#divProduitPrix").show('fast');

			$.scrollTo("#divProduitPrix",100, {axis:'y',margin:true,offset:-250});

	}




	///////////////////////////
	// efface les champs
	/////////////////////////////


function effaceErreurs(){

			$("#poidErreurlineMessage").text("");
			$("#poidErreurline").hide();

			$("#natureEnvoiErreurlineMessage").text("");
			$("#natureEnvoiErreurline").hide();

			$("#formatEmballageErreurlineMessage").text("");
			$("#formatEmballageErreurline").hide();

			$("#valeurDeclareeErreurlineMessage").text("");
			$("#valeurDeclareeErreurline").hide();

			$("#assuranceOptionnelleErreurlineMessage").text("");
			$("#assuranceOptionnelleErreurline").hide();

			$("#tauxrecommandationErreurlineMessage").text("");
			$("#tauxrecommandationErreurline").hide();

			$("#contreRemboursementErreurlineMessage").text("");
			$("#contreRemboursementErreurline").hide();

			$("#templateRechercheDivErreurLine").hide();


			$("#erreursDansFicheProduitDiv").hide();


}

	function effaceApresPaysArr(){

		effaceModeDeLivraison();
		effaceoptions();
		effaceProduits();
		effaceSolutionsAffranchissements();
		effacePaysDestinations2();
		effaceTauxRec();
		effacePoids();
		effaceFormatEmb();
		effaceNatureEnvoi();
		effaceAvisReception();

		effaceContreRemboursement();
		effaceValeurDeclare();
		effaceAssuranceOptionnelle();
		effaceFormFicheProduit();
	}



	function effaceApresModeLivraison(){
		effaceoptions();
		effaceProduits();
		effaceSolutionsAffranchissements();
		effacePaysDestinations2();
		effaceTauxRec();
		effacePoids();
		effaceFormatEmb();
		effaceNatureEnvoi();
		effaceAvisReception();

		effaceContreRemboursement();
		effaceValeurDeclare();
		effaceAssuranceOptionnelle();
		effaceFormFicheProduit();
	}


	function effaceApresOptions(){
		effaceProduits();
		effaceSolutionsAffranchissements();
		effacePaysDestinations2();
		effaceTauxRec();
		effacePoids();
		effaceFormatEmb();
		effaceNatureEnvoi();
		effaceAvisReception();

		effaceContreRemboursement();
		effaceValeurDeclare();
		effaceAssuranceOptionnelle();
		effaceFormFicheProduit();
	}


	function effaceApresProduits(){


		effaceSolutionsAffranchissements();
		effacePaysDestinations2();
		effaceTauxRec();
		effacePoids();
		effaceFormatEmb();
		effaceNatureEnvoi();
		effaceAvisReception();

		effaceContreRemboursement();
		effaceValeurDeclare();
		effaceAssuranceOptionnelle();


	}


	function effaceApresSolutionsAffranchissements(){
		effacePaysDestinations2();
		effaceTauxRec();
		effacePoids();
		effaceFormatEmb();
		effaceNatureEnvoi();
		effaceAvisReception();

		effaceContreRemboursement();
		effaceValeurDeclare();
		effaceAssuranceOptionnelle();


	}

	function effaceApresPaysDestination(){
		effaceTauxRec();
		effacePoids();
		effaceFormatEmb();
		effaceNatureEnvoi();
		effaceAvisReception();

		effaceContreRemboursement();
		effaceValeurDeclare();
		effaceAssuranceOptionnelle();


	}

	function effaceApresTauxRec(){
		effacePoids();
		effaceFormatEmb();
		effaceNatureEnvoi();
		effaceAvisReception();

		effaceContreRemboursement();
		effaceValeurDeclare();
		effaceAssuranceOptionnelle();


	}


	function effaceApresPoids(){
		effaceFormatEmb();
		effaceNatureEnvoi();
		effaceAvisReception();

		effaceContreRemboursement();
		effaceValeurDeclare();
		effaceAssuranceOptionnelle();


	}


	function effaceApresFormatEmb(){
		effaceNatureEnvoi();
		effaceAvisReception();

		effaceContreRemboursement();
		effaceValeurDeclare();
		effaceAssuranceOptionnelle();


	}

	function effaceApresNatureEnvoi(){
		effaceAvisReception();

		effaceContreRemboursement();
		effaceValeurDeclare();
		effaceAssuranceOptionnelle();


	}



function detectNavIE6(){

	var ver=navigator.appVersion;
	var agent=navigator.userAgent;
	var dom=document.getElementById?1:0;

	var opera5=agent.indexOf("Opera 5")>-1;

	var ie6=(ver.indexOf("MSIE 6")>-1 && dom && !opera5)?1:0;

	//alert('ie6:'+ie6);

	return ie6;




}


	////////////

	function effaceModeDeLivraison(){
		// select mode de livraison
		$('#modeLivraison').empty();

		//alert('detectNavIE6():'+detectNavIE6());

		// test : if not IE6
//		if (detectNavIE6()==0){
//			alert('je cache');


			$("#modeDeLivraisonDiv").hide();

$("#erreursDansFicheProduitDiv").hide();
//		} else {alert('je cahche pas');}


	}


	function effaceoptions(){
		// select options
		$('#optionSelect').empty();
		$("#optionsDiv").hide();
		$("#erreursDansFicheProduitDiv").hide();
	}



	function effaceProduits(){
		// les produits
		$("#productsDiv").html("");

		$("#introProductsDiv").hide();

		$("#productsDiv").hide();
		$("#erreursDansFicheProduitDiv").hide();
	}



	function effaceSolutionsAffranchissements(){
		// select solution affanchissement
		$('#formProduitSolution').empty();
		$("#solutionAffranchissement").hide();
		$("#erreursDansFicheProduitDiv").hide();
	}


	function effacePaysDestinations2(){
		// select pays destination2
		$('#formProduitPays').empty();
		$("#paysDestination").hide();
		$("#erreursDansFicheProduitDiv").hide();
	}


	function effaceTauxRec(){
		// select taux rec
		$('#formProduitTaux').empty();
		$("#txRecommandation").hide();
		$("#tauxrecommandationErreurline").hide();
		$("#erreursDansFicheProduitDiv").hide();
	}



	function effacePoids(){
		// input poids
		$('#poid').attr("value", "");
		$("#poidline").hide();
		$("#poidErreurline").hide();
		$("#erreursDansFicheProduitDiv").hide();
	}



	function effaceFormatEmb(){
		// select format emb
		$('#formProduitFormatEmballage').empty();
		$("#Formatline").hide();
		$("#formatEmballageErreurline").hide();
		$("#erreursDansFicheProduitDiv").hide();
	}



	function effaceNatureEnvoi(){
		// select nature envoi
		$('#formProduitEnvoi').empty();
		$("#natureEnvoi").hide();
		$("#natureEnvoiErreurline").hide();
		$("#erreursDansFicheProduitDiv").hide();
	}


	function effaceAvisReception(){
		// checkbox avis reception
		$('#avisReception').removeAttr("checked");
		$("#divAvisReception").hide();
		$("#erreursDansFicheProduitDiv").hide();
	}



	function effaceContreRemboursement(){
		// checkbox + input contre remboursement
		$('#contreRemboursement').removeAttr("checked");

		$('#inputContreRemboursement').attr("value", "");
		$("#inputContreRemboursement").css("display", "none").fadeOut(1000);

		$("#contreRemboursementErreurline").hide();

		$("#divContreRemboursement").hide();
		$("#erreursDansFicheProduitDiv").hide();
	}


	function effaceValeurDeclare(){
		// checkbox + input valeur declaree
		$('#valeurDeclaree').removeAttr("checked");

		$('#inputvaleurdeclaree').attr("value", "");
		$('#inputvaleurdeclaree').css("display", "none").fadeOut(1000);

		$("#valeurDeclareeErreurline").hide();

		$("#divValeurDeclaree").hide();
		$("#erreursDansFicheProduitDiv").hide();
	}

	function effaceAssuranceOptionnelle(){
		// checkbox + input assurance optionnelle
		$('#assuranceOpt').removeAttr("checked");

		$('#inputassurance').attr("value", "");
		$("#inputassurance").css("display", "none").fadeOut(1000);

		$("#assuranceOptionnelleErreurline").hide();

		$("#divAssuranceOptionelle").hide();

		// presentation prix
		$("#divProduitPrix").html("");
		$("#divProduitPrix").hide();
		$("#bouttonCalcul").hide();
		$("#erreursDansFicheProduitDiv").hide();




	}

	function effaceFormFicheProduit(){

		$("#formProduitDiv").hide();

	}



	function traiteChangementPoids(){

		if(autoriseRechargementEmballage){
			showFormProductFormatEmballageACondition();
		}


	}

	
	
	var previousID;
	
	function entoure(idDivAEntourer){
		
	$("#"+previousID).css({'border' : '0px solid black'}); 
	
	$("#"+idDivAEntourer).css({'border' : '1px solid black'});
	/*$("#"+idDivAEntourer).css({"background-color":"yellow"});*/
	
	
	previousID=idDivAEntourer;
	 
		
	}
