function Inint_AJAX() {
   
   try { return new ActiveXObject("Msxml2.XMLHTTP");  } catch(e) {} //IE
   try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) {} //IE
   try { return new XMLHttpRequest(); } catch(e) {} //Native Javascript
   alert("XMLHttpRequest not supported");
   return null;
};

function oncontent(obj){
	
	setStatus (obj);
	
 	var xmlhttp=Inint_AJAX();
    xmlhttp.onreadystatechange = function () { 
          if (xmlhttp.readyState==4) {
               if (xmlhttp.status==200) {
                    document.getElementById(obj).innerHTML=xmlhttp.responseText;
               } 
          }
     };
     xmlhttp.open("GET", "security/login/includes/home_forgot.php");
     xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=iso-8859-1");
     xmlhttp.send(null); //send value
	
}

function sendforgot(subobj) {

	var fuser=document.getElementById('forgot_user').value;
	var fmail=document.getElementById('forgot_email').value;

	if(fuser==""){
		alert("O campo \"Usuário(ID)\" precisa ser preenchido");
		document.getElementById('forgot_user').focus();
		return false;
	} else if (fmail==""){
		alert("O campo \"E-mail\" precisa ser preenchido");
		document.getElementById('forgot_email').focus(); 
		return false;
	} else if(fmail.indexOf('@')==-1 || fmail.indexOf('.')==-1 ) {
		alert("O campo \"E-mail\" precisa ser preenchido corretamente");
		document.getElementById('forgot_email').focus(); 
		return false; 
	}

	setStatus (subobj);

	var params;
	params = "userid="+fuser;
	params+= "&usermail="+fmail;

 	var xmlhttp=Inint_AJAX();
    xmlhttp.onreadystatechange = function () { 
          if (xmlhttp.readyState==4) {
               if (xmlhttp.status==200) {        
					document.getElementById(subobj).innerHTML=xmlhttp.responseText;
               } 
          }
     };
     xmlhttp.open("POST", "security/login/includes/send_forgot.php", true);
     xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
     xmlhttp.send(params); //send value
}
