// JavaScript Document

function include(fileName){
	document.write("<script src='"+fileName+"'></script>" );
}

include("js/jquery-1.4.4.min.js");
include("js/jquery.easing.1.3.js");
include("js/jquery.backgroundPosition.js");
include("js/jqueryLoader.js");
include("js/jquery.wipetouch.js");
include("js/jquery.tools.min.js");


function inscriptionBulletin() {
	var dataPost = "";
	dataPost += "email="+document.formBulletin.email.value;
	
	$.ajax({
	   type: "POST",
	   url: "php/inscriptionBulletin.php",
	   data: dataPost,
	   success: function(datas){
			successInscriptionBulletin(datas);
	   },
	   dataType: "json"
	 }); 
}

function successInscriptionBulletin(datas) {
	$("#reponseInscription").empty();
	if (datas['success']==0) {
		$("#reponseInscription").append("");
	} else {
		$("#email").val("Adresse email");
		$("#email").addClass("inputLegende");
		$("#email").removeClass("inputWrite");
	}
	$("#reponseInscription").append(datas['message']);
	$("#reponseInscription").hide();
	$("#reponseInscription").slideDown(500).delay(2500).slideUp(500);
}

function ecrivezNous() {
	var dataPost = "";
	dataPost += "societe="+document.formEcrivezNous.societe.value;
	dataPost += "&nom="+document.formEcrivezNous.nom.value;
	dataPost += "&telephone="+document.formEcrivezNous.telephone.value;
	dataPost += "&email="+document.formEcrivezNous.email.value;
	dataPost += "&message="+document.formEcrivezNous.message.value;
	
	
	$.ajax({
	   type: "POST",
	   url: "php/ecrivezNous.php",
	   data: dataPost,
	   success: function(datas){
			successEcrivezNous(datas);
	   },
	   dataType: "json"
	 });
}

function successEcrivezNous(datas) {
	$("#reponseEcrivezNous").empty();
	$("#reponseEcrivezNousSucces").empty();
	if (datas['success']==0) {
		$("#reponseEcrivezNous").append(datas['message']);
		$("#reponseEcrivezNous").hide();
		$("#reponseEcrivezNous").slideDown(500).delay(2500).slideUp(500);
	} else {
		$("#reponseEcrivezNousSucces").append(datas['message']);
		$(".form").fadeOut(500);
		$("#reponseEcrivezNousSucces").delay(800).fadeIn(500);
	}
	
}

function urlGetParam(name)  { 
	 var start=location.search.indexOf("?"+name+"=" ); 
	 if (start<0) start=location.search.indexOf("&"+name+"=" ); 
	 if (start<0) return ''; 
	 start += name.length+2; 
	 var end=location.search.indexOf("&",start)-1; 
	 if (end<0) end=location.search.length; 
	 var result=''; 
	 for(var i=start;i<=end;i++) { 
		var c=location.search.charAt(i); 
		result=result+(c=='+'?' ':c); 
	 } 
	 return unescape(result); 
} 

function getParam(address,name)  { 
	 var start=address.indexOf("?"+name+"=" ); 
	 if (start<0) start=location.search.indexOf("&"+name+"=" ); 
	 if (start<0) return ''; 
	 start += name.length+2; 
	 var end=address.indexOf("&",start)-1; 
	 if (end<0) end=address.length; 
	 var result=''; 
	 for(var i=start;i<=end;i++) { 
		var c=address.charAt(i); 
		result=result+(c=='+'?' ':c); 
	 } 
	 return unescape(result); 
} 


