

//GLOBALES RELOJ
var timerID = null;
var timerRunning = false;

//******************************** CONTROL FECHA ********************************
//FUNCION PARA FECHA ACTUAL
function FechaActual()
{
var dias_semana = new Array ('Domingo','Lunes','Martes','Miércoles','Jueves','Viernes','Sábado');
var nombres_mes = new Array ('Enero','Febrero','Marzo','Abril','Mayo','Junio','Julio','Agosto', 'Septiembre','Octubre','Noviembre','Diciembre');

 var fecha = new Date (); 
 var dia = fecha.getDay (); 
 dia = dias_semana[dia]; 
 var dia_mes = fecha.getDate(); 
 var mes = fecha.getMonth (); 
 mes = nombres_mes[mes]; 
 var anio = fecha.getYear(); 
 document.write (dia + ' ' + dia_mes + ' de ' + mes + ' de ' + anio); 
 }
 
//MUESTRA EL DIA DE LA SEMANA EN EL QUE ESTAMOS
function diaSemana()
{
var dias_semana = new Array ('Domingo','Lunes','Martes','Miércoles','Jueves','Viernes','Sábado');

 var fecha = new Date (); 
 var dia = fecha.getDay (); 
 dia = dias_semana[dia]; 
 
document.write(dia);
}
 
//TERMINA DE COMPLETAR EL RESTO DE LA FECHA
function restoFecha()
{
var nombres_mes = new Array ('Enero','Febrero','Marzo','Abril','Mayo','Junio','Julio','Agosto', 'Septiembre','Octubre','Noviembre','Diciembre');

 var fecha = new Date (); 
 var mes = fecha.getMonth (); 
 var dia_mes = fecha.getDate(); 
 var anio = fecha.getYear(); 
 mes = nombres_mes[mes]; 

 document.write(dia_mes + ' de ' + mes + ' de ' + anio);
}
//******************************** FIN CONTROL FECHA ********************************


//******************************** RELOJ ********************************

//PARA EL RELOJ 
function stopclock (){

        if(timerRunning)
                clearTimeout(timerID);
        timerRunning = false;
}

//MUESTRA EL MOVIMIENTO DEL RELOJ CADA SEGUNDO
function showtime () {

        var now = new Date();
        var hours = now.getHours();
        var minutes = now.getMinutes();
        var seconds = now.getSeconds()

        var timeValue = "" + ((hours >12) ? hours -12 :hours)
        timeValue += ((minutes < 10) ? ":0" : ":") + minutes
        timeValue += ((seconds < 10) ? ":0" : ":") + seconds

        //document.clock.face.value = timeValue;
		document.getElementById('face').value = timeValue;

        timerID = setTimeout("showtime()",1000);
        timerRunning = true;

}

// INICIO DE RELOJ
function startclock () {

        stopclock();
        showtime();
}

//******************************** FIN RELOJ ********************************

//******************************** BARRA DE ESTADO **********************
//-------comienzo del mensaje en la barra de estado para ocultar los LINKS----------
// me creo una variable en la que defino el TEXTO en blanco
var texto="";
// creo una función llamada MENSAJE() en la que hago referencia desde la página por medio de ONMOUSEOVER
function mensaje(){
window.status=texto
return true
}
//-----------final del mensaje de la barra de estado-------------------
//******************************** FIN BARRA DE ESTADO **********************

//******************************** PINTA LISTA  **********************
function entrar(src,color_entrada) {
if (src.bgColor != "FF0000")
	src.bgColor=color_entrada;
//src.style.cursor="hand";
}

function sortir(src,color_default) {
if (src.bgColor != "FF0000")
	src.bgColor=color_default;
//src.style.cursor="default";
}

function eliminar(src,color_eliminar) {
src.bgColor="FF0000";
}
//******************************** FIN PINTA LISTA **********************

//------------------- abre ventana pop up para imagenes -----------------
new_window=null;
function start_window(url,alto,ancho){
  if (new_window==null){
    new_window = null;
  }
  else {
    new_window.close();
        new_window=null;
  }
  new_window = window.open(url, "ventana", "directories=no, menubar =no,status=no,toolbar=no,location=no,scrollbars=no,fullscreen=no,height="+alto+",width="+ancho);
  new_window.focus();
  
}
//------------------- fin ventana pop up para imagenes ----------------------


//******************************** BUSCADOR *****************************
function validarBusqueda(formu) {

if (formu.txt.value=="")
	alert("Debes Introducir un Criterio de Busqueda");
else if (formu.opBusqueda.value == "0")
	alert("Debes Seleccionar una Opcion de la Lista");
else
	formu.submit();
}
//******************************** FIN BUSCADOR **************************

//******************************** fondo plantillas **********************

var tipo = 0;

function swapImg(){
	var object = document.getElementById('contenido');	
	if(tipo == 0){
		object.style.backgroundImage='url(http://www.afapclm.com/img/bgdetW.gif)';
	}else{
		object.style.backgroundImage='url(http://www.afapclm.com/img/bggenW.gif)';			
		//habilitamos los anuncios breves si estamos en la plantilla general
		changecontent();
	}
}

//******************************** efecto lista menú **********************



function listMenu(modo){
	var menu = document.getElementById('listmenu').style;
	if (modo==true){
		menu.borderRight='solid 12px #EA861B';
	}else{
		menu.borderRight='solid 5px #EA861B';
	}
}

//tabulador activo de panel para los menus
function menuActivo(obj){
	var menu = new Array(document.getElementById('menu1'),document.getElementById('menu2'),document.getElementById('menu3'),document.getElementById('menu4'), document.getElementById('menu5'), document.getElementById('menu6'));

	for(i=0; i<menu.length;i++){
		if(i==obj){
			menu[i].className = 'current';
		}else{			
			menu[i].className = null;
		}
	}
}

function onFocusInOut(element) {
	var objeto = document.getElementById(element);	
	
	if (navigator.appName == 'Microsoft Internet Explorer') {
		objeto.style.border='1px solid #EA861B';
		
	}
	
	objeto.onfocusin = function(){
		objeto.style.border='1px solid #EA861B';							
	}
	
	objeto.onfocusout = function(){ 
		objeto.style.border='1px solid #999999';					
	}
	
	
}

//aplicar el foco a todos los formularios, para IE
function onFocusInput (form) {
	var elementos = document.forms[form].elements;	
	
	for (var i = 0; i < elementos.length; i++) {
		elementos[i].onfocus = function(){
			//llamada a la función que pinta el foco
			onFocusInOut(this.name);
			
		}
	}
	return true;
}
