
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].set('Text','');
			
			new Element('img').setProperties({
				'src' : '/imgs/ico.cargando-animado.gif'
			}).injectInside($$('#mesCalendario')[0]);
			
			//ajaxHandler = new Ajax(this.href, {'method': 'get', 'update': $('calendario_div')}).request();

    			new Request(
			    {
			    method: 'get',
			    url: this.href,
			    onSuccess: function(texto){
				    $('calendario').innerHTML = texto;
				    captureLinks();}
			    }).send(); 
/*			ajaxHandler = new Ajax(this.href, {
				'method': 'get',
				'onComplete': captureLinks,
				'update': $('calendario')});
			ajaxHandler.request();
*/
			//return false;	
		}		
		//el.addEvent('click', function(){alert('clicked!')});		
	});
	$$('.TipCalendar').each(function(element,index) {
		var content = element.get('title').split('::');
		element.store('tip:title', content[0]);
		element.store('tip:text', content[1]);
	}); 
	var TipCalendar = new Tips($$('.TipCalendar'), {
		fixed: true,
		hideDelay: 50,
		showDelay: 50,
/*		initialize:function(){
			//this.fx = new Fx.Tween(this.toolTip,{property:'opacity', duration: 500, transition: Fx.Transitions.Quart.easeInOut});
		},
*/
		onShow: function(toolTip) {
			toolTip.fade('in');
			//this.fx.start(1);
		},
		onHide: function(toolTip) {
			toolTip.fade('out');
//			this.fx.start(0);
		}
		
	});
	
	
	$$('.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);
		})
		
		
	})	
	
	$$('.link_aumenta').each(function(el) {
		el.addEvent('click',function(e) {			
			changeStyle(+1,'');
		})
		
		
	})	
	
	$$('.link_disminuye').each(function(el) {
		el.addEvent('click',function(e) {			
			changeStyle(-1,'');
		})
		
		
	})
	
	$$('.select_group').each(function(el) {
		el.addEvent('change',function(e) {			
			location.href=this.get("value");
		})
		
		
	})
}

window.addEvent('domready', function() 
{
	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',
					'html': 'Top',
					'href': 'javascript:window.scrollTo(0,0);'				
			}).injectInside('goTop');
			var imgTop=new Element('img', {				
					'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();
		
	}*/

	
});

