/** odeslání XMLHttp požadavku
@param function obsluha funkce zajišťující obsluhu při změně stavu požadavku, dostane parametr s XMLHttp objektem
@param string method GET|POST|...
@param string url URL požadavku
@param string [content] tělo zprávy
@param array [headers] pole předaných hlaviček ve tvaru { 'hlavička': 'obsah' }
@return bool true v případě úspěchu, false jinak
*/
function send_xmlhttprequest(obsluha, method, url, content, headers, handlerParameterArray) {
//	var xmlhttp = (window.XMLHttpRequest ? new XMLHttpRequest : (window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : false));
//	var xmlhttp = (window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : (window.XMLHttpRequest ? new XMLHttpRequest : false));
	var xmlhttp = ajaxRequestObject();
	if (!xmlhttp) {
		return false;
	}
	xmlhttp.open(method, url);
	xmlhttp.onreadystatechange = function() {
		if (handlerParameterArray) {
			obsluha(xmlhttp, handlerParameterArray);
		} else {
			obsluha(xmlhttp);
		}
	};
	if (headers) {
		for (var key in headers) {
			xmlhttp.setRequestHeader(key, headers[key]);
		}
	}
	if (method=='GET') {
		xmlhttp.setRequestHeader("Content-type", "text/xml");
		xmlhttp.send();
	}
	if (method=='POST') {
		//Send the proper header information along with the request
		http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		http.setRequestHeader("Content-length", content.length);
		http.setRequestHeader("Connection", "close");		
		xmlhttp.send(content);
	}
	return true;
}

function ajaxRequestObject(){
 var activexmodes=["Msxml2.XMLHTTP", "Microsoft.XMLHTTP"] //activeX versions to check for in IE
 if (window.ActiveXObject){ //Test for support for ActiveXObject in IE first (as XMLHttpRequest in IE7 is broken)
  for (var i=0; i<activexmodes.length; i++){
   try{
    return new ActiveXObject(activexmodes[i])
   }
   catch(e){
    //suppress error
   }
  }
 }
 else if (window.XMLHttpRequest) // if Mozilla, Safari etc
  return new XMLHttpRequest()
 else
  return false
}
