﻿var niveau = 0;
var pathRacine = "";
if($("#crouzetJs")){
	var srcJs = $("#crouzetJs").attr("src");
	var temp = srcJs.split("../");
	niveau = (temp.length - 1);

	if(niveau != 0){
		for(var iNiveau = 0; iNiveau < parseInt(niveau) ; iNiveau++){
			pathRacine += "../";
		}
	}
}

function getDistriStock(sDistri)
{
}

function distriStock()
{
	sVal = $("#distristock").val();
	var tmpPathRacine = pathRacine.replace("../", "");
	window.location.href = tmpPathRacine + "distributor-stock.htm?ref=" + sVal;
}

function distriStock2()
{
	sVal = $("#distristock2").val();
	var tmpPathRacine = pathRacine.replace("../", "");
	window.location.href = tmpPathRacine + "distributor-stock.htm?ref=" + sVal;
}

function tb_show_mask(){
	if(document.getElementById("TB_window"))
	{
		document.getElementById("TB_window").style.display = "none";
	}
	if(typeof document.body.style.maxHeight === "undefined") {//if IE 6
		$("body","html").css({height: "100%", width: "100%"});
		$("html").css("overflow","hidden");
		if(document.getElementById("TB_HideSelect") === null) {//iframe to hide select elements in ie6
			$("body").append("<iframe id='TB_HideSelect'></iframe><div id='TB_overlay'></div><div id='TB_window'></div>");
		}
	}else{//all others
		if(document.getElementById("TB_overlay") === null){
			$("body").append("<div id='TB_overlay'></div><div id='TB_window'></div>");
		}
	}
	
	if(tb_detectMacXFF()){
		$("#TB_overlay").addClass("TB_overlayMacFFBGHack");//use png overlay so hide flash
	}else{
		$("#TB_overlay").addClass("TB_overlayBG");//use background and opacity
	}

	$("body").append("<div id='TB_load'><img src='"+ pathRacine +"../_images/loading.gif' /><div style=\"color:#FFF; margin:10px 0 0 0;\">...</div></div>");//add loader to the page
	$('#TB_load').show();//show loader
}

//FONCTION PERMETTANT DE REDIMENSIONNER DEUX BLOCS
function ResizeColonne(idGauche, idDroite, plus_gauche, plus_droite){
	// HEIGHT
	var height_gauche 			= $("#" + idGauche).height();
	var height_droite 			= $("#" + idDroite).height();
	
	// Taille complète gauche
	if (plus_gauche != ""){
		height_gauche= height_gauche + parseInt(plus_gauche);
	}else{
		plus_gauche = 0
	}

	// Taille complète droite
	if (plus_droite != ""){
		height_droite= height_droite + parseInt(plus_droite);
	}else{
		plus_droite =0;
	}
				
	// comparaison des tailles
	if(height_gauche > height_droite){ // Le bloc de gauche est plus grand
		$("#" + idDroite).height(height_gauche - parseInt(plus_droite));
	}else{
		$("#" + idGauche).height(height_droite - parseInt(plus_gauche));
	}
}

function rss()
{
	lg = codeLangue;
	window.open(pathRacine + "_inc/genrss.asp?lg=" + lg);
}

function afficheImagesApplications(marche, vehicule, application, zone)
{
	//alert("lg=" + codeLangue + "&marche=" + marche + "&vehicule=" + vehicule + "&application=" + application + "&zone=" + zone);
	// on va chercher les images de la zone
	$.ajax({
		type: "POST",
		url: "../../_inc/getzones.asp",
		data: "lg=" + codeLangue + "&marche=" + encodeURIComponent(marche) + "&vehicule=" + encodeURIComponent(vehicule) + "&application=" + encodeURIComponent(application) + "&zone=" + zone,
		success: function(imagesapplication)
		{
			$("#zonesImages").html(imagesapplication);
		},
		error: function(retour)
		{
		   alert(retour.responseText);
		}
	});	
}

function changeLangue(lg)
{

	// on va chercher la page équivalente dans la nouvelle langue
	$.ajax({
		type: "get",
		url: pathRacine + "_inc/ip.asp",
		success: function(codePays)
		{
			$("#localisation2").val(codePays);
		},
		error: function(retour)
		{
		   //alert("Erreur, veuillez recommencer");
		}
	});
	
	//window.location.href = "";
}

function changeSite(sUrl)
{
	sUrl2 = sUrl;

	sUrl2 = sUrl2.replace("../../../../../francais/", "http://www.crouzet.fr/francais/");
	sUrl2 = sUrl2.replace("../../../../../english/", "http://www.crouzet.com/english/");
	sUrl2 = sUrl2.replace("../../../../../deutsch/", "http://www.crouzet.de/deutsch/");
	sUrl2 = sUrl2.replace("../../../../../espanol/", "http://www.crouzet.es/espanol/");

	sUrl2 = sUrl2.replace("../../../../francais/", "http://www.crouzet.fr/francais/");
	sUrl2 = sUrl2.replace("../../../../english/", "http://www.crouzet.com/english/");
	sUrl2 = sUrl2.replace("../../../../deutsch/", "http://www.crouzet.de/deutsch/");
	sUrl2 = sUrl2.replace("../../../../espanol/", "http://www.crouzet.es/espanol/");
	
	sUrl2 = sUrl2.replace("../../../francais/", "http://www.crouzet.fr/francais/");
	sUrl2 = sUrl2.replace("../../../english/", "http://www.crouzet.com/english/");
	sUrl2 = sUrl2.replace("../../../deutsch/", "http://www.crouzet.de/deutsch/");
	sUrl2 = sUrl2.replace("../../../espanol/", "http://www.crouzet.es/espanol/");

	sUrl2 = sUrl2.replace("../../francais/", "http://www.crouzet.fr/francais/");
	sUrl2 = sUrl2.replace("../../english/", "http://www.crouzet.com/english/");
	sUrl2 = sUrl2.replace("../../deutsch/", "http://www.crouzet.de/deutsch/");
	sUrl2 = sUrl2.replace("../../espanol/", "http://www.crouzet.es/espanol/");

	sUrl2 = sUrl2.replace("../francais/", "http://www.crouzet.fr/francais/");
	sUrl2 = sUrl2.replace("../english/", "http://www.crouzet.com/english/");
	sUrl2 = sUrl2.replace("../deutsch/", "http://www.crouzet.de/deutsch/");
	sUrl2 = sUrl2.replace("../espanol/", "http://www.crouzet.es/espanol/");
	
	window.location.href = sUrl2;
}

function localise()
{
	
	// on va chercher le pays en fonction de l'IP
	$.ajax({
		type: "get",
		url: pathRacine + "_inc/ip.asp",
		success: function(codePays)
		{

			//codePays = "US";
		
			$("#localisation2").val(codePays);
			$("#idLocalisation").attr("href", $("#idLocalisation").attr("href") + "?pays=" + codePays);
			

			$("#disPays").val(codePays);
			if($("#dlLang").length > 0){
				$("#dlLang").val(codePays);
			}
					
			switch(codePays) 
			{ 
				case "US": 
				case "PR": 
				case "CA": 
				case "VI": 
				//case "FR": 
				//case "ES": 
				//case "SP": 
				
					var tabOldNamePage = $("#idLocalisation").attr("href").split("/");
					pageName = tabOldNamePage.pop();
					
					$.ajax({
						type: "POST",
						url: pathRacine + "_ajax/getPageName.asp",
						data: "marqueur=localisation&lg=" + codeLangue,
						success: function(msg)
						{
							$("#idLocalisation").attr("href", $("#idLocalisation").attr("href").replace(pageName, msg) + "?pays=" + codePays);					 
						},
						error: function(retour)
						{
						   alert(retour.responseText);
						}
					});		

					
					// on cache les elements US des pages catalogues
					//var sLoc = document.location.toString();
					//var aSlash = sLoc.split("/");
					//filename= aSlash[aSlash.length-1];					
					//if (filename == "position-sensors.htm")
					//{
						/*
						$(".blocfamille").eq(4).css("display","block");
						$(".blocfamille").eq(4).find(".blocfamilleimage").html("<img src='" + pathRacine + "_photos/normal/404.gif' />");
						$(".blocfamille").eq(5).css("display","block");
						$(".blocfamille").eq(5).find(".blocfamilleimage").html("<img src='" + pathRacine + "_photos/normal/404.gif' />");
						$(".blocfamille").eq(6).css("display","block");
						$(".blocfamille").eq(6).find(".blocfamilleimage").html("<img src='" + pathRacine + "_photos/normal/404.gif' />");
						
						$(".blocfamille[numChap='421']").css("display","block");
						$(".blocfamille[numChap='421']").find(".blocfamilleimage").html("<img src='" + pathRacine + "_photos/normal/404.gif' />");
						$(".blocfamille[numChap='421']").css("display","block");
						$(".blocfamille[numChap='421']").find(".blocfamilleimage").html("<img src='" + pathRacine + "_photos/normal/404.gif' />");
						$(".blocfamille[numChap='421']").css("display","block");
						$(".blocfamille[numChap='421']").find(".blocfamilleimage").html("<img src='" + pathRacine + "_photos/normal/404.gif' />");
						*/
					//}
					
					// OUTILS US
					$("#haut1Droit1").css("width", "305px");
					$("#haut1Droit2").css("background", "none");
					$("#haut1Droit2").css("padding-left", "5px");
					$("#haut1Droit2").html("");

					//menu syrelec only US
					$("#menuproduits .catMenu .libelle_chapitre1 .txtMenuCat").eq(8).css("display","block");
										
					sHTML = "<div style=\"width:316px;\">";
					//sHTML += "<div style=\"padding-left:28px;padding-top:5px;float:left;width:130px;height:19px;background-image:url(" + pathRacine + "_images/extranet.png);\"><a style=\"font-size:12px;\" target=\"_blank\" href=\"https://www.extra.crouzet.com\">Extranet login</a></div>";
					sHTML += "<div style=\"padding-left:28px;padding-top:5px;float:left;width:130px;height:19px;background-image:url(" + pathRacine + "_images/noextranet.png);\"><a style=\"font-size:12px;\" target=\"_blank\" href=\"https://storefront.crouzet-usa.com\">Eportal</a></div>";
					sHTML += "</div>";
					
					sHTML += "<div style=\"width:316px;\">";
					sHTML += "<div style=\"padding-left:28px;padding-top:5px;float:left;width:130px;height:19px;background-image:url(" + pathRacine + "_images/distristock.png);\">";
					
						sHTML += "<input type=\"text\" id=\"distristock\" name=\"PartNo\" value=\"Enter Part No:\" onclick=\"this.select();\" style=\"color:#FFFFFF; width:105px;background:none;\" />&nbsp;";
						sHTML += "<input type=\"image\" src=\"" + pathRacine + "_images/fleche-blancheForm.png\" name=\"btnInventory\" value=\"Go\" onclick=\"distriStock();\">";
						//sHTML += "<a style=\"font-family:arial;font-size:11px;text-decoration:none;\" href=\"http://www.mectronic.net\" target=\"_blank\" class=\"menusmall\">Powered by Mectronic.net</a>";
						
					sHTML += "</div>";
					
					sHTML += "<div style=\"padding-left:28px;padding-top:5px;float:left;width:130px;height:19px;background-image:url(" + pathRacine + "_images/noextranet.png);\"><a style=\"font-size:12px;\" target=\"_blank\" href=\"http://www.crouzet-usa.com/techtalk/\">TechTalk Forums</a></div>";
					sHTML += "</div>";
					$("#haut1Droit2").html(sHTML);
					
					// RSS > FORUM TECH TALK
					$("#centre2gauche2droite").css("background-image", "url(" + pathRacine + "_images/techtalk.png)");
					$("#centre2gauche2droite").css("padding-right", "5px");
					$("#centre2gauche2droite").css("width", "221px");
					$("#rsstitre").html("<a href='http://www.crouzet-usa.com/techtalk/' target='_blank'>TechTalk forums</a>");
					$("#rsstitre a").css("color", "#035aa7");
					$("#rsstexte").html("<a href='http://www.crouzet-usa.com/techtalk/' target='_blank'>Interact with the team of Crouzet experts and other engineers to ask questions and share knowledge on our forums</a>");
					
					$("#doctitre a").html("Sales & Tech Support");
					$("#doctexte a").html("Get in contact with us");
					$("#doctexte").css("width", "195px");
					$("#doctexte a").replaceWith($('#doctexte a').html());
					$("#doctitre a").replaceWith($('#doctitre a').html());				
					$("#doctitre").css("color", "#035AA7");				
					$("#doctitre").css("font-size", "14px");				
					$("#doctitre").css("font-weight", "bold");				
					$("#doctexte").css("color", "#6E6E6E");				
					$("#doctexte").css("font-size", "12px");				
					$("#centre2gauche2gauche").css("cursor", "pointer");
					$("#centre2gauche2gauche").click(function(){
						window.location.href="localisation.htm?pays=" + codePays;
					});
					
					
					// on remplace les actus par le distributor stock
					if (codePage == "accueil")
					{
						$("#titre_actu").html("Check Distributor Stock");
						$("#actualitesnavigation a").hide();
						$("#mycarousel").html("");
						$(".jcarousel-control").html("");
						$("#mycarousel").css("padding-left","25px");
						$("#mycarousel").css("padding-top","15px");
						
						//sForm = "<FORM method=post name=PartNo action=http://www.mectronic.com/scripts/crouzet/mfgpartlist.asp><INPUT value=5804 type=hidden name=mfgID> <INPUT value=Crouzet type=hidden name=mfgname> <INPUT value=S type=hidden name=E>";
						sForm = "<TABLE><TBODY><TR><TD vAlign=bottom><B>Enter part no.</B><BR><INPUT style='BACKGROUND-COLOR: #cccccc; FONT-SIZE: 12px; VERTICAL-ALIGN: text-top' size=30 type=text name=PartNo id='distristock2'> &nbsp; <INPUT value=' Search ' type=submit onclick=\"distriStock2();\" /> </TD></TR>";
						//sForm += "<TR><TD style='PADDING-LEFT: 1px; PADDING-TOP: 5px'><SELECT class=text name=intl> <OPTION id=rbusa2 selected value=''>Americas</OPTION> <OPTION id=rbint2 value=y>Europe</OPTION> <OPTION id=rbasia value=a>Asia</OPTION></SELECT></TD></TR><TR>";
						sForm += "<TD height=20><BR><A style='FONT-SIZE: 9px' href='http://www.mectronic.net' target=_blank>Powered By Mectronic.Net</A><BR></TD></TR></TBODY></TABLE>";
						sForm += "</FORM>";
						
						$("#mycarousel").html(sForm);
						
						$("#centre2gauche1").css("background-image","url('../_images/localisationus.png')");
						$("#localisation").html("<span style='font-size:24px;'>Find a Distributor near you<br /></span><a style='color:#657596;font-size:12px;text-decoration:none;' href='distributors.htm'>View list of distributors</a>");
						$("#centre2gauche2gauche").css("background-image","url('../_images/contactation.png')");
					}
					
					
					$("#bas1").html($("#bas1").html() + ' | <a href="export-compliance.htm">Export compliance</a>');
					
					//on affiche le lien competitor cross ref pour US only
					$("#competitor_tool").show();
					
					break;
				
				default: 

						//on cache les chapitres du swi pour les non us
						$("#menuproduits .421").hide();					

						//on cache le lien competitor cross ref pour les non US
						var objLink = $("#competitor_tool").parent("span");
						$("#competitor_tool").remove("a");
						objLink.html("<br />");

						//menu syrelec
						$("#menuproduits .catMenu .libelle_chapitre1 .txtMenuCat").eq(8).css("display","none");

						
						//on affiche les 2 selects 'activity'  'typeContact' dans localisation pour us only
						$("#SelectZone #disActivity").hide();
						$("#SelectZone #disTypeContact").hide();
						$("#SelectZone #etat").hide();
				
						if (codePage == "accueil")
						{
							jQuery("#mycarousel").jcarousel({
								auto: 3,
								scroll: 1,
								animation: 500,
								initCallback: mycarousel_initCallback,
								buttonNextHTML: null,
								buttonPrevHTML: null
							});
						}


						// on cache les elements US du menu
						$("#menuproduits .catMenu .libelle_chapitre4 .txtMenuCat").eq(4).css("display","none");
						$("#menuproduits .catMenu .libelle_chapitre4 .txtMenuCat").eq(5).css("display","none");
						$("#menuproduits .catMenu .libelle_chapitre4 .txtMenuCat").eq(6).css("display","none");
						
						//on cache le product launch
						$(".linkmenuproductlaunch").hide();
						
						// on cache les elements US des pages catalogues
						var sLoc = document.location.toString();
						var aSlash = sLoc.split("/");
						filename= aSlash[aSlash.length-1];
						
						if (filename == "micro-control.htm")
						{
							$(".blocfamille").eq(8).css("display","none");
						}
						
						if (filename == "position-sensors.htm")
						{
							$(".blocfamille[numChap='421']").css("display","none");
							$(".blocfamille[numChap='421']").css("display","none");
							$(".blocfamille[numChap='421']").css("display","none");						
						}
						
						// on va chercher le pays en fonction de l'IP
						$.ajax({
							type: "get",
							url: pathRacine + "_ajax/get_contact2.asp",
							//data: "codeActivite=MCT&codePays=" + codePays + "&lang=" + codeLangue,
							data: "codePays=" + codePays + "&lang=" + codeLangue,
							success: function(sContact)
							{
								$.ajax({
									type: "POST",   
									url: pathRacine + "_ajax/get_expression.asp",        
									data: "lang="+ codeLangue +"&marqueur=contact_local",
									success: function(msg){   
										$("#contact1 div div div.textBleu").html(msg + "<br />" + sContact);
									},
									error:function(msg){       
										alert(msg.ResponseText);
									}
								}); 
							},
							error: function(retour)
							{
							   //alert("Erreur, veuillez recommencer");
							}
						});						
						

					break;
					
			}
			
			if (codePage == "distributeurs")
			{
				loadDistributeurs();
			}

			
		},
		error: function(retour)
		{
		   //alert("Erreur, veuillez recommencer");
		}
	});
}

function localiseMaps()
{
	
	// on va chercher le pays en fonction de l'IP
	$.ajax({
		type: "get",
		url: pathRacine + "_inc/ip_lib.asp",
		success: function(nomPays)
		{
			return nomPays;
		},
		error: function(retour)
		{
			return "France";
		}
	});
}

function getCodePays()
{
	// on va chercher le pays en fonction de l'IP
	$.ajax({
		type: "get",
		url: pathRacine + "_inc/ip.asp",
		success: function(codePays)
		{
		},
		error: function(retour)
		{
		   //alert("Erreur, veuillez recommencer");
		}
	});
}



function loadApplication(iAppli)
{
	$(".menuapplicationitem").css("background-color", "");
	$(".menuapplicationitem").eq(iAppli-1).css("background-color", "#f3982f");

	$(".menuapplicationitem a").css("color", "#005aa1");
	$(".menuapplicationitem a").eq(iAppli-1).css("color", "#FFFFFF");
	
	$(".menuapplicationitemfl").css("display", "none");
	$(".menuapplicationitemfl").eq(iAppli-1).css("display", "block");
	
	$(".applicationFlash").css("display", "none");
	$(".applicationFlash").eq(iAppli-1).css("display", "block");
	
	$(".applicationProduits").css("display", "none");
	$(".applicationProduits").eq(iAppli-1).css("display", "block");

	//afficheImagesApplications("", "", "", "");
}

function loadProductCarac(iAppli, codeCouleur)
{
	$(".menudescriptifitem").css("background-color", "");
	$(".menudescriptifitem").eq(iAppli-1).css("background-color", codeCouleur);

	$(".menudescriptifitem a").css("color", codeCouleur);
	$(".menudescriptifitem a").eq(iAppli-1).css("color", "#FFFFFF");
	
	$(".menudescriptifitemfl").css("display", "none");
	$(".menudescriptifitemfl").eq(iAppli-1).css("display", "block");
	
}

function GetDownload(CookieName,lg,activite, bSmartBook){
		
	if(lg == "" || lg == null )
	{
		lg = "fr";
		if (codeLangue  != "" && codeLangue != null ) lg = codeLangue;
	}
		
	var sData = "lang="+lg+"&activite="+activite;
	
	if(bSmartBook != ""){
		sData += "&bSmartBook="+bSmartBook;
	}	
		
	var ids = "";
	if(CookieName != "notDefined"){
		ids  = getIdsInCookie(CookieName); 
		sData += "&ids="+ids;
	}

	if(CookieName == "notDefined" || ids != ""){

		$.ajax({
			type: "POST",   
			url: pathRacine + "_ajax/get_download.asp",        
			data: sData,
			success: function(msg){  
				tb_remove();					
				if(msg != ""){
					if (msg.indexOf("<div") > -1)
					{
						// on affiche le formulaire d'authentification
						$("#hiddenModalContent").html(msg);
						tb_show($("#hiddenModalContent").attr("title"),"#TB_inline?height=280&width=450&inlineId=hiddenModalContent", false);
					}
					else
					{
						// on renvoie le fichier
						$("#hiddenModalContent").html(msg);
						tb_show($("#hiddenModalContent").attr("title"),"#TB_inline?height=280&width=400&inlineId=hiddenModalContent"  ,false);				
						
						//parent.location.href = msg;
						//window.open('http://www.crouzet.com/english/download/0143F8B1-589A-4816-8DB8-582D2EB8.zip', '_blank');
					}
				}
			},
			error:function(msg){       
				alert(msg.ResponseText);
			},
			beforeSend:function(){
				 tb_show_mask();
			}
		});  
	}
}


function ReloadSelecRegion(SelectName, SelectId, CodePays, lg, selectedValue)
	{

	if(lg == "" || lg == null)
	 lg = "fr";

	$.ajax({
			type: "POST",   
			url: pathRacine + "_ajax/get_RenderRegion.asp",        
			data: "SelectName="+ SelectName+"&SelectId="+SelectId+"&CodePays="+CodePays+"&Lang="+lg,
			success: function(msg){   
				if(msg != ""){
					$("#" + SelectId +"").html(msg);
					$("#" + SelectId +"").show();
					if (selectedValue != ""){
						$("#" + SelectId +"").val(selectedValue);
						SearchDistrib();
					}
				}else{
					$("#" + SelectId +"").html("<option value=\"all\" selected>all</option>");
					$("#" + SelectId +"").hide();
					

					
					SearchDistrib();
				}
							   
			},
			error:function(msg){       
				alert(msg.ResponseText);
			},
			beforeSend:function(){
				   
			}
		});  
}

function LoadFormContact(Lang){

	if($("#typeDemande").val() == "newsletter"){
		return;
	}
	
	if($("#profession").val() != "" && $("#typeDemande").val() != "" && $("#client").val() != ""){
		
		$.ajax({
			type: "POST",   
			url: pathRacine + "_ajax/load_formContact.asp",        
			data: "lang="+ Lang +"&profession="+ $("#profession").val()+"&Activite="+ $("#Activite").val()+"&typeDemande="+ $("#typeDemande").val()+"&client="+ $("#client").val()+"&formAction="+ $("#FormAction").val()+"&postAjax="+ $("#PostAjax").val()+"&UrlReferrer="+document.referrer +"&UrlPage="+document.URL +"&CssName="+ $("#CssName").val(),
			success: function(msg){   
			if(msg != ""){
				$("#ResultContact2").html(msg);
				$("#ResultContact2").show();               
			}else{
				$("#ResultContact2").hide();                                     
			}		   
			},
			error:function(msg)
			{       
				alert(msg.ResponseText);
			},
			beforeSend:function(){
				$("#ResultContact2").hide();     
			}
		}); 
	}
	$("#retourContact").hide();
}

function LoadFormNewsletter(Lang, email){
	
	$.ajax({
		type: "POST",   
		url: pathRacine + "_ajax/load_formNewsletter.asp",        
		data: "lang="+ Lang + "&email=" + encodeURIComponent(email),
		success: function(msg){   
		if(msg != ""){
			$("#ResultContact2").html(msg);
			$("#ResultContact2").show();
			if(email != "" && email != null){
				$("#news_email").val(unescape(email));
			}
		}		   
		},
		error:function(msg)
		{       
			alert(msg.ResponseText);
		},
		beforeSend:function(){
			$("#ResultContact2").hide();     
		}
	}); 
}

function SaveFormContact(CookieName,Lang){

		if(verifForm()){
			var sData = "action=dlDoc&lang="+ Lang;

			$("#TB_ajaxContent input").each(function(){
				sData += "&"+$(this).attr("name")+"="+$(this).val();
			});
			$("#TB_ajaxContent select").each(function(){
				sData += "&"+$(this).attr("name")+"="+$(this).val();
			});
			
			var sCheckboxSmartBook = "";
			if($("#dlsmartbook").attr("checked") == true){
				sCheckboxSmartBook = $("#dlsmartbook").val();
			}else{
				sCheckboxSmartBook = "";
			}
			//smartBook
			sData += "&bsmartBook=" + sCheckboxSmartBook;
			
			sData += "&"+$(this).attr("name")+"="+$(this).val();
			
			$.ajax({
				type: "POST",   
				url: pathRacine + "_ajax/save_contact.asp",        
				data: sData,
				success: function(msg){  
					if(msg != "")
						eval(msg)
				},
				error:function(msg)
				{       
					alert(msg.ResponseText);
				},
				beforeSend:function(){ 
				}
			}); 
	}

}

function SendUrl(lg){

		if(verifForm()){
			var sData = "action=SendUrl&lang="+ lg;

			$("#TB_ajaxContent input").each(function(){
				sData += "&"+$(this).attr("name")+"="+$(this).val();
			});
			
			$("#TB_ajaxContent select").each(function(){
				sData += "&"+$(this).attr("name")+"="+$(this).val();
			});


			$.ajax({
				type: "POST",   
				url: pathRacine + "_ajax/send_url.asp",        
				data: sData,
				success: function(msg){  
					if(msg != "")
						$("#TB_ajaxContent").html(msg);
				},
				error:function(msg)
				{       
					alert(msg.ResponseText);
				},
				beforeSend:function(){ 
				}
			}); 
	}

}

function SendUrlToFriend(lg){

		if(lg == "" || lg == null )
			lg = "fr";
		
		var sData = "Lang="+lg+"&Url="+document.URL;

		$.ajax({
				type: "POST",   
				url: pathRacine + "_ajax/send_url.asp",        
				data: sData,
				success: function(msg){  
					tb_remove();
					if(msg != ""){
						document.getElementById("hiddenModalContentUrl").innerHTML = msg;
						//$("#hiddenModalContentUrl").html(msg);
						tb_show($("#hiddenModalContentUrl").attr("title"),"#TB_inline?height=200&width=400&inlineId=hiddenModalContentUrl", false);
					}
								   
				},
				error:function(msg){       
					alert("Erreur, veuillez recommencer");
				},
				beforeSend:function(){
					 //tb_show_mask(); 
					 $("#hiddenModalContentUrl").html("<div id='TB_load'><img src='"+ pathRacine + +"_images/loading.gif' /></div>");
				}
			});  

}

function SendProductLaunch(lg){

		if(lg == "" || lg == null )
			lg = "fr";
		
		var sData = "Lang="+lg+"&Url="+document.URL;

		$.ajax({
				type: "POST",   
				url: pathRacine + "_ajax/send_url.asp",        
				data: sData,
				success: function(msg){  
					tb_remove();
					if(msg != ""){
						msg = msg.replace("50%","99%");
						document.getElementById("hiddenModalContentUrl").innerHTML = msg;
						tb_show($("#hiddenModalContentUrl").attr("title"),"#TB_inline?height=200&width=400&inlineId=hiddenModalContentUrl", false);
					}
								   
				},
				error:function(msg){       
					alert("Error, please retry");
				},
				beforeSend:function(){
					 $("#hiddenModalContentUrl").html("<div id='TB_load'><img src='"+ pathRacine + +"_images/loading.gif' /></div>");
				}
			});  

}

function tb_show_mask(){
	if(document.getElementById("TB_window"))
	{
		document.getElementById("TB_window").style.display = "none";
	}
	if (typeof document.body.style.maxHeight === "undefined") {//if IE 6
		$("body","html").css({height: "100%", width: "100%"});
		$("html").css("overflow","hidden");
		if (document.getElementById("TB_HideSelect") === null) {//iframe to hide select elements in ie6
			$("body").append("<iframe id='TB_HideSelect'></iframe><div id='TB_overlay'></div><div id='TB_window'></div>");
		}
	}else{//all others
		if(document.getElementById("TB_overlay") === null){
			$("body").append("<div id='TB_overlay'></div><div id='TB_window'></div>");
		}
	}
	
	if(tb_detectMacXFF()){
		$("#TB_overlay").addClass("TB_overlayMacFFBGHack");//use png overlay so hide flash
	}else{
		$("#TB_overlay").addClass("TB_overlayBG");//use background and opacity
	}


	$("body").append("<div id='TB_load'><img src='"+ pathRacine +"_images/loading.gif' /></div>");//add loader to the page
	$('#TB_load').show();//show loader
	
}

function getExpression(lg, marqueur)
{
	$.ajax({
		type: "POST",   
		url: pathRacine + "_ajax/get_expression.asp",        
		data: "lang="+ lg +"&marqueur="+ marqueur,
		success: function(msg){   
			return msg;
		},
		error:function(msg){       
			alert(msg.ResponseText);
		}
	}); 	
}

function verifForm(){

	var bOk = true
	$(".required[title]").each(function(){
		var defaultValue = trim($(this).attr("title"));
		var presentValue = trim($(this).val());
		
		if(defaultValue == presentValue || presentValue == ""){
			$(this).css("background-color","#ff0000");
			bOk = false;
			$(".infoForm").show();
		}
		if($(this).attr("name").toLowerCase().indexOf("mail") > 0){
			if(!isMailValid(presentValue)){
				$(this).css("background-color","#ff0000");
				bOk = false;
				$(".infoForm").show();
			}
		}		
	});
	
	$("select.required").each(function(){
		var presentValue = trim($(this).val());
		if(presentValue == ""){
			$(this).css("background-color","#ff0000");
			bOk = false;
			$(".infoForm").show();
		}
	});


	//si form ok on remplace les valeur par defaut encore existant par vide
	if(bOk == true){
		$("input[title]").each(function(){	
			var defaultValue = trim($(this).attr("title"));
			var presentValue = trim($(this).val());		
			if(defaultValue == presentValue){
				$(this).val("")
			}
		});
	}

	return bOk;
	
}

function trim(string){
	return string.replace(/(^\s*)|(\s*$)/g,'');
} 

function isMailValid(email){
	 var verif = /^[a-zA-Z0-9_.-]+@[a-zA-Z0-9_.-]{2,}[.][a-zA-Z]{2,3}$/;
	 if (verif.exec(email) == null)
		return false; //mail incorrect
	 else
		return true; //mail correct
} 

function getQueryVariable(variable) {
  var query = window.location.search.substring(1);
  var vars = query.split("&");
  for (var i=0;i<vars.length;i++) {
    var pair = vars[i].split("=");
    if (pair[0] == variable) {
      return pair[1];
    }
  } 
}


