// JavaScript Document
var v2;
window.addEvent('domready',function(){
	SexyLightbox = new SexyLightBox({
		color:'white', emergefrom:'bottom',
		dir: '_libreria/scripts/sexybox/sexyimages'
	});
	if($('slide')){
		var V2 = new viewer($$('#slide img)'),{
			mode: 'alpha',
			interval: 4000
		});
		

	}
	if($('previo')){
		V2.play();
		$('previo').addEvent('click',V2.previous.bind(V2));
		$('nexto').addEvent('click',V2.next.bind(V2));	
	}
					
		$$('.menu-superior ul li').each(function(el){
		(el.getChildren('ul')).setStyle('opacity',0);
		(el.getChildren('ul')).setStyle('visibility','hidden');
		var viejo;
			el.addEvent('mouseover',function(){
				if(el.getElement('ul')){
					idtx =(el.getChildren('ul'));
					ver = el.getChildren('div').hasClass('class');	
						el.getChildren('div').addClass("activo");
					idtx.fade('in');
					//alert(el);
				}
				
			});
			el.addEvent('mouseout',function(){
				if(el.getElement('ul')){
					ulv = (el.getChildren('ul'));
					ulv.fade('out');
					el.getChildren('div').removeClass('activo')
				}
			});
	});

	if($('buscar')){
		$('buscar').addEvent('focus',function(){
			if(this.get('value')=="Buscar"){
				this.value='';	
			}
		});
		$('buscar').addEvent('blur',function(){
			if(this.get('value')==""){
				this.value='Buscar';	
			}
		});
	}
	$$('.pequenio').addEvent('click',function(){
		if(this.get("rel")!=null){
			window.location.href=this.get('rel');
		}
	});
	$$('.largo').addEvent('click',function(){
		if(this.get("rel")!=null){
			window.location.href=this.get('rel');
		}
	});
	$$('.siguiente').addEvent('click',function(){
		cargaCalendario(this.get('rel'));
	});
	$$('.anterior').addEvent('click',function(){
		cargaCalendario(this.get('rel'));
	});
	if($('btnBuscar')){
		$('btnBuscar').addEvent('click',function(){
			if($('buscar').get('value')!="Buscar" && $('buscar').get('value')!=""){
				document.formBuscar.submit();	
			}else{
				$('buscar').focus();	
			}
		});
	}
	
	if($('contacto')){
        new FormCheck('contacto');
	}
	if($('solicitud')){
        new FormCheck('solicitud');
	}
	
	toolTips();
});
 function cargaCalendario(mes){
	 var c = $('dias');
		new Request({
    	    	    method: 'post',
        	    	url: 'llamada.php?id=calendario',
	        	  	data: { 'ver_actual' : mes },
    	        	onRequest: function() { c.set('html','<div align="center">Cargando</div>'); },
               		update: c.set('html','Espere un momento por favor esta tardando mas de lo normal, si no carga, vuelva a intentarlo'),
 		       	    onComplete: function(response) {
						divide = response.split("::");
						c.set('html',divide[0]);
						$$('.mes-actual').set('html',divide[1]);
						toolTips();
						anterior = parseInt(divide[2])-1;
						siguiente = parseInt(divide[2])+1;
						if(anterior<1){
							anterior=1;	
						}
						$$('.anterior').set('rel',anterior);
						if(siguiente>12){
							siguiente=12;	
						}
						$$('.siguiente').set('rel',siguiente);
					}
	    }).send(); 
 }
 function toolTips(){
	$$('a').each(function(el){
			if(el.get('content')!=null){
				el.tooltip (el.get('content'), { width: 200, style: 'alert', sticky: 0, hook: 1 });
			}
	}); 
 }
 function MostrarFecha()  
    {  
    var nombres_dias = new Array("Domingo", "Lunes", "Martes", "Miércoles", "Jueves", "Viernes", "Sábado")  
    var nombres_meses = new Array("Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre")  
   
    var fecha_actual = new Date()  
   
    dia_mes = fecha_actual.getDate()   
    dia_semana = fecha_actual.getDay()
    mes = fecha_actual.getMonth() + 1  
    anio = fecha_actual.getFullYear()  
	$('fecha-hora').set('html',nombres_dias[dia_semana] + ", " + dia_mes + " de " + nombres_meses[mes - 1] + " de " + anio);
//document.write(nombres_dias[dia_semana] + ", " + dia_mes + " de " + nombres_meses[mes - 1] + " de " + anio)  
} 
