// osetreni spousteni vice skriptu behem onload
function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			if (oldonload) {
				oldonload();
			}
			func();
		}
	}
}

function interactiveMenu() {
	if (document.getElementById("menu").getAttribute("class") == null ) { //resi problem class/className IE < 8
		document.getElementById("menu").setAttribute("className","box");
	} else { //vsechny normalni prohlizece
		document.getElementById("menu").setAttribute("class","box");
	}
}

function getUrlVars()
{
	var vars = [], hash;
	var decodeduri = decodeURI(window.location.href);
	var hashes = decodeduri.slice(window.location.href.indexOf('?') + 1).split('&');

	for(var i = 0; i < hashes.length; i++)
		{
			hash = hashes[i].split('=');
			vars.push(hash[0]);
			vars[hash[0]] = hash[1];
		}
		return vars;
}

function formState() {
	if ( getUrlVars()["typhledani"] == "dleoblasti" )
	{
		document.getElementById("obchz-hledani-oblast").checked = true;
		document.getElementById("obchz-hledani-obec").checked = false;
		document.getElementById("obchz-oblast").disabled = false;
		document.getElementById("obchz-obec").disabled = true;
	}
	else if ( getUrlVars()["typhledani"] == "dleobce" )
	{
		document.getElementById("obchz-hledani-oblast").checked = false;
		document.getElementById("obchz-hledani-obec").checked = true;
		document.getElementById("obchz-oblast").disabled = true;
		document.getElementById("obchz-obec").disabled = false;
	}

	if ( getUrlVars()["oblast"] ) {
		document.getElementById("obchz-oblast").value = getUrlVars()["oblast"].replace(/\+/g," ");
	}
	if ( getUrlVars()["typubyt"] ) {
		document.getElementById("obchz-typ").value = getUrlVars()["typubyt"].replace(/\+/g," ");
	}
	if ( getUrlVars()["obec"] ) {
		document.getElementById("obchz-obec").value = unescape(getUrlVars()["obec"].replace(/\+/g," "));
	}
}

//addLoadEvent(interactiveMenu);
addLoadEvent(formState);

