function startRequest(xUrl, handlerFunction) {

  var xmlhttp = false;

  /*@cc_on @*/

  /*@if (@_jscript_version >= 5)

  // JScript gives us Conditional compilation, we can cope with old IE versions.
  // and security blocked creation of the objects.

  try {
    xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
   } catch (e) {
      try {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (E) {
        xmlhttp = false;
      }
   }

  /*@end @*/

  if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
    xmlhttp = new XMLHttpRequest();
  }

  xmlhttp.open("GET", xUrl,true);
  
  xmlhttp.onreadystatechange=function() {

          if (xmlhttp.readyState==4) {
            if (xmlhttp.status == 200) {
                eval( handlerFunction+"('"+ escape(xmlhttp.responseText) +"');" );
                
            }
            else {
                if ( xmlhttp.status == 404 ) {
                    alert("Página não encontrada.");
                }
                else if ( xmlhttp.status == 12029 ) {
                    alert("Ligação com o servidor perdida.");
                }
                else{
                    alert('There was a problem with the request. Err.: '+ xmlhttp.statusText);
                }
            }
            
          }
  }
  
  xmlhttp.send(null);

}
//*************
function loadXML( htmlCode )
{
    var xmlDoc;
    // code for IE
    if (window.ActiveXObject)
    {
      xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
      xmlDoc.async=false;
      xmlDoc.load( htmlCode );
    }
    // code for Mozilla, Firefox, Opera, etc.
    else if (document.implementation && document.implementation.createDocument)
    {
      xmlDoc=document.implementation.createDocument("","",null);
      xmlDoc.load( htmlCode );
     }
    else
    {
      alert('Your browser cannot handle this script');
    }
    
    return xmlDoc;
}
//***********************
function showWaitScreen(){

  var tbody = document.getElementsByTagName("body")[0];
	var tnode = document.createElement('div');

  var windowHeight = getWindowHeight();
  var startTop = windowHeight/2.5;
  var startLeft = getWindowWidth()/(2.5);

			tnode.style.position='absolute';
			tnode.style.top= startTop+'px';
			tnode.style.left= startLeft+'px';
			//tnode.style.overflow='hidden';
      tnode.style.margin='auto';
      tnode.style.width='150px';
      //tnode.style.height='100px';
			tnode.style.display='block';
      //tnode.style.border='2px outset';
      //tnode.style.background='#FFFFFF';
      tnode.style.filter.opacity="(alpha=60)"; /* para o IE */
      //tnode.style="-moz-opacity:0.6"; /* para o FireFox */
      tnode.style.opacity="0.6";
      
			tnode.id='waitScreenObj';
      tnode.innerHTML = "<div class='xbox-loading'><b class='xtop-loading'><b class='xb1-loading'></b><b class='xb2-loading'></b><b class='xb3-loading'></b><b class='xb4-loading'></b></b><div class='xboxcontent-loading'>"+
                        "<table align='center' style='height:30px;'><tr><td valign='middle'><img id='wait' src='http://"+ window.location.host +"/ACDV2/imgs/ajax-loader.gif' width='16' height='16'></td><td>"+
                        "&nbsp;<font face='verdana' color='#3F73E3' size='1'><b>A processar...</b></font></td></tr></table>"+
                        "</div><b class='xbottom-loading'><b class='xb4-loading'></b><b class='xb3-loading'></b><b class='xb2-loading'></b><b class='xb1-loading'></b></b></div>";
		tbody.appendChild(tnode);

    //para forçar mostrar a imagem
    //setTimeout('document.images["wait"].src = "imgs/rodas.gif"', 200);
    
    return tnode.id;
}

//*********************
function getWindowHeight() {
			var windowHeight = 0;
			if (typeof(window.innerHeight) == 'number') {
				windowHeight = window.innerHeight;
			}
			else {
				if (document.documentElement && document.documentElement.clientHeight) {
					windowHeight = document.documentElement.clientHeight;
				}
				else {
					if (document.body && document.body.clientHeight) {
						windowHeight = document.body.clientHeight;
					}
				}
			}
			return windowHeight;
		}
//**************************
function getWindowWidth() {
			var windowWidth = 0;
			if (typeof(window.innerWidth) == 'number') {
				windowWidth = window.innerWidth;
			}
			else {
				if (document.documentElement && document.documentElement.clientWidth) {
					windowWidth = document.documentElement.clientWidth;
				}
				else {
					if (document.body && document.body.clientWidth) {
						windowWidth = document.body.clientWidth;
					}
				}
			}
			return windowWidth;
		}
//remove waitScreen
function hideWaitScreen( idWaitScreen ){
    document.getElementsByTagName("body")[0].removeChild( document.getElementById( idWaitScreen ) );
}
