// JavaScript Document

// JavaScript Document
window.addEvent('domready',function(e){
	
	if($('slide')){
		var V2 = new viewer($$('#slide img'),{
			mode: 'alpha',
			interval: 4500
		}).play(true);
	}
	if($('formulario')){
		new FormCheck('formulario', {
		display : {
			showErrors : 0,	
			closeTipsButton : 0,
			flashTips : 1
		}
	})	
	}
	
	
	if($('accordeon')){
		
		new Accordion('#accordeon h2.accordeon_', '#accordeon div.accordeon_',
		{
			//Cuando se abre, agregamos la clase 'seleccionado' al titulo
			onActive: function(titulo, contenido)
		{
			titulo.addClass('seleccionado');
		},
			//Cuando se cierra, quitamos la clase 'seleccionado' del titulo
			onBackground: function(titulo, contenido)
		{
			titulo.removeClass('seleccionado');
	}
	
	
		
});	
	}
	
	$$('#menu li.op').each(function(e){
		e.set('morph',{
			duration: 200
		}).addEvents({
			mouseover: e.getChildren('div').morph.pass('.expandeSubmenu',e.getChildren('div')) ,
			mouseleave: e.getChildren('div').morph.pass('.regresaSubmenu',e.getChildren('div'))
		});
		
	});
	
	$$('#menu li.op2').each(function(e){
		e.set('morph',{
			duration:200
		}).addEvents({
			mouseenter: function(){
				e.getChildren('div').morph({
        			'width': '405px',
        			'visibility': 'visible',
					'opacity': 1,
					'padding-top': '0px',
					'padding-right': '10px',
					'padding-bottom': '10px',
					'padding-left': '10px'
     			});	
				
			},mouseleave: function(){
				e.getChildren('div').morph({
        			'width': '0px',
					'opacity': 0,
					'padding': 0
     			});	
			}
		});
	});
	$$('#login_sistemas .pcw').each(function(e){
		e.set('morph',{
			duration:200
		}).addEvents({
			mouseenter: $('cuadropcw').morph.pass('.cuadroAbierto',$('cuadropcw')),
			mouseleave: $('cuadropcw').morph.pass('.cuadroCerrado',$('cuadropcw'))
		});
	});
	toolTips();
	if($('loginUsuario')){
		$('usuario').addEvent('focus',function(e){
			if($('usuario').get('value')=="Usuario" ){	
				this.set('value',"");
			}
		});
		$('usuario').addEvent('blur',function(e){
			if(this.get('value')!="Usuario" && this.get('value')=="" ){	
				this.set('value',"Usuario");
			}
		});
		$('clave').addEvent('focus',function(e){
			if(this.get('value')=="contrasenia" ){	
				this.set('value',"");
			}
		});
		$('clave').addEvent('blur',function(e){
			if(this.get('value')!="contrasenia" && this.get('value')=="" ){	
				this.set('value',"contrasenia");
			}
		});
		
	}
		if($('accordion')){
			
		var accordion = new Accordion($$('.toggler'),$$('.element'), {
			opacity: 0,
			onActive: function(toggler,el) { 
				toggler.addClass('activo');
				toggler.getChildren('.dot').set('style','background-position:-32px 0;');
			},
			onBackground: function(toggler,el) { 
				toggler.removeClass('activo');
				toggler.getChildren('.dot').set('style','background-position:0px 0;');
			}
		});
			
		}
		
});
 
function ventana(dir,ancho,alto){
	window.open(dir,'ventana',"location=1,status=1,scrollbars=1, width="+ancho+",height="+alto);
}
 function toolTips(ancho){
	
	$$('a').each(function(el){
			if(el.get('accesskey')!=null && el.get('accesskey')!=""){
				el.tooltip (el.get('accesskey'), { width: 320, style: 'alert', sticky: 0, hook: 1 });
			}
	});
	
	if($('revisarNotas')){
		$('revisarNotas').tooltip ('<div class="formularioNotas"><form method="post" action="http://190.52.72.226/cgi-bin/querytes.cgi" enctype="application/x-www-form-urlencoded" id="loginUsuario"><div align="right"><input type="submit" value="ingresar" class="enviar" /></div><input type="text" name="usuario" value="Usuario" id="usuario" class="input" style="margin-top:0px;" /><div><input class="input" type="password" name="clave" class="input" value="contrasenia" id="clave" /></div></form></div>', { width: 270, style: 'wiki', sticky: 1 });
	}
	
 }
