// Scripts CVG

//Script para desplegar las ligas ocultas del menu
<!--
var time = 3000;
var numofitems = 6;

//menu constructor
function menu(allitems,thisitem,startstate){ 
  callname= "gl"+thisitem;
  divname="subglobal"+thisitem;  
	this.numberofmenuitems = 6;
	this.caller = document.getElementById(callname);
	this.thediv = document.getElementById(divname);
	this.thediv.style.visibility = startstate;
}
				 
//menu methods
function ehandler(event,theobj){
  for (var i=1; i<= theobj.numberofmenuitems; i++){
	  var shutdiv =eval( "menuitem"+i+".thediv");
    shutdiv.style.visibility="hidden";
	}
	theobj.thediv.style.visibility="visible";
}
				
function closesubnav(event){
  if ((event.clientY <48)||(event.clientY > 107)){
    for (var i=1; i<= numofitems; i++){
      var shutdiv =eval('menuitem'+i+'.thediv');
			shutdiv.style.visibility='hidden';
		}  
	}
}

// Script para la sacar la fecha en ingles

print1="";
print2="";
print3="";
today = new Date();
weekday = today.getDay();
	if (weekday == 6) print1='Saturday ';
	if (weekday == 0) print1='Sunday ';
	if (weekday == 1) print1='Monday ';
	if (weekday == 2) print1='Tuesday';
	if (weekday == 3) print1='Wednesday';
	if (weekday == 4) print1='Thursday';
	if (weekday == 5) print1='Friday ';
month = today.getMonth();
	if (month == 0) print2='January';
	if (month == 1) print2='February';
	if (month == 2) print2='March';
	if (month == 3) print2='April :'
	if (month == 4) print2='May;'
	if (month == 5) print2='June';
	if (month == 6) print2='July';
	if (month == 7) print2='August';
	if (month == 8) print2='September';
	if (month == 9) print2='October';
	if (month == 10) print2='November';
	if (month == 11) print2='December';
date = today.getDate();
year=today.getYear();

//Fecha en español

dia="";
mes="";
if (weekday == 6) dia='Sabado ';
if (weekday == 0) dia='Domingo ';
if (weekday == 1) dia='Lunes ';
if (weekday == 2) dia='Martes ';
if (weekday == 3) dia='Miercoles ';
if (weekday == 4) dia='Jueves ';
if (weekday == 5) dia='Viernes ';

if (month == 0) mes='Enero';
if (month == 1) mes='Febrero';
if (month == 2) mes='Marzo';
if (month == 3) mes='Abril';
if (month == 4) mes='Mayo';
if (month == 5) mes='Junio';
if (month == 6) mes='Julio';
if (month == 7) mes='Agosto';
if (month == 8) mes='Septiembre';
if (month == 9) mes='Octubre';
if (month == 10) mes='Noviembre';
if (month == 11) mes='Diciembre';

// Check that a string contains only numbers...  http://www.dithered.com/javascript/form_validation/form_validation.txt
function isNumeric(string, ignoreWhiteSpace) {
   if (string.search) {
      if ((ignoreWhiteSpace && string.search(/[^\d\s]/) != -1) || (!ignoreWhiteSpace && string.search(/\D/) != -1)) return false;
   }
   return true;
} 

// Check that a string contains only letters
function isAlphabetic(string, ignoreWhiteSpace) {
   if (string.search) {
      if ((ignoreWhiteSpace && string.search(/[^a-zA-Z\s]/) != -1) || (!ignoreWhiteSpace && string.search(/[^a-zA-Z]/) != -1)) 
	  return false;
   }
   return true;
}

//funcion que verifica que el campo sea un correo
function verifyEmail(frmEmailAdd)
{
	invalidChars = " /:,;";
	if (frmEmailAdd == "") {
	  return false;
	}
	for (i = 0; i < invalidChars.length; i++) {
	  badChar = invalidChars.charAt(i);
	  if (frmEmailAdd.indexOf(badChar, 0) > -1) {
		return false;
	  }
	}
	atPos = frmEmailAdd.indexOf("@", 1);
	if (atPos == -1) {
	  return false;
	}
	if (frmEmailAdd.indexOf("@", (atPos + 1)) > -1) {
	  return false;
	}
	periodPos = frmEmailAdd.indexOf(".", atPos);
	if (periodPos == -1) {
	  return false;
	}
	if ((periodPos + 3) > frmEmailAdd.length) {
	  return false;
	}
	return true;
}

function validafmContacto()
{
	if (document.fmContacto.nombre.value == "") {
	  alert("Debe de escribir un nombre");
	  document.fmContacto.nombre.focus();
	  return false;
	}
	if (!isAlphabetic(document.fmContacto.nombre.value,2)){
	  alert("Solo debe escribir letras en el campo nombre");
	  document.fmContacto.nombre.focus();
	  document.fmContacto.nombre.select();
	  return false;
	}
	if (document.fmContacto.email.value == "") {
	  alert("Debe de escribir una dirección de email");
	  document.fmContacto.email.focus();
	  return false;
	}
	
	if (!verifyEmail(document.fmContacto.email.value)) {
	  alert("Dirección de correo electrónico inválida...intente de nuevo");
	  document.fmContacto.email.focus();
	  document.fmContacto.email.select();
	  return false;
	}
	
	if (document.fmContacto.comentarios.value == "") {
	  alert("Debe de escribir sus comentarios");
	  document.fmContacto.comentarios.focus();
	  return false;
	}
}

function validafmContacto2()
{
	if (document.fmContacto2.nombre.value == "") {
	  alert("Please right the contact name");
	  document.fmContacto2.nombre.focus();
	  return false;
	}
	if (!isAlphabetic(document.fmContacto2.nombre.value,2)){
	  alert("You can only write letters in the name");
	  document.fmContacto2.nombre.focus();
	  document.fmContacto2.nombre.select();
	  return false;
	}
	if (document.fmContacto2.email.value == "") {
	  alert("You must write an email address");
	  document.fmContacto2.email.focus();
	  return false;
	}
	
	if (!verifyEmail(document.fmContacto2.email.value)) {
	  alert("Invalid email address, please try again");
	  document.fmContacto2.email.focus();
	  document.fmContacto2.email.select();
	  return false;
	}
	
	if (document.fmContacto2.comentarios.value == "") {
	  alert("Please write your comments");
	  document.fmContacto2.comentarios.focus();
	  return false;
	}
}

// -->