// kopiowanie zabronione, naucz siê i napisz sobie sam.

function otworz_okno(adres, w, h){
	F=window.open('','','width='+w+',height='+h);
	F.screenX=100;
	F.screenY=100;
	F.document.open();
	F.document.write('<html><head><title>'+adres+'</title></head><body style="margin: 0px; padding: 0px; text-align: center;"><img src="upload/'+adres+'" alt="" style="cursor: pointer;" onclick="window.close();"></body></html>');
	F.document.close();
}

$(document).ready(function(){
	if($.browser.opera) { 
    $.support.opacity = true; 
	}
	$('#top li a').css({opacity: 0});
	$('#top li a').hover(function(){
		$(this).animate({opacity: 1}, 200);
	},
	function(){
		$(this).animate({opacity: 0}, 200);
	});
	$('#butonStrony1').attr('className', 'butonAktywny');
	$('#strona1').css({display: 'block'});
	var x = 0;
	$('#ude ul li').each(function(){
		x++;
		$(this).attr('numerek', x);
		$(this).click(function(){
			$('.strona').css({display: 'none'});
			$('#strona' + $(this).attr('numerek')).css({display: 'block'});
			$('.butonAktywny').attr('className', '');
			$('#butonStrony'+$(this).attr('numerek')).attr('className', 'butonAktywny');
			return false;
		});
	});	
	
	function fotosy(link){
		var plik = link.attr('href');
		var podpis = link.find('img').attr('alt');
		$('#duzeFoto').remove();
		$('#duzeFotoBG').remove();
		$('body').append('<div id="duzeFotoBG"></div><div id="duzeFoto"><img src="'+plik+'" alt="" /><span>X</span><div id="fotopodpis">'+podpis+'</div></div>');
		var h = $(document).height()+0;
		var w = $(document).width()+0;
		$('#duzeFotoBG').css({opacity: 0, height: h+'px', width: w+'px'});
		$('#duzeFotoBG').animate({opacity: 0.7}, 500);
		$('#fotopodpis').css({opacity: 0.5});
		$('#duzeFoto').click(function(){
			$('#duzeFotoBG').remove();
			$('#duzeFoto').remove();
		});
		
		$('#duzeFoto').css({top: (document.documentElement.scrollTop+20)+'px', left: ((w/2)-(800/2))+'px', opacity: 1});
		//var img = new Image();
		//if(!$.browser.opera) { 
//			$(img).bind('load', (function(){
				//$('#duzeFoto').append(img);
				//$('#duzeFoto').animate({top: (document.documentElement.scrollTop+20)+'px', opacity: 1}, 1000);
			//}));
		//} else {
//			$('#duzeFoto').append(img);
			//$('#duzeFoto').animate({top: (document.documentElement.scrollTop+20)+'px'}, 1000);
		//}
		//$(img).attr('src', plik);
		//$(img).attr('alt', ' ');
	};
	$('.przykladowaStrona a').click(function(){
		fotosy($(this));
		return false;
	});
	$('#portfolio .strona .screen').click(function(){
		fotosy($(this));
		return false;
	});
	$('#portfolio .strona .screen').append('<img src="grafika/lupa.jpg" alt="" class="lupa" />');
	$('.nazwaStrony').css({opacity: 0.8});
	$('.przykladowaStrona a').hover(function(){
		$(this).find('span').css({background: 'orange', color: '#222'});
	}, function(){
		$(this).find('span').css({background: '#08c', color: '#fff'});
	});
	
	var keys = [];
	function keyDown(e) {
		keys[e.keyCode] = true;
		if(keys[27]){
			$('#duzeFoto').remove();
			$('#duzeFotoBG').remove();
		}
	}
	$(this).keydown(keyDown);
});