function setCookie(name, value) {
	expires = new Date();
	expires.setTime(expires.getTime() + 1000*60*60*24);
	document.cookie = name + '=' + value + "; expires=" + expires.toGMTString() + "; path=/";
}
function getCookie(name) {
	var search = name + '=';
	if (document.cookie.length > 0) {
		offset = document.cookie.indexOf(search);
		if (offset != -1) {
			offset += search.length;
			end = document.cookie.indexOf(';', offset);
			if (end == -1) {end = document.cookie.length;}
			return unescape(document.cookie.substring(offset, end));
		} else { return '';}
	} else { return ''; }
}
function deleteCookie(name) {
	if (getCookie(name)) { document.cookie = name + "=; path=/; expires=Thu, 01-Jan-70 00:00:01 GMT"; }
}

function do_bookmark() {
	var agt=navigator.userAgent.toLowerCase();
	var major = parseInt(navigator.appVersion);
	if ( ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1)) && (major >= 4) ) {
		window.external.AddFavorite(window.top.document.location, window.top.document.title);
	} else {
		alert("Na pridanie stránky k obľúbeným stlačte Ctrl+D.");
	}
}
function do_send(lnk) {
//	url = document.location.toString().replace("index.php", "content.php");
	url = "content.php?go=" + lnk;
	if (url.indexOf("?") == -1) { url = url+"?action=send"; } else { url = url+"&action=send"; }
	_open(url, "SiteLabSendPage", "375", "275");
}
function do_print(lnk) {
//	url = document.location.toString().replace("index.php", "content.php");
	url = "content.php?go=" + lnk;
	if (url.indexOf("?") == -1) { url = url+"?action=print"; } else { url = url+"&action=print"; }
	_open(url, "_blank", "640", "480");
}

function _open(wURL, wName, wWidth, wHeight) {
	return window.open(wURL, wName, "width="+wWidth+",height="+wHeight+",top="+((screen.availHeight-wHeight)/2)+",left="+((screen.availWidth-wWidth)/2)+"");
}

var isIE = document.all?true:false;
var isNS = document.layers?true:false;
function onlyInteger(myfield,e) {
	var _ret = true;
	if (isIE) {
		if ((window.event.keyCode < 48 || window.event.keyCode > 57) && window.event.keyCode != 45) { window.event.keyCode = 0; _ret = false; }
		if (window.event.keyCode == 45) { if (myfield.value.indexOf("-") != -1) { window.event.keyCode = 0; _ret = false; } }
	}
	if (isNS) {
		if ((e.which < 48 || e.which > 57) && e.which != 45) { e.which = 0; _ret = false; }
		if (e.which == 45) { if (myfield.value.indexOf("-") != -1) { e.which = 0; _ret = false; } }
	}
	return (_ret); 
}
function onlyReal(myfield,e) {
	var _ret = true;
	if (isIE) {
		if ((window.event.keyCode < 48 || window.event.keyCode > 57) && window.event.keyCode != 46 && window.event.keyCode != 44) { window.event.keyCode = 0; _ret = false; }
		if (window.event.keyCode == 44) { window.event.keyCode = 46; }
		if (window.event.keyCode == 46) { if (myfield.value.indexOf(".") != -1) { window.event.keyCode = 0; _ret = false; } }
	}
	if (isNS) {
		if ((e.which < 48 || e.which > 57) && e.which != 46 && e.which != 44) { e.which = 0; _ret = false; }
		if (e.which == 44) { e.which = 46; }
		if (e.which == 46) { if (myfield.value.indexOf(".") != -1) { e.which = 0; _ret = false; } }
	}
	return (_ret); 
}

function onlyChars(myfield,e,def_only,def_chrs) {
	if (def_only) { var _ret = false; } else { var _ret = true; }
	if (isIE) { keyCode = window.event.keyCode; }
	if (isNS) { keyCode = e.which; }
	for (i=0; i<=def_chrs.length; i++) {
		if (def_only) {
			if (String.fromCharCode(keyCode) == def_chrs.substr(i,1)) { _ret = true; }
		} else {
			if (String.fromCharCode(keyCode) == def_chrs.substr(i,1)) { _ret = false; }
		}
	}
	if (isIE) { if (!_ret) { window.event.keyCode = 0; } }
	if (isNS) { if (!_ret) { e.which = 0; } }
	return (_ret); 
}

function formatNum(expr,decplaces) {
	var str = (Math.round(parseFloat(expr) * Math.pow(10,decplaces))).toString();
	while (str.length <= decplaces) { str = "0" + str; }
	var decpoint = str.length - decplaces;
	return str.substring(0,decpoint) + "." + str.substring(decpoint,str.length);
}