/* Main koruna js file */
jQuery(document).ready(function(){
  jQuery(".div_btn_big .div_hover").hover(
  function () {        
    jQuery(this).stop().animate({opacity: '1.0'},100);     
  }, 
  function () {
    jQuery(this).stop().animate({opacity: '0.0'},250);
  });  
  jQuery("#div_hrefs_top .div_hrefs_top_item").hover(
  function () {        
    jQuery(this).stop().animate({opacity: '1.0'},100);     
  }, 
  function () {
    jQuery(this).stop().animate({opacity: '0.72'},250);
  }); 
  jQuery(".div_btn_send .div_hover").hover(
  function () {        
    jQuery(this).stop().animate({opacity: '1.0'},100);     
  }, 
  function () {
    jQuery(this).stop().animate({opacity: '0.0'},250);
  }); 

  jQuery("body").mousedown(function(){
    closeAllSelects();
  });    
  
  jQuery(".div_tab_container").hover(
  function () {        
    var isNotActive = (jQuery(this).attr("id").indexOf("active") == -1);
    if (isNotActive){
      jQuery(this).stop().animate({opacity: '0.9', marginTop: '2px'},100);
    }     
  }, 
  function () {
    var isNotActive = (jQuery(this).attr("id").indexOf("active") == -1);
    if (isNotActive){  
      jQuery(this).stop().animate({opacity: '0.75', marginTop: '4px'},100);
    }
  });   

  

    jQuery("#top_fulltext").blur(function () {
        if (jQuery(this).attr("value") == "") {
            jQuery(this).attr("value", "Hledaný výraz");
        }
    });

    jQuery("#top_fulltext").focus(function () {
        if (jQuery(this).attr("value") == "Hledaný výraz") {

            jQuery(this).attr("value", "");
        }
    });  
  
});  

jQuery(window).load(function(){  
  var typId = jQuery("#zpusob2").attr("value");
  //alert(typId);
  if (typId != ""){
    var value = jQuery("#zpusob2 option:selected").html();  
    jQuery(".div_select_container[for_select*=zpusob2]").children(".div_select_main").children(".div_select_label").html(value);
  } 
  var nemovitostId = jQuery("#object_type2").attr("value");
  if (nemovitostId != ""){
    var value = jQuery("#object_type2 option:selected").html();  
    jQuery(".div_select_container[for_select*=object_type2]").children(".div_select_main").children(".div_select_label").html(value);
  }   
  //alert(nemovitostId);

});

function showSelect(select){ 
    select.attr("opened", "true");
    select.children('.div_select_main').children('.div_open_ui').css("display", "block");
    select.children('.div_select_main').children('.div_btn_open').css("display", "none");
    select.children('.div_select_main').children('.div_btn_close').css("display", "block");
}

function hideSelect(select){ 
    select.attr("opened", "false");
    select.children('.div_select_main').children('.div_open_ui').css("display", "none");
    select.children('.div_select_main').children('.div_btn_open').css("display", "block");
    select.children('.div_select_main').children('.div_btn_close').css("display", "none");
    
    var value = select.children('.div_select_main').children('.div_select_label').html();
    var forWhat = select.attr("for_select");
    var selIda = parseInt(select.attr("selected_id"));
    jQuery("#"+forWhat).val(selIda);  
}

//function showDistricts(a){}
//function hideAllSearchFields(){}
//function showSearchFields(a){}

function closeAllSelects(){
  var count = jQuery(".div_select_container").length;
  for (var i=0; i < count; i++){
    hideSelect(jQuery(".div_select_container:eq("+i+")"));
  }
}


jQuery(window).load(function(){
	var hash = location.hash;
	var len = hash.length;
	if (len > 3 ){
		if (hash.indexOf("vykup") != -1){
			jQuery("html, body").animate({ scrollTop: jQuery('.pasive_content img:eq(3)').offset().top}, 1000);
		}else if (hash.indexOf("exekuce") != -1){
			jQuery("html, body").animate({ scrollTop: jQuery('.pasive_content img:eq(4)').offset().top}, 1000);
		}else if (hash.indexOf("privatizace") != -1){
			jQuery("html, body").animate({ scrollTop: jQuery('.pasive_content img:eq(5)').offset().top}, 1000);
		}    
	}
});

  function goToPart(id){
    if (id == -1){
      jQuery("html, body").animate({ scrollTop: jQuery('.pasive_content').offset().top}, 1000);
    }else{
      jQuery("html, body").animate({ scrollTop: jQuery('.pasive_content img:eq('+id+')').offset().top+22}, 1000);
    }
  }
  
  jQuery("#div_hrefs_top .div_hrefs_top_item").hover(
  function () {        
    jQuery(this).css("opacity", "1.0");
  }, 
  function () {
    jQuery(this).css("opacity", "0.72");
  }); 
