$(document).ready(function() {
//top navig
//$("#top_navig").find("ul").hide(); //init the 0 level
$("#top_navig .main").hover(
    function(){
 	    $(this).find('a:first').addClass('current2');
 	},
 	function(){
 	    $(this).find('a:first').removeClass('current2');
});
function dodji(){
    $(this).find("ul:first").fadeIn(200);
}
function nestani(){
    $(this).find("ul:first").fadeOut(200);
}
$("#top_navig .main").hoverIntent({
    over: dodji,
    timeout: 600,
    out: nestani
});
	
// left navig
  $(".navigation #left_navig li").each(function(){
    var item;
    if ( $(this).find("ul").length ) {
      item = $("<span class='button'></span>").click(function(e){
        $(this)
          .parent().toggleClass("selected")
          .parent().find("ul:first").toggle("slow");
        return false;
      });
      $(this).find(".children").hide();
    } 
    $(this).children("a").prepend( item );
  });
  $(".navigation #left_navig").find("ul").hide(); //init the 0 level
  $(".navigation #left_navig .active").show();
  $(".navigation #left_navig .current").toggleClass("selected");
// left navig dodatak
$("#left_navig .main_parent").click(
    function () {
        $(this)
        .toggleClass("selected")
        .parent().find("ul:first").toggle("slow");
    }
);
//  search results toggle
$('.toggle').live('click',
  function () {
    x = $(this).parent().hasClass('closed');
    if (x==true) {
    $('.results .opened').toggleClass('opened').toggleClass('closed').find('.cont').slideToggle('slow');
    $(this).parent().toggleClass('closed');
    $(this).parent().toggleClass('opened');
    $(this).parent().find('.cont').slideToggle('fast');
//  $('html,body').animate({scrollTop: 590}, 500);
    }
});
// hover efekt za rezultate
$('.rez').live('mouseover', function() { $(this).addClass('rez_a'); })
         .live('mouseout', function() { $(this).removeClass('rez_a'); });
// hover efekt za justInfo  (foto galerija - galleryCycle)
$('.justInfo').hover(
	function(){	$(this).addClass('hovered');
	$(this).find('.ji_opis').fadeIn(200);
	},
	function(){	$(this).removeClass('hovered');
	$(this).find('.ji_opis').fadeOut(200);
    }
);
// hover efekt za kategorije  (Cycle category)
$('.kat').hover(
	function(){	$(this).addClass('hovered');
	$(this).find('.tekst').show();
	},
	function(){	$(this).removeClass('hovered');
	$(this).find('.tekst').hide();
    }
);
// hover efekt za akcije top (slika se mora brze otvarat i sporije zatvarat)
$('.action-top .act').hover(function() { //On hover...
	$(".action-top .pg_flp, .action-top .cycle").stop()
	.animate({width:'300px',height:'300px'},480);
	$(".action-top .cycle").stop().animate({width:'300px',height:'300px'}, 500);
	} , function() {
	$(".action-top .pg_flp").stop().animate({width:'50px',height:'50px'},240);
	$(".action-top .cycle").stop().animate({width:'50px',height:'50px'},200);
});
// hover efekt za stavke  (Cycle category)
$('.content_short_text').hover(
	function(){	$(this).addClass('hovered');
	$(this).find('.over').stop(true, true).slideToggle(200);
	},
	function(){	$(this).removeClass('hovered');
	$(this).find('.over').stop(true, true).slideToggle(200);
    }
);
// hover efekt za slideshow
$('.content-cycle .trig')
.live('mouseover',function(){ 
    $(this).parent().find('.ss-toolbar').show(); 
})
.live('mouseout',function(){ 
    $(this).parent().find('.ss-toolbar').hide(); 
});

// enlarge gumb za slideshow
$('.ss-toolbar .enlarge').live('click', function() {
	$href= $(this).attr("rel");
	$title= $(this).attr("alt");
	Shadowbox.open({player:'img', title: $title, content: $href});
});	
//  novosti + akcije tabovi
$('.na .na_tabs a').filter(':first').addClass('sel');
$('.na .na_cont .na_div').filter(':first').addClass('sel');
$('.na .na_tabs a').live('click', function () {
    if (!$(this).hasClass('sel')) { 
    $('.na .na_tabs a').toggleClass('sel');
    $('.na .na_cont .na_div').toggleClass('sel');
    }
}); 
// toggle efekt za search
$('.srch_toggle').click(
	function(){ $(this).toggleClass('srch_t_hov');
	$(this).parent().find('#search').stop(true, true).slideToggle(200);
	},
	function(){ $(this).toggleClass('srch_t_hov');
	$(this).parent().find('#search').stop(true, true).slideToggle(200);
    }
);
$('#pikto-c').click(function(){
    $('#search').slideDown(200);
    $('#search .text').focus();
});

}); //end
