$(document).ready(function(){  			
	$("a.affichetoi").lightBox();
	
	$("a.affichepdf").fancybox({
		'width'				: '75%',
		'height'			: '90%',
		'autoScale'			: false,
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'type'				: 'iframe'
	});
	
	$("#top_page a").click(function () { 
		$("html, body").animate({ scrollTop: 0 }, "fast"); 
	});
	
	$("#logements_en_vente, #vous_cherchez_une_location, #vous_etes_locataire, #locaux_entreprises, .liste_photo_logement img").mouseover(function(){
	   $(this).animate({
		opacity: 0.6
	  }, 200 );
	});
	
	$("#logements_en_vente, #vous_cherchez_une_location, #vous_etes_locataire, #locaux_entreprises, .liste_photo_logement img").mouseout(function(){
	   $(this).animate({
		opacity: 1
	  }, 200 );
	});
			
	$("input, textarea").focus(function(){
		$(this).css("background", "#fbfbfb" );
		$(this).css("border-color", "#97be0d");
	});
	 
	$("input, textarea").blur(function(){
		$(this).css("background", "#ffffff" );
		$(this).css("border-color", "#cccccc");
	});
	
	$("p a").hover(
		 function(){
			$(this).fadeOut(20);
			$(this).fadeIn(500);
		 }
	 );
});


function cacheRecherche()
{
	$('#rechercher').fadeOut('slow');
	setTimeout("$('#bouton_recherche').slideDown();",800);
}

function afficheRecherche()
{
	$("#bouton_recherche").slideUp();
	$("#rechercher").slideDown();
}

function changeTypeRecherche()
{
	var type_recherche = document.getElementById("type_recherche").value;
	
	if (type_recherche == "1")
	{
		document.getElementById("type_recherche_1").style.display = "block";
		document.getElementById("type_recherche_2").style.display = "none";
	}
	else if (type_recherche == "2")
	{		
		document.getElementById("type_recherche_1").style.display = "none";
		document.getElementById("type_recherche_2").style.display = "block";
	}
}

function verifRecherche()
{
	if (document.getElementById("tr1").checked || document.getElementById("tr2").checked)
	{
		if (parseInt(document.getElementById("sup_min").value) < parseInt(document.getElementById("sup_max").value))
		{
			return true;
		}
		else
		{			
			alert("Merci de verifier la surface choisie.");	
			return false;
		}
	}
	else
	{
		alert("Choisissez un type de transaction.");	
		return false;
	}
}

function recupereURL()
{
	var url = "81_"; // URL de destination du formulaire.
	
	var type_recherche = document.getElementById("type_recherche").value;
	var sup_min = document.getElementById("sup_min").value;
	var sup_max = document.getElementById("sup_max").value;
	var type_de_logement = document.getElementById("type_de_logement").value;
	
	if (document.getElementById("tr1").checked)
	{
		var tr = "2";
	}
	else
	{
		var tr = "1";
	}
	
	url += tr+"_"+sup_min+"_"+sup_max+"_"+type_recherche+"_"+type_de_logement+"_recherche.html";
		
	window.location.href = url;
}


function recupereURL_2()
{
	var url_2 = "81_"; // URL de destination du formulaire.
	
	var type_recherche = document.getElementById("type_recherche_81").value;
	var sup_min = document.getElementById("sup_min_2").value;
	var sup_max = document.getElementById("sup_max_2").value;
	var type_de_logement = document.getElementById("type_de_logement_2").value;
	
	if (document.getElementById("tr1_2").checked)
	{
		var tr = "2";
	}
	else
	{
		var tr = "1";
	}
	
	url_2 += tr+"_"+sup_min+"_"+sup_max+"_"+type_recherche+"_"+type_de_logement+"_recherche.html";
		
	window.location.href = url_2;
}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

function changeTypeRecherche_2()
{	
	var type_recherche = document.getElementById("type_recherche_81").value;
	
	if (type_recherche == "1")
	{
		document.getElementById("type_recherche_1_2").style.display = "block";
		document.getElementById("type_recherche_2_2").style.display = "none";
	}
	else if (type_recherche == "2")
	{		
		document.getElementById("type_recherche_1_2").style.display = "none";
		document.getElementById("type_recherche_2_2").style.display = "block";
	}
}

function verifRecherche_2()
{
	if (document.getElementById("tr1_2").checked || document.getElementById("tr2_2").checked)
	{
		if (parseInt(document.getElementById("sup_min_2").value) < parseInt(document.getElementById("sup_max_2").value))
		{
			return true;
		}
		else
		{			
			alert("Merci de verifier la surface choisie.");	
			return false;
		}
	}
	else
	{
		alert("Choisissez un type de transaction.");	
		return false;
	}
}

function afficheTelechargerDossier()
{
	$("#telecharger_dossier").fadeIn(120);
}

function cacheTelechargerDossier()
{
	$("#telecharger_dossier").fadeOut(120);
}
