/* tarantowicz.net @ 2007 */

function init() {
	
	h = $('html').height();
	
	
	$("body").height(h).prepend("<span />");  

	$('ul#preferencje li a').focus(function() { $('ul#preferencje').addClass('focus'); });
	$('ul#preferencje').blur(function() { $('ul#preferencje').removeClass('focus'); });

		
	var Design = $('.readimg a').attr('rel');
	var background = new Image();
	
	var lang = $('html').attr('lang');	
	if(lang == 'pl') { var translacja = 'Wczytywanie projektu graficznego...'; var zamknij = 'Zamknij podgląd'; }
	if(lang == 'en') { var translacja = 'Loading design preview...';  var zamknij = 'Close preview'; }
	
		
	$('.readimg a').hover(function() {
	
		$("body").append("<div id='preload'>"+translacja+"</div>");
		background.src = Design;
		background.onload = function() {
			$('body').css({background: 'url('+Design+')  no-repeat 90% 90% fixed'});
			$("#preload").remove();
		}		
	},function(){
		$('body').css({background: 'url(/wizytowka-11/i/pagoda4.png) no-repeat 100% 110% fixed'});
		$("#preload").remove();
	});	
	
	$('.readimg a').click(function(event) {
		event.preventDefault();
		$('body').append("<div id='overlay'><img src='"+Design+"' alt='"+Design+"' title='"+zamknij+"' /></div>");
		$('img[@alt="'+Design+'"]').bind('click', preview_close);
	});
				
	document.onkeyup = function(e){ 	
		if (e == null) { keycode = event.keyCode; } 
		else { keycode = e.which; }
		if(keycode == 27){ preview_close(); }	
	}
	
	
	function preview_close() {
		$("#overlay img").unbind('click');
		$("#overlay").remove();
		$('body').css({background: 'url(i/pagoda4.png) no-repeat 100% 110% fixed'});
		return false;
	}
				
				
}

$(document).ready(init);