
function inputLen(obj, maxlen) {
	if(!maxlen) { maxlen = 255 }
	if (obj.value.length>maxlen)
	{
		obj.value = obj.value.substring(0,maxlen)
	}
	window.status = 'Napsáno '+obj.value.length+' znaků z '+maxlen;
}

function ok() {
	return confirm("Opravdu provést?")
}
function del() {
	return confirm("Opravdu smazat?")
}
function setCook(key, val, domain) {
	if (!val) { val = "" }
	if (domain==undefined) { domain = 'libimseti.cz' }
	var txt = key+"="+val+";expires=Thu, 1-Jan-2050 00:00:00 GMT; path=/;"
	if (domain) { txt += "domain="+domain+";"; }
	document.cookie = txt;
	return true;
}
function fetchUrl(url, id, callback, charset) {
	// callback si musi resit vysledny JS sam! Opera ho nezvlada
	//if (!id) { id = 'ajax' }
	var oScript = document.getElementById(id);
	var head = document.getElementsByTagName("head")[0];
	if (oScript) { head.removeChild(oScript); }

	var oScript = document.createElement("script");
	//alert('id'+id)
	if (id && id != '' && id != undefined) {
		oScript.id  = id;
	}
	oScript.type = 'text/javascript';
	if (charset) {
		oScript.charset=charset;
	}
	oScript.src = url;
	head.appendChild(oScript);

	if (callback) {
		/* pouze IE a FF !!! */
		oScript.onreadystatechange = function () {
			//alert(oScript.readyState)
			if (oScript.readyState == 'complete') {
	        		//alert('JS onreadystate fired');
				callback();
			}
		}
		oScript.onload = function () {
			//alert('JS onload fired');
			callback();
		}
	}
	return false;
}
function addEvent(obj, evType, fn) {
        if (obj.addEventListener)
        {
                obj.addEventListener(evType, fn, false);
                return true;
        }
        else if (obj.attachEvent)
        {
                var r = obj.attachEvent("on"+evType, fn);
                return r;
        }
        return false;
}
function cancelBubble(e) {
	if (!e) { e = event; }
	e.cancelBubble = true;
	e.cancel = true;
	if (e.stopPropagation) { e.stopPropagation() };
	e.returnValue  = false;
}
function radio( uid )
{
	window.open( 'http://radio2.libimseti.cz/radio_sekce/?uid='+uid,'Libimseti_radio_HP','width=622,height=585,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no');
}
var lastSearchObj = '';
function searchSwitch( obj, m, txt ) {
	if (!lastSearchObj) { lastSearchObj=document.getElementById('searchDefault') }
	if (lastSearchObj == obj) { return }
	obj.className = 'cyan';
	if (lastSearchObj) { lastSearchObj.className = '' }
	lastSearchObj = obj;
	document.getElementById('search-submit').value = txt;
	document.getElementById("sform").m.value = m;
	document.getElementById("search-arrow").style.left = (obj.offsetLeft + (obj.offsetWidth/2) - 5) + 'px';
}
