function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
			window.onload = func;
	} else {
		window.onload = function() {
			if (oldonload) {
				oldonload();
			}
			func();
		}
	}
}
	
function createXHR(){
	if (typeof XMLHttpRequest != "undefined"){
		return new XMLHttpRequest();
	} else if (typeof ActiveXObject != "undefined"){
		if (typeof arguments.callee.activeXString != "string"){
			var versions = ["MSXML2.XMLHttp.6.0", "MSXML2.XMLHttp.3.0","MSXML2.XMLHttp"];
			for (var i=0,len=versions.length; i < len; i++){
				try {
					var xhr = new ActiveXObject(versions[i]);
					arguments.callee.activeXString = versions[i];
					return xhr;
				} catch (ex){
					// přeskoč
				}
			}
		}
		return new ActiveXObject(arguments.callee.activeXString);
		} else {
			throw new Error("Nepodporovaný prohlížeč Internetu.");
		}
	}

function trim(stringValue)
{
	return stringValue.replace(/(^\s*|\s*$)/g, "");
}

function unixTime(){
	return Math.round(((new Date()).getTime()-Date.UTC(1970,0,1))/1000);
}        

function getXHR(soubor){
	var xhr = createXHR();
	xhr.open("get", soubor + "?" + unixTime(), false);
	xhr.send(null);
	if ((xhr.status >= 200 && xhr.status < 300) || xhr.status == 304){
		return xhr.responseText;
    } else return false;
}

function getXHR2(soubor){
	var xhr = createXHR();
	xhr.open("get", soubor + "&" + unixTime(), false);
	xhr.send(null);
	if ((xhr.status >= 200 && xhr.status < 300) || xhr.status == 304){
		return xhr.responseText;
    } else return false;
}



function fbConnect(id) {
	var e = document.createElement('script');
	e.src = document.location.protocol + '//connect.facebook.net/cs_CZ/all.js';
	e.async = true;
	document.getElementById(id).appendChild(e);
};


function LogLikeEvent(id,fbuser) {
	getXHR2("/scripts/fblikecount.php?likeid=" + id + "&fbuser=" + fbuser);
			
}



function ReloadCaptcha(){
	var xhrstring=getXHR('/captcha.php');
	var xhrdata="var data=new Array(" + xhrstring + ");";
	eval(xhrdata);
	var Hcaptcha=document.getElementById('captchaimg');
	var Htoken=document.getElementById('token');
	Hcaptcha.setAttribute('src',data[0]);
	Htoken.setAttribute('value',data[1]);
}

function openLiMenu(id){
	var item=document.getElementById("li" + id);
	if(item.getAttribute("class")=='lisubhid'){
		item.setAttribute("class", "lisubopen");
	} else {
		item.setAttribute("class", "lisubhid");
	}
		
		
	
}

