var xmlHTTP = false;;

function vytvorXMLHttpRequest (url, parametry) {
	
	document.getElementById('obsah').innerHTML = '<div style="margin-top: 130px; height: 201px; float:left; text-align: center; width: 100%;">Načítám data .....</div>';
	
	if (window.ActiveXObject) {
		xmlHTTP = new ActiveXObject("Microsoft.XMLHTTP");
	}
	else if (window.XMLHttpRequest) {
		xmlHTTP = new XMLHttpRequest();
	}
	
	if (!xmlHTTP) {
		alert('Giving up :( Nemohu vytvořit XMLHTTP instanci');
		return false;
    }
    
	xmlHTTP.onreadystatechange = function() { stavObsahu(xmlHTTP); };
	xmlHTTP.open('GET', url, true);
	xmlHTTP.send(null);
}

function stavObsahu(xmlHTTP) {

	if (xmlHTTP.readyState == 4) {
		if (xmlHTTP.status == 200) {
        	document.getElementById('obsah').innerHTML = xmlHTTP.responseText;
        } else {
        	//alert('Byl problém se žádostí.');
		}
	}
}



function vytvorXMLHttpRequestChat (url, parametry) {
	
	//document.getElementById('obsah_chat').innerHTML = '<div style="margin-top: 130px; height: 201px; float:left; text-align: center; width: 100%;">Načítám data .....</div>';
	
	if (window.ActiveXObject) {
		xmlHTTP = new ActiveXObject("Microsoft.XMLHTTP");
	}
	else if (window.XMLHttpRequest) {
		xmlHTTP = new XMLHttpRequest();
	}
	
	if (!xmlHTTP) {
		alert('Giving up :( Nemohu vytvořit XMLHTTP instanci');
		return false;
    }
    
	xmlHTTP.onreadystatechange = function() { stavObsahuChat(xmlHTTP); };
	xmlHTTP.open('GET', url, true);
	xmlHTTP.send(null);
}

function stavObsahuChat(xmlHTTP) {

	if (xmlHTTP.readyState == 4) {
		if (xmlHTTP.status == 200) {
        	document.getElementById('obsah_chat').innerHTML = xmlHTTP.responseText;
        } else {
        	//alert('Byl problém se žádostí.');
		}
	}
}

function vytvorXMLHttpRequestPrihlaseni (url, parametry) {
	
	//document.getElementById('obsah_chat').innerHTML = '<div style="margin-top: 130px; height: 201px; float:left; text-align: center; width: 100%;">Načítám data .....</div>';
	
	if (window.ActiveXObject) {
		xmlHTTP = new ActiveXObject("Microsoft.XMLHTTP");
	}
	else if (window.XMLHttpRequest) {
		xmlHTTP = new XMLHttpRequest();
	}
	
	if (!xmlHTTP) {
		alert('Giving up :( Nemohu vytvořit XMLHTTP instanci');
		return false;
    }
    
	xmlHTTP.onreadystatechange = function() { stavObsahuPrihlaseni(xmlHTTP); };
	xmlHTTP.open('GET', url, true);
	xmlHTTP.send(null);
}

function stavObsahuPrihlaseni(xmlHTTP) {

	if (xmlHTTP.readyState == 4) {
		if (xmlHTTP.status == 200) {
        	document.getElementById('leva_seznam_prihlasenych').innerHTML = xmlHTTP.responseText;
        } else {
        	//alert('Byl problém se žádostí.');
		}
	}
}




function nacist_calendar (url, parametry) {
	//document.getElementById('calendar').innerHTML = 'Loading, please wait.';
		
	var http_zadost = false;
	if (window.XMLHttpRequest) { // Mozilla, Safari, Opera, Konqueror...
		http_zadost = new XMLHttpRequest();
		if (http_zadost.overrideMimeType) {
		    http_zadost.overrideMimeType('text/xml');
		}
		    } else if (window.ActiveXObject) { // Internet Explorer
		        try {
		           http_zadost = new ActiveXObject("Msxml2.XMLHTTP");
		        } catch (e) {
		            try {
		                http_zadost = new ActiveXObject("Microsoft.XMLHTTP");
		           } catch (e) {}
		        }
		    }
		    if (!http_zadost) {
		        alert('Error with XMLHTTP instance. Please upgrade your browser. Error code: #02');
		        return false;
		    }
		    http_zadost.open('GET', url, true);
	        http_zadost.onreadystatechange = function() {
	      	if (http_zadost.readyState == 4) {
			        		
	        if (http_zadost.status == 200) {
	         	document.getElementById('kalendar_obal').innerHTML = http_zadost.responseText;
	         	//alert(http_zadost.responseText);
	        } else {
	           	/*Problem se zadosti*/
	            alert('Error with XMLHTTP instance. Please upgrade your browser. Error code: #01');
	        }
	    }
	}
	http_zadost.send(null);
	
	return false;
} 
