var bg1Color = "#EEEEEE";
var bg2Color = "#FFCC33";
var link1Color = "#000066";
var link2Color = "#000066";
function imprimirVentana() { window.focus(); window.print()}
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
//Script que evita que el usuario ingrese un aņo nulo
function fechaUsuario(year,month)
{
 if(year.value=="" && month.value=="00")
 { alert('Tiene que ingresar el Mes y Aņo');
  month.focus();
  return false;
  } else {
  if(year.value=="")
  {alert('Tiene que ingresar el Aņo');
   year.focus();
   return false;
  }
 }
}
/********Evento Enter********/
function checkEnter(e,form){ //e is event object passed from function invocation
//var characterCode  literal character code will be stored in this variable
	 if(e && e.which){ //if which property of event object is supported (NN4)
	 e = e
	 characterCode = e.which //character code is contained in NN4's which property
	 }
	 else{						
	 e = event						
	 characterCode = e.keyCode //character code is contained in IE's keyCode property
	 }
	 if(characterCode == 13){ //if generated character code is equal to ascii 13 (if enter key)
	 form.submit() //submit the form
	 return false 	 }
	 else{	 return true 	 }
}
function checkEnterSsl(e,form){ //e is event object passed from function invocation
//var characterCode  literal character code will be stored in this variable
	 if(e && e.which){ //if which property of event object is supported (NN4)
	 e = e
	 characterCode = e.which //character code is contained in NN4's which property
	 }
	 else{						
	 e = event						
	 characterCode = e.keyCode //character code is contained in IE's keyCode property
	 }
	 if(characterCode == 13){ //if generated character code is equal to ascii 13 (if enter key)
	 submitform() //submit the form
	 return false 	 }
	 else{	 return true 	 }
}
/******Load*****/
function loada() {
 MM_preloadImages('images/diseno/layout/ingreso.gif','images/diseno/layout/ayuda2.gif','images/diseno/layout/comentarios2.gif','images/diseno/layout/salir2.gif','images/diseno/layout/ulima2.gif','images/diseno/rollovers/personalizar2.gif','images/diseno/rollovers/aula2.gif','images/diseno/rollovers/normas2.gif','images/diseno/rollovers/usuarios2.gif','images/diseno/rollovers/requerimientos2.gif','images/diseno/rollovers/contrasena2.gif');
 if (login!=null){ login.userName.focus(); }
}
function loadb(user,tipo) {
 MM_preloadImages('images/diseno/layout/ingreso.gif','images/diseno/layout/ayuda2.gif','images/diseno/layout/comentarios2.gif','images/diseno/layout/salir2.gif','images/diseno/layout/ulima2.gif','images/diseno/rollovers/personalizar2.gif','images/diseno/rollovers/aula2.gif','images/diseno/rollovers/normas2.gif','images/diseno/rollovers/usuarios2.gif','images/diseno/rollovers/requerimientos2.gif','images/diseno/rollovers/contrasena2.gif');
}
/*******Abrir y cerrar ventanas******/
var ckTemp = document.cookie;
var newWin=new Array();
var i=0;
 
function cerrar()
	{ setCookie("popup",'00000000');
        cierraVentanas();
	  window.open("servlets/CustomLogoutServlet","_self","");
}
function cierraVentanas(){
	var j;
	  var ventana;
	  if(i>0){
		for(j=1;j<=i;j++){
		  ventana=newWin[j];
		  ventana.close();
		}
	  }
	}
function openWin2(url, title, width, height)
{	i++;   newWin[i] = window.open(url, title, 'width=' + width + ',dependent=yes, height=' + height +', resizable=yes, scrollbars=yes,status=yes');
}
function openWinMatricula(url, title, width, height)
{   i++;
	newWin[i] = window.open(url, title, 'width=' + width + ',dependent=yes, height=' + height +', resizable=yes, scrollbars=yes');
	return newWin[i];
}
function openWin(url, title, width, height)
{   var ventana = window.open(url, title, 'width=' + width + ',dependent=yes, height=' + height +', resizable=yes, scrollbars=yes');    }
function openWin3(url, title, width, height)
{    i++;
     newWin[i] = window.open(url, title, 'width=' + width + ',dependent=yes, height=' + height +', resizable=yes, scrollbars=yes, location=yes, menubar=yes, toolbar=yes');
}
function openAplic(url, Tipo)
{ if(Tipo=='0'){window.location.replace(url);}
  if(Tipo=='1'){
  	var winW=(screen.availWidth*0.95);	var winH=(screen.availHeight*0.95); var t=new Date();
    openWin2(url,'',winW,winH); 
  }
}
/******PopUp******/
function setCookie(name, value) { 
 if (value != null && value != "")
  document.cookie=name + "=" + escape(value) + ";";
  ckTemp = document.cookie;
 }
  
function getCookie(name,user) { 
 var index = ckTemp.indexOf(name+'=');
 if(index >=0) {  return ckTemp.substr(name.length+1,8);} return 1; }
  
function checkCookie(user,tipo) {
 var temp = getCookie("popup",user);
 var a = user.substr(0,1);
 if ( (a==1) || (a==2) ) {
	 if(temp!=user) {
      	 setCookie("popup",user);
		 if(tipo==1) {
		    i++;
	          newWin[i] = window.open('manual/tramite/tram_pers.html','pop1','directories=no, scrollbars=no,width=350,height=250,left=100,top=100');
		} else { 
		    i++;
      	    newWin[i]= window.open('manual/tramite/tram_no_pers.html','pop2','directories=no, scrollbars=no,width=350,height=250,left=100,top=100');
		}
	  }
}
}

/****Tramite******/
function tramitedirecto() { 
  window.opener.location ='../../layout.jsp?tab=1';
  window.close();
}
function tramite() { 
 window.location ='help_tram_pers.html';
 window.resizeTo(770,535);
}
function cerrarhelptramite() {  window.close();}
/*****Reloj*****/
		var clockInterval;
		var fgclockInterval=false;
		function updateTime(){
			matDate.setSeconds(matDate.getSeconds()+1);
			if(document.all['Clock']==null){
				finishClock();
				return; }
			document.all['Clock'].innerHTML="<span class=textoHora>&nbsp;&nbsp;&nbsp;"+getFormatedTime(matDate)+"&nbsp;&nbsp;&nbsp;</span>";
		}
		function initClock(){
			if(fgclockInterval==false){
				fgclockInterval=true;
				if(navigator.appName.indexOf('Microsoft Internet Explorer')==-1){	return;	}
				clockInterval=setInterval("updateTime()",1000);
			}
		}
		function finishClock(){	clearInterval(clockInterval);	}
		function getFormatedTime(dateObj){
			return ((dateObj.getHours()<10)?"0":"")+dateObj.getHours()+":"+((dateObj.getMinutes()<10)?"0":"")+dateObj.getMinutes()+":"+((dateObj.getSeconds()<10)?"0":"")+dateObj.getSeconds();
		}
/****disable F%***/
function disableRefresh(){
	if(window.event && window.event.keyCode==116){ // Capture and remap F5
		window.event.keyCode=505;	}
	if(window.event && window.event.keyCode==122){ // Capture and remap F11
		window.event.keyCode=505;	}
	if(window.event && window.event.keyCode==505){ // New action for F5
		return false; 	}
}