$(document).ready(function()
{	
	var flag1 = true;
	
	$("h2.h2_m1").click(function(){	
		if (flag1)
		{ 
			$("#full_foto1").fadeIn("slow"); 
			flag1 = false; 
		}
		else
		{ 
			$("#full_foto1").fadeOut("slow"); 
			flag1 = true; 
		}
		return false;	
	});
	
	var flag2 = true;
	
	$("h2.h2_m2").click(function(){	
		if (flag2)
		{ 
			$("#full_foto2").fadeIn("slow"); 
			flag2 = false; 
		}
		else
		{ 
			$("#full_foto2").fadeOut("slow"); 
			flag2 = true; 
		}
		return false;	
	});
	
	var flag3 = true;
	
	$("h2.h2_m3").click(function(){	
		if (flag3)
		{ 
			$("#full_foto3").fadeIn("slow"); 
			flag3 = false; 
		}
		else
		{ 
			$("#full_foto3").fadeOut("slow"); 
			flag3 = true; 
		}
		return false;	
	});
	
	var flag4 = true;
	
	$("h2.h2_m4").click(function(){	
		if (flag4)
		{ 
			$("#full_foto4").fadeIn("slow"); 
			flag4 = false; 
		}
		else
		{ 
			$("#full_foto4").fadeOut("slow"); 
			flag4 = true; 
		}
		return false;	
	});
	
	var flag5= true;
	
	$("h2.h2_m5").click(function(){	
		if (flag5)
		{ 
			$("#full_foto5").fadeIn("slow"); 
			flag5 = false; 
		}
		else
		{ 
			$("#full_foto5").fadeOut("slow"); 
			flag5 = true; 
		}
		return false;	
	});
	
	var flag6 = true;
	
	$("h2.h2_m6").click(function(){	
		if (flag6)
		{ 
			$("#full_foto6").fadeIn("slow"); 
			flag6 = false; 
		}
		else
		{ 
			$("#full_foto6").fadeOut("slow"); 
			flag6 = true; 
		}
		return false;	
	});
	
	
	function hide_type_object() 
	{
		
		if (encodeURIComponent($("#type_object").val()) == encodeURIComponent("Квартира"))
		{
			$("#tr_rooms").fadeIn(1000);			
		}
		else
		{
			$("#tr_rooms").hide();
		}
	}
	
	$("#type_object").change(hide_type_object);
	
	
	function hide_type_price() 
	{
		
		if (encodeURIComponent($("#type_price").val()) == encodeURIComponent("Желаемая"))
		{
			$("#tr_price").fadeIn(1000);			
		}
		else
		{
			$("#tr_price").hide();
		}
	}
	
	$("#type_price").change(hide_type_price);
	
	function hide_odessa() 
	{
		
		if (encodeURIComponent($("#odessa").val()) == encodeURIComponent(""))
		{
			$("#tr_odessa_obl").fadeIn(1000);
			$("option[@value='']").attr("selected", "selected");
		}
		else
		{
			$("#tr_odessa_obl").hide();
			$("#tr_odessa_city").hide();
			$("#tr_odessa_rn").hide();
		}
	}
	
	$("#odessa").change(hide_odessa);
	
	
	function hide_odessa_obl() 
	{
		
		if (encodeURIComponent($("#odessa_obl").val()) == encodeURIComponent(""))
		{
			$("#tr_odessa_city").hide();	
			$("#tr_odessa_rn").hide();
		}
		if (encodeURIComponent($("#odessa_obl").val()) == encodeURIComponent("Города"))
		{
			$("#tr_odessa_rn").hide();	
			$("#tr_odessa_city").fadeIn(1000);
		}
		if (encodeURIComponent($("#odessa_obl").val()) == encodeURIComponent("Районы"))
		{
			$("#tr_odessa_city").hide();	
			$("#tr_odessa_rn").fadeIn(1000);
		}
	}
	
	$("#odessa_obl").change(hide_odessa_obl);
	
	
	
	
	
	function change_type_auc() 
	{
		
		var sel = $("#type_object");
		
		if (encodeURIComponent($("#type_auc").val()) == encodeURIComponent("Жилая недвижимость"))
		{
			$('select[@name=type_object] option').remove();
			$("<option></option>").attr("value", "Дом").html("Дом").appendTo(sel);
			$("<option></option>").attr("value", "Квартира").html("Квартира").appendTo(sel);
			$("<option></option>").attr("value", "Коттедж").html("Коттедж").appendTo(sel);
			$("<option></option>").attr("value", "Особняк").html("Особняк").appendTo(sel);
		}
		if (encodeURIComponent($("#type_auc").val()) == encodeURIComponent("Коммерческая недвижимость"))
		{
			$('select[@name=type_object] option').remove();
			$("<option></option>").attr("value", "Офисы, представительства").html("Офисы, представительства").appendTo(sel);
			$("<option></option>").attr("value", "Складские, производственные помещения").html("Складские, производственные помещения").appendTo(sel);
			$("<option></option>").attr("value", "Объекты свободного назначения").html("Объекты свободного назначения").appendTo(sel);
			$("<option></option>").attr("value", "Торговые помещения, салоны").html("Торговые помещения, салоны").appendTo(sel);
			$("<option></option>").attr("value", "Кафе, рестораны, бары").html("Кафе, рестораны, бары").appendTo(sel);
			$("<option></option>").attr("value", "Гостиницы, базы отдыха").html("Гостиницы, базы отдыха").appendTo(sel);
			$("<option></option>").attr("value", "СТО, АЗС, автомойки").html("СТО, АЗС, автомойки").appendTo(sel);
			$("<option></option>").attr("value", "Объекты для инвестиций").html("Объекты для инвестиций").appendTo(sel);
		}
	}
	
	$("#type_auc").change(change_type_auc);
	
	
	hide_type_object();
	hide_type_price();
	hide_odessa();
	hide_odessa_obl();
	
	
	
	
});
