﻿function getScrollXY() {
  var scrOfX = 0, scrOfY = 0;
 if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
  
  var newArray = new Array(scrOfX,scrOfY);
  return newArray;
  //return [ scrOfX, scrOfY ];
}

function GetWindowSize() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  
  var newArray = new Array(myWidth,myHeight);
  return newArray;
  //return [ myWidth, myHeight ];
}

function relocatedivwin(width,heigh)
{
    document.getElementById("frame").height = heigh;
    document.getElementById("frame").width = width;   
}

function bloquear()
{
	try
	{
	var ifra=document.getElementById("frame");
	var ancho;
	var alto;
	var top;
	
	document.getElementById("fondoOpaco").style.display = "block";
	document.getElementById("aviso").style.display = "block";		
	document.getElementById("BodyMaster").setAttribute("scroll","yes");	
	    
	ancho=GetWindowSize()[0]-20;	
	alto=GetWindowSize()[1]-15;
	top=getScrollXY()[1] - 10;
	
    ifra.height=alto+"px";
    ifra.width=ancho+"px";
    document.getElementById("aviso").style.top = top+"px"; 
	}
	catch(err)
	{}
}

function bloquearDimencionar(ancho,alto)
{
try
{
	var ifra=document.getElementById("frame");
	var top;
	document.getElementById("fondoOpaco").style.display = "block";
	document.getElementById("aviso").style.display = "block";		
	document.getElementById("BodyMaster").setAttribute("scroll","yes");
	top=getScrollXY()[1] - 10;
    ifra.height=alto+"px";
    ifra.width=ancho+"px";
    document.getElementById("aviso").style.top = top+"px";   
}
catch(err){}
}

function ocultar(){
	document.getElementById("fondoOpaco").style.display = "none";
	document.getElementById("aviso").style.display = "none";
	
	document.getElementById("BodyMaster").style.overflow = "auto";
	document.getElementById("BodyMaster").setAttribute("scroll","yes");
	HideCombos('visible');	
}

   /*Funciones para los globos de ayuda*/
     function getPositionLeft(This){
        var el = This;var pL = 0;
        while(el){pL+=el.offsetLeft;el=el.offsetParent;}
        return pL
        }
        
        function getPositionTop(This){
        var el = This;var pT = 0;
        while(el){pT+=el.offsetTop;el=el.offsetParent;}
        return pT
        }
        
  function mostrarGlobo(nombreControl,anchoControl,textoIlustrar)
        {
            var objFlotante = document.getElementById("divFlotante");
            if(textoIlustrar != "")
            {    
                var isIE = (window.navigator.userAgent.indexOf("MSIE")> 0);  
                if (! isIE){   
                    HTMLElement.prototype.__defineGetter__("innerText",function () { return(this.textContent); });   
                    HTMLElement.prototype.__defineSetter__("innerText",function (txt) { this.textContent = txt; });
                }
            
                var objControlPosicionar = document.getElementById(nombreControl);
                
                var leftPosition = getPositionLeft(objControlPosicionar) + anchoControl;
                var topPosition = getPositionTop(objControlPosicionar);
                
                objFlotante.style.top = topPosition + 'px';
                objFlotante.style.left = leftPosition + 'px';
                document.getElementById("textoInterno").innerText = textoIlustrar;
                objFlotante.style.display = "block";
            }
            else
            {
                hideDivFlotante("divFlotante");
            }
        }
    
    
    
    function hideDivFlotante(nomDiv)
    {
        var isIE = (window.navigator.userAgent.indexOf("MSIE")> 0);  
        if (! isIE){   
            HTMLElement.prototype.__defineGetter__("innerText",function () { return(this.textContent); });   
            HTMLElement.prototype.__defineSetter__("innerText",function (txt) { this.textContent = txt; });
        }
         
        var objDiv = document.getElementById(nomDiv);
        objDiv.style.display = "none";        
    }


function ocultarRequisicion(obj)
{
    
    try
    {
    document.getElementById("fondoOpaco").style.display = "none";
	document.getElementById("aviso").style.display = "none";
	
	document.getElementById("BodyMaster").style.overflow = "auto";
	document.getElementById("BodyMaster").setAttribute("scroll","yes");
	HideCombos('visible');	    	
	
	document.getElementById(obj).focus();
    }
    catch(err)
    {}
}

function cambiarURL(strURL)
{
    window.location.href= strURL;
}

function opendivwin(width,heigh,path)
{    
    try    
    {
        HideCombos('hidden');    
        document.getElementById("frame").src = path;    
        document.getElementById("tbl").width = width;
        document.getElementById("frame").height = heigh+'px';    
        document.getElementById("frame").width = width+'px';	
        ScrollToElement("frame");
    }
    catch(err)
    {
    }
        
}

function opendivwinPreview(path,btn)
{    
    try
    {
    HideCombos('hidden');
    var ifra=document.getElementById("frame");
	var ancho;
	var alto;
	var top;
	
	document.getElementById("TdPrevisualizar").focus();
	
	ancho=GetWindowSize()[0]-20;		
	alto="1000px";
	top=getScrollXY()[1] - 10;	

	ifra.src = path;
	document.getElementById("tbl").width = alto;
	document.getElementById("fondoOpaco").style.display = "block";
	document.getElementById("aviso").style.display = "block";		
	document.getElementById("BodyMaster").setAttribute("scroll","yes");
	
	ifra.height=alto;
    ifra.width=ancho+"px";    
    document.getElementById("aviso").style.top = top+"px";
    }
    catch(err)
    {    
    }
}

 function HideCombos(State)
    {
        var objArray = document.getElementsByTagName('SELECT');
        for(i=0; i < objArray.length; i++)
        {
            objArray[i].style.visibility = State;
        }
    }


/*funciones para mostrar tool tip*/

 //Funcion obtener la posicion X y Y 
        function getPosition(e) {
        e = e || window.event;
        var cursor = {x:0, y:0};
        if (e.pageX || e.pageY) {
            cursor.x = e.pageX;
            cursor.y = e.pageY;
        } 
        else {
            var de = document.documentElement;
            var b = document.body;
            cursor.x = e.clientX + 
                (de.scrollLeft || b.scrollLeft) - (de.clientLeft || 0);
            cursor.y = e.clientY + 
                (de.scrollTop || b.scrollTop) - (de.clientTop || 0);
        }
        return cursor;
    }

    function showDiv(divNombre,strTexto)
    {
        var isIE = (window.navigator.userAgent.indexOf("MSIE")> 0);  
        if (! isIE){   
            HTMLElement.prototype.__defineGetter__("innerText",function () { return(this.textContent); });   
            HTMLElement.prototype.__defineSetter__("innerText",function (txt) { this.textContent = txt; });
        }
         
        var objDiv = document.getElementById(divNombre);
        objDiv.style.display = "block";
        objDiv.style.left = getPosition().x + 5;
        objDiv.style.top = getPosition().y - 5;
        document.getElementById("textoInterno").innerText = strTexto;
    }
    
    function showDivProcesos(divNombre)
    {
        var isIE = (window.navigator.userAgent.indexOf("MSIE")> 0);
        var objDiv = document.getElementById(divNombre);
        
        if(objDiv.style.display == "none")
        {
            objDiv.style.marginLeft = "10px";
            objDiv.style.marginTop = "2px";
            objDiv.style.display = "block";
            HideCombos('hidden');
        }
        else
        {
            ocultarDiv(divNombre);
        }
    }

     function ocultarDiv(divNombre)
    {
        var objDiv = document.getElementById(divNombre);
        objDiv.style.display = "none";
        HideCombos('visible');
    }
  
   /*Fin funciones para mostrar tool tip*/ 
    
    
    
    
function closeRealoadPage(pageToReload)
{
	document.getElementById('fondoOpaco').style.display = 'none';
	document.getElementById('aviso').style.display = 'none';
	document.getElementById("frame").src = '';
	if(pageToReload != "")
	{
	    document.location.href=pageToReload;
    }
    else
    {
        document.location.href=pageToReload;
    }
}



 //Asociar el evento de un boton a un control runar server
    function asociarBoton(evento,btnAsociar)
    {
        if(evento.keyCode!=13)
      {     
          MM_returnValue = true;
      }     
      else
      {
          var ctlbtnAsociar = document.getElementById(btnAsociar);
          if (ctlbtnAsociar != null)
          {
            //__doPostBack(btnAsociar,'');
            MM_returnValue = false;  
          }
      }
}

    //Funcion que simula el click en un boton cuando se da enter en una caja de texto
    function Enter(evento,btn)
    {
       
        var boton=document.getElementById(btn);
        ac = teclaEvento(evento);    
        if(ac==13)
        {
            try
            {
                boton.click(); 
            }
            catch (er)
            {
                window.location = boton.href;
            }
        }
    }


    function teclaEvento(evento)
    { 
        if (evento.keyCode)
	        return evento.keyCode;
        else
	        return evento.which;
    }
    
    function homeEmpresas()
    {
        location.href = "MiCuenta.aspx";
    }
    
    function trim(s){
        s = s.replace('/\s+/gi', ' '); //sacar espacios repetidos dejando solo uno
        s = s.replace('/^\s+|\s+$/gi',''); //sacar espacios blanco principio y final
        return s;
    }
    
    function hidediv(pass)
    {
       var divs = document.getElementsByTagName('div');
       for(i=0;i<divs.length;i++)
       {
           if(divs[i].id.match(pass))
           {//if they are 'see' divs
               if (document.getElementById) // DOM3 = IE5, NS6
                    divs[i].style.visibility="hidden";// show/hide
               else
               if (document.layers) // Netscape 4
                    document.layers[divs[i]].display = 'hidden';
               else // IE 4
                    document.all.hideShow.divs[i].visibility = 'hidden';
           }
       }
    }

    function showdiv(pass)
    {
       var divs = document.getElementsByTagName('div');
       for(i=0;i<divs.length;i++)
       {
           if(divs[i].id.match(pass))
           {
               if (document.getElementById)
                    divs[i].style.visibility="visible";
               else
               if (document.layers) // Netscape 4
                    document.layers[divs[i]].display = 'visible';
               else // IE 4
                    document.all.hideShow.divs[i].visibility = 'visible';
           }
       }
    } 
    
    function ActivarPestana(divPestana,Estado)
    {
        var divPestanaHojas1 = document.getElementById("divPestanaHojas1");
        var divPestanaHojas2 = document.getElementById("divPestanaHojas2");
        var divPestanaHojas3 = document.getElementById("divPestanaHojas3");
        var divPestanaHojas4 = document.getElementById("divPestanaHojas4");
        var divPestanaHojas5 = document.getElementById("divPestanaHojas5");
        
        divPestanaHojas1.className="cntr_tabs_inactive";
        divPestanaHojas2.className="cntr_tabs_inactive_left";
        divPestanaHojas3.className="cntr_tabs_inactive_mid";
        divPestanaHojas4.className="txt_tabs_inactive";
        divPestanaHojas5.className="cntr_tabs_inactive_right";
        
        document.getElementById("divPestanaPreSelec1").className="cntr_tabs_inactive";
        document.getElementById("divPestanaPreSelec2").className="cntr_tabs_inactive_left";
        document.getElementById("divPestanaPreSelec3").className="cntr_tabs_inactive_mid";
        document.getElementById("divPestanaPreSelec4").className="txt_tabs_inactive";
        document.getElementById("divPestanaPreSelec5").className="cntr_tabs_inactive_right";
        
        document.getElementById("divPestanaSelect1").className="cntr_tabs_inactive";
        document.getElementById("divPestanaSelect2").className="cntr_tabs_inactive_left";
        document.getElementById("divPestanaSelect3").className="cntr_tabs_inactive_mid";
        document.getElementById("divPestanaSelect4").className="txt_tabs_inactive";
        document.getElementById("divPestanaSelect5").className="cntr_tabs_inactive_right";
        
        document.getElementById("divPestanaContr1").className="cntr_tabs_inactive";
        document.getElementById("divPestanaContr2").className="cntr_tabs_inactive_left";
        document.getElementById("divPestanaContr3").className="cntr_tabs_inactive_mid";
        document.getElementById("divPestanaContr4").className="txt_tabs_inactive";
        document.getElementById("divPestanaContr5").className="cntr_tabs_inactive_right";     
        
        document.getElementById(divPestana + "1").className="cntr_tabs_active";
        document.getElementById(divPestana + "2").className="cntr_tabs_active_left2";
        document.getElementById(divPestana + "3").className="cntr_tabs_active_mid";
        document.getElementById(divPestana + "4").className="txt_tabs_active";
        document.getElementById(divPestana + "5").className="cntr_tabs_active_right";
        
        if (Estado=='false')   
        {
            document.getElementById("pestanaEditarVacante").style.display = "none";
            document.getElementById("pestanaBuscar").style.display = "none";
            document.getElementById("divPestanaHojas1").style.display = "none";
        }
        else
        {
            document.getElementById("pestanaEditarVacante").style.display = "block";
            document.getElementById("pestanaBuscar").style.display = "block";
            document.getElementById("divPestanaHojas1").style.display = "block";        
        }
    }
    
    function dimensionar()
    {
        try    
        {
            window.frames["frame"].document.getElementById("divMensaje").style.height=document.getElementById("frame").height-50+"px";
            window.frames["frame"].document.getElementById("TbMensaje").style.height=document.getElementById("frame").height-60+"px";
            window.frames["frame"].document.getElementById("TbMensaje").style.width=document.getElementById("frame").width-30+"px";
        }
        catch(err)
        {
        }
    }    
    
    function GoToTab(newTab)
    {
        var sPath = window.location.pathname;
        var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);    
        window.location = newTab + '?PreviusTab=' + 'resultadoHojasdeVida.aspx';
    }
    
    function GoToPreviusTab()
    {
        var sPath = "" + window.location;
        var estado = sPath.substring(sPath.lastIndexOf('=') + 1);    
        if (estado != "")        
            window.location = 'resultadoHojasVida.aspx?estado=' + estado;
        else 
            window.location = 'resultadoHojasVida.aspx';
    }
    
    function Copia()
    {   
       
        var tamanoclave = document.getElementById("TxtClave");
        var tamanoclave1 = document.getElementById("TxtClave1");
        var tam = tamanoclave.value.length;
                 
        if(tamanoclave.value.length < tamanoclave1.value.length)
        {

            if(tam == 0)
            {
            tamanoclave1.value = "";
            }
            else
            {

            tamanoclave1.value = tamanoclave1.value.substring(0,tamanoclave.value.length);
            }
    
        }
        if(tamanoclave.value.length > tamanoclave1.value.length)
        {
            tamanoclave1.value = tamanoclave1.value + tamanoclave.value.substring(tam - 1);
         }
        tamanoclave.value = "";
        for (var x = 0; x < tam; x++)  
        {  
            tamanoclave.value = tamanoclave.value + "*";  
         }
    }
    
    function tabs(boton)
    {
        var divoficios = document.getElementById('oficios');
        var divprofesiones = document.getElementById('profesiones');
        var divPestana1 = document.getElementById('divPestana1');
        var divPestana2 = document.getElementById('divPestana2');
        var hdPestanaSeleccionada = document.getElementById(hdPestanaSeleccionadaID);
        
        
        if (divoficios != null && divprofesiones != null && hdPestanaSeleccionada != null && divPestana1 != null && divPestana2 != null )
        {
            if(boton == 1)
            {
                divoficios.style.display="none";
                divprofesiones.style.display="block";
                hdPestanaSeleccionada.value = "profesiones";
                divPestana2.style.display="block";
                divPestana1.style.display="none";
            }
            else
            {
                divoficios.style.display="block";
                divprofesiones.style.display="none";
                hdPestanaSeleccionada.value = "oficios";
                divPestana2.style.display="none";
                divPestana1.style.display="block";
            }
        }
    }

    function ClaveOnFocus(TxtClave,Password){
        var TxtClave = document.getElementById(TxtClave);     
        if (TxtClave != null){
            if(TxtClave.value.toLowerCase() == 'clave' ||TxtClave.value.toLowerCase() == '********************' ){                    
                var Divpwd = document.getElementById('Divpwd');
                var DivPwdTxt = document.getElementById('DivPwdTxt');                
                var Password = document.getElementById(Password);
                if (Divpwd && DivPwdTxt && Password){        
                    DivPwdTxt.style.display = 'none';
                    Divpwd.style.display='block';
                    Password.focus();
                }            
            }
        }
    }
    
    function PassWordOnBlur(TxtClave1){
        var TxtClave1 = document.getElementById(TxtClave1);        
        if (TxtClave1 != null)
            if(TxtClave1.value == ''){
                var Divpwd = document.getElementById('Divpwd');
                var DivPwdTxt = document.getElementById('DivPwdTxt');
                
                if (Divpwd && DivPwdTxt && TxtClave1){
                    Divpwd.style.display='none';
                    DivPwdTxt.style.display = 'block';
                    TxtClave1.value = '';
                }
            }
    }
    
    function CambiarImagenEsperar(Ctl)
    {
        Ctl.className = 'btn_enviar_cargando';
        return true;
    }

    function MostrarImagenEsperar(idDiv)
    {
        var Ctl = document.getElementById(idDiv);
        if (Ctl)
        {
            Ctl.style.display = 'block';
        }
        return true;
    }    
    
    function RestaurarImagenEnviar(CtlID)
    {
        var Ctl = document.getElementById(CtlID);
        if (Ctl){
        Ctl.className = 'btn_enviar_hva';}
        return true;
    }
    
     //Imprimir IFrame de HV
    function iprint(codCandidato) 
    { 
        var objFramePrint = window.frames["printHv"];
        objFramePrint.focus();
        objFramePrint.print();
    } 
    
    function WaitForIFrame()
    {
        if (iframe.readyState != "complete")
            setTimeout("WaitForIFrame();", 200);
        else
            printhere();
    }

    function printhere()
    {
        iframe=document.getElementById('printHv');
        iframe.contentWindow.focus();
        iframe.contentWindow.print();
        document.body.removeChild(iframe);
    }
    
    function loadiframe(url)
    {
        /*try
        {
            document.getElementById('printHv').src = url;
            iframe=document.getElementById('printHv');
            WaitForIFrame();
        }
        catch (er)
        {*/
            ifra = document.createElement("IFRAME");
            ifra.setAttribute("src", url);
            ifra.setAttribute("name", "printHv");
            ifra.setAttribute("id", "printHv");
            ifra.style.width = "0px";
            ifra.style.height = "0px";
            document.body.appendChild(ifra);
            iframe=document.getElementById('printHv');
            WaitForIFrame();
        //}
    }
    
    //Mantener posicion del scroll
    function mantainScrollUpdatePanel(divName)
    {
        // This Script is used to maintain Grid Scroll on Partial Postback
        var scrollTop;
       //Register Begin Request and End Request 
        Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(BeginRequestHandler);
        Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
        //Get The Div Scroll Position
        function BeginRequestHandler(sender, args) 
            {
              var m = document.getElementById(divName);
                  scrollTop=m.scrollTop;
            }
             //Set The Div Scroll Position
          function EndRequestHandler(sender, args)
           {
           var m = document.getElementById(divName);
               m.scrollTop = scrollTop;
            }   
    }

    function ScrollToElement(theElement)
    {
        var selectedPosX = 0;
        var selectedPosY = 0;
        while(theElement != null)
        {
            selectedPosX += theElement.offsetLeft;
            selectedPosY += theElement.offsetTop;
            theElement = theElement.offsetParent;
        }
        window.scrollTo(selectedPosX,selectedPosY);
    }

    function ocultarContenedor(nombreContenedor)
    {
        var objContenedor = document.getElementById(nombreContenedor);
        if(objContenedor != null)
        {
            if(objContenedor.style.display == "none")
            {
                objContenedor.style.display = "block";
            }
            else
            {
                objContenedor.style.display = "none";
            }
        }
    }
    
    //Validar numeros textBox
    function fncInputNumericValuesOnly()	
    {
        if(!(event.keyCode==45||event.keyCode==48||event.keyCode==49
            ||event.keyCode==50||event.keyCode==51||event.keyCode==52||event.keyCode==53||
                event.keyCode==54||event.keyCode==55||event.keyCode==56||event.keyCode==57))		
        {			
            event.returnValue=false;		
        }	
    }
    
    function MostrarEsconderComentarios(id)
    {
        try
        {
            var name = 'divContenedor' + id;
            var el = document.getElementById(name);
            var esconder = false;
            if (el.style.display != "none")
                esconder = true;
            else
                esconder = false;
            name = 'verMasComentarios' + id;
            if (esconder)
            {
                el.style.display = "none";
                el = document.getElementById(name);
                el.innerHTML = 'Ver más comentarios';
            }
            else
            {
                el.style.display = "inline";
                el = document.getElementById(name);
                el.innerHTML = 'Ocultar comentarios';
            }
        }
        catch (er)
        {
        }        
    }
