function popHash(str) {
	var hash = '';
	for(var x=0; x<str.length; x++) {
		hash += str.charCodeAt(x);
	}
	return hash;
}

function pop(url, width, height, scroll, wname) {

	var scrW = window.opera ? document.body.clientWidth : screen.width;
	var scrH = window.opera ? document.body.clientHeight : screen.height;

	var xp = parseInt((scrW - width)/2);
	var yp = parseInt((scrH - height)/2);

	var sc = scroll ? 'yes' : 'no';

	var opts = 'width=' + width;
	opts += ',height=' + height;
	opts += ',left=' + xp;
	opts += ',top=' + yp;
	opts += ',screenX=' + xp;
	opts += ',screenY=' + yp;
	opts += ',toolbar=no';
	opts += ',location=no';
	opts += ',directories=no';
	opts += ',status=no';
	opts += ',menubar=no';
	opts += ',scrollbars=' + sc;
	opts += ',resizable=no';

	if(!wname) {
		var wn = popHash(url);
	}
	else {
		var wn = wname;
	}

	var html1 = '<html><head><title>' + document.title + '</title></head><body style="margin:0px; padding:0px"><img alt="" src=' + url + ' width=' + width + ' height=' + height + ' border="0" onclick="self.close()" style="cursor:pointer"></body></html>';

	var w2 = width - 30;
	var h2 = height - 60;
	var html = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>' + document.title + '</title><link rel="stylesheet" type="text/css" href="html/css/style.css" /></head><body><div style="padding: 15px 15px 0 15px;"><a href="javascript:self.close()"><img src="' + url + '" alt="" width="' + w2 + '" height="' + h2 + '" /></a></div><div style="padding: 15px; text-align: right;"><a href="javascript:self.close()"><img src="html/img/btn_zamknij.gif" alt="zamknij" /></a> </div> </body> </html>';

	var win = window.open('', wn, opts);
	win.document.open();
	win.document.clear();
	win.document.write(html);
	win.document.close();

	if(win && win.top) {
		win.focus();
	}
}


$(document).ready(function(){

	$('.tabRozgrywek a').click(function(){
		var arti_id = parseInt($(this).attr('href').split('#')[1]);

		if ( arti_id > 0 ) {
			$('html').append('<div id="tabRozgrywek_layer"><div style="position: absolute; right: 2px; top: 0px;"><a href="#" id="tabRozgrywek_close">X</a></div><div id="tabRozgrywek_layer_content"></div></div>');
			$('#tabRozgrywek_layer_content').load('?page=article&arti_id='+arti_id);
			$('#tabRozgrywek_layer')
				.css("top", 150 + "px")
				.css("left",parseInt((screen.width - 498)/2 - 50) + "px")
				.show();
		}
		return false;
	});

	$('a#tabRozgrywek_close').live('click', function(){
		$('#tabRozgrywek_layer').remove();
	});	

});


