
var http = null; 
var inCall = false;

function getObj(name) {
	return document.getElementById(name);
}

function createRequestObject() {
  var reqObj;
  var browser = navigator.appName;
  if(browser == "Microsoft Internet Explorer"){
	reqObj = new ActiveXObject("Microsoft.XMLHTTP");
	isIE = true;
  }else{
	reqObj = new XMLHttpRequest();
  }
  return reqObj;
}

function doCall(whereTo, returnTo,async){
	if (async == null)
		async = false;
  inCall = true;
  http = createRequestObject();
  http.open('get', noCache(whereTo), async);
  
  // DO WE HAVE A FUNCTION TO CALL ONCE CALL IS COMPLETED?
  if(returnTo.length > 0){
	eval("http.onreadystatechange = "+returnTo);
  }
  // SEND CALL
  http.send('1');
}

function noCache(uri)
{
	return uri.concat(/\?/.test(uri)?"&":"?","noCache=",(new Date).getTime(),".",Math.random()*1234567);
}

/*
function salvarCadastro() {
	var params = getFormParameters(getObj('frmcadastro'));
	doCall("cadastro_salvar.php"+params,"trataRetorno",true);
}

function trataRetorno() {
	if (http.readyState == 4) {
		eval(http.responseText);
	}
}
*/ 

