function closeWindow(winId) {
	document.getElementById('topWindow').className = "old";
	return false;
}

/**
*	Obecna funkce, ktera nahraje obsah do noveho AJAX okna
*/
function newAjaxWindow(url, loadInto, docTitle) {
	// odeslání požadavku na aktualizaci dat 
	if (!loadIntoAjaxWindow(setAjaxWindowContent, 'GET', url, loadInto, docTitle)) { 
		return false; 
	}
	
	return false;
}

function setDirectAjaxWindowContent(sourceId, loadInto, docTitle) {
	document.body.style.cursor = 'default';

	var txtContent = document.getElementById(sourceId).innerHTML;
	document.getElementById('topWindow').className = "win";
	document.getElementById(loadInto).innerHTML = txtContent;		
	document.getElementById(loadInto+'Title').innerHTML = docTitle;		
}

function loadIntoAjaxWindow(obsluha, method, docUrl, loadInto, docTitle) {
	var xmlhttp = (window.XMLHttpRequest ? new XMLHttpRequest : (window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : false));
	if (!xmlhttp) { 
		return false; 
	} 
	
	document.body.style.cursor = 'wait';

	xmlhttp.open(method, docUrl); 
	xmlhttp.onreadystatechange = function() {
		obsluha(xmlhttp, loadInto, docTitle);
	}; 

	xmlhttp.send(''); 
	return true; 
}

/**
*	Obecna funkce obsluhujici vetsinu navratu xmlHttpRequest pozadavku, ulozi responseText do pozadovaneho ID
*/
function setAjaxWindowContent(xmlhttp, loadInto, docTitle) {
	if (xmlhttp.readyState == 4) {			
		document.body.style.cursor = 'default';

		var txtContent = xmlhttp.responseText;
		document.getElementById('topWindow').className = "win";
		document.getElementById(loadInto).innerHTML = txtContent;		
		document.getElementById(loadInto+'Title').innerHTML = docTitle;		

		var matchScript = txtContent.match(/<script>([^<]*)/gim);
		if (matchScript != null) {
			for (var scrNum=0;scrNum<matchScript.length;scrNum++) {
				createScript(matchScript[scrNum].slice(8));
			}
		}
	}
}


/*
	Funkce, ktera zobrazi preloader s hlaskou o chvili strpeni
*/
function showFrontendPreloader() {
	// nastaveni hlaseni nacita se
	var preload = document.getElementById('loader');
	if (preload == null || preload == "undefined") {
		return false;
	}
	showFrontendAlpha();
	preload.className = null;		
	preload.style.top = (xClientHeight() / 2) - 75 + xScrollTop() + 'px';
	preload.style.left = (xClientWidth() / 2) - 250 + xScrollLeft() + 'px';
}

/*
	Funkce skryje zobrazeny preloader
*/
function hideFrontendPreloader() {
	// zruseni hlasky, ze se neco nacita
	var preload = document.getElementById('loader');
	if (preload == null || preload == "undefined") {
		return false;
	}
	hideFrontendAlpha();
	preload.className = "old";	
}

/*
	Funkce, ktera zobrazi preloader s hlaskou o chvili strpeni
*/
function showFrontendAlpha() {
	// nastaveni hlaseni nacita se
	var bgElem = document.getElementById('bkgAlphaLoad');
	bgElem.style.height = (xClientHeight() + xScrollTop()) + 'px';

	if (bgElem != null)	{
		if (OPERA || NS) {
			bgElem.className = "loadAlphaO";
		} else {
			bgElem.className = "loadAlphaIE";
		}
	}

	if (IE) {
		// na zkousku zkusim pozakryvat vsechny select boxy
		var sbElems = document.getElementsByTagName('select');
		for(var i=0;i<sbElems.length;i++) {
			sbElems[i].style.display = 'none';
		}
	}
}

/*
	Funkce, ktera zobrazi preloader s hlaskou o chvili strpeni
*/
function hideFrontendAlpha() {
	// nastaveni hlaseni nacita se
	var bgElem = document.getElementById('bkgAlphaLoad');
	if (bgElem != null) {	bgElem.className = "old"; }
	
	if (IE) {
		// na zkousku zkusim pozakryvat vsechny select boxy
		var sbElems = document.getElementsByTagName('select');
		for(var i=0;i<sbElems.length;i++) {
			sbElems[i].style.display = '';
		}
	}
}

