$(function() { 
	$('.picture a').lightBox({fixedNavigation:true});
	
	var col = '#FC4B1C';
	var col_hover = '#007F9F';  
	
	$(".news-picture").hover(function () {
	  $(this).css({'border-bottom-color' : col, 'border-left-color' : col, 'border-top-color' : col, 'border-right-color' : col });
	}, function () {
	  var cssObj = {
		'border-bottom-color' : col_hover, 'border-left-color' : col_hover, 'border-top-color' : col_hover, 'border-right-color' : col_hover
	  }
	  $(this).css(cssObj);
	});
	$('.picture_galeria a').lightBox({fixedNavigation:true});
});

$(document).ready(function() {
	
    $('#main').delay(500).fadeIn();
	

	var footer = true;
	
	// pokazuje stopkę
	function showFooter(){
		$('#activator').hide();
		
		$('#bottom-bar').stop().animate({'bottom': 70}, {duration: 500, easing: 'easeOutQuint', complete: function(){ $('#deactivator').fadeIn();footer = true; }});
	}
	
	// chowa stopkę
	function hideFooter(){
		$('#deactivator').hide(); $('#activator').fadeIn(); footer = false;
		$('#bottom-bar').stop().animate({'bottom': -80}, {duration: 500, easing: 'easeOutQuint'});	
	}
	
	function menuHover(){
		$("#dot").fadeIn(700);
	}
	
	function menuOut(){
		$("#dot").delay(300).fadeOut(500);
	}
	
	var configMenu = {    
		 sensitivity: 2, // number = sensitivity threshold (must be 1 or higher)    
		 interval: 100, // number = milliseconds for onMouseOver polling interval    
		 over: menuHover, // function = onMouseOver callback (REQUIRED)    
		 timeout: 200, // number = milliseconds delay before onMouseOut    
		 out: menuOut // function = onMouseOut callback (REQUIRED)    
	};

	//$("ul#topnav").hoverIntent(configMenu);
	
	function megaHoverOver(){
		$(this).find(".sub").stop().fadeTo('fast', 1).show();
	}
	
	function megaHoverOut(){ 
	  $(this).find(".sub").stop().fadeTo('fast', 0, function() {
		  $(this).hide(); 	  
	  });
	}
	
	var config = {    
		 sensitivity: 2, // number = sensitivity threshold (must be 1 or higher)    
		 interval: 100, // number = milliseconds for onMouseOver polling interval    
		 over: megaHoverOver, // function = onMouseOver callback (REQUIRED)    
		 timeout: 0, // number = milliseconds delay before onMouseOut    
		 out: megaHoverOut // function = onMouseOut callback (REQUIRED)    
	};

	$("ul#topnav li .sub").css({'opacity':'0'});
	$("ul#topnav li").hoverIntent(config);
	
	$("#activator").hover(function(){$("#activator").stop().animate({'left': 0}, {duration: 500, easing: 'easeOutQuint'});},
	function(){$("#activator").stop().animate({'left': -53}, {duration: 500, easing: 'easeOutQuint'});});	
	
	$("#deactivator").hover(function(){$("#deactivator").stop().animate({'left': 0}, {duration: 500, easing: 'easeOutQuint'});},
	function(){$("#deactivator").stop().animate({'left': -53}, {duration: 500, easing: 'easeOutQuint'});});
	
	$('#activator').click(function() {
		showFooter();
	});
	
	$('#deactivator').click(function() {
		hideFooter();
	});

});

// wykrywa wielkosc okna i dopasowuje wielkosci menu glownego
jQuery.event.add(window, "load", resizeFrame);
jQuery.event.add(window, "resize", resizeFrame);

function resizeFrame() 
{
    var h = $(window).height();
    var w = $(window).width();
	
	if(h < 718)
	{
		$('#bottom-bar').stop().animate(
			{'bottom': -80},
			{duration: 500, easing: 'easeOutQuint', complete: function(){
				$('#activator').fadeIn();
				$('#deactivator').fadeOut();
				$('#footer').animate({'bottom': 0, easing: 'easeOutQuint'});
				$('#top-bar').animate({'top': 0, easing: 'easeOutQuint'});
			}}); 
	}
	else
	{
		$('#activator').fadeOut();
		$('#deactivator').fadeIn();
		$('#bottom-bar').stop().animate(
			{'bottom': 70},
			{duration: 500, easing: 'easeOutQuint', complete: function(){
				$('#footer').animate({'bottom': 0, easing: 'easeOutQuint'});
				$('#top-bar').animate({'top': 0, easing: 'easeOutQuint'});
			}}); 
	}
}

//Cufon.replace('h1');
//Cufon.replace('h2');
//Cufon.replace('h3');
	
