function getParameter(myArray){
	var chaine="";
	var ok=true;
	for(var i=0; i<myArray.length; i++){
		chaine += myArray[i]+"="+$("#"+myArray[i]).val();
		if($("#"+myArray[i]).val()==""){
			ok = false;
			break;
		}
		if(i<(myArray.length-1)){
			chaine+="&";
		}
	}
	if(ok==false){
		return false;
	}else{
		return chaine;
	}
}

function emailContact(){
	var tmp = new Array("add_contact", "nom_contact", "email_contact", "sujet_contact", "message_contact");
	var chaine = getParameter(tmp);
	if(chaine==false){
		alert("Veuillez remplir tous les champs");
	}else{
		get("contact", chaine);
	}
}

function get(url,data){
	var a="#main";
	$.ajax({
		url: "ajax/"+url,
		data: data,
		async: false,
		success: function(html){
			$(a).fadeOut("fast",function(){
				$(a).empty();
				$(a).append(html);
				ouvrir();
				$(a).fadeIn("fast", function(){
					resizeMe();
				});
			});
		}
	});
}

function get_commentaire(url,data){
	var a="#commentaires";
	$.ajax({
		url: "ajax/"+url,
		data: data,
		async: false,
		success: function(html){
			$(a).fadeOut("fast",function(){
				$(a).empty();
				$(a).append(html);
				ouvrir();
				$(a).fadeIn("fast", function(){
					resizeMe();
				});
			});
		}
	});
}

function getSearch(){
var a="#search_result";
	$.ajax({
		url: "ajax/search/"+$("#search").val(),
		async: true,
		success: function(html){
			$(a).fadeOut("fast",function(){
				$(a).empty();
				$(a).append(html);
				$(a).fadeIn("fast", function(){
					resizeMe();
				});
			});
		}
	});
}

function add_commentaire(url,data){
	var a="#commentaires";
	data = data.replace(/\n/gi, "<br />");
	data = data.replace(/\r/gi, "");
	$.ajax({
		url: url,
		data: data,
		async: false,
		success: function(html){
			$(a).fadeOut("fast",function(){
				$(a).empty();
				$(a).append(html);
				$(a).fadeIn("fast", function(){
					resizeMe();
					ajouterCommentaire('ajouter_commentaire_cacher');
				});
			});
		}
	});
}
