//jquery.function.js

//----------JQUERY-FUNCTION----------//

$(document).ready(

function() {

  	//----------drukowanie----------//
	$("#drukowanie_img").click(
	function() {
		
		//window-width
		var window_width = $(document).width();
		
		//window-height
		if ( navigator.appName == 'Microsoft Internet Explorer' ) {
			var window_height = $(window).height();
		} else {
			var window_height = window.innerHeight;
		}
		
		//document-height
		var all_height = $('#hover_main').height();
		
		//top-height
		var top_height = 30;
		top_height += getPageScroll();
		
		//alert-background
		$("#hover_background").css( {width: ""+window_width+"px", height: ""+all_height+"px", opacity: '0.5', display: 'block'} );
			
		//alert-box-css
		$("#hover_div").css( {top: ""+top_height+"px"} );
		
		//alert-opis-display
		//$(".alert_opis").css({display: "block"});
		
		//alert-box-display
		$("#hover_div").fadeIn("slow");
		
	});
	
	$("#hover_div_drukuj").click(
	function()
	{	
		$("#hover_div").css({display: "none"});
		$("#hover_background").css({display: "none"});
		window.print();
	});
	
	$("#hover_div_zamknij").click(
	function()
	{
		$("#hover_div").fadeOut("slow", 
		function()
		{
			$("#hover_background").css({display: "none"});
		});
	});
	
	$("#image_show").click(
	function() {
		
		var imageHeight = $("#hover_image img").attr("name");
		
		//window-width
		var window_width = $(document).width();
		
		//window-height
		if ( navigator.appName == 'Microsoft Internet Explorer' ) {
			var window_height = $(window).height();
		} else {
			var window_height = window.innerHeight;
		}
		
		//document-height
		var all_height = $('#hover_main').height();
		
		//top-height
		var top_height = (window_height - imageHeight)/2;
		top_height += getPageScroll();
		
		//alert-background
		$("#hover_background").css( {width: ""+window_width+"px", height: ""+all_height+"px", opacity: '0.5', display: 'block'} );
		
		//hover-image
		$("#hover_image").css({top: ""+top_height+"px"});
		$("#hover_image").fadeIn("slow");
		
	});
	
	$("#hover_image_zamknij").click(
	function()
	{
		$("#hover_image").fadeOut("slow", 
		function()
		{
			$("#hover_background").css({display: "none"});
		});
	});
  	
  	$(".partnerzy_nazwa").mousemove(
	function(e) {
		
		var nazwa = $(this)[0].firstChild.nodeValue;
		var opis = $(this).parents(".partnerzy_lista").children(".partnerzy_opis_hover")[0].firstChild;
		
		if (opis != null && opis != '')
		{
			opis = opis.nodeValue;
			
			$("#partnerzy_hover_title").html(nazwa);
			$("#partnerzy_hover_opis").html(opis);
			
			var left = e.clientX + document.documentElement.scrollLeft + 30 + 'px';
			var top = e.clientY + document.documentElement.scrollTop + getPageScroll() + 0 + 'px';
			
			$("#partnerzy_hover").css({ left: ""+left+"", top: ""+top+"", display: "block"});
		}
		
	});
	
	$(".partnerzy_nazwa").mouseout(
	function() {
		
		$("#partnerzy_hover").css({ display: "none"});
		
	});

});

//----------FUNCTION----------//

//getPageScroll
function getPageScroll() {
	
	var xScroll, yScroll;

	if (self.pageYOffset) 
	{
		yScroll = self.pageYOffset;
		xScroll = self.pageXOffset;
	}
	// Explorer 6 Strict
	else if (document.documentElement && document.documentElement.scrollTop)
	{
		yScroll = document.documentElement.scrollTop;
		xScroll = document.documentElement.scrollLeft;
	}
	// all other Explorers
	else if (document.body) 
	{
		yScroll = document.body.scrollTop;
		xScroll = document.body.scrollLeft;	
	}
	
	return yScroll;
}













