
var showloading = false;
var act = null;
var to  = null;

/*
 * gotowy HTML
 */
$(document).ready(function() 
{
	$("#gbanner a").click(function(){
		 this.blur();
	});

	$("#hormenu img").addClass("over");
	
	/* guziki on / off */
	$(".over").mouseover(function(){
		this.src = this.src.replace('btn-','btn-on-');		 
	});

	$(".over").mouseout(function(){
		this.src = this.src.replace('btn-on-','btn-');		 
	});

	$("#nav > li > a").mouseover(function()
	{
		$("#nav > li > ul").hide();
		
		var el = $(this).find('~ ul');
		
		if (el) {
			el.show();
			act = el;
		}
		 
	});

	$('.submenu').mouseover(function(){
		window.clearTimeout(to);
	});
	
	$('.submenu').mouseout(function(){
		to = window.setTimeout(function(){
			act.hide();
		}, 1000);
	});


});

/*
 * Zaadowana strona
 */
window.onload = function(){

//	if (showloading) 
//	{
//		$("#dloader").fadeOut(500, function (){
//			   $("#header").fadeIn(700, function(){});
//			   $("#body").fadeIn(700, function(){
//				   $('#headerImageI').ifixpng();
//				   $("#headerlogo").fadeIn(700);
//				   $("#leftmenu").fadeIn(700,function(){
//				   });
//			   });
//		});
//	} else {
		$("#dloader").fadeOut(500);
		$("#gbanner").show();
		$("#body").show();
	    $("#headerlogo").show();
		$("#leftmenu").show();
		$("#footer").show();
		
		$('#headerImageI').ifixpng();
//	} 

	
};


function centerThis(div) {
        var winH = $(window).height();
        var winW = $(window).width();
        var centerDiv = $('#' + div);
        centerDiv.css('top', winH/2-centerDiv.height()/2);
        centerDiv.css('left', winW/2-centerDiv.width()/2);
} 

var sendToUrl  = '';
var sendToTitle = '';

function sendToFriend(url, title)
{
	centerThis('sendToFriend');

	sendToUrl = url;
	sendToTitle = title;
	
	$('#sendToFriend').load($('#sendToFriend').attr('src'), {},function()
	{
		$('#sendToFriend').fadeIn();
		
		$('#sendFriendForm').ajaxForm({
			target:'#sendFriendFormResult',
			success: function () {
				$('#sfSubmitButton').attr('disabled', false);
			}
		});
		
		$('#sendUrl').attr('value', window.location);
		$('#sendTitle').attr('value', document.title);
		
	});
}
