function makeHTTPRequestObject() {
   var req = null;
   try {
      req = new ActiveXObject("Msxml2.XMLHTTP");
   } catch(e) {
          try {
             req = new ActiveXObject("Microsoft.XMLHTTP");
          } catch(e) { req = null; } }

   if(!req && typeof(XMLHttpRequest) != "undefined") {
       req = new XMLHttpRequest();
   }
   if(!req) return false;
   if(req) { req.onreadystatechange = processReqChange; }
   return req;
}
function getUrl(url) {
    xmlHTTPReq = makeHTTPRequestObject();
    if(xmlHTTPReq) {
    	xmlHTTPReq.open("GET",url+"&cache="+(new Date().getTime()),true);
    	xmlHTTPReq.send(null);
    	return true;
    }
    return false;
}
function processReqChange() {
    if(xmlHTTPReq.readyState == 4) {
       if(xmlHTTPReq.status == 200) {
           var xml = xmlHTTPReq.responseXML.documentElement;
           onData(xml);
       } else if(xmlHTTPReq.documentElement) {
           var xml = xmlHTTPReq;
           onData(xml);
       } else {
           onData(null);
       }
    }
}

function onData(xml) {
     if(xml && xml.getAttribute('handler')) {        var action = xml.getAttribute('handler');

        for(index in eHandlers) {         	if(index == action) {         		if(typeof(eHandlers[index]) == 'function') {         			func = eHandlers[index];
         			func(xml);         		}
         		break;         	}        }     } else {        alert('Error !!!');     }
}

function send(view, action, params) {
    if(typeof(view) != 'string' || typeof(action) != 'string') return;
    var url = "/"+view+"/"+action;

	if(typeof(params) == 'object') {  		for(index in params)
  		  if((index != 'view') && (index != 'action'))
  			url += "/" + params[index];	}
    if(!getUrl(url)) return false;
    OnSend(view, action);

    return true;
}

function setText(obj,text) {
    var oElem = document.all ? dociment.all[obj] : document.getElementById(obj);
    if(oElem)
       oElem.innerHTML = text;
}



