// JavaScript Document
var myDiv;
var xmlHttpA = createXmlHttpRequestObject();
function createXmlHttpRequestObject(){
	var xmlHttpA;
	try{
		xmlHttpA = new XMLHttpRequest();
	}catch(e){
		var XmlHttpVersions = new Array("MSXML2.XMLHTTP.6.0",
									   "MSXML2.XMLHTTP.5.0",
									   "MSXML2.XMLHTTP.4.0",
									   "MSXML2.XMLHTTP.3.0",
									   "MSXML2.XMLHTTP",
									   "Microsoft.XMLHTTP");
		for(var i=0; i<XmlHttpVersions.length && !xmlHttpA; i++){
			try{
				xmlHttpA = new ActiveXObject(XmlHttpVersions[i]);
			}catch(e){
			}
		}
	}
	if(!xmlHttpA){
		alert('Error1');
	}else{
		return xmlHttpA;
	}
}
function processPocasi(domena){
	//alert('bbb'+domena);
	myDiv = document.getElementById('pocasicko');
	//alert('ds');
	if(xmlHttpA){
		//alert('xxxx');
		try{
			xmlHttpA.open('POST','http://'+domena+'/POCASI/pocasi.php', true);
			xmlHttpA.setRequestHeader('Content-type','application/x-www-form-urlencoded'); 
			xmlHttpA.send(null);
			xmlHttpA.onreadystatechange = handleRequestStateChangeA;
		}catch(e){
			alert('Cant\'t connect to server: \n'+e.toString());
		}
	}
}
function handleRequestStateChangeA(){	
	//alert('ddd');
	if(xmlHttpA.readyState == 1){
		myDiv.innerHTML = '<br/>Zpracovávám data';
	}else if(xmlHttpA.readyState == 2){
		//myDiv.innerHTML += 'Request status: 2 (loaded)<br/>';
	}else if(xmlHttpA.readyState == 3){
		//myDiv.innerHTML += 'Request status: 3 (interactive)<br/>';
	}else if(xmlHttpA.readyState == 4){
		if(xmlHttpA.status==200){
			try{
				response = xmlHttpA.responseText;
				//myDiv.innerHTML += 'Request status: 4 (complete). Server said : <br/>';
				myDiv.innerHTML = response;
			}catch(e){
				//alert('Error reading the response: '+ e.toString());
			}
		}else{
			//alert('Vyskytla se chyba:\n-------------------------------------\n - Velikost obrazku maximálně 1000px x 1000px \n - Špatný typ souboru, užívejte pouze (".jpg",".gif",".png")\n -----> ( Zkus uložit inzerát bez obrázku )');
		}
	}
}