$(document).ready(function()
{
	
	$("div.div_menu").hover(
      function () 
	  {
		  $(this).css("cursor", "pointer");
		  $(this).find(".ul_menu").show();
		 
	  },
	  function () 
	  {
		  $(this).css("cursor", "default");
		  $(this).find(".ul_menu").hide();
	  }
    );
	
	$("ul.ul_menu li").hover(
      function () {$(this).addClass("select");},
	  function () {$(this).removeClass("select");}
    );
	
	///////////////////////////////////////////////
	
	
	var str = "";
	
    $("#type_object option:selected").each(function () {
		str += $(this).text();
	  });
	
	function hide_div() {
		
	$("div.ctrlHolder:hidden").fadeIn(100);
	
	if (encodeURIComponent($("#type_object").val()) == encodeURIComponent("Квартира")
	 || encodeURIComponent($("#type_object").val()) == encodeURIComponent("Новострой"))
	{
		$("#hide_area_ar").fadeOut(1000);
		$("#hide_area_house").fadeOut(1000);
		$("#hide_amount_apart").fadeOut(1000);
		$("#hide_area_cabinets").fadeOut(1000);
		$("#hide_communic").fadeOut(1000);
		$("#hide_legal_status").fadeOut(1000);
		$("#hide_useful_area").fadeOut(1000);
		$("#hide_garage").fadeOut(1000);
		$("#hide_area_plan").fadeOut(1000);
		
		$("#hide_structures").fadeOut(1000);
		$("#hide_green_planting").fadeOut(1000);
		$("#hide_fruit_trees").fadeOut(1000);
		$("#hide_near_built_territory").fadeOut(1000);
		$("#hide_guard").fadeOut(1000);
		$("#hide_podezd").fadeOut(1000);
		$("#hide_type_comm_object").fadeOut(1000);
		
	}
	if (encodeURIComponent($("#type_object").val()) == encodeURIComponent("Дома")
	 || encodeURIComponent($("#type_object").val()) == encodeURIComponent("Дом, дача")
	 || encodeURIComponent($("#type_object").val()) == encodeURIComponent("Участок_город")
	 || encodeURIComponent($("#type_object").val()) == encodeURIComponent("Участки"))
	{
		$("#hide_amount_apart").fadeOut(1000);
		$("#hide_area_cabinets").fadeOut(1000);
		$("#hide_useful_area").fadeOut(1000);
		$("#hide_life_area").fadeOut(1000);
		$("#hide_hot_water").fadeOut(1000);
		$("#hide_hot_water").fadeOut(1000);
		$("#hide_state").fadeOut(1000);
		$("#hide_door").fadeOut(1000);
		$("#hide_place_car").fadeOut(1000);
		$("#hide_type_comm_object").fadeOut(1000);
	}

	if (encodeURIComponent($("#type_object").val()) == encodeURIComponent("Офис")
	 || encodeURIComponent($("#type_object").val()) == encodeURIComponent("Коммерческая недвижимость")
	 || encodeURIComponent($("#type_object").val()) == encodeURIComponent("Курортная недвижимость"))
	{
		$("#hide_area_ar").fadeOut(1000);
		$("#hide_area_house").fadeOut(1000);
		$("#hide_life_area").fadeOut(1000);
		$("#hide_hot_water").fadeOut(1000);
		$("#hide_garage").fadeOut(1000);
		$("#hide_pool").fadeOut(1000);
		$("#hide_area_plan").fadeOut(1000);
		$("#hide_regular_shape").fadeOut(1000);
		$("#hide_structures").fadeOut(1000);
		$("#hide_green_planting").fadeOut(1000);
		$("#hide_fruit_trees").fadeOut(1000);
		$("#hide_near_built_territory").fadeOut(1000);
		$("#hide_podezd").fadeOut(1000);
	}
	
	if (encodeURIComponent($("#type_object").val()) == encodeURIComponent("Дома"))
	{
		$("#hide_legal_status").fadeOut(1000);
		$("#hide_area_plan").fadeOut(1000);
		$("#hide_regular_shape").fadeOut(1000);
		$("#hide_structures").fadeOut(1000);
		$("#hide_green_planting").fadeOut(1000);
		$("#hide_fruit_trees").fadeOut(1000);
		$("#hide_near_built_territory").fadeOut(1000);
		$("#hide_guard").fadeOut(1000);
		$("#hide_podezd").fadeOut(1000);
		$("#hide_door").fadeOut(1000);
	}
	if (encodeURIComponent($("#type_object").val()) == encodeURIComponent("Участок_город")
	 || encodeURIComponent($("#type_object").val()) == encodeURIComponent("Участки"))
	{
		$("#hide_material_walls").fadeOut(1000);
		$("#hide_material_ceilings").fadeOut(1000);
		$("#hide_material_chaffs").fadeOut(1000);
		$("#hide_material_walls").fadeOut(1000);
		$("#hide_garage").fadeOut(1000);
		$("#hide_pool").fadeOut(1000);
		$("#hide_door").fadeOut(1000);
	}
	}
	
	function hide_price() {
	
	if (encodeURIComponent($("#type_operation").val()) == encodeURIComponent("Аренда"))
	{
		$("option.price_ed_hide").fadeOut(1000);		
		$("option.price_ed_unhide").fadeIn(1000);
		$("option[@value='в месяц']").attr("selected", "selected");
		
	}
	else
	{
		$("option.price_ed_hide").fadeIn(1000);		
		$("option.price_ed_unhide").fadeOut(1000);
		$("option[@value='полная цена']").attr("selected", "selected");
	}
	}
			
			
	$("#type_object").change(hide_div);
	
	$("#type_operation").change(hide_price);
	
	hide_div();
	
	///////////////////////////////////////////////////////////
	
	
	$("#garage").change(function () {
	if (this.checked)
	{
		$("#garage_cap").fadeIn(1000);
		$("#garage_pit").fadeIn(1000);			
	}
	else
	{
		$("#garage_cap").fadeOut(1000);
		$("#garage_pit").fadeOut(1000);
		
	}
	});
	
	$("#pool").change(function () {
	if (this.checked)
	{
		$("#pool_covered").fadeIn(1000);			
	}
	else
	{
		$("#pool_covered").fadeOut(1000);	
	}
	});
	
	
	
	$("div.last").hover(
      function () {$(this).addClass("select");},
	  function () {$(this).removeClass("select");}
    );
	
	//$("table.table_info tr").find(td).text("<a>Якорь</a>");
	
	//if($("table.table_info tr td").html() == "0.00 кв.м.")
		///alert('dsaasas')
		
	var flag = true;
	
	$("h2.h2_m").click(function(){	
		if (flag)
		{ 
			$("#full_foto").fadeIn("slow"); 
			flag = false; 
		}
		else
		{ 
			$("#full_foto").fadeOut("slow"); 
			flag = true; 
		}
		return false;	
	});
	
	 $('#video').cycle({ 
	   fx:     'wipe', 
	   speed:   1000, 
	   timeout: 6000, 
	   clip:   'zoom' 
	});     
	
	$('#tourism_img').cycle({ 
		fx:     'scrollDown', 
		random:  1 
	});
	$('#advertising_img').cycle('fade');
	
	
	$(document).bind("contextmenu",function(e){
    return false;
  	});
	
	
	
	
});
