$(document).ready(function(){

 /* horni pruh fixed -------------------------------------------------------- */
 $(window).scroll(function() { 
  $("#top-bar-logged").css("top", $(window).scrollTop() + "px"); 
  $("#top-bar").css("top", $(window).scrollTop() + "px"); 
 }); 

 /* prepinani ve vzhledavani ------------------------------------------------ */
 $('#search-btn-1,#search-btn-2').click(function() {
  $(this).toggleClass("act");
 });

 /* sliding novinky --------------------------------------------------------- */
 if ($('#ne1').length) { 
  $('#ne1').loopedSlider();
 }
 
 /* submenu ----------------------------------------------------------------- */
 $("#menu-more, #menu-more div").hover(
  function() { $("#menu-sub").css({display: 'block'}); }, 
  function() { }
 ); 
 
 $("#menu-sub div").hover(
  function() { }, 
  function() { $("#menu-sub").css({display: 'none'}); }
 ); 
 
 $("#menu-sub a").hover(
  function() { $("#menu-sub").css({display: 'block'}); }, 
  function() { $("#menu-sub").css({display: 'block'}); }
 ); 
 
 /* zavreni pruvodce -------------------------------------------------------- */
 $('#guide-close').click(function() {
  $('.guide').hide('slow');
 });

 /* taby -------------------------------------------------------------------- */
 $("#mf-tabs,#st-tabs,#ne-tabs,#vi-tabs,#di-tabs,#sp-tabs,#ti-tabs").tabs(1);

 /* inzerce ----------------------------------------------------------------- */
 $('.st-item img').each(function() {   
  $(this).hover(
   function() { $("#pop-"+$(this).attr("longdesc")).css('display', 'block'); },   
   function() { $("#pop-"+$(this).attr("longdesc")).css('display', 'none'); }
  );   
 }); 

 /* poznej sve kolegy ------------------------------------------------------- */
 $('#mf-body div div div').css('opacity', 0);
 $('#mf-body div div').each(function() {   
  $(this).hover(function() {  
   $('div', this).css('display', 'block'); 
   $('div', this).stop().animate({ opacity: .85 }, 100);   
  },   
  function() {   
   $('div', this).stop().animate({ opacity: 0 }, 100);   
  });   
 });  

 /* horni pruh prepinani zprav ---------------------------------------------- */
 var cnt = $('#adv-cont').children().size();
 var wdth = 390*cnt;
 var cssObj1 = {"width": wdth}
 $("#adv-cont").css(cssObj1);
 if (cnt>2) {
  $("#adv-right").css({"display": "block"});
 }
 $("#adv-left").click(function () {
  // if ($("#adv-cont:animated").size() != 0) return false;
  $("#adv-right").css({"display": "block"});
  $("#adv-cont").animate({"left": "+=390px"}, 300, function() {
  	if ($("#adv-cont").css("left")=="0px") {
  		$("#adv-left").css({"display": "none"});
  	}
  });
  return false;   
 });
 $("#adv-right").click(function () {
	 // if ($("#adv-cont:animated").size() != 0) return false;
	 var wdth2 = wdth-390;
  $("#adv-left").css({"display": "block"});
  $("#adv-cont").animate({"left": "-=390px"}, 300, function() {
  	if ($("#adv-cont").css("left")=="-"+wdth2+"px") {
  		$("#adv-right").css({"display": "none"});
  	}
  });
  return false;   
 });  

 /* horni pruh hover na sipkach --------------------------------------------- */
 $("#adv-left").hover(
  function() { $(this).css({backgroundPosition: 'right top'}); }, 
  function() { $(this).css({backgroundPosition: 'left bottom'}); }
 );

 $("#adv-right").hover(
  function() { $(this).css({backgroundPosition: 'left top'}); }, 
  function() { $(this).css({backgroundPosition: 'right bottom'}); }
 );
 
 /* hover znacek na mape ---------------------------------------------------- */
 $("#map-list a").hover(
  function() { $(".mark.uni-" + $('span', this).text()).css({backgroundPosition: 'right top'}); }, 
  function() { $(".mark.uni-" + $('span', this).text()).css({backgroundPosition: 'left top'}); }
 );

 /* kulate rohy ------------------------------------------------------------- */
 $(".box").corner({
  tl: { radius: 6 },
  tr: { radius: 6 },
  bl: { radius: 6 },
  br: { radius: 6 },
	 antiAlias: true,
	 autoPad: true
 });
 
 /* hover na radcich tabulky ------------------------------------------------ */
 $("#ti1 tr").hover(
  function() { $(this).addClass("highlight"); }, 
  function() { $(this).removeClass("highlight"); }
 ); 
 
});