var fadeSpeed=1000;

currentDropDown=0;
somethingToClose=0;

closedd = function close() {
	if (currentDropDown==0) {
		$(somethingToClose).find(".wrapcontrol").slideUp();
	}	
}

opendd = function open() {
	if (currentDropDown!=0&&currentDropDown!=somethingToClose) {
		$(".wrapcontrol").not($(somethingToClose).find(".wrapcontrol")).slideUp();
		$(somethingToClose).find(".wrapcontrol").slideDown();
	}
}

$(document).ready(function() {
	//Menus
	$(".menudropdown").hover(function() {
		currentDropDown=1;
		somethingToClose=this;
		setTimeout(opendd,1000);
	});
	
	$(".menudropdown").click(function() {
		currentDropDown=1;
		somethingToClose=this;
		opendd();
	});
	
	$(".menudropdown").mouseleave(function() {
		currentDropDown=0;
		setTimeout(closedd,500);
	});
	
	//Images
	$(".img_link").fancybox({
		'hideOnContentClick': true,
		'transitionIn'		: 'fade',
		'transitionOut'		: 'fade',
		'titlePosition' 	: 'over',
		'width'         : 'auto',
		'height'        : 'auto',
		'autoScale'     	: false,
		'autoDimensions': false,
		'titleFormat'       : function(title, currentArray, currentIndex, currentOpts) {
		    return '<span id="fancybox-title-over">Slika ' +  (currentIndex + 1) + ' / ' + currentArray.length + ' ' + title + '</span>';
		}
	});


	
	//Tabs
	$(".rgt_content").hide(); 
		$("ul.tabs li:first a").attr("id", "sub_active").show(); 
		$(".rgt_content:first").show(); 

	$("ul.tabs li a").hover(function() {
		$(".rgt_content").hide(); 
		$("ul.tabs li a").attr("id", ""); 
		$(this).attr("id", "sub_active"); 
		var activeTab = $(this).attr("href"); 
		$(".rgt_content").hide(); 
		$(activeTab).show();
		return false;
	});
	
	//Slideshow
	$('a.slideshow').click(function() {
		var id = $(this).attr("id");
		$('div.slideshow').hide(); //skrije vse
		$('div.slideshow#'+id).show(); // pokaze trenutnega
	});
	
	$(".panel_holder").hide(); 
		$(".arrow").hide(); 
		$("ul.tabspanel li:first").attr("id", "active").show(); 
		$(".panel_holder:first").show(); 

		$("ul.tabspanel li").hover(function() {
			$("ul.tabspanel li").attr("id", ""); 
			$(this).attr("id", "active"); 
			$(".panel_holder").hide(); 
			var activeTab = $(this).find("a").attr("href"); 
			$(".arrow").show(); 
			$(activeTab).toggle(); 
			return false;
		});
});
