var timerID = null
var timerRunning = false

function getsysdate()
{
    var idioma='sp';
    var dia;
    var mes;
    var anio;
    var dias = new Array("Domingo", "Lunes", "Martes", "Miercoles", "Jueves", "Viernes", "Sabado");
    var idia = new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Saturday", "Sunday");
    var meses = new Array("Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre");
    var imeses = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
    var retorno;


	
	fecha = new Date();
        anio = fecha.getYear();

        if ( anio < 1900) anio += 1900;
	
	switch(idioma)
	{
	 	case 'en':
		         dia = idia[fecha.getDay()];
				 mes = imeses[fecha.getMonth()];
			     retorno = dia + ' ' + mes + ' ' + fecha.getDate() +', ' + anio;
				 break;	  
	 	case 'sp':
	             dia = dias[fecha.getDay()];
           	     mes = meses[fecha.getMonth()];
			 	 retorno = dia + ' ' + fecha.getDate() +  ' de ' + mes + ' de ' + anio;
				 break;
	}
	
    return retorno;

}

function stopTimer(){

        if(timerRunning) {
                clearTimeout(timerID);
                timerRunning = false;
        }
} 

function startTimer(){

    stopTimer();
    runClock();
}

function runClock(){

        window.status = TimeNow();

        timerID = setTimeout("runClock()",1000);
        timerRunning = true;
}

function timeNow() {
        now = new Date();
        hours = now.getHours();
        minutes = now.getMinutes();
        seconds = now.getSeconds();
        timeStr = "" + ((hours > 12) ? hours - 12 : hours);
        timeStr  += ((minutes < 10) ? ":0" : ":") + minutes;
        timeStr  += ((seconds < 10) ? ":0" : ":") + seconds;
        timeStr  += (hours >= 12) ? " PM" : " AM";
        return timeStr;
}

function writeDate()
{

   var fecha
   
   fecha = getsysdate() + " " + timeNow();
   document.write(fecha);
}

function directoaulacit()
{
   window.open("https://ssi.ulacit.ac.pa/","login","toolbars=0,scrollbars=0,location=0,statusbars=0,menubars=0,resizable=0,top=200,width=190,height=260,screenX=300,screenY=200");
}

function mailcheck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		
		if (str.indexOf(at)==-1) return false;
		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr) return false;
		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr) return false;
		if (str.indexOf(at,(lat+1))!=-1) return false;
		if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot) return false;
		if (str.indexOf(dot,(lat+2))==-1) return false;
		if (str.indexOf(" ")!=-1) return false;
 		return true;					
}

function CheckForm()
{

	  var Forma=document.mailform;
	  
	  if (Forma.txtNombre.value=='')
	     {
			document.getElementById('lbl_error').innerHTML = 'Por favor, especifique su nombre...!';
			Forma.txtNombre.focus();
			return false;
		 } 
	
	  if (Forma.txtApellido.value=='') 
	     {
			document.getElementById('lbl_error').innerHTML = 'Por favor, especifique su apellido...!';
			Forma.txtApellido.focus();
		 	return false;
		 }

	  if (Forma.txtTelefono.value=='')
	     {
			document.getElementById('lbl_error').innerHTML = 'Por favor, especifique su No. de Télefono...!';
			Forma.txtTelefono.focus();
			return false;
		 }
		 
	  if (Forma.txtCorreo.value=='')
	     {
			document.getElementById('lbl_error').innerHTML = 'Por favor, especifique su correo electrónico...!';
			Forma.txtCorreo.focus();
			return false;
		 }
		 
	  if (!mailcheck(Forma.txtCorreo.value))
	     {
		   document.getElementById('lbl_error').innerHTML = 'Correo inválido.  Por favor especifique su correo electrónico...!';
		   Forma.txtCorreo.focus();
		   return false; 
		 }
		 
	  if (Forma.ddlb_carrera.value=='')
	     {
	  		document.getElementById('lbl_error').innerHTML = 'Debe escoger el programa ó carrera de interés';
	  	    Forma.ddlb_carrera.focus();
	  	    return false;
	  	 }
		 
	  if (isnull(Forma.ddlb_carrera.value))
	     {
	  		document.getElementById('lbl_error').innerHTML = 'Debe escoger el programa ó carrera de interés';
	  	    Forma.ddlb_carrera.focus();
	  	    return false;
	  	 }
		 
	  if (Forma.ddlb_carrera.value=='Seleccione Carrera')
	     {
	  	    document.getElementById('lbl_error').innerHTML = 'Debe escoger el programa ó carrera deseada..!';
	  	    Forma.ddlb_carrera.focus();
	  	    return false;
	  	 }
}

function CheckSSI()
{
		
		var Flogin=document.login;

		if (Flogin.txtUser.value=='')
		   {
			  document.getElementById('lbl_error2').innerHTML = 'Identificación Inválida';
			  Flogin.txtUser.focus();
			  return false;
		   }
		   
		 if (Flogin.txtId.value=='')
		   {
			   document.getElementById('lbl_error2').innerHTML = 'Clave Inválida';
			   Flogin.txtId.focus();
			   return false;
		   }
}
	
function SwapText(index)
{
 document.getElementById(index).style.color='#2101d7';
 document.getElementById(index).style.fontWeight='bold';
}

function UnSwapText(index)
{
  document.getElementById(index).style.color='#000000';
  document.getElementById(index).style.fontWeight='normal';
}


function cw()
{
   window.open("http://www.ulacit.ac.pa/html/alianza.html","Información","toolbars=0,scrollbars,location=0,resizable=0,statusbars=0,top=200,width=818,height=750,screenX=300,screenY=200");
}
