function captureLinks(){
	
	$$('.calendar').each(function(el) {
		
		var url = el.getProperty('href');		
		
		if(!url.match(/[?\&]js=1/))
			el.setProperty('href', url  + '&js=1');		
		
		el.addEvent('click', hacer);
		
		function hacer(e) {
			//console.log(e);
			e = new Event(e);
			e.stop();
			//e.stopPropagation();
			$$('#mesCalendario')[0].setText('');
			
			new Element('img').setProperties({
				'src' : '/imgs/ico.cargando-animado.gif'
			}).injectInside($$('#mesCalendario')[0]);
			
			//ajaxHandler = new Ajax(this.href, {'method': 'get', 'update': $('calendario_div')}).request();
			
			ajaxHandler = new Ajax(this.href, {
				'method': 'get',
				'onComplete': captureLinks,
				'update': $('calendario')});
			ajaxHandler.request();
			//return false;	
		}		
		//el.addEvent('click', function(){alert('clicked!')});		
	})
	
	$$('.nuevaVentana').each(function(el) {
		el.addEvent('click',function(e) {
			e = new Event(e);
			e.stop();
			var features='toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,copyhistory=no';
			window.open(this.href, 'nuevaVentana', features);
		})
		
		
	})	
	$$('.enviarAmigo').each(function(el) {
		el.addEvent('click',function(e) {
			e = new Event(e);
			e.stop();
			var features='width=800,height=360';
			window.open(this.href, 'enviarAmigo', features);
		})
		
		
	})	
	$$('.estiloMas').each(function(el) {
		el.addEvent('click',function(e) {			
			changeStyle(+1,'');
		})
		
		
	})	
	
	$$('.estiloMenos').each(function(el) {
		el.addEvent('click',function(e) {			
			changeStyle(-1,'');
		})
		
		
	})
	
	$$('.select_group').each(function(el) {
		el.addEvent('change',function(e) {			
			location.href=this.getValue();
		})
		
		
	})
}

//window.addEvent('domready', function(){
function prueba(){
	var cookie = readCookie("style");	
	var title = cookie ? cookie : getPreferredStyleSheet();	
	setActiveStyleSheet(title);
	
	//scrY=getScrollXY();
	//alert(window.getScrollHeight()+' - '+window.getHeight());
	
	var cur_url=window.location.href;	        
	if (!cur_url.match(/index\.php\/[^\/]+\/?$/)) {
		if (window.getScrollHeight() > window.getHeight()) {
			var new_div=new Element('div', {
				'id': 'goTop'
			});
			new_div.injectInside('main_texto');
			new Element('a', {
					'id': 'linkTop',
					'class': 'subir goTop',
					'properties': {'href': 'javascript:window.scrollTo(0,0);'}				
			}).setHTML('Top').injectInside('goTop');
			var imgTop=new Element('img', {				
					'properties': {'alt': 'subir', 'src':'/imgs/subir.gif'}
			});
			imgTop.injectInside('linkTop');
		}
	}

	captureLinks();
	
	
	//Banners en GeneralFrontpage
	if ($('frontpageBanner')) {
		var obj = {
			wait: 5000, 
			effect: 'fade',
			duration: 1000, 
			loop: true, 
			thumbnails: false,
			backgroundSlider: false,
			onClick: function(i){location.href=links[i]}
		}
		show = new SlideShow('frontpageBanner',banners,obj,links);
		
		/*$('img_init').remove();
		var imgBlank=new Element('img', {				
					'properties': {'alt': 'blank', 'src':'/~xabgalo/irb/htdocs/imgs/blank.jpg'}
		});
		imgBlank.injectInside('frontpageBanner');*/
		show.play();
		
	}
	
}
window.onload = prueba();