/*Fonction de chargement sur toutes les pages*/
$(document).ready(function() 
{
    $('#banniere_header').cycle({
		fx: 'fade',
		speed:    1000, 
		timeout:  5000 		
	});
});

function favoris() 
{
	if ( navigator.appName != 'Microsoft Internet Explorer' )
	{ 
		window.sidebar.addPanel("Mr-immo","http://www.mr-immo.com",""); 
	}
	else
	{ 
		window.external.AddFavorite("http://www.mr-immo.com","Mr-immo");
	} 
}

function change_lang()
{
	if($("#content_description_an").css("display") == "none"){
		$('#content_description_an').animate({opacity: 0}, 000);		
		$('#content_description_fr').animate({opacity: 0}, 500, function() {
			$("#content_description_fr").css("display","none");
			$("#content_description_an").css("display","");
			$('#content_description_an').animate({opacity: 1}, 500);						
		});			
	}else{
		$('#content_description_fr').animate({opacity: 0}, 000);		
		$('#content_description_an').animate({opacity: 0}, 500, function() {
			$("#content_description_an").css("display","none");
			$("#content_description_fr").css("display","");
			$('#content_description_fr').animate({opacity: 1}, 500);						
		});			
	}
}

function change_big_img(id_bien,i)
{
	$('#big_img').animate({opacity: 0}, 500, function() {
		$("#big_img").attr("src","/image.php/bien.jpg?width=600&height=600&image=/visuels/norm/"+id_bien+"_0"+i+".jpg");		
		$('#big_img').animate({opacity: 1}, 500);
	});	
}

function change_search()
{
	var search_transaction = $("#search_transaction").val();
	var search_typeBien = $("#search_typeBien").val();
	var search_dept = $("#search_dept").val();
	var search_ville = $("#search_ville").val();
	create_dept_select(search_transaction,search_typeBien,search_dept);
	create_ville_select(search_transaction,search_typeBien,search_dept,search_ville);	
}

function create_dept_select(search_transaction,search_typeBien,search_dept){
	$.ajax({
   type: "POST",
   url: "ajax_create_select_dept.php",
   data: "search_transaction="+search_transaction+"&search_typeBien="+search_typeBien+"&search_dept="+search_dept,
   success: function(msg){
    	$("#display_search_dept").html(msg);
   }
 });
}

function create_ville_select(search_transaction,search_typeBien,search_dept,search_ville){
	$.ajax({
   type: "POST",
   url: "ajax_create_select_ville.php",
   data: "search_transaction="+search_transaction+"&search_typeBien="+search_typeBien+"&search_dept="+search_dept+"&search_ville="+search_ville,
   success: function(msg){
    	$("#display_search_ville").html(msg);
   }
 });
}

function visite_virtuelle(vUrl)
{
	window.open(vUrl, 'virtual_visite', 'location=no,statusbar=no,url=no,width=300,height=300,top=200,left=200');
}

function change_piece(id){
	if(id == 1 || id == 8){
		$("#content_check_piece_titre").css("display","");
		$("#content_check_piece").css("display","");
	}else{
		$("#content_check_piece").css("display","none");				
		$("#content_check_piece_titre").css("display","none");
	}
}

function contact_form(ID_bien)
{
	$( "#modalWin" ).dialog(
	{
				title: "Contactez-nous", 
				autoOpen: true,
				//height: 300,
				width: 500,
				modal: true,
				position: Array('center', 90),
				open: function() 
				{
		        		//display correct dialog content
			        	$("#modalWin").load("/contact-form.php");
				},			
				buttons: 
				{
						"Envoyer": function() 
						{			
    							$.ajax(
    							{
    								  url: '/contact-form-process.php',
									  type: 'POST',
									  data: 'nom='+encodeURIComponent($( "#contactFormNom" ).val())+'&prenom='+encodeURIComponent($( "#contactFormPrenom" ).val())+'&email='+encodeURIComponent($( "#contactFormEmail" ).val())+'&tel='+encodeURIComponent($( "#contactFormTel" ).val())+'&txt='+encodeURIComponent($( "#contactFormTxt" ).val())+'&ID_bien='+ID_bien,    								  
    								  dataType: 'script'
    							});
						},
						"Fermer": function() 
						{
							$( this ).dialog( "close" );
						}
				}
	});	
}
