/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
/******************************************************************
* This is the ajaxform.js.
*
* LoadPageAjax	for load page
* ajaxForm		for load form and values
*
* @access		public
* @programer 	MARCELO MOSCOSO [clonixb@msn.com]
* @version		1.0
*/
function _getHTTPObject(){
	var objetoAjax=false;
	  try {
	   /*for browsers distinc a internet explorer*/
	   objetoAjax = new ActiveXObject("Msxml2.XMLHTTP");
	  } catch (e) {
	   try {
	     /*for explorer*/
	     objetoAjax = new ActiveXObject("Microsoft.XMLHTTP");
	     } 
	     catch (E) {
	     objetoAjax = false;
	   }
	  }
	
	  if (!objetoAjax && typeof XMLHttpRequest!='undefined') {
	   objetoAjax = new XMLHttpRequest();
	  }
	  return objetoAjax;
}

function loadPageAjax(url,div){
	var http_ajax = _getHTTPObject();
	_updatediv = div;
	
	http_ajax.open("GET",url);
	//http.onreadystatechange = handleHttpResponse;
	
	http_ajax.onreadystatechange = function (){
			if (http_ajax.readyState == 4)
				document.getElementById(_updatediv).innerHTML = http_ajax.responseText;
			else
				document.getElementById(_updatediv).innerHTML = "<img src='imagenes/loading.gif' align='absmiddle'>";
	}
	
	http_ajax.send(null);
}



function ajaxForm(url,div,values,metod){
	var http_ajax = _getHTTPObject();
	_updatediv = div;
	
	http_ajax.open("POST",url);
	
	http_ajax.onreadystatechange = function (){
			if (http_ajax.readyState == 4)
				document.getElementById(_updatediv).innerHTML = http_ajax.responseText;
			else
				document.getElementById(_updatediv).innerHTML = "<img src='imagenes/loading.gif' align='absmiddle'>";
	}
	
	http_ajax.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	http_ajax.send(values);
	return;
}

function ajaxAlert()
{
    alert('ajax');
}


