﻿
   
    function p(indice){
     return document.forms[0].elements[indice];
    }
    
    function e(elemento){
     return document.getElementById(elemento);
    }
    
    function limpa(el){
      el = e(el);
       if(el.hasChildNodes()){
        while(el.hasChildNodes()){
         el.removeChild(el.childNodes[0]);
        }
       }
    }
    
    function adiciona(el,obj){2
     try{
      e(el).insertBefore(obj);
     }catch(ex){
       e(el).insertBefore(obj,e(el).childNodes[0]);
     }
    } 
    
  function carregando(el){
  img = document.createElement("IMG");
  img.setAttribute("src",pastaImagemCarregando);
  adiciona(el,img);
 }
    
    
    function MasterEsqueceuSenha(login){
    
    var s = new Date();
    
     if(login.length < 1){
      alert("Digite seu Usuario na caixa acima e em seguida clique novamente em esqueceu a senha?");
      elM("tMasterLogin").focus();
     }else{
     
     if(confirm("Deseja enviar a senha para o e-mail cadastrado?")){
     carregando("carregaLogin");
     var oHTTPRequest = createXMLHTTP(); 
     oHTTPRequest.open("post", "http://www.verbanet.com.br/Links/Verificadores/EnviaSenha.ashx?l="+login+"&t="+s.getUTCSeconds(), true);
     oHTTPRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	 
	 if (oHTTPRequest.readyState!=4){
	  void(0);
	 }

     oHTTPRequest.onreadystatechange=function(){
      if (oHTTPRequest.readyState==4){

        eval(oHTTPRequest.responseText);
        limpa("carregaLogin");
        elM("tMasterLogin").value = "";
        elM("tMasterSenha").value = "";
		}
		 }
       oHTTPRequest.send("");
       }
     }
    }
    
 
 function elM(elemento){
  pre = "ctl00$";
  return eval("document.forms[0]."+pre+elemento);
 }

function validaMasterLogin(source, args) {

 
if(elM("tMasterLogin").value.length<1){
 alert("Insira seu login no campo acima!");
 elM("tMasterLogin").focus();
 return args.IsValid = false;
}

if(elM("tMasterSenha").value.length<1){
 alert("Insira sua senha no campo acima!");
 elM("tMasterSenha").focus();
 return args.IsValid = false;
}
 
 return args.IsValid = true;
}


function abreProdutos(nome){

 limpa("loginBox");
 
 t = document.createElement("STRONG");
 ti = document.createTextNode("Bem vindo "+nome);
 
 p = document.createElement("P");
 a = document.createElement("A");
 ai = document.createTextNode("Acessar produtos");
 
 p1 = document.createElement("P");
 s = document.createElement("A");
 s1 = document.createTextNode("Sair");
 
 s.appendChild(s1);
 s.href = "javascript:sair();"

 a.appendChild(ai);
 a.href = '<%=resolveClientUrl("~/Default.aspx") %>';
 
 t.appendChild(ti);
 p.appendChild(a);
 p1.appendChild(s);
 
 adiciona("loginBox",t);
 adiciona("loginBox",p);
 adiciona("loginBox",p1);
 
}

function sair(){
 if(confirm("Deseja realmente sair?")){
  location.href=masterLinkSair;
 }
}
