
function valida()
{
erro=0;
username=document.getElementById('username');
password=document.getElementById('password');

var erro_txt = new Array(2);
if (username.value=='')
	{
		
	 logonForm.username.focus();
	 username.style.background='#FFCC33';
	alert ('Campo Email é Obrigatório'); 
	erro++;
	}
	
if (password.value=='')
	{
	alert ('Campo Senha é Obrigatório'); 
	 password.style.background='#FFCC66';
	
	erro++;
	 
	}


	
if (erro>0)
{ 
 	return false;
	
}
	else
	{
	username.style.background='#E8FFF3';
	password.style.background='#E8FFF3';
	 window.location.href ='';
	}	
	
}




//Ajusta Layer para Netscape
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);


//Exibe mensagem "Carregando" em um elemento com id =carregando_msg
function ajaxHTML(id,status_tela){

 if (status_tela =='show')
	 {
		//Carregando...
		document.getElementById('carregando_msg').innerHTML="<span style='font-size:9px;font-family:Verdana, Arial, Helvetica,sans-serif;color:#999999;font-weight:700;'>"+
	
	                                        "<img src='images/animated_loading.gif' width='16' height='16' />Carregando...</span>";
	}  
	  if (status_tela =='hide')
	 {
		//Carregando...
		document.getElementById('carregando_msg').innerHTML="";
	}  

}

   
   
  function CriaAjax() 
   {
   
   
     try { 
      req = new ActiveXObject("Msxml2.XMLHTTP"); 
      } 
     catch (e)
      { 
      try 
      { 
       req = new ActiveXObject("Microsoft.XMLHTTP"); 
      } 
      catch (E) 
      { 
       req  = false; 
      } 
     } 
      if  (!req  && typeof  XMLHttpRequest != 'undefined' ) { 
       try  { 
        req = new  XMLHttpRequest(); 
       } catch  (e) { 
        req  = false ; 
       } 
      } 
   
   
      return req;
   }
  

     
     
  

//função ajax para carregar o conteudo de uma url passando um paramentro
function loadXMLDoc(url,valor) 
{
	 
	 req =  CriaAjax();
	
	 
   
	
	req.onreadystatechange = processReqChange;
            req.open("GET", url+'?conteudo='+valor, true);
			req.setRequestHeader("Content-Type", "text/html;");
			//req.setRequestHeader('Cache-Control', 'no-cache');
			req.setRequestHeader("encoding", "utf-8"); 
            req.send(null);
			
}



//processo para exibir o conteudo retornado pelo objeto xhtmrequest
function processReqChange()
{
    // apenas quando o estado for "completado"
	if (req.readyState !=4)
	{
	ajaxHTML('conteudo','show');
	}
    if (req.readyState == 4)
	 {
        // apenas se o servidor retornar "OK"
			if (req.status == 200) 
			{
			ajaxHTML('conteudo','hide');
				// procura pela div id="tela_login_html" e insere o conteudo
				// retornado nela, como texto HTML
				document.getElementById('conteudo').innerHTML = req.responseText;
			} 
		else 
			{
				alert("Houve um problema ao obter os dados:\n" + req.statusText);
			}
			
    }
}




function CarregaPagina(Url_Load,valor)
		{

			loadXMLDoc(Url_Load,valor);
		}


function loadEmail(url,valor,inicio) 
{
 req2 =  CriaAjax();
	
	req2.onreadystatechange =processEmail;
            req2.open("GET", url+'?conteudo='+valor, true);
			req2.setRequestHeader("Content-Type", "text/html;");//
			req2.setRequestHeader("encoding", "utf-8"); 
            req2.send(null);
			
			
}



//processo para exibir o conteudo retornado pelo objeto xhtmrequest
function processEmail()
{
	
    // apenas quando o estado for "completado"
	if (req2.readyState !=4)
	{
	ajaxHTML('conteudo','show');
	}
    if (req2.readyState == 4)
	 {
        // apenas se o servidor retornar "OK"
			if (req2.status == 200) 
			{
			ajaxHTML('conteudo','hide');
				// procura pela div id="tela_login_html" e insere o conteudo
				// retornado nela, como texto HTML
				document.getElementById('LoadEmail').innerHTML = req.responseText;
				document.getElementById('username').focus();
				
				
			} 
		else 
			{
				alert("Houve um problema ao obter os dados:\n" + req2.statusText);
			}
			
    }
}




function CarregaMail(Url_Load,valor)
		{

			loadEmail(Url_Load,valor);
		}
