$(document).ready(function () {

  //this is causing problems in firefox
  if (navigator.userAgent.indexOf("Firefox")==-1) {
	  $.each($(".hp-portlet td.same-height"), function(i, val) {
	    $(this).children(".portlet-top").height($(this).height());
	  });
  }
  
  
  
  //pravá strana u clanku na stejnou vysku jako leva strana pokud je prava mensi -(paddingy a jeden margin)
  $(".site1 td.right-col").children().children("div.right-col-in").css('min-height',$(".site1 td.right-col").height()-19-2);
  if ($.browser.msie && $.browser.version=="6.0") {
		$(".site1 td.right-col").children().children("div.right-col-in").css('height',$(".site1 td.right-col").height()-19-2);
  }
  
  //button - ie6 - hover
	if ( $.browser.msie && /6.0/.test(navigator.userAgent) ) {
    $(".form input.button").hover(
        function () {
          $(this).addClass("hoverSubmit");
        },
        function () {
          $(this).removeClass("hoverSubmit");
        }
      );
      
      $(".form input.button-back").hover(
        function () {
          $(this).addClass("hoverSubmit-back");
        },
        function () {
          $(this).removeClass("hoverSubmit-back");
        }
      );
      
      
/*
    $(".form input.button").mouseup(function(){
      $(this).removeClass("activeSubmit");
    }).mousedown(function(){
      $(this).addClass("activeSubmit");
    });
    neni idealni, protoze muze se kliknout a zakliknuty odjet z tlacitka pryc
*/
  }

  // menu
  $("li.u1").hover(
    function () {
      //$(this).addClass("hover");
      $(this).children("a").addClass("hover"); // pro ie6 aby nulta uroven mela grafiku hoveru
      $(this).children("div").show();
      if ($.browser.msie && $.browser.version=="6.0") {
				$("select").css("visibility","hidden");
			}
    },
    function () {
      //$(this).removeClass("hover");
      $(this).children("a").removeClass("hover");
      $(this).children("div").hide();
      if ($.browser.msie && $.browser.version=="6.0") {
				$("select").css("visibility","visible");
			}
    }
  );
  
  //submenu
  $("li.u1 li").hover(
    function () {
      $(this).children("a").addClass("hover"); // pro ie6 aby nulta uroven mela grafiku hoveru
      $(this).children("div").show();
    },
    function () {
      $(this).children("a").removeClass("hover");
      $(this).children("div").hide();
    }

  );
  
  //nutna graficka vzpomoc pri spodnim oblouku(pod boxem na vyhledavani) u "sub"menu pokud je polozek hodne a roztahne to vysku

	if ( $("div.menu").height()>35 )
    $("div.menu-in2").addClass("menu-in2JS");
    

	var mapaCRsrc=$(".mapa-cr-img").attr("src");
	$(".vyhledavani-pobocek .mapa-cr map area").hover(
	
	  function () {
	    
      href=$(this).attr("id");
			
			nahrada="/vm-"+href.substring(1,href.length)+".png";
			regexp='/[a-zA-Z0-9._-]+.png';
      //regexp='/(.+).png';
	    var rex = new RegExp(regexp, "i");
	    mapaCRsrcnova=mapaCRsrc.replace(rex, nahrada);
	    $(".mapa-cr-img").attr("src",mapaCRsrcnova);
	  },
	  function () {
	    $(".mapa-cr-img").attr("src",mapaCRsrc);
	  }
	);
// mala mapa na HP
	var malaMapaCRsrc=$(".mala-mapa-cr-img").attr("src");
	$(".portlet-pab map area").hover(
	  function () {
	    href=$(this).attr("id");

			nahrada="/mm-"+href.substring(1,href.length)+".png";
			regexp='/[a-zA-Z0-9._-]+.png';
	    //regexp='/(.+).png';
	    var rex = new RegExp(regexp, "i");
	    malaMapaCRsrcnova=malaMapaCRsrc.replace(rex, nahrada);
	    $(".mala-mapa-cr-img").attr("src",malaMapaCRsrcnova);
	  },
	  function () {
	    $(".mala-mapa-cr-img").attr("src",malaMapaCRsrc);
	  }
	);

	$(".onePortletHeight").find(".portlet").height($(".onePortletHeight").height()-7);

  //vice - odkaz - pro ie6 min-width
	$.each($(".vice-in a"), function(i, val) {
		if ( $(this).width()<62 )
	  	$(this).width(62);
  });

//$(".menu1-sh-top > ul > li:last").addClass("last");
  $.each($(".menu1-sh-top > ul"), function(i, val) {
    $(this).children("li:last").addClass("last");
  });

//Rozestupy v menu dynamicky
  $.each($("td.menu ul li span"), function(i, val) {
    if($(this).width()<60){
      //20px
      $(this).css("padding","0px 20px 0 20px");
		}
		if($(this).width()>200){
		  //6px
		  $(this).css("padding","0px 6px 0 6px");
		}
		if( ($(this).width()>60) && ($(this).width()<200) ){
		  //dopocitat lehce
		  var padding = (260 - $(this).width()) / 10 ;
		  $(this).css("padding","0px "+padding+"px 0 "+padding+"px")
		}

  });

});