function getHTTPObject() {



  var xmlhttp;



      if (window.XMLHttpRequest) { // Mozilla, Safari,...

         xmlhttp = new XMLHttpRequest();

         if (xmlhttp.overrideMimeType) {

         	// set type accordingly to anticipated content type

            //http_request.overrideMimeType('text/xml');

            xmlhttp.overrideMimeType('text/html');

         }

      } else if (window.ActiveXObject) { // IE

         try {

            xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");

         } catch (e) {

            try {

               xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");

            } catch (e) {}

         }

      }

      if (!xmlhttp) {

         alert('Cannot create XMLHTTP instance');

         xmlhttp = false;

      }

	  return xmlhttp;

	  

 

 

 

 

}

//inicia

var httpReceiveData = getHTTPObject();





var httpReceiveData = getHTTPObject();



function executarAjax(result, strCommand, opr, tipo ) {

  if( !strCommand ) {

    alert( "Error: Você não passou o parâmetro para a função." );

    return false;

  }

  

  if( opr=="del" ) {

	  

       if (confirm("Tem certeza que deseja excluir "+tipo+"?")){

          httpReceiveData.open( "GET", strCommand, true );  

		  

		  httpReceiveData.onreadystatechange = function() {

              if( httpReceiveData.readyState == 4 ) {

                 window.document.getElementById( result ).innerHTML = httpReceiveData.responseText;

              }

          }

		  

          httpReceiveData.send( null );

		  

       }else{

	      return false;

       }

	      

  }else{

  

   httpReceiveData.open( "GET", strCommand, true );

     httpReceiveData.onreadystatechange = stateChanged;

  }



  

  

  function stateChanged() 

{ 

     if(httpReceiveData.readyState == 1) { // Quando estiver carregando, exibe: carregando... 

        window.document.getElementById( result ).innerHTML = '<div class="carregando" align="center"><img src="loadAjaxBarra.gif"></div><br><br><br>'; 

     } 

	 

	



     

		   if(httpReceiveData.status == 200){

              window.document.getElementById( result ).innerHTML = httpReceiveData.responseText;

		 

           }

	



}

 httpReceiveData.send( null );

  

}



 function makePOSTRequest(resultt,url,parameters) {

	 

	   http_request = false;

      if (window.XMLHttpRequest) { // Mozilla, Safari,...

         http_request = new XMLHttpRequest();

         if (http_request.overrideMimeType) {

         	// set type accordingly to anticipated content type

            //http_request.overrideMimeType('text/xml');

            http_request.overrideMimeType('text/html');

         }

      } else if (window.ActiveXObject) { // IE

         try {

            http_request = new ActiveXObject("Msxml2.XMLHTTP");

         } catch (e) {

            try {

               http_request = new ActiveXObject("Microsoft.XMLHTTP");

            } catch (e) {}

         }

      }

      if (!http_request) {

         alert('Cannot create XMLHTTP instance');

         return false;

      }

	  

	  

	  

	  



	  

	  

	  

	  

	        http_request.open('POST', url, true);

			 

			

			  http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");

			       http_request.setRequestHeader("Content-type", "text/html; charset=ISO-8859-1");

   http_request.setRequestHeader("Cache-Control", "no-cache")

    http_request.setRequestHeader("Content-length", parameters.length);

    http_request.setRequestHeader("Connection", "close");



	       http_request.onreadystatechange = stateChanged;

    http_request.send(parameters);

   

		

   

	  

	

		

	  function stateChanged() 

  { 

     if(http_request.readyState == 1) { // Quando estiver carregando, exibe: carregando... 

        window.document.getElementById( resultt ).innerHTML = '<br><br><div class="carregando" align="center"><img src="loadAjaxBarra.gif"></div><br><br>'; 

     } 



      if(http_request.readyState == 4   ) {

        window.document.getElementById( resultt ).innerHTML = http_request.responseText;

		 

     }

       



  }

}

   

   

   function get5(obj,div,action) {

	

	 var poststr = "";

	 

             for (var i=0;i<obj.length;i++){

				

			         poststr += obj.elements[i].name +"="+ encodeURI(obj.elements[i].value) + "&";

				  

			 }

					

	  makePOSTRequest(div,action, poststr);

}



function executarAgenda(result, strCommand, opr) {

  if( !strCommand ) {

    alert( "Error: Você não passou o parâmetro para a função." );

    return false;

  }

  

  

    httpReceiveData.open( "GET", strCommand, true );

     httpReceiveData.onreadystatechange = stateChanged;

   httpReceiveData.send( null );

  

  

  function stateChanged() 

{ 

     if(httpReceiveData.readyState == 1) { // Quando estiver carregando, exibe: carregando... 

        window.document.getElementById( result ).innerHTML = '<br><br><div class="carregando" align="center"><img src="loadAjaxBarra.gif"></div><br><br>'; 

     } 



      if( httpReceiveData.readyState == 4   ) {

        window.document.getElementById( result ).innerHTML = httpReceiveData.responseText;

		 

     }

       



}



}

