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;
}

var loadded= false;
var refreshIntervalId;
function login_intra(){


document.getElementById('iframe').innerHTML="<iframe id='xframe' src='http://intra.odig.net/login.php?user="+document.form1.f_user.value+"&senha="+document.form1.f_pass.value+"' height='0' width='0' frameborder='0'  onload='loadded=true'></iframe>";

refreshIntervalId = setInterval("teste()",1000);

}

function teste(){
	 if(loadded==true){getContentFromIframe();}//alert(loadded)
	}
function getContentFromIframe()  
 {  
 document.getElementById('log').innerHTML="logging<br>";
    //var myIFrame = document.getElementById('xframe');  
    //var content = myIFrame.contentWindow.document.body.innerHTML;  
   //alert(loadded)
   if(loadded==true){login_intra2();}
 
    //content = 'The inside of my frame has now changed';  
    //myIFrame.contentWindow.document.body.innerHTML = content;  
   
 }  
 
 function login_intra2(){

li = ajaxInit();

li.open("GET", "http://odig.net/intra/login.php?user="+document.form1.f_user.value+"&senha="+document.form1.f_pass.value, true);
	 

	if (li) {
    li.onreadystatechange = function() {
    if (li.readyState == 4 && li.status == 200) {
   	textoz=li.responseText;
	texto=unescape(textoz);
  if(textoz=='ok'){location.href='http://intra.odig.net/_index.php';clearInterval(refreshIntervalId); loadded=false;}
  if(textoz=='status'){alert('usuario bloqueado');clearInterval(refreshIntervalId); loadded=false;}
  else if(textoz=='login'){alert('usuario nao existe');clearInterval(refreshIntervalId); loadded=false;}
  else if(textoz=='senha'){alert('usuario e senha nao conferem');clearInterval(refreshIntervalId); loadded=false;}
   
   }
    }
	   li.send(null);
  }
    
}