/***********************************************
* Drop Down/ Overlapping Content- © Dynamic Drive (www.dynamicdrive.com)
* This notice must stay intact for legal use.
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

function getposOffset(overlay, offsettype){
var totaloffset=(offsettype=="left")? overlay.offsetLeft : overlay.offsetTop;
var parentEl=overlay.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}

function overlay(curobj, subobjstr, opt_position, x_posi){
    if(x_posi=="")x_posi = 0;
    if (document.getElementById){
        var subobj=document.getElementById(subobjstr)
        subobj.style.display=(subobj.style.display!="block")? "block" : "none"
        var xpos=getposOffset(curobj, "left")+((typeof opt_position!="undefined" && opt_position.indexOf("right")!=-1)? -(subobj.offsetWidth-curobj.offsetWidth) : x_posi) 
        //alert(xpos)
        //alert(getposOffset(curobj,"width"))
        //alert(xpos-getposOffset(curobj,"width"))
        //alert(typeof( opt_position));
        if((typeof opt_position!="undefined" && opt_position.indexOf("right")!=-1) && x_posi != null)
           xpos = curobj.offsetLeft;
        xpos = (opt_position!=null && opt_position.indexOf("left")!=-1) ? (xpos-getposOffset(curobj,"width")-50) : xpos;
        var ypos=getposOffset(curobj, "top")+((typeof opt_position!="undefined" && opt_position.indexOf("bottom")!=-1)? curobj.offsetHeight : 0)
        if (isNaN(xpos)){
            xpos = 300;
        }
        subobj.style.left = xpos+"px"
        subobj.style.top = ypos+"px"
        return false;
    }else
        return true
}

function overlayclose(subobj){
 document.getElementById(subobj).style.display="none"
 document.getElementById("malAutenticado").innerHTML="";
 document.getElementById("vLoginForma").innerHTML="";
 document.getElementById("vClaveForma").innerHTML="";
 document.getElementById("password").value="";
 document.getElementById("login").value="";
}

function validarFormaLogin() 
{
   var divErrores = document.getElementById("malAutenticado");
   
   divErrores.innerHTML = "<p>Estamos validando tu información...</p>";
   divErrores.style.background = "#FFFF00";
   document.getElementById("vLoginForma").innerHTML = document.getElementById("vClaveForma").innerHTML = "";
   a = true;
   with(document.formaCajitaLogin) 
   {
     if (document.formaCajitaLogin.login.value == "")
     {
        document.getElementById("vLoginForma").innerHTML = "<p>Por favor, ingresa tu nombre de usuario</p>";
        a = false;
     }
     if (password.value == "") 
     {
        document.getElementById("vClaveForma").innerHTML = "<p>Por favor, ingresa tu clave</p>";
        a = false;
     }
     if (a)
     {
        var persi="";
        if (cookieCajiPersis.checked)
        { 
           persi = cookieCajiPersis.checked; 
        }
        incluirObjeto("AUTENTICAR_USUARIO",login.value,password.value , persi,'malAutenticado');
     }
     else
	 {
		divErrores.innerHTML = "";
		divErrores.style.background = "none";
	 }
   }
}
