/**
 * Released under Creative Commons License
 * http://creativecommons.org/licenses/by/2.0/
 *
 * Author: Kornel Lesinski
 * http://pornel.ldreams.net/pornpups
 *
 * Modified by: mejbi
 */

function pp_click() {
	if(this.pp_win && this.pp_win.close && !this.pp_win.closed) {
		this.pp_win.close();
		this.pp_win = false;
		return false;
	}
	var imgs = this.getElementsByTagName('img');
	var title = this.getAttribute('title');
	var alt = this.getAttribute('title');
	var size = (this.getAttribute('title') ? this.getAttribute('title') : title).match(new RegExp('\(([0-9]+)x([0-9]+)\)'));
	var mwidth = (parseInt(size[2]));
	var mheight = (parseInt(size[3]));
	var winopts = "left="+((screen.availWidth/2)-(mwidth/2)-20)+",top="+((screen.availHeight/2)-(mheight/2)-30)+",dependent=yes,toolbar=no,resizable=yes,width=" + (mwidth+30) + ",height=" + (mheight+50);
	if(win = window.open(this.href, '_blank', winopts)) {
		this.pp_win = win;
		pp_writedoc(this.href, win.document, title, alt);
		return false;
	}
	return true;
}


function pp_writedoc(href, doc, title, alt) {
	doc.open();
	doc.write('<?xml version="1.0" encoding="iso-8859-2"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/XHTML1/DTD/XHTML1-strict.dtd">\n');
	doc.write('<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="pl">\n\n');
	doc.write('\t<head>\n\n');
	doc.write('\t\t<meta http-equiv="Content-type" content="text/html; charset=iso-8859-2" />\n');
	doc.write('\t\t<title>'+title+'</title>\n');
	doc.write('\t\t<style type="text/css">\n');
	doc.write('\t\t\tbody { margin: 0; margin-top: 10px; padding: 0; background: #678998; font-size: 12px; font-family: verdana,arial,sans-serif; color: white; }\n');
	doc.write('\t\t\tp { margin: 0; text-align: center; }\n');
	doc.write('\t\t\timg { background: black; padding: 3px; border: 3px double gray; }\n');
	doc.write('\t\t</style>\n\n');
	doc.write('\t</head>\n\n');
	doc.write('<body>\n\n');
	doc.write('<p><img title="' + title + '" src="' + href + '" alt="' + alt + '" onclick="window.close()" /></p>\n');
	doc.write('<p>' + title + '</p>\n\n');
	doc.write('</body>\n\n');
	doc.write('</html>\n');
	doc.close();
}


function pp_init(element) {
	if(!element.getElementsByTagName) {
		return false;
	}
	var as = element.getElementsByTagName('a');
	for(i = 0; i < as.length; i ++) if(as[i].href.substr(as[i].href.length-3, 3) == 'jpg' || as[i].href.substr(as[i].href.length-3, 3) == 'gif' || as[i].href.substr(as[i].href.length-3, 3) == 'png') as[i].onclick = pp_click;
	return true;
}






function order(a, b) {
	var temp = document.getElementById('t' + a).innerHTML;
	var nejm = document.getElementsByName('i[' + a + ']')[0].value;
	document.getElementById('t' + a).innerHTML = document.getElementById('t' + b).innerHTML;
	document.getElementsByName('i[' + a + ']')[0].value = document.getElementsByName('i[' + b + ']')[0].value;
	document.getElementById('t' + b).innerHTML = temp;
	document.getElementsByName('i[' + b + ']')[0].value = nejm;
}


function amhideshow(a) {
	if(a == 0) val = new Array('none', 'block', 0); else val = new Array('block', 'none', 1);
	document.getElementById('adminmenu').style.display = val[0];
	document.getElementById('adminmenuh').style.display = val[1];
	document.cookie = "mCore_am_visible=" + val[2];
	if(!document.body.getElementsByTagName) return false;
	var as = document.body.getElementsByTagName('li');
	for(i = 0; i < as.length; i ++) if(as[i].className == 'manmen') as[i].style.display = val[0];
}



function mainStart() {
	pp_init(document.body);
}

window.onload = mainStart;

