// JavaScript Document

$(document).ready(function(){

  // Focus/blur on search
  $("#search input, #search-sidebar input").focus(function() { 
    if( this.value == this.defaultValue ) { 
      this.value = ""; 
    } 
  }).blur(function() { 
    if( !this.value.length ) { 
      this.value = this.defaultValue; 
    } 
  });

  // Moj RECRO-net login box behaviour
  $("#moj-recronet-box > a").attr("href","#").toggle(function(){
    $(this).prev().css({color:"#333"});
    $(this).next().show();
    $(this).text("Zatvori");
  }, function(){
    $(this).prev().css({color:"#777"});
    $(this).next().hide();
    $(this).text("Prijavi se");
  });
  
  // Moj RECRO-net news options beahviour
  $("#news-options").hide();
  $("#content-wrap.moj-recronet #main .box h2 a").toggle(function(){
    $(this).addClass("click").text("Zatvori");
    $("#news-options").slideDown(200);
  }, function(){
    $(this).removeClass("click").text("Prikaži samo");
    $("#news-options").slideUp(200);
  });
  
  // Table zebra striping
  $("table tr:has(td):odd").addClass("odd");
  
  // Accordion
  $(".accordion, #index-accordion").accordion({header:"h3"});
  $("#faq").accordion({header:"h3"}); 
  
  // Greybox
  $("a.greybox").click(function(){
    var t = this.title || $(this).text() || this.href;
    $.GB_show(this.href, "#wrapper", {
      height: 660,
      width: 518,
      animation: false,
      overlay_clickable: true,
      caption: t
    });
    return false;
  });   

  // IE6
  if ($.browser.msie && $.browser.version < 7) {
  
    // Main nav behaviour
    $("#main-nav > li").hover(function() {
      $(this).find(".dropdown-wrap").css({display:"block"});    
    }, function(){
      $(this).find(".dropdown-wrap").css({display:"none"});
    });
    
    $("#main-nav > li > .dropdown-wrap").hover(function() {
      $(this).parent().addClass("hover");
    }, function() {
      $(this).parent().removeClass("hover");
    });
    
    // Sub nav behaviour    
    $("#sub-nav li").hover(function() {
      $(this).addClass("hover");
    }, function() {
      $(this).removeClass("hover");
    });
    
    $("#sub-nav ul > li.active:has(ul)").attr("id","open");
  }

});

