﻿// Archivo JScript
//document.oncontextmenu = new Function("return false");

function stopRKey(evt) {
var evt = (evt) ? evt : ((event) ? event : null);
var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
if (evt.keyCode == 13) {return false;}
}
document.onkeypress = stopRKey; 

function pressEnter(e,buttonId)
{
    try
    {
    var keynum;
    
    if(window.event) // IE
	    keynum = e.keyCode;	    
    else if(e.which) // Netscape/Firefox/Opera
	    keynum = e.which;

    if(keynum==13)
        document.getElementById(buttonId).click();
    }
    catch(err)
    {
        //---
    }
}

function openWindow(theURL,winName, alto, ancho)
{ 
  var x,y;
  x= (screen.width / 2) / 2;
  y= (screen.height / 2) / 2;
  window.open(theURL,winName,'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=' + ancho + ',height=' + alto + ',left=' + x + ',top=' + y );
}

function LimpiarTextBox(id)
{
    document.getElementById(id).value = "";
}

function Click(id)
{
    if (window.event.keyCode == 13)
        document.getElementById(id).click();
}

function redirigir(url, retardo)
{
    setTimeout("redirigirRetardo('" + url + "')",parseInt(retardo));
}
function redirigirRetardo(url)
{
    window.location = url;    
}

var timer;
function showMenu(menuId)
{
    try
    {
        var menu;
        if(menuId != "")
        {            
            menu = document.getElementById(menuId);
            if(timer != null)            
                clearTimeout(timer);
        }

        // Se chequea que capa se deben ocultar                                    
        if(menuId != "menuServiciosMedicos")
            document.getElementById("menuServiciosMedicos").style.visibility = "hidden";
        if(menuId != "menuNoticias")                
            document.getElementById("menuNoticias").style.visibility = "hidden";
        if(menuId != "menuAreaPaciente")
            document.getElementById("menuAreaPaciente").style.visibility = "hidden";
        if(menuId != "menuClinica")            
            document.getElementById("menuClinica").style.visibility = "hidden";
         
        if(menuId != "")
        {   
            // En caso de que la capa se encuentre oculta se muestra    
            if(menu.style.visibility != "visible")            
                menu.style.visibility = "visible";
            
            // Se establece el timer para el ocultamiento automático de la capa
            timer = setTimeout("hideMenu('" + menuId + "');", 2000);            
        }
    }
    catch(err)
    {
        //---
    }
}
function hideMenu(menuId)
{                    
    if(timer != null)            
        clearTimeout(timer);     
    
    timer = setTimeout("document.getElementById('" + menuId + "').style.visibility = 'hidden';", 2000);                                                             
}
function checkScreenWidth()
{  
    try
    {    
        if(document.body.clientWidth < 990)
         {             
            document.getElementById("Contenedor").style.marginLeft = "0%";
            document.getElementById("Contenedor").style.left = "0px"; 
         }
         else
         {
            document.getElementById("Contenedor").style.marginLeft = "50%";
            document.getElementById("Contenedor").style.left = "-495px";
         }
    }
    catch(err)
    {
        //---
    }
}
window.setInterval(checkScreenWidth,100);

function selectTXT(id)
{
    document.getElementById(id).select();
}

function mostrarOcultarCapa(id)
{
    var display = document.getElementById(id).style.display;    
    if(display != "block")
        document.getElementById(id).style.display = "block";
    else
        document.getElementById(id).style.display = "none";
}

//<script language="javascript" type="text/javascript">   
//        function mostrarPostal(capaId,mostrar)
//        {
//            if(mostrar)
//            {
//                /* Se calcula el tamaño de la ventana */ 
//                var winW,winH; 
//                if (parseInt(navigator.appVersion)>3) 
//                { 
//                    if (navigator.appName=="Netscape") 
//                    { 
//                        winW = window.innerWidth; 
//                        winH = window.innerHeight; 
//                    } 
//                    if (navigator.appName.indexOf("Microsoft")!=-1) 
//                    { 
//                        winW = document.body.offsetWidth; 
//                        winH = document.body.offsetHeight; 
//                    } 
//                    if (navigator.appName=="Opera") 
//                    { 
//                        winW = window.innerWidth; 
//                        winH = window.innerHeight; 
//                    } 
//                } 
//                document.getElementById(capaId).style.display = "block"; 
//                document.getElementById(capaId).style.height = parseInt(winH) + "px"; 
//                document.getElementById(capaId).style.width = parseInt(winW) + "px"; 
//            } 
//            else 
//                document.getElementById(capaId).style.display = "none"; 
//        } 
//    </script>  
