var tiempo = new Date();
var hora, cad;
with (tiempo){
hora = getHours();}
if (hora >= 0)
     cad = "GRUPO GLORIETA LE DESEA BUENAS NOCHES";
if (hora > 6)
     cad = "GRUPO GLORIETA LE DESEA BUENOS DÍAS";
if (hora > 12)
     cad = "GRUPO GLORIETA LE DESEA BUENAS TARDES";
if (hora > 20)
     cad = "GRUPO GLORIETA LE DESEA BUENAS NOCHES";
window.defaultStatus = " " + cad
function ventana_comodin (pagina, ancho, largo, elscroll) {

     ventana_c=window.open(pagina,'miVentana_c','location=no,directories=no,status=no,menubar=no,toolbar=no,scrollbars=' + elscroll + ',resizable=no,copyhistory=no,width=' + ancho + ' height=' + largo)
     ventana_c.focus();
}

function vpass() {
  var nom0 = document.descargar.eldoc.value.length
  if (nom0 < 1) {document.descargar.eldoc.focus();alert("Error:\n\nPara descargar este documento debe\nautentificarse en el Area de Clientes");return false;} 
  var enlaza = 'pag3.asp?eldoc=' + document.descargar.eldoc.value
 // document.descargar.submit()
  ventana_comodin (enlaza, 780, 630, 'yes')
                 } 

function ventana_comodin2 (pagina, ancho, largo, elscroll) {

     ventana_c=window.open(pagina,'miVentana_c2','location=no,directories=no,status=no,menubar=yes,toolbar=yes,scrollbars=' + elscroll + ',resizable=yes,copyhistory=no,width=' + ancho + ' height=' + largo)
     ventana_c.focus();
}


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);

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr;
  for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc; //x=a[0];x.src=x.oSrc;alert(x.src); 
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
desactivado = ""
function desactivar(nombreImagen,desactivado) {
      var desac= new Image();
      desac.src=desactivado
      document[nombreImagen].src=desac.src;
}

function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}

function setActiveStyleSheet(title) {
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      a.disabled = true;
      if(a.getAttribute("title") == title) a.disabled = false;
    }
  }
}

function getActiveStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
  }
  return null;
}

function getPreferredStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1
       && a.getAttribute("rel").indexOf("alt") == -1
       && a.getAttribute("title")
       ) return a.getAttribute("title");
  }
  return null;
}

function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}

var cookie = readCookie("style");
var title = cookie ? cookie : getPreferredStyleSheet();
setActiveStyleSheet(title);

window.onunload = function(e) {
  var title = getActiveStyleSheet();
  createCookie("style", title, 365);
}

// ------------ MENU  ---------------

sAgent = navigator.userAgent;
bIsMac = sAgent.indexOf("Mac") > -1;	
bIsIE = sAgent.indexOf("MSIE") > -1;
bIsIE4 = sAgent.indexOf("IE 4") > -1;
bIsIE5 = sAgent.indexOf("IE 5")  > -1;
bIsIE6 = sAgent.indexOf("IE 6")  > -1;
bIsIE7 = sAgent.indexOf("IE 7")  > -1;
bIsNav = sAgent.indexOf("Mozilla") > -1 && !bIsIE;
bDoesAll = (bIsIE4 || bIsIE5 || bIsIE6 || bIsIE7) && !bIsMac;

function paseMenu(objMenu,objImage) {
   // if (bDoesAll | bIsMac) {
        if (objMenu.style.display == "none") {
            objMenu.style.display = "";
            objImage.src = "imagen/minus.gif";
        }
        else {
            objMenu.style.display = "none";
						objImage.src = "imagen/plus.gif";
        }
 //   }
}

// ------------ FIN MENU ------------

// VALIDAR FECHAS -------------------
function validarFecha(elcampo) {

var input=elcampo // .value;
	if (input.length != 10) {
                alert("Día y Mes deben ir con 2 dígitos\n\nEl Año con 4 dígitos\n\nLa separación con el caracter /") 
		return false;
	}
	for (j=0; j<input.length; j++) {
//all figures and spacers in place?
		if ((j == 2) || (j == 5)) {

			if (input.charAt(j) != "/") {
				return false;
			}
		} else if ((input.charAt(j)<"0") || (input.charAt(j)>"9")) {
			
				return false;
			
		}
	}
//using right format dd/mm/yyyy and year 2002 or more? Change this for diff formats...
bits = input.split("/");
days = Number(bits[0]);
month = Number(bits[1]);
year=Number(bits[2]);
if (days > 31) { alert("El día no puede ser mayor de 31");eval("document." + document.forms[0].name + "." + event.srcElement.name + ".value=''");return false;}
else if (month > 12) { alert("El mes no puede ser mayor de 12");eval("document." + document.forms[0].name + "." + event.srcElement.name + ".value=''");return false;}

var no_dia = new Array (4, 6, 9, 11)
var si_mes = 0
for(i=j=0;i<5;i++)
   if(no_dia[i]==month)
   {
      si_mes = 1;
      j++;
    }

if ((days == 31) && (si_mes == 1)) { alert("Este mes no tiene más de 30 días");eval("document." + document.forms[0].name + "." + event.srcElement.name + ".value=''");return false;}

if ((days > 29) && (month == 2) && (anyoBisiesto(year) == true)) { alert("Este mes no tiene más de 29 días");eval("document." + document.forms[0].name + "." + event.srcElement.name + ".value=''");return false;}

if ((days > 28) && (month == 2) && (anyoBisiesto(year) == false)) { alert("Este mes no tiene más de 28 días");eval("document." + document.forms[0].name + "." + event.srcElement.name + ".value=''");return false;}

//if (year < 06) { alert("El año no puede ser menor de 2000");elcampo.focus();return false;}
//if (year > 99) { alert("El año no puede ser mayor de 2099");elcampo.focus();return false;}

return true;
}


function anyoBisiesto(anyo)
{
    /**
    * si el año introducido es de dos cifras lo pasamos al periodo de 1900. Ejemplo: 25 > 1925
    */
    if (anyo < 100)
        var fin = anyo + 1900;
    else
        var fin = anyo ;

    /*
    * primera condicion: si el resto de dividir el año entre 4 no es cero > el año no es bisiesto
    * es decir, obtenemos año modulo 4, teniendo que cumplirse anyo mod(4)=0 para bisiesto
    */
    if (fin % 4 != 0)
        return false;
    else
    {
        if (fin % 100 == 0)
        {
            /**
            * si el año es divisible por 4 y por 100 y divisible por 400 > es bisiesto
            */
            if (fin % 400 == 0)
            {
                return true;
            }
            /**
            * si es divisible por 4 y por 100 pero no lo es por 400 > no es bisiesto
            */
            else
            {
                return false;
            }
        }
        /**
        * si es divisible por 4 y no es divisible por 100 > el año es bisiesto
        */
        else
        {
            return true;
        }
    }
}

//------------- FIN VALIDAR FECHAS --