function ajaxInit(){
	var req;
	try {
		req = new ActiveXObject("Microsoft.XMLHTTP");
	} catch(e) {
  		try {
    		req = new ActiveXObject("Msxml2.XMLHTTP");
  		} catch(ex) {
    		try {
      			req = new XMLHttpRequest();
    		} catch(exc) {
      			alert("Esse browser não tem recursos para uso do Ajax");
      			req = null;
    		}
  		}
	}
	return req;
}
function carrega(url,alvo){
   	ajax = ajaxInit();
	ajax.onreadystatechange = function(){
		document.getElementById(alvo).innerHTML="<br /><br /><br /><br /><br /><br /><br /><br /><p align='center' style='color:#000'>Carregando...</p>";
		if (ajax.readyState == 4) {
			if (ajax.status == 200) {
				document.getElementById(alvo).innerHTML=ajax.responseText;
			} else {
				alert("Error: "+ajax.responseText);
			}
		}
	}
	ajax.open("GET", url, true);
	ajax.send(null);
}
function AjaxPost(url,o_form) {
	ajax = ajaxInit();
	ajax.onreadystatechange = procesResp;
	ajax.open("POST", url, true);
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	ajax.send(criaSTR(o_form));
}
function procesResp() {
  if (ajax.readyState == 4) {
    if (ajax.status == 200) {
		var to_alert, to_div=false;
    	eval(ajax.responseText);
		if(to_alert) alert(to_alert);
		if(to_div) document.getElementById('col_dir').innerHTML=to_div;
    } else {
        alert("Desculpe, erro:\n"+ajax.responseText);
	}
  }
}
function criaSTR(qual_form){
   var indCampo=0;
   var strPost="";
   var tipoCampo;
   var obj = eval('document.'+qual_form+'.elements');
   while(obj[indCampo]){
	  tipoCampo=obj[indCampo].type;
	  checkado=obj[indCampo].checked;
	  if(tipoCampo!="reset" && tipoCampo!="submit" && tipoCampo!="button"){
		 if(tipoCampo!="radio")
			strPost=strPost+obj[indCampo].name+"="+obj[indCampo].value+"&";
		 else
			if(checkado)
			   strPost=strPost+obj[indCampo].name+"="+obj[indCampo].value+"&";
	  }
	  indCampo++;
   }
   return strPost+"null";
}