
/** init **************************************************/

function addOnloadEvent (fnc) {
	if (!self.inits) self.inits = new Array();
	self.inits[self.inits.length] = fnc;
}

function init () {
	var i;
	for (i = 0; i < self.inits.length; i++) {
		var initFunc = self.inits[i];
		if (initFunc) initFunc();
	}
}

document.onload = init;
document.onkeypress = function (ev) {
	if (window.event) ev = window.event;
	switch(ev.keyCode) {
	case 27:
		if (self.opener) {
			window.close();
		}
		break;
	}
}


/** cookies ***********************************************/

function getCookie(name) {
	var bites = document.cookie.split(";");
	for (i=0; i < bites.length; i++) {
		bite = bites[i].split("=");
		var cname = bite[0];
		if (cname.charCodeAt(0) == 32) cname = cname.substring(1,cname.length);
		if (cname == name) return unescape(bite[1]);
	}
    return null;
}

function clearCookie(name) {
	document.cookie = name + "=x; expires=Fri, 31 Dec 1999 23:59:59 GMT";
}

function setCookie(name, value) {
    if (value != null && value != "") {
		var today = new Date();
		var expiry = new Date(today.getTime() + 31 * 24 * 60 * 60 * 1000);
		document.cookie = name + "=" + escape(value) + "; path=/; expires=" + expiry.toGMTString();
	}
}

/** positioning *******************************************/

function leftPosition(obj){
	return obj.offsetLeft + ((obj==document.body) ? 0 : leftPosition(obj.offsetParent));
}

function topPosition(obj){
	return obj.offsetTop + ((obj==document.body) ? 0 : topPosition(obj.offsetParent));
}


function showImage(img, title, w, h) {
	var win = window.open('about:blank','','scrollbars=no,width=' + w + ',height=' + h); // ,left='+PositionX+',top='+PositionY;
	win.document.writeln('<html><head><title>' + title + '</title><style>body{margin:0px;}</style>' +
		'<body bgcolor="#FFFFFF" scroll="no" onclick="self.close();">' +
		'<table><tr><td align="center"><img src="' + img + '" /></td></tr></table>' +
		'</body></html>');
	win.document.close();
}

/***controla formularu*****************************************************/
function control_form(){
	var chyba='';
	if (document.getElementById('prezdivka').value == '') chyba+="- Přezdívka\n";
	if (document.getElementById('nadpis').value == '') chyba+="- Nadpis\n";
	if (document.getElementById('captch').value == '') chyba+="- Text z obrázku\n";
	if (chyba!='') {
	alert ("Vyplňte prosím následující údaje:\n\n"+chyba);
	return false;
	}else return true;
}




