

/**
 * jQuery lightBox plugin
 * This jQuery plugin was inspired and based on Lightbox 2 by Lokesh Dhakar (http://www.huddletogether.com/projects/lightbox2/)
 * and adapted to me for use like a plugin from jQuery.
 * @name jquery-lightbox-0.5.js
 * @author Leandro Vieira Pinho - http://leandrovieira.com
 * @version 0.5
 * @date April 11, 2008
 * @category jQuery plugin
 * @copyright (c) 2008 Leandro Vieira Pinho (leandrovieira.com)
 * @license CC Attribution-No Derivative Works 2.5 Brazil - http://creativecommons.org/licenses/by-nd/2.5/br/deed.en_US
 * @example Visit http://leandrovieira.com/projects/jquery/lightbox/ for more informations about this jQuery plugin
 */
(function($){$.fn.lightBox=function(settings){settings=jQuery.extend({overlayBgColor:'#000',overlayOpacity:0.8,fixedNavigation:false,imageLoading:'images/lightbox-ico-loading.gif',imageBtnPrev:'images/lightbox-btn-prev.gif',imageBtnNext:'images/lightbox-btn-next.gif',imageBtnClose:'images/lightbox-btn-close.gif',imageBlank:'images/lightbox-blank.gif',containerBorderSize:10,containerResizeSpeed:400,txtImage:'Image',txtOf:'of',keyToClose:'c',keyToPrev:'p',keyToNext:'n',imageArray:[],activeImage:0},settings);var jQueryMatchedObj=this;function _initialize(){_start(this,jQueryMatchedObj);return false;}
function _start(objClicked,jQueryMatchedObj){$('embed, object, select').css({'visibility':'hidden'});_set_interface();settings.imageArray.length=0;settings.activeImage=0;if(jQueryMatchedObj.length==1){settings.imageArray.push(new Array(objClicked.getAttribute('href'),objClicked.getAttribute('title')));}else{for(var i=0;i<jQueryMatchedObj.length;i++){settings.imageArray.push(new Array(jQueryMatchedObj[i].getAttribute('href'),jQueryMatchedObj[i].getAttribute('title')));}}
while(settings.imageArray[settings.activeImage][0]!=objClicked.getAttribute('href')){settings.activeImage++;}
_set_image_to_view();}
function _set_interface(){$('body').append('<div id="jquery-overlay"></div><div id="jquery-lightbox"><div id="lightbox-container-image-box"><div id="lightbox-container-image"><img id="lightbox-image"><div style="" id="lightbox-nav"><a href="#" id="lightbox-nav-btnPrev"></a><a href="#" id="lightbox-nav-btnNext"></a></div><div id="lightbox-loading"><a href="#" id="lightbox-loading-link"><img src="'+settings.imageLoading+'"></a></div></div></div><div id="lightbox-container-image-data-box"><div id="lightbox-container-image-data"><div id="lightbox-image-details"><span id="lightbox-image-details-caption"></span><span id="lightbox-image-details-currentNumber"></span></div><div id="lightbox-secNav"><a href="#" id="lightbox-secNav-btnClose"><img src="'+settings.imageBtnClose+'"></a></div></div></div></div>');var arrPageSizes=___getPageSize();$('#jquery-overlay').css({backgroundColor:settings.overlayBgColor,opacity:settings.overlayOpacity,width:arrPageSizes[0],height:arrPageSizes[1]}).fadeIn();var arrPageScroll=___getPageScroll();$('#jquery-lightbox').css({top:arrPageScroll[1]+(arrPageSizes[3]/10),left:arrPageScroll[0]}).show();$('#jquery-overlay,#jquery-lightbox').click(function(){_finish();});$('#lightbox-loading-link,#lightbox-secNav-btnClose').click(function(){_finish();return false;});$(window).resize(function(){var arrPageSizes=___getPageSize();$('#jquery-overlay').css({width:arrPageSizes[0],height:arrPageSizes[1]});var arrPageScroll=___getPageScroll();$('#jquery-lightbox').css({top:arrPageScroll[1]+(arrPageSizes[3]/10),left:arrPageScroll[0]});});}
function _set_image_to_view(){$('#lightbox-loading').show();if(settings.fixedNavigation){$('#lightbox-image,#lightbox-container-image-data-box,#lightbox-image-details-currentNumber').hide();}else{$('#lightbox-image,#lightbox-nav,#lightbox-nav-btnPrev,#lightbox-nav-btnNext,#lightbox-container-image-data-box,#lightbox-image-details-currentNumber').hide();}
var objImagePreloader=new Image();objImagePreloader.onload=function(){$('#lightbox-image').attr('src',settings.imageArray[settings.activeImage][0]);_resize_container_image_box(objImagePreloader.width,objImagePreloader.height);objImagePreloader.onload=function(){};};objImagePreloader.src=settings.imageArray[settings.activeImage][0];};function _resize_container_image_box(intImageWidth,intImageHeight){var intCurrentWidth=$('#lightbox-container-image-box').width();var intCurrentHeight=$('#lightbox-container-image-box').height();var intWidth=(intImageWidth+(settings.containerBorderSize*2));var intHeight=(intImageHeight+(settings.containerBorderSize*2));var intDiffW=intCurrentWidth-intWidth;var intDiffH=intCurrentHeight-intHeight;$('#lightbox-container-image-box').animate({width:intWidth,height:intHeight},settings.containerResizeSpeed,function(){_show_image();});if((intDiffW==0)&&(intDiffH==0)){if($.browser.msie){___pause(250);}else{___pause(100);}}
$('#lightbox-container-image-data-box').css({width:intImageWidth});$('#lightbox-nav-btnPrev,#lightbox-nav-btnNext').css({height:intImageHeight+(settings.containerBorderSize*2)});};function _show_image(){$('#lightbox-loading').hide();$('#lightbox-image').fadeIn(function(){_show_image_data();_set_navigation();});_preload_neighbor_images();};function _show_image_data(){$('#lightbox-container-image-data-box').slideDown('fast');$('#lightbox-image-details-caption').hide();if(settings.imageArray[settings.activeImage][1]){$('#lightbox-image-details-caption').html(settings.imageArray[settings.activeImage][1]).show();}
if(settings.imageArray.length>1){$('#lightbox-image-details-currentNumber').html(settings.txtImage+' '+(settings.activeImage+1)+' '+settings.txtOf+' '+settings.imageArray.length).show();}}
function _set_navigation(){$('#lightbox-nav').show();$('#lightbox-nav-btnPrev,#lightbox-nav-btnNext').css({'background':'transparent url('+settings.imageBlank+') no-repeat'});if(settings.activeImage!=0){if(settings.fixedNavigation){$('#lightbox-nav-btnPrev').css({'background':'url('+settings.imageBtnPrev+') left 15% no-repeat'}).unbind().bind('click',function(){settings.activeImage=settings.activeImage-1;_set_image_to_view();return false;});}else{$('#lightbox-nav-btnPrev').unbind().hover(function(){$(this).css({'background':'url('+settings.imageBtnPrev+') left 15% no-repeat'});},function(){$(this).css({'background':'transparent url('+settings.imageBlank+') no-repeat'});}).show().bind('click',function(){settings.activeImage=settings.activeImage-1;_set_image_to_view();return false;});}}
if(settings.activeImage!=(settings.imageArray.length-1)){if(settings.fixedNavigation){$('#lightbox-nav-btnNext').css({'background':'url('+settings.imageBtnNext+') right 15% no-repeat'}).unbind().bind('click',function(){settings.activeImage=settings.activeImage+1;_set_image_to_view();return false;});}else{$('#lightbox-nav-btnNext').unbind().hover(function(){$(this).css({'background':'url('+settings.imageBtnNext+') right 15% no-repeat'});},function(){$(this).css({'background':'transparent url('+settings.imageBlank+') no-repeat'});}).show().bind('click',function(){settings.activeImage=settings.activeImage+1;_set_image_to_view();return false;});}}
_enable_keyboard_navigation();}
function _enable_keyboard_navigation(){$(document).keydown(function(objEvent){_keyboard_action(objEvent);});}
function _disable_keyboard_navigation(){$(document).unbind();}
function _keyboard_action(objEvent){if(objEvent==null){keycode=event.keyCode;escapeKey=27;}else{keycode=objEvent.keyCode;escapeKey=objEvent.DOM_VK_ESCAPE;}
key=String.fromCharCode(keycode).toLowerCase();if((key==settings.keyToClose)||(key=='x')||(keycode==escapeKey)){_finish();}
if((key==settings.keyToPrev)||(keycode==37)){if(settings.activeImage!=0){settings.activeImage=settings.activeImage-1;_set_image_to_view();_disable_keyboard_navigation();}}
if((key==settings.keyToNext)||(keycode==39)){if(settings.activeImage!=(settings.imageArray.length-1)){settings.activeImage=settings.activeImage+1;_set_image_to_view();_disable_keyboard_navigation();}}}
function _preload_neighbor_images(){if((settings.imageArray.length-1)>settings.activeImage){objNext=new Image();objNext.src=settings.imageArray[settings.activeImage+1][0];}
if(settings.activeImage>0){objPrev=new Image();objPrev.src=settings.imageArray[settings.activeImage-1][0];}}
function _finish(){$('#jquery-lightbox').remove();$('#jquery-overlay').fadeOut(function(){$('#jquery-overlay').remove();});$('embed, object, select').css({'visibility':'visible'});}
function ___getPageSize(){var xScroll,yScroll;if(window.innerHeight&&window.scrollMaxY){xScroll=window.innerWidth+window.scrollMaxX;yScroll=window.innerHeight+window.scrollMaxY;}else if(document.body.scrollHeight>document.body.offsetHeight){xScroll=document.body.scrollWidth;yScroll=document.body.scrollHeight;}else{xScroll=document.body.offsetWidth;yScroll=document.body.offsetHeight;}
var windowWidth,windowHeight;if(self.innerHeight){if(document.documentElement.clientWidth){windowWidth=document.documentElement.clientWidth;}else{windowWidth=self.innerWidth;}
windowHeight=self.innerHeight;}else if(document.documentElement&&document.documentElement.clientHeight){windowWidth=document.documentElement.clientWidth;windowHeight=document.documentElement.clientHeight;}else if(document.body){windowWidth=document.body.clientWidth;windowHeight=document.body.clientHeight;}
if(yScroll<windowHeight){pageHeight=windowHeight;}else{pageHeight=yScroll;}
if(xScroll<windowWidth){pageWidth=xScroll;}else{pageWidth=windowWidth;}
arrayPageSize=new Array(pageWidth,pageHeight,windowWidth,windowHeight);return arrayPageSize;};function ___getPageScroll(){var xScroll,yScroll;if(self.pageYOffset){yScroll=self.pageYOffset;xScroll=self.pageXOffset;}else if(document.documentElement&&document.documentElement.scrollTop){yScroll=document.documentElement.scrollTop;xScroll=document.documentElement.scrollLeft;}else if(document.body){yScroll=document.body.scrollTop;xScroll=document.body.scrollLeft;}
arrayPageScroll=new Array(xScroll,yScroll);return arrayPageScroll;};function ___pause(ms){var date=new Date();curDate=null;do{var curDate=new Date();}
while(curDate-date<ms);};return this.unbind('click').click(_initialize);};})(jQuery);

/**
 * Boxy 0.1.4 - Facebook-style dialog, with frills
 *
 * (c) 2008 Jason Frame
 * Licensed under the MIT License (LICENSE)
 */
 
/*
 * jQuery plugin
 *
 * Options:
 *   message: confirmation message for form submit hook (default: "Please confirm:")
 * 
 * Any other options - e.g. 'clone' - will be passed onto the boxy constructor (or
 * Boxy.load for AJAX operations)
 */

jQuery.fn.boxy=function(options){options=options||{};return this.each(function(){var node=this.nodeName.toLowerCase(),self=this;if(node=='a'){jQuery(this).click(function(){var active=Boxy.linkedTo(this),href=this.getAttribute('href'),localOptions=jQuery.extend({actuator:this,title:this.title},options);if(active){active.show();}else if(href.indexOf('#')>=0){var content=jQuery(href.substr(href.indexOf('#'))),newContent=content.clone(true);content.remove();localOptions.unloadOnHide=false;new Boxy(newContent,localOptions);}else{if(!localOptions.cache)localOptions.unloadOnHide=true;Boxy.load(this.href+'show_full/',localOptions);}
return false;});}else if(node=='form'){jQuery(this).bind('submit.boxy',function(){Boxy.confirm(options.message||'Please confirm:',function(){jQuery(self).unbind('submit.boxy').submit();});return false;});}});};function Boxy(element,options){this.boxy=jQuery(Boxy.WRAPPER);jQuery.data(this.boxy[0],'boxy',this);this.visible=false;this.options=jQuery.extend({},Boxy.DEFAULTS,options||{});if(this.options.modal){this.options=jQuery.extend(this.options,{center:true,draggable:false});}
if(this.options.actuator){jQuery.data(this.options.actuator,'active.boxy',this);}
this.setContent(element||"<div></div>");this._setupTitleBar();this.boxy.css('display','none').appendTo(document.body);this.toTop();if(this.options.fixed){if(jQuery.browser.msie&&jQuery.browser.version<7){this.options.fixed=false;}else{this.boxy.addClass('fixed');}}
if(this.options.center&&Boxy._u(this.options.x,this.options.y)){this.center();}else{this.moveTo(Boxy._u(this.options.x)?this.options.x:Boxy.DEFAULT_X,Boxy._u(this.options.y)?this.options.y:Boxy.DEFAULT_Y);}
if(this.options.show)this.show();};Boxy.EF=function(){};jQuery.extend(Boxy,{WRAPPER:"<table cellspacing='0' cellpadding='0' border='0' class='boxy-wrapper'>"+"<tr><td class='top-left'></td><td class='top'></td><td class='top-right'></td></tr>"+"<tr><td class='left'></td><td class='boxy-inner'></td><td class='right'></td></tr>"+"<tr><td class='bottom-left'></td><td class='bottom'></td><td class='bottom-right'></td></tr>"+"</table>",DEFAULTS:{title:null,closeable:true,draggable:true,clone:false,actuator:null,center:true,show:true,modal:false,fixed:true,closeText:'[cerrar]',unloadOnHide:false,clickToFront:false,behaviours:Boxy.EF,afterDrop:Boxy.EF,afterShow:Boxy.EF,afterHide:Boxy.EF,beforeUnload:Boxy.EF},DEFAULT_X:50,DEFAULT_Y:50,zIndex:1337,dragConfigured:false,resizeConfigured:false,dragging:null,load:function(url,options){options=options||{};var ajax={url:url,type:'GET',dataType:'html',cache:false,success:function(html){html=jQuery(html);if(options.filter)html=jQuery(options.filter,html);new Boxy(html,options);}};jQuery.each(['type','cache'],function(){if(this in options){ajax[this]=options[this];delete options[this];}});jQuery.ajax(ajax);},get:function(ele){var p=jQuery(ele).parents('.boxy-wrapper');return p.length?jQuery.data(p[0],'boxy'):null;},linkedTo:function(ele){return jQuery.data(ele,'active.boxy');},alert:function(message,callback,options){return Boxy.ask(message,['OK'],callback,options);},confirm:function(message,after,options){return Boxy.ask(message,['OK','Cancelar'],function(response){if(response=='OK')after();},options);},ask:function(question,answers,callback,options){options=jQuery.extend({modal:true,closeable:false},options||{},{show:true,unloadOnHide:true});var body=jQuery('<div></div>').append(jQuery('<div class="question"></div>').html(question));var map={},answerStrings=[];if(answers instanceof Array){for(var i=0;i<answers.length;i++){map[answers[i]]=answers[i];answerStrings.push(answers[i]);}}else{for(var k in answers){map[answers[k]]=k;answerStrings.push(answers[k]);}}
var buttons=jQuery('<form class="answers"></form>');buttons.html(jQuery.map(answerStrings,function(v){return"<input type='button' value='"+v+"' />";}).join(' '));jQuery('input[type=button]',buttons).click(function(){var clicked=this;Boxy.get(this).hide(function(){if(callback)callback(map[clicked.value]);});});body.append(buttons);new Boxy(body,options);},isModalVisible:function(){return jQuery('.boxy-modal-blackout').length>0;},_u:function(){for(var i=0;i<arguments.length;i++)
if(typeof arguments[i]!='undefined')return false;return true;},_handleResize:function(evt){var d=jQuery(document);jQuery('.boxy-modal-blackout').css('display','none').css({width:d.width(),height:d.height()}).css('display','block');},_handleDrag:function(evt){var d;if(d=Boxy.dragging){d[0].boxy.css({left:evt.pageX-d[1],top:evt.pageY-d[2]});}},_nextZ:function(){return Boxy.zIndex++;},_viewport:function(){var d=document.documentElement,b=document.body,w=window;return jQuery.extend(jQuery.browser.msie?{left:b.scrollLeft||d.scrollLeft,top:b.scrollTop||d.scrollTop}:{left:w.pageXOffset,top:w.pageYOffset},!Boxy._u(w.innerWidth)?{width:w.innerWidth,height:w.innerHeight}:(!Boxy._u(d)&&!Boxy._u(d.clientWidth)&&d.clientWidth!=0?{width:d.clientWidth,height:d.clientHeight}:{width:b.clientWidth,height:b.clientHeight}));}});Boxy.prototype={estimateSize:function(){this.boxy.css({visibility:'hidden',display:'block'});var dims=this.getSize();this.boxy.css('display','none').css('visibility','visible');return dims;},getSize:function(){return[this.boxy.width(),this.boxy.height()];},getContentSize:function(){var c=this.getContent();return[c.width(),c.height()];},getPosition:function(){var b=this.boxy[0];return[b.offsetLeft,b.offsetTop];},getCenter:function(){var p=this.getPosition();var s=this.getSize();return[Math.floor(p[0]+s[0]/2),Math.floor(p[1]+s[1]/2)];},getInner:function(){return jQuery('.boxy-inner',this.boxy);},getContent:function(){return jQuery('.boxy-content',this.boxy);},setContent:function(newContent){newContent=jQuery(newContent).css({display:'block'}).addClass('boxy-content');if(this.options.clone)newContent=newContent.clone(true);this.getContent().remove();this.getInner().append(newContent);this._setupDefaultBehaviours(newContent);this.options.behaviours.call(this,newContent);return this;},moveTo:function(x,y){this.moveToX(x).moveToY(y);return this;},moveToX:function(x){if(typeof x=='number')this.boxy.css({left:x});else this.centerX();return this;},moveToY:function(y){if(typeof y=='number')this.boxy.css({top:y});else this.centerY();return this;},centerAt:function(x,y){var s=this[this.visible?'getSize':'estimateSize']();if(typeof x=='number')this.moveToX(x-s[0]/2);if(typeof y=='number')this.moveToY(y-s[1]/2);return this;},centerAtX:function(x){return this.centerAt(x,null);},centerAtY:function(y){return this.centerAt(null,y);},center:function(axis){var v=Boxy._viewport();var o=this.options.fixed?[0,0]:[v.left,v.top];if(!axis||axis=='x')this.centerAt(o[0]+v.width/2,null);if(!axis||axis=='y')this.centerAt(null,o[1]+v.height/2);return this;},centerX:function(){return this.center('x');},centerY:function(){return this.center('y');},resize:function(width,height,after){if(!this.visible)return;var bounds=this._getBoundsForResize(width,height);this.boxy.css({left:bounds[0],top:bounds[1]});this.getContent().css({width:bounds[2],height:bounds[3]});if(after)after(this);return this;},tween:function(width,height,after){if(!this.visible)return;var bounds=this._getBoundsForResize(width,height);var self=this;this.boxy.stop().animate({left:bounds[0],top:bounds[1]});this.getContent().stop().animate({width:bounds[2],height:bounds[3]},function(){if(after)after(self);});return this;},isVisible:function(){return this.visible;},show:function(){if(this.visible)return;if(this.options.modal){var self=this;if(!Boxy.resizeConfigured){Boxy.resizeConfigured=true;jQuery(window).resize(function(){Boxy._handleResize();});}
this.modalBlackout=jQuery('<div class="boxy-modal-blackout"></div>').css({zIndex:Boxy._nextZ(),opacity:0.7,width:jQuery(document).width(),height:jQuery(document).height()}).appendTo(document.body);this.toTop();if(this.options.closeable){jQuery(document.body).bind('keypress.boxy',function(evt){var key=evt.which||evt.keyCode;if(key==27){self.hide();jQuery(document.body).unbind('keypress.boxy');}});}}
this.boxy.stop().css({opacity:1}).show();this.visible=true;this._fire('afterShow');return this;},hide:function(after){if(!this.visible)return;var self=this;if(this.options.modal){jQuery(document.body).unbind('keypress.boxy');this.modalBlackout.animate({opacity:0},function(){jQuery(this).remove();});}
this.boxy.stop().animate({opacity:0},300,function(){self.boxy.css({display:'none'});self.visible=false;self._fire('afterHide');if(after)after(self);if(self.options.unloadOnHide)self.unload();});return this;},toggle:function(){this[this.visible?'hide':'show']();return this;},hideAndUnload:function(after){this.options.unloadOnHide=true;this.hide(after);return this;},unload:function(){this._fire('beforeUnload');this.boxy.remove();if(this.options.actuator){jQuery.data(this.options.actuator,'active.boxy',false);}},toTop:function(){this.boxy.css({zIndex:Boxy._nextZ()});return this;},getTitle:function(){return jQuery('> .title-bar h2',this.getInner()).html();},setTitle:function(t){jQuery('> .title-bar h2',this.getInner()).html(t);return this;},_getBoundsForResize:function(width,height){var csize=this.getContentSize();var delta=[width-csize[0],height-csize[1]];var p=this.getPosition();return[Math.max(p[0]-delta[0]/2,0),Math.max(p[1]-delta[1]/2,0),width,height];},_setupTitleBar:function(){if(this.options.title){var self=this;var tb=jQuery("<div class='title-bar'></div>").html("<h2>"+this.options.title+"</h2>");if(this.options.closeable){tb.append(jQuery("<a href='#' class='close'></a>").html(this.options.closeText));}
if(this.options.draggable){tb[0].onselectstart=function(){return false;}
tb[0].unselectable='on';tb[0].style.MozUserSelect='none';if(!Boxy.dragConfigured){jQuery(document).mousemove(Boxy._handleDrag);Boxy.dragConfigured=true;}
tb.mousedown(function(evt){self.toTop();Boxy.dragging=[self,evt.pageX-self.boxy[0].offsetLeft,evt.pageY-self.boxy[0].offsetTop];jQuery(this).addClass('dragging');}).mouseup(function(){jQuery(this).removeClass('dragging');Boxy.dragging=null;self._fire('afterDrop');});}
this.getInner().prepend(tb);this._setupDefaultBehaviours(tb);}},_setupDefaultBehaviours:function(root){var self=this;if(this.options.clickToFront){root.click(function(){self.toTop();});}
jQuery('.close',root).click(function(){self.hide();return false;}).mousedown(function(evt){evt.stopPropagation();});},_fire:function(event){this.options[event].call(this);}};




	var INSTALATION_DIR = $('base').attr('href');
	var LNG = $('html').attr('xml:lang');
	var mes,anyo;
	var eventos;
	var marcaEventos = function($td, thisDate, month, year)
	{
		var dia=thisDate.getDate();
		dia=parseInt(dia,10);
		
//		console.log(eventos[dia],month,year);
		
		
		if(eventos[dia] && month==thisDate.getMonth() && year==thisDate.getFullYear())
		{		
			//alert(dia);
			$td.addClass('evento');
			var fecha_arr=new Array();
			fecha_arr[2]=parseInt(thisDate.getDate(),10);
			fecha_arr[1]=lng.months_short[parseInt(thisDate.getMonth(),10)];
			fecha_arr[0]=parseInt(thisDate.getFullYear(),10);
			$td.html("<a class='diacalendario cat"+arridscats[dia]+"' href='#' rel='"+arrids[dia]+"' title='"+INSTALATION_DIR+"/"+fecha_arr[2]+"-"+fecha_arr[1]+"-"+fecha_arr[0]+"'>"+dia+"</a>");
		}

	}
	

	function calendario(fecha)
	{
		$.ajax(
		{
			type: "POST",
			url: INSTALATION_DIR+"/public/ajax/agenda.php",
			data: { fecha:fecha },

			success: function(datos)
			{
				eventos = {};
				arrids = {};
				arridscats = {};
				
				if (datos.length>0)
				{	
								
					arrfechas=datos.split(':');					
					mes=arrfechas[0];					
					anyo=arrfechas[1];
					var i=2;
					while(i<arrfechas.length)
					{
						arrfechas[i]=parseInt(arrfechas[i],10);	
						eventos[arrfechas[i]]=1;
						i=i+3;
					}
					
					var i=3;
					while(i<arrfechas.length)
					{
						arrids[arrfechas[i-1]]=arrfechas[i];
						i=i+3;
					}
					
					var i=4;
					while(i<arrfechas.length)
					{
						arridscats[arrfechas[i-2]]=arrfechas[i];
						i=i+3;
					}
				}
				
				$('#date-view1').renderCalendar({month:mes, year:anyo, renderCallback:marcaEventos, showHeader:$.dpConst.SHOW_HEADER_SHORT});					
				
				dias = $("a.diacalendario");	
				
				
				dias.each(function(index) {		
					$(this).click(function() {
						$("#infoevento").html( "<p><strong>"+datos["evento_"+$(this).attr("rel")].title +"</strong><br />"+datos["evento_"+$(this).attr("rel")].text +"</p>"); 
					});
					
					
					
					var datos;	
					var myrel=$(this).attr('rel');					
					$.ajax({						
					  url: INSTALATION_DIR+'/public/ajax/infoagenda.php?idagendadays='+myrel,
					  dataType: 'json',
					
					  success: function(data) {
						$('.result').html(data);
						datos=data;
					  }
					});
				});
				
				
				
								
				/*if($("#amigos").length > 0)
				{ 
				var datos;
				$.ajax({
				  url: INSTALATION_DIR+'/public/ajax/datos.php?lng='+LNG,
				  dataType: 'json',
				
				  success: function(data) {
					$('.result').html(data);
					datos=data;
					//alert(datos["foto_14"].title);
				  }
				}); 
				*/

				
				
			}
		});
			
	}
	
$(document).ready(function()
{
	mesNames = ['Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio', 'Julio', 'Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre'];
	
	calendario(0);
	
	$('#mes_anterior').bind('click', function(event)
		{
			event.preventDefault();			
			calendario($(this).attr('rel'));
			
			var fech = $(this).attr('rel').split("-");
			$("#fechacalendario").html(  mesNames[fech[0]] + " - " + fech[1]  ); //escribimos fecha del calendario
			
			fech[0]=parseInt(fech[0]);
			
			if (fech[0]==0){
				$('#mes_siguiente').attr("rel", '1-'+fech[1]);
				
				fech[0]=11;
				fech[1]=parseInt(fech[1])-1;
			}
			else{
				fech[1]=parseInt(fech[1]);
				if (fech[0]==11){
					ann=fech[1]+1;
					$('#mes_siguiente').attr("rel", '0-'+ann);
				}
				else{
					$('#mes_siguiente').attr("rel", fech[0]+1+'-'+fech[1]);
				}
				fech[0]--;
			}
			
			$(this).attr("rel", fech[0]+'-'+fech[1]); 
			
			
		});
	
	$('#mes_siguiente').bind('click', function(event)
		{
			event.preventDefault();
			
			calendario($(this).attr('rel')); //mostramos calendario
			
			var fech = $(this).attr('rel').split("-"); //obtenemos fecha del calendario
			//alert(fech[0]);
			
			$("#fechacalendario").html(  mesNames[parseInt(fech[0])] + " - " + fech[1]  ); //escribimos fecha del calendario
			
			
			fech[0]=parseInt(fech[0]);
			
			
			if (fech[0]==11){
				$('#mes_anterior').attr("rel", '10-'+parseInt(fech[1]));				
				
				fech[0]=0;
				fech[1]=parseInt(fech[1])+1;				
			}
			else{
				
				if (fech[0]==0)
				{
					ann=parseInt(fech[1])-1;
					$('#mes_anterior').attr("rel", '11-'+ann);
				}
				else
				{
					$('#mes_anterior').attr("rel", fech[0]-1+'-'+parseInt(fech[1]));
				}
				fech[0]++;
				
			}
			$(this).attr("rel", fech[0]+'-'+fech[1]);
			
		});
		
		
	
});

/**
 * Javascript público
 *
 * @category javascript
 * @copyright Copyright © 2011, BITTIA - Grupo BITTIA
 * @filesource
 * @package javascript
 * @version 1.0 2008/10/01
 */


/**
 * Ruta web de instalación e idioma
 */
var INSTALATION_DIR = $('link[rel="index"]').attr('href');
var LNG = $('html').attr('xml:lang');


/**
 * Mostrar símbolo de carga 
 * @param e object Elemento al que superponer el cargador
 */
function loading(e, opac)
{
	var opac = opac || '0.5';
	var lwidth = '100%';
	var lheight = $(window).height();
	var container = 'body';
	var ltop = 0;
	var lleft = 0;
	var lposition = 'fixed';
	//Ventana contenedora
	if(e == 'parent')
	{
		lwidth = '100%';
		lheight = '100%';
		container = window.parent.document.getElementById('content');		
	}
	else if(e)
	{
		lwidth = $(e).outerWidth(true);
		lheight = $(e).outerHeight(true);
		container = e;
		ltop = (parseInt($(e).css('top')) > $(e).offset().top)? parseInt($(e).css('top')) : $(e).offset().top;
		lleft = (parseInt($(e).css('left')) > $(e).offset().left)? parseInt($(e).css('left')) : $(e).offset().left;
		lposition = 'absolute';
	}
	else
	{
		lwidth = '100%';
		lheight = $(window).height();
		container = window.document.getElementById('content');
	}

	//Crea loading si no existe
	if($('#loading').length < 1)
	{
		$('body').append('<div id="loading"></div>');
		$('#loading').css({opacity: opac, left: lleft, top: ltop, width: lwidth, height: lheight, position: lposition});
	}
	return true;
}
function loadingEnd()
{
	while($('#loading').length > 0)
	{
		$('#loading').remove();
	}
	return true;
}


/**
 * Cargar lightbox con parámetros 
 */
function loadLb()
{
	$('a[rel*=lightbox]').lightBox(
	{
		imageLoading: INSTALATION_DIR+'/img/lightbox-ico-loading.gif',
		imageBtnClose: INSTALATION_DIR+'/lng/'+LNG+'/lightbox-btn-close.gif',
		imageBtnPrev: INSTALATION_DIR+'/lng/'+LNG+'/lightbox-btn-prev.gif',
		imageBtnNext: INSTALATION_DIR+'/lng/'+LNG+'/lightbox-btn-next.gif',
		imageBlank: INSTALATION_DIR+'/img/lightbox-blank.gif',
		containerResizeSpeed: 250,
		txtImage: lng.image,
		txtOf: lng.of,
		keyToPrev: lng.lightbox_prev,
		keyToNext: lng.lightbox_next
	});
}


/**
 * JS propio de la página
 */
function loadPage()
{
	//Borrar contenido input
	$('#header #searcher input').live('click', function(event)
	{
		if($(this).val() == 'Buscar')
		{
			$(this).val('');
		}
	});

	
	//Enlaces externos
	$('a[rel="nofollow"], a[rel="external"]').live('click', function(event)
	{
		event.preventDefault();
		window.open($(event.target).closest("a").attr("href"));
	});
}


/**
 * Defuscador de email
 * Uso: $(enlace elemento).defuscate();
 */ 
jQuery.fn.defuscate = function()
{
	return this.each(function(){
	var email = String($(this).html()).replace(/\s*\(.+\)\s*/, "@");
	$(this).before('<a href="mailto:' + email + '">' + email + "</a>").remove();
	});
}; 







/**
 * Cargar funcionalidades js tras cargar DOM
 */
$(document).ready(function()
{
	$(".email a").defuscate();
	
	//LiveQuery. Bind eventos tras ajax automáticamente
	loadPage();
	//Carga de lightbox
	loadLb();
	
	//para cargar los boxys
	$('a[rel=boxy]').click(function(event)
    {
       
		event.preventDefault(); 
		
		Boxy.load(INSTALATION_DIR+'/public/ajax/junta.php?id='+$(this).attr('href'), {
		closeable: true, 
		title: "Junta de Gobierno",
		modal:'true',
		afterHide: function() {
			$("object").css("display","block");
		}
		
	})});
	
	//para cargar los boxys en el formulario de pedidos
	$('a[rel=boxy2]').click(function(event)
    {
       
		event.preventDefault(); 
		
		Boxy.load(INSTALATION_DIR+'/public/ajax/articulo.php?id='+$(this).attr('href'), {
		closeable: true, 
		title: "Artículo",
		modal:'true',
		afterHide: function() {
			$("object").css("display","block");
		}
		
	})});
	
	
	
	$("#inscForm").validate();

	
	
	/**
	 * Árbol de elementos
	 */
	if($('#tree_elements').length > 0)
	{
		var simpleTree = $('.simpleTree');
		var simpleTreeCollection = simpleTree.simpleTree(
		{
			animate: false,
			autoclose: false,
			docToFolderConvert: true
		});

		//Mostrar acciones al hover en árbol
		$('li[rev]', simpleTree).live('mouseenter', function(event)
		{
			var class_item = $(event.target).attr('class');
			if(class_item != 'line' && class_item != 'line-last' && class_item != 'line-over')
			{
				$('.row_actions:first', this).css({'visibility': 'visible', 'display': 'block'});
			}	
		});
		$('li[rev]', simpleTree).live('mouseleave', function()
		{
			$('.row_actions').css({'visibility': 'hidden', 'display': 'none'});
		});
		
		//Mostrar todos
		$('.view_all').bind('click', function(event)
		{
			event.preventDefault();
			//ul ocultos sin class mostrar
			$('ul:hidden', simpleTree).css({'display': 'block'});
			//Cambiar folder-close por folder-open
			$('.folder-close', simpleTree).removeClass('folder-close').addClass('folder-open');
			$('.folder-close-last', simpleTree).removeClass('folder-close-last').addClass('folder-open-last');
		});
		//Ocultar todos
		$('.hide_all').bind('click', function(event)
		{
			event.preventDefault();
			//ul ocultos sin class mostrar
			$('.root ul ul:visible[class!="row_actions"]', simpleTree).css({'display': 'none'});
			//Cambiar folder-close por folder-open
			$('.folder-open', simpleTree).removeClass('folder-open').addClass('folder-close');
			$('.folder-open-last', simpleTree).removeClass('folder-open-last').addClass('folder-close-last');
		});
	}
	
});

// Script para el menu desplegable
sfHover = function() {
	var sfEls = document.getElementById("menuppal").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=(this.className.length>0? " ": "") + "sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp("( ?|^)sfhover\\b"), "");
		}
	}
}

mcAccessible = function() {
	var mcEls = document.getElementById("menuppal").getElementsByTagName("A");
	for (var i=0; i<mcEls.length; i++) {
		mcEls[i].onfocus=function() {
			this.className+=(this.className.length>0? " ": "") + "sffocus"; //a:focus
			this.parentNode.className+=(this.parentNode.className.length>0? " ": "") + "sfhover"; //li < a:focus
			if(this.parentNode.parentNode.parentNode.nodeName == "LI") {
				this.parentNode.parentNode.parentNode.className+=(this.parentNode.parentNode.parentNode.className.length>0? " ": "") + "sfhover"; //li < ul < li < a:focus
				if(this.parentNode.parentNode.parentNode.parentNode.parentNode.nodeName == "LI") {
					this.parentNode.parentNode.parentNode.parentNode.parentNode.className+=(this.parentNode.parentNode.parentNode.parentNode.parentNode.className.length>0? " ": "") + "sfhover"; //li < ul < li < ul < li < a:focus
				}
			}
		}
		mcEls[i].onblur=function() {
			this.className=this.className.replace(new RegExp("( ?|^)sffocus\\b"), "");
			this.parentNode.className=this.parentNode.className.replace(new RegExp("( ?|^)sfhover\\b"), "");
			if(this.parentNode.parentNode.parentNode.nodeName == "LI") {
				this.parentNode.parentNode.parentNode.className=this.parentNode.parentNode.parentNode.className.replace(new RegExp("( ?|^)sfhover\\b"), "");
				if(this.parentNode.parentNode.parentNode.parentNode.parentNode.nodeName == "LI") {
					this.parentNode.parentNode.parentNode.parentNode.parentNode.className=this.parentNode.parentNode.parentNode.parentNode.parentNode.className.replace(new RegExp("( ?|^)sfhover\\b"), "");
				}
			}
		}
	}
}

// only ie needs the sfHover script. all need the accessibility script...
// thanks http://www.brothercake.com/site/resources/scripts/onload/
if(window.addEventListener) window.addEventListener('load', mcAccessible, false); // gecko, safari, konqueror and standard
else if(document.addEventListener) document.addEventListener('load', mcAccessible, false); // opera 7
else if(window.attachEvent) { // win/ie
	window.attachEvent('onload', sfHover);
	window.attachEvent('onload', mcAccessible);
} else { // mac/ie5
	if(typeof window.onload == 'function') {
		var existing = onload;
		window.onload = function() {
			existing();
			sfHover();
			mcAccessible();
		}
	} else {
		window.onload = function() {
			sfHover();
			mcAccessible();
		}
	}
}
