// regle le bug png d'IE6
function fixall(){
	$('.transparent').ifixpng(); 
}

////////////////////////////

// Affiche l'animation de chargement
function imageLoading(){
	//$('#content_groupe_apavou_dynamique').html("<span style=\"margin-left:300px;\"><img src=\"http://www.apavou-immobilier.com/img/layout/ajax-loader.gif\"</span>");
}

// Pour la page le-groupe-apavou
function changePageGroupeApavou(id){
	//$('#content_groupe_apavou_dynamique > img')
	$('#content_groupe_apavou_dynamique').html("");
	$.get("apavougroups/"+id, function(data){
  		$('#content_groupe_apavou_dynamique').html(data);
	});
}

// Pour la page Syndics
function changePageSyndic(id){
	$('#content_syndics_dynamique').html("");
	$.get("syndics/"+id, function(data){
  		$('#content_syndics_dynamique').html(data);
	});
}

// Affiche les diferentes pages de recherche sur l'accueil
function changePageRecherche(id){
	$('#content_recherches_dynamique').html("");
	$.get("recherches/"+id, function(data){
  		$('#content_recherches_dynamique').html(data);
	});
}

// Affiches les different formulaires de la page service client
function changePageContactServiceClient(id){
	$('#content_nous-contacter_right').html("");
	$.get("contacts/"+id, function(data){
  		$('#content_nous-contacter_right').html(data);
	});
}

// Affiches les different formulaires de la page Achats (acheter)
function changePageRechercheAchatsZone(id){
	$('#content_dynamique').html("");
	$.get("achats/"+id, function(data){
  		$('#content_dynamique').html(data);
	});
	/*$('#bt_zone_reunion').css("background", "transparent url(img/layout/content/achats/bt_recherche_reunion_active.jpg) no-repeat scroll center top");
	$('#bt_zone_reunion').css("display", "block");
	$('#bt_zone_reunion').css("float", "left");
	$('#bt_zone_reunion').css("height", "24px");
	$('#bt_zone_reunion').css("line-height", "2em");
	$('#bt_zone_reunion').css("margin-top", "6px");
	$('#bt_zone_reunion').css("text-align", "center");
	$('#bt_zone_reunion').css("width", "88px");*/
}

// Affiches les different formulaires de la page Locations (location)
function changePageRechercheLocationsZone(id){
	$('#content_dynamique').html("");
	$.get("locations/"+id, function(data){
  		$('#content_dynamique').html(data);
	});
}

/* Affiches les resultats de la recherche Achats dans la page
function changePageRechercheAchats(id){
	$('#content_achats_right').html("");
	$.get("achats/"+id, function(data){
		$('#content_achats_right').html(data);
	});
}

// Affiches les resultats de la recherche Locations dans la page
function changePageRechercheLocations(id){
	$('#content_achats_right').html("");
	$.get("locations/"+id, function(data){
		$('#content_achats_right').html(data);
	});
}*/

/*********************************/
// Verif Recherche Achats (acheter)
/*********************************/
function verifContactServiceClientForm(){
	//alert("verif");
	var erreur = 0;
	var msg = "";
	
	//Nom
	if ($('#ContactNom').val() == '' || $('#ContactNom').val() == null) {
		msg = msg+"| Vous devez spécifier votre nom";
		//alert("Vous devez spécifier votre nom.");
		$('#ContactNom').focus();
		$('#ContactNom').css("background-color","red");
		erreur++;
		//return false;
	} else{
		$('#ContactNom').css("background-color","white");
	}
	
	//Prenom
	if ($('#ContactPrenom').val() == ''|| $('#ContactPrenom').val() == null) {
		msg = msg+" | Vous devez spécifier votre prénom";
		//alert("Vous devez spécifier votre nom.");
		$('#ContactPrenom').focus();
		$('#ContactPrenom').css("background-color","red");
		erreur++;
		//return false;
	} else{
		$('#ContactPrenom').css("background-color","white");
	}
	
	// Mail
	if ($('#ContactEmail').val() == null) {
		msg = msg+" | Vous devez spécifier votre email";
		//alert("Vous devez spécifier votre nom.");
		$('#ContactEmail').focus();
		$('#ContactEmail').css("background-color","red");
		erreur++;
		//return false;
	} else {
		if (!checkEmail($('#ContactEmail').val())) {
			msg = msg+" | Le format de votre email n'est pas valide";
			//alert("Le format de votre email n'est pas valide.");
				$('#ContactEmail').focus();
				$('#ContactEmail').css("background-color","red");
			erreur++;
			//return false	
		}else{
			$('#ContactEmail').css("background-color","white");
		}
	}
	
	//Adresse
	if ($('#ContactAdresse').val() == ''|| $('#ContactAdresse').val() == null) {
		msg = msg+" | Vous devez spécifier votre adresse";
		//alert("Vous devez spécifier votre nom.");
		$('#ContactAdresse').focus();
		$('#ContactAdresse').css("background-color","red");
		erreur++;
		//return false;
	} else{
		$('#ContactAdresse').css("background-color","white");
	}
	
	//Ville
	if ($('#ContactVille').val() == ''|| $('#ContactVille').val() == null) {
		msg = msg+" | Vous devez spécifier votre ville";
		//alert("Vous devez spécifier votre nom.");
		$('#ContactVille').focus();
		$('#ContactVille').css("background-color","red");
		erreur++;
		//return false;
	} else{
		$('#ContactVille').css("background-color","white");
	}
	
	if (erreur != 0) {
		//alert(msg);
		$("div#error_msg").html(msg);
		return false;
	} else {
		return true;
		
	}
}

function verifNewsletterForm(){
	var erreur = 0;
	var msg = "";
	
	// Mail
	if ($('#NewsletterEmail').val() == null) {
		msg = msg+" | Vous devez spécifier votre email";
		//alert("Vous devez spécifier votre nom.");
		$('#NewsletterEmail').focus();
		$('#NewsletterEmail').css("background-color","red");
		erreur++;
		//return false;
	} else {
		if (!checkEmail($('#NewsletterEmail').val())) {
			msg = msg+"Le format de votre email n'est pas valide";
			//alert("Le format de votre email n'est pas valide.");
				$('#NewsletterEmail').focus();
				$('#NewsletterEmail').css("background-color","red");
			erreur++;
			//return false	
		}else{
			$('#NewsletterEmail').css("background-color","white");
		}
	}
	
	// renvoie erreur ou pas
	if (erreur != 0) {
		alert(msg);
		//$("div#error_msg").html(msg);
		return false;
	} else {
		return true;
		
	}
}

////////////////////////////
// Fonction recurante
////////////////////////////

function isNumeric(form_value) 
{ 
    if (form_value.match(/^\d+$/) == null) 
        return false; 
    else 
        return true; 
}

function checkEmail(email)
{
	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	return (reg.test(email));
}