var domainBase=base_url;//'http://flashdance.es/gestor/';


/*
 * Special event for image load events
 * Needed because some browsers does not trigger the event on cached images.

 * MIT License
 * Paul Irish     | @paul_irish | www.paulirish.com
 * Andree Hansson | @peolanha   | www.andreehansson.se
 * 2010.
 *
 * Usage:
 * $(images).bind('load', function (e) {
 *   // Do stuff on load
 * });
 *
 * Note that you can bind the 'error' event on data uri images, this will trigger when
 * data uri images isn't supported.
 *
 * Tested in:
 * FF 3+
 * IE 6-8
 * Chromium 5-6
 * Opera 9-10
 */
// (function ($) {
// 	$.event.special.load = {
// 		add: function (hollaback) {
// 			if ( this.nodeType === 1 && this.tagName.toLowerCase() === 'img' && this.src !== '' ) {
// 				// Image is already complete, fire the hollaback (fixes browser issues were cached
// 				// images isn't triggering the load event)
// 				if ( this.complete || this.readyState === 4 ) {
// 					hollaback.handler.apply(this);
// 				}
//
// 				// Check if data URI images is supported, fire 'error' event if not
// 				else if ( this.readyState === 'uninitialized' && this.src.indexOf('data:') === 0 ) {
// 					$(this).trigger('error');
// 				}
//
// 				else {
// 					$(this).bind('load', hollaback.handler);
// 				}
// 			}
// 		}
// 	};
// }(jQuery));

// $('img.photo',this).imagesLoaded(myFunction)
// execute a callback when all images have loaded.
// needed because .load() doesn't work on cached images

// mit license. paul irish. 2010.
// webkit fix from Oren Solomianik. thx!

// callback function is passed the last image to load
// as an argument, and the collection as `this`
// $.fn.imagesLoaded = function(callback){
//   var elems = this.filter('img'),
//       len = elems.length;
//
//   elems.bind('load',function(){
//       if (--len <= 0){ callback.call(elems,this); }
//   }).each(function(){
//      // cached images don't fire load sometimes, so we reset src.
//      if (this.complete || this.complete === undefined){
//         var src = this.src;
//         // webkit hack from http://groups.google.com/group/jquery-dev/browse_thread/thread/eee6ab7b2da50e1f
//         // data uri bypasses webkit log warning (thx doug jones)
//         this.src = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==";
//         this.src = src;
//      }
//   });
//
//   return this;
// };

/* jQuery Color Animations
 *
 * Copyright 2007 John Resig
 * Released under the MIT and GPL licenses.
 *
 * RGBA support by Mehdi Kabab <http://pioupioum.fr>
 */
(function(e){e.extend(e.support,{rgba:c()});e.each(["backgroundColor","borderBottomColor","borderLeftColor","borderRightColor","borderTopColor","color","outlineColor"],function(g,f){e.fx.step[f]=function(i){var h=[];if(!i.colorInit){i.start=d(i.elem,f);i.end=b(i.end);i.alphavalue={start:4===i.start.length,end:4===i.end.length};if(!i.alphavalue.start){i.start.push(1)}if(!i.alphavalue.end){i.end.push(1)}if(e.support.rgba&&(!i.alphavalue.start&&i.alphavalue.end)||(i.alphavalue.start&&i.alphavalue.end)||(i.alphavalue.start&&!i.alphavalue.end)){i.colorModel="rgba"}else{i.colorModel="rgb"}i.colorInit=true}h.push(Math.max(Math.min(parseInt((i.pos*(i.end[0]-i.start[0]))+i.start[0]),255),0));h.push(Math.max(Math.min(parseInt((i.pos*(i.end[1]-i.start[1]))+i.start[1]),255),0));h.push(Math.max(Math.min(parseInt((i.pos*(i.end[2]-i.start[2]))+i.start[2]),255),0));if(i.colorModel=="rgba"){h.push(Math.max(Math.min(parseFloat((i.pos*(i.end[3]-i.start[3]))+i.start[3]),1),0).toFixed(2))}i.elem.style[f]=i.colorModel+"("+h.join(",")+")"}});function b(g){var f,i,j="(?:,\\s*((?:1|0)(?:\\.0+)?|(?:0?\\.[0-9]+))\\s*)?\\)",h=new RegExp("rgb(a)?\\(\\s*([0-9]{1,3})\\s*,\\s*([0-9]{1,3})\\s*,\\s*([0-9]{1,3})\\s*"+j),k=new RegExp("rgb(a)?\\(\\s*([0-9]+(?:\\.[0-9]+)?)\\%\\s*,\\s*([0-9]+(?:\\.[0-9]+)?)\\%\\s*,\\s*([0-9]+(?:\\.[0-9]+)?)\\%\\s*"+j);if(g&&g.constructor==Array&&g.length>=3&&g.length<=4){return g}if(f=/#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(g)){return[parseInt(f[1],16),parseInt(f[2],16),parseInt(f[3],16)]}if(f=/#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(g)){return[parseInt(f[1]+f[1],16),parseInt(f[2]+f[2],16),parseInt(f[3]+f[3],16)]}if(f=h.exec(g)){i=[parseInt(f[2]),parseInt(f[3]),parseInt(f[4])];if(f[1]&&f[5]){i.push(parseFloat(f[5]))}return i}if(f=k.exec(g)){i=[parseFloat(f[2])*2.55,parseFloat(f[3])*2.55,parseFloat(f[4])*2.55];if(f[1]&&f[5]){i.push(parseFloat(f[5]))}return i}return a[e.trim(g).toLowerCase()]}function d(h,f){var g;do{g=e.curCSS(h,f);if(g!=""&&g!="transparent"||e.nodeName(h,"body")){break}f="backgroundColor"}while(h=h.parentNode);return b(g)}function c(){var h=e("script:first"),g=h.css("color"),f=false;if(/^rgba/.test(g)){f=true}else{try{f=(g!=h.css("color","rgba(0, 0, 0, 0.5)").css("color"));h.css("color",g)}catch(i){}}return f}var a={aqua:[0,255,255],azure:[240,255,255],beige:[245,245,220],black:[0,0,0],blue:[0,0,255],brown:[165,42,42],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgrey:[169,169,169],darkgreen:[0,100,0],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkviolet:[148,0,211],fuchsia:[255,0,255],gold:[255,215,0],green:[0,128,0],indigo:[75,0,130],khaki:[240,230,140],lightblue:[173,216,230],lightcyan:[224,255,255],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightyellow:[255,255,224],lime:[0,255,0],magenta:[255,0,255],maroon:[128,0,0],navy:[0,0,128],olive:[128,128,0],orange:[255,165,0],pink:[255,192,203],purple:[128,0,128],violet:[128,0,128],red:[255,0,0],silver:[192,192,192],white:[255,255,255],yellow:[255,255,0],transparent:(e.support.rgba)?[0,0,0,0]:[255,255,255]}})(jQuery);
/*
 * aeImageResize
 * https://github.com/adeelejaz/jquery-image-resize/blob/master/README
 * Version: v2.1.1
 * Author: Adeel Ejaz (http://adeelejaz.com/)
 * License: Dual licensed under MIT and GPL licenses.
 */
(function(d){d.fn.aeImageResize=function(a){var i=0,j=d.browser.msie&&6==~~d.browser.version;if(!a.height&&!a.width)return this;if(a.height&&a.width)i=a.width/a.height;return this.one("load",function(){this.removeAttribute("height");this.removeAttribute("width");this.style.height=this.style.width="";var e=this.height,f=this.width,g=f/e,b=a.height,c=a.width,h=i;h||(h=b?g+1:g-1);if(b&&e>b||c&&f>c){if(g>h)b=~~(e/f*c);else c=~~(f/e*b);this.height=b;this.width=c}}).each(function(){if(this.complete||j)d(this).trigger("load")})}})(jQuery);

// DESIGN MODE
function initDesignMode() {
	$('#designMode').hover(getIn,getOut);
	function getIn(){
		$(".designModeOut").switchClass('designModeOut', 'designModeIn', 500);
	}
	function getOut(){
		$(".designModeIn").switchClass('designModeIn', 'designModeOut', 500);
	}
}

// ANIMACIÓN INICIO
function homeAnimation() {
	//alert('homeAnimation');
	wW=$(window).width();
	articleW=$('article').width();
	var freeWidth=wW-(articleW+16);
	//TODO do this by config in case courtains not needed in home
	//var wantedSideW=wW*0.19;
	var wantedSideW=0;
	var neededFreeW=wantedSideW*2;
	var availableSideW=freeWidth/2;
	var minSideW=127;
	//window.status=$(window).width()+'x'+$(window).height()+' '+availableSideW;
	if(neededFreeW>freeWidth){
		availableSideW=freeWidth/2;

		if(availableSideW>minSideW){
			headerW=availableSideW;
			navW=availableSideW;
		} else {
			if(freeWidth>minSideW){
				headerW=freeWidth;
				navW=0;
			} else {
				headerW=0;
				navW=0;
			}
		}
	} else {
		headerW=wantedSideW;
		navW=wantedSideW;
	}
	//$("body.home article>h1").detach().prependTo(".nav");
	/*$("courtainL").addClass('start');
	$("courtainR").addClass('start');*/
	//$("article").addClass('start');//ie7
	//$("footer").addClass('start');
	//alert('inicio: '+$('inicio').css());
	$('inicio').alignWith('body','b',{appendToBody:true});
	$("courtainR").delay(2300).animate( { width:headerW+"px" } , 700 , "swing");
	$("courtainL").delay(2300).animate( { width:navW+"px" } , 700 , "swing", function() {
			layout();
		});
	//if($("article").css('opacity')=='0'){
		//$("body.home article").delay(2500).animate( { opacity:'1' } , 700 ,"swing");//.addClass('start');//ie7
	//}
	$("inicio").delay(1500).animate( { opacity:'0' } , 700 ,"swing");
	//$("body.home article").delay(2500).removeClass('start');//ie7
}

/*
TOC (tabla de contenidos lateral para elementos h2 de la página)
*/
function getEspectaculosTOC() {
	if ( $("article h2.tocdownloads").length>= 1) {
		$("nav").prepend('<div class="article-toc downloadstoc"><p>Descargas:</p><ul></ul></div>');
	}
	if ( $("article h2.toctxt").length>= 1) {
		$("nav").prepend('<div class="article-toc txttoc"><ul></ul></div>');
	}
	if ( $("article h2.tocimg").length>= 1) {
		$("nav").prepend('<div class="article-toc imgtoc"><ul></ul></div>');
	}
	var selectedTab='';
	var dli=0;
	var ti=0;
	var ii=0;
	//Patrocinadores
	$('div.patrocinadores').detach().appendTo('nav');
	$("article h2").each(function(i) {
		var tab;
		var aId='';
		var current = $(this);
		var toctype='';
		if(current.hasClass('tocdownloads')){
			dli++;
			/*toctype='tocdownloads';
			current.addClass("toc-downloads-title");
			current.addClass("toc-downloads-title-" + dli);
			aId='H2downloadsTOC' + dli;
			current.nextUntil("h2").andSelf().wrapAll('<div id="'+aId+'" class="tab downloadstab downloadstab'+ dli +'" />');
			toc=".article-toc.downloadstoc>ul";
			toclink='<li>'+'<a href="#'+ aId +'">'+current.text()+'</a></li>';*/
			//TODO toclink = link clone && remove tab && no tabaction
			current.nextUntil("h2").andSelf().detach();//.css('display','none');
			toc=".article-toc.downloadstoc>ul";
			//current.clone().appendTo(toc);
			//toclink='<li>'+'<a href="'+ current.find('a').attr('href') +'" title="'+ current.find('a').attr('title') +'">'+current.text()+'</a></li>';
			//$(toc).append(toclink);
			current.children('a').clone().appendTo(toc).wrapAll('<li/>');
			return;
		}
		if(current.hasClass('toctxt')){
			ti++;
			toctype='toctxt';
			current.addClass("toc-title");
			current.addClass("toc-title" + ti);
			aId='H2TOC' + ti;
			current.nextUntil("h2").andSelf().wrapAll('<div id="'+aId+'" class="tab tab'+ ti +'" />');
			toc=".article-toc.txttoc>ul";
			toclink='<li>'+'<a href="#'+ aId +'">'+current.text()+'</a></li>';
		}
		if(current.hasClass('tocimg')){
			ii++;
			toctype='tocimg';
			current.addClass("toc-img-title");
			current.addClass("toc-img-title-" + ii);
			aId='H2imgTOC' + ii;
			current.nextUntil("h2").andSelf().wrapAll('<div id="'+aId+'" class="tab imgtab imgtab'+ ii +'" />');
			toc=".article-toc.imgtoc>ul";
			toclink='<li>'+'<a href="#'+ aId +'"></a></li>';
		}
		if(toctype=='') return;
		tab = current.parent();
		if(i==0){
			tab.addClass('selected');
			selectedTab=tab;
		}
		$(toc).append(toclink);
		if(toctype=='tocimg'){
			//tab.find('img:first').clone().removeAttr("width").removeAttr("height").css('width','56px').css('height','auto').appendTo(".article-toc.imgtoc>ul>li a:last");
			//TODO Only gallery should open gallery, not all images (or not))
			tab.find('img:first').clone().removeAttr("width").removeAttr("height").css('height','56px').css('width','auto').appendTo(".article-toc.imgtoc>ul>li a:last").bind('click', function() {
				$('.colorboxPhotoGallery-Item:first').click();
			});
		}
		$(toc+">li:last").click(function(event){

			event.preventDefault();
			$(this).addClass('selected');
			if(tab.hasClass('selected')){
				return false;
			}
			tab.detach();
			$(window).scrollTop(0);
			tab.insertBefore(selectedTab);
			tab.addClass('selected');
			selectedTab.removeClass('selected');
			selectedTab=tab;
			$('article').scrollTop(0);
		}).mouseover(function(event){
			event.preventDefault();
			$(this).addClass('selected');
		}).mouseout(function(event){
			event.preventDefault();
			$(this).removeClass('selected');
		});
		$(toc+">li:last").click(function(event){
			event.preventDefault();
		});
	});
}

function getH2TOC() {
	if ( $("article h2.toctxt").length>= 1) {
		//$("article").append('<div class="article-toc txttoc"><ul></ul></div>');
		//$('body').append('<div class="article-toc txttoc"><ul></ul></div>');
		//$(".article-toc.txttoc").offset({top:tocY, left:tocX});
		//$("article").prepend('<div class="article-toc txttoc"><ul></ul></div>');
		//$("nav").empty();
		$("nav").prepend('<div class="article-toc txttoc"><ul></ul></div>');
		//var selectedTab='';
		$("article h2.toctxt").each(function(i) {
			var current = $(this);
			//current.attr("id", "title" + i);
			current.addClass("toc-title");
			current.addClass("toc-title" + i);
			//var ic= i>5 ? 0 : i;
			//var ic= i>5 ? 0 : i;
			var aId='H2TOC' + i;
			current.nextUntil("h2").andSelf().wrapAll('<div id="'+aId+'" class="tab tab'+ i +'" />');
			var tab = current.parent();
			if(i==0){
				tab.addClass('selected');
				//selectedTab=tab;
			}
			$(".article-toc.txttoc>ul").append('<li>'+'<a href="#'+ aId +'">'+current.text()+'</a></li>');
			$(".article-toc.txttoc>ul>li:last").mouseover(function(event){
				event.preventDefault();
				$(this).addClass('selected');
				if(tab.hasClass('selected')){
					return false;
				}
				/*tab.detach();
				tab.insertBefore(selectedTab);
				tab.addClass('selected');
				selectedTab.removeClass('selected');
				//alert('tab: '+tab+' old-selectedTab: '+selectedTab+' was selected: '+tab.hasClass('selected'));
				selectedTab=tab;*/

				tab.detach();
				var selectedTab=$("article .tab").filter('.selected');
				//var nsel=$("article .tab").filter('.selected').size();
				//alert(nsel);
				tab.insertBefore(selectedTab);
				selectedTab.removeClass('selected');
				tab.addClass('selected');
				$(window).scrollTop(0);
			}).mouseout(function(event){
				event.preventDefault();
				$(this).removeClass('selected');
			});
		});
	}
}

function getEventsTOC() {

	if ( $("article div.event").length>= 1) {
		$("nav").append('<div class="article-toc event-toc"><p><span class="programacion">Programación</span> / <span class="curso">Cursos</span></p><ul></ul></div>');
		//var selectedTab='';
		$("article div.event").each(function(i) {
			var current = $(this);
			//current.attr("id", "title" + i);
			current.addClass("toc-event");
			current.addClass("toc-event" + i);
			//var ic= i>5 ? 0 : i;
			//var ic= i>5 ? 0 : i;
			var aId='toc-event-' + i;
			//current.nextUntil("h2").andSelf().wrapAll('<div id="'+aId+'" class="tab event-tab-'+ i +'" />');
			//current.wrapAll('<div id="'+aId+'" class="tab event-tab-'+ i +'" />');
			current.attr('id',aId).addClass('tab event-tab-'+ i);
			//var tab = current.parent();
			var tab = current;
			/*if(i==0){
				tab.addClass('selected');
				selectedTab=tab;
			}*/


			$(".article-toc.event-toc>ul").append('<li>'+'<a href="#'+ aId +'">'+current.find('h3').text()+'</a></li>');
			var eventClasses=current.attr('class').replace("event ", "");
			$(".article-toc.event-toc>ul>li:last").addClass(eventClasses);
			$(".article-toc.event-toc>ul>li:last").mouseover(function(event){
				event.preventDefault();
				$(this).addClass('selected');
				if(tab.hasClass('selected')){
					return false;
				}
				tab.detach();
				var selectedTab=$("article .tab").filter('.selected');
				//alert($("article .tab").lenght)
				tab.insertBefore(selectedTab);
				selectedTab.removeClass('selected');
				tab.addClass('selected');
				//alert('tab: '+tab+' old-selectedTab: '+selectedTab+' was selected: '+tab.hasClass('selected'));
				//selectedTab=tab;
				$(window).scrollTop(0);
			}).mouseout(function(event){
				event.preventDefault();
				$(this).removeClass('selected');
			});
			tab.detach();
			tab.appendTo($("article .contenidos"));
		});
		$("article>div.eventList").remove();
	}
}

function getFuncionesTOC() {
	//alert('getFuncionesTOC');
	if ( $(".cartelFuncion").length>= 1) {
		//alert('getFuncionesTOC');
		$("article").append('<div id="article-toc"><ul></ul></div>');
		var selectedTab='';
		$(".cartelFuncion").each(function(i) {
			var current = $(this);
			//current.attr("id", "title" + i);
			//var ic= i>5 ? 0 : i;
			//var ic= i>5 ? 0 : i;
			var aId='funcion' + i;
			current.nextUntil("cartelFuncion").andSelf().wrapAll('<div id="'+aId+'" class="tab tab'+ i +'" />');
			var tab = current.parent();
			if(i==0){
				tab.addClass('selected');
				selectedTab=tab;
				tab.detach();
				tab.prependTo($(".cartelOn"));
			}
			//var datos=current.children(".cartela").children().not("h2").text();
			var datos=current.children(".cartela").children().not("h2").html();
			//alert('datos: '+datos);
			var funcion=current.children(".cartela").children("h2").text();
			$("#article-toc>ul").append('<li>'+'<a href="#'+ aId +'">'+funcion+'</a><br/>'+datos+'</li>');
			//$("#article-toc>ul").append('<li>'+'<a href="#'+ aId +'">'+funcion+'</a><br/></li>');
			$("#article-toc>ul>li:last").mouseover(function(event){
				event.preventDefault();
				$(this).addClass('selected');
				if(tab.hasClass('selected')){
					return false;
				}
				tab.detach();
				//tab.insertBefore($(".cartelOn"));
				tab.prependTo($(".cartelOn"));
				tab.addClass('selected');
				//var ntH=tab.outerHeight(true);
				selectedTab.removeClass('selected');
				selectedTab=tab;
				//$(window).scrollTop(0);
			}).mouseout(function(event){
				event.preventDefault();
				$(this).removeClass('selected');
			});
		});
	}
}
function getClickH2TOC() {
	if ( $("article>h2").length>= 1) {
		$(".nav.left").append('<div id="toc"><p>En esta página:</p><br/></div>');
		var selectedTab='';
		$("article>h2").each(function(i) {
			var current = $(this);
			current.attr("id", "title" + i);
			var ic= i>5 ? 0 : i;
			current.nextUntil("h2").andSelf().wrapAll('<div class="tab '+ i +'" />');
			var tab = current.parent();
			if(i==0){
				tab.addClass('selected');
				selectedTab=tab;
			}
			$("#toc").append(current.clone());
			$("#toc>h2:last").click(function(event){
				event.preventDefault();
				if(tab.hasClass('selected')){return false;}
				var ntH=tab.outerHeight(true);
				tab.detach();
				tab.insertBefore(selectedTab);
				tab.addClass('selected');
				selectedTab.removeClass('selected');
				selectedTab=tab;
				$(window).scrollTop(0);
			});
		});
	}
}
function getImgTOC() {
	if ( $("article div>p.over a").length>= 1) {
		$(".nav.left").append('<div id="toc"><p>Desde esta página:</p><br/></div>');
		$("article div>p.over").each(function(i) {
			var current = $(this);
			var tocItem=current.children('a').clone();
			$("#toc").append(tocItem).append('<br />');
			$("#toc>a:last").hover(
				function () {
					current.css('display','block');
				},
				function () {
					current.css('display','none');
				}
			);
		});
	}
}
function getImgTOC2() {
	if ( $("article div>p.over a").length>= 1) {
		$(".nav.left").append('<div id="toc"><p>Desde esta página:</p><br/></div>');
		var selectedTab='';
		$("article div>p.over").each(function(i) {
			var current = $(this);
			var tocItem=current.children('a').clone();
			var tab = current.parent();
			if(i==0){
				tab.addClass('selected');
				selectedTab=tab;
			}
			$("#toc").append(tocItem).append('<br />');
			/*$("#toc>a:last").hover(
				function () {
					current.css('display','block');
				},
				function () {
					current.css('display','none');
				}
			);*/
			$("#toc>a:last").hover(
				function () {
					current.css('display','block');
					//alert(tab);
					if(tab.hasClass('selected')){
						return false;
					}
					tab.detach();
					tab.insertBefore(selectedTab);
					tab.addClass('selected');
					selectedTab.removeClass('selected');
					selectedTab=tab;
					$(window).scrollTop(0);
				},
				function () {
					current.css('display','none');
				}
			);
			/*$("#toc>a:last").mouseover(function(event){
				event.preventDefault();
				if(tab.hasClass('selected')){
					return false;
				}
				//var ntH=tab.outerHeight(true);
				tab.detach();
				tab.insertBefore(selectedTab);
				tab.addClass('selected');
				selectedTab.removeClass('selected');
				selectedTab=tab;
				current.css('display','block');
			});
			$("#toc>a:last").mouseout(function(event){
				event.preventDefault();
				current.css('display','none');
			});*/
		});
	}
}

// Choose what toc to use acording to uri / section


/*function movePhone(){
	wH=$(window).height();
	iy=$('div.contactWrapper').offset().top;
	ny=wH-(68+$('div.contactWrapper').height());
	d=ny-iy;
	$('div.contactWrapper').animate({
    top: '+='+d
  }, 1000, function() {
    // Animation complete.
  });

	//$('div.contactWrapper').animate({bottom: '=' + 84 + 'px'}, 2000, 'swing');
	//$('div.contactWrapper').css('display','none');
}*/


//Add event color to calendar
function calendarEventsColors(){
	var eventTags=['curso', 'programacion'];
	var properties=['background-color', 'background-color'];
	var values=['#7E7FB8', '#9B9A61'];
	//var properties=['background-color', 'border'];
	//var values=['#7E7FB8', '#9B9A61 dotted 1px'];
	target=$(".date_has_event");
	for (var i = 0; i < eventTags.length; i++){
		var tag=eventTags[i];
		var prop=properties[i];
		var val=values[i];
		target.has("li."+tag).each(function(){
			current=$(this);
			current.css(prop,val);
			current.parent().addClass(tag);
			//TODO if it has more than one class ?
		});
	}
}


/* CALENDAR  */
$(function () {
	$('.date_has_event').each(function () {
		var distance = 10;
		var time = 0;
		var timeout = 0;
		var hideDelay = 0;
		var hideDelayTimer = null;
		var beingShown = false;
		var shown = false;
		var trigger = $(this);
		//var popup = $('.events ul', this).css('opacity', 0);
		var popup = $('.events ul', this).css('display', 'none');
		//trigger.click(function(){alert('hi '+$(this).html())});
		$([trigger.get(0), popup.get(0)]).mouseover(function () {
		//alert($(this));
		//$(this).mouseover(function () {
			//alert($(this).hasClass('date_has_event'));
			//alert($(this).text());
			if (hideDelayTimer) clearTimeout(hideDelayTimer);
			if (beingShown || shown) {
				return;
			} else {
				beingShown = true;
				popup.css({
					position:'relative',
					top: 20,
					left: -604,
					"z-index":10000,
					display: 'block'
				})
				/*.animate({
					bottom: '+=' + distance + 'px',
					opacity: 1
				}, time, 'swing', function() {

				});*/

				beingShown = false;
				shown = true;
			}
		}).mouseout(function () {
			if (hideDelayTimer) clearTimeout(hideDelayTimer);
			hideDelayTimer = setTimeout(function () {
				hideDelayTimer = null;
				/*popup.animate({
					bottom: '-=' + distance + 'px',
					opacity: 0
				}, timeout, 'swing', function () {

					popup.css('display', 'none');
				});*/
				popup.css({
					top: 0,
					left: 0,
					"z-index":10000,
					display: 'none'
				});
				shown = false;
			}, hideDelay);
		});
	});
});

/* 	xBreadcrumbs (Extended Breadcrums) jQuery Plugin
	2009 ajaxBlender.com
	For any questions please visit www.ajaxblender.com
	or email us at support@ajaxblender.com
*/

;(function($){
	/*  Variables  */
	$.fn.xBreadcrumbs = function(settings){
		var element = $(this);
		var

		settings = $.extend({}, $.fn.xBreadcrumbs.defaults, settings);

		function _build(){
			if(settings.collapsible){
				var sz = element.children('LI').length;
				element.children('LI').children('A').css('white-space', 'nowrap').css('float', 'left');
				element.children('LI').children('A').each(function(i, el){
					if(i != sz - 1){
						$(this).css('overflow', 'hidden');
						$(this).attr('init-width', $(this).width());
						$(this).width(settings.collapsedWidth);
					}
				});
			}

            element.children('LI').mouseenter(function(){
                if($(this).hasClass('hover')){ return; }

            	_hideAllSubLevels();
            	if(!_subLevelExists($(this))){ return; }

            	// Show sub-level
            	var subLevel = $(this).children('UL');
            	_showHideSubLevel(subLevel, true);

            	if(settings.collapsible && !$(this).hasClass('current')){
            		var initWidth = $(this).children('A').attr('init-width');
            		$(this).children('A').animate({width: initWidth}, 'normal');
            	}
            });

            element.children('LI').mouseleave(function(){
                var subLevel = $(this).children('UL');
                _showHideSubLevel(subLevel, false);

                if(settings.collapsible && !$(this).hasClass('current')){
                	$(this).children('A').animate({width: settings.collapsedWidth}, 'fast');
                }
            });
		};

		function _hideAllSubLevels(){
			element.children('LI').children('UL').each(function(){
                $(this).hide();
                $(this).parent().removeClass('hover');
			});
		};

		function _showHideSubLevel(subLevel, isShow){
			if(isShow){
                subLevel.parent().addClass('hover');
                if($.browser.msie){
                	var pos = subLevel.parent().position();
                	subLevel.css('left', parseInt(pos['left']));
                }
				if(settings.showSpeed != ''){ subLevel.fadeIn( settings.showSpeed ); }
				else { subLevel.show(); }
			} else {
                subLevel.parent().removeClass('hover');
                if(settings.hideSpeed != ''){ subLevel.fadeOut( settings.hideSpeed ); }
                else { subLevel.hide(); }
			}
		};

		function _subLevelExists(obj){
			return obj.children('UL').length > 0;
		};

		//    Entry point
		_build();
	};

	/*  Default Settings  */
	$.fn.xBreadcrumbs.defaults = {
		showSpeed:        'fast',
		hideSpeed:        '',
		collapsible:      false,
		collapsedWidth:   10
	};
})(jQuery);

//TODO Breadcrumbs detach and position elsewhere according to settings (if not done with php template parts how to know where? =>additional class on body?)

// mainMenu width and paddings to fit article width

function spreadMainMenu() {
	var wW=$(window).width();
	var articleW=$('article').width();
	var liMargin=$('#mainMenu>li').css('margin-left').replace("px", "");
	var liPadding=$('#mainMenu>li').css('padding-left').replace("px", "");
	var el = $("#mainMenu li").length;
	var ex=el-1;
	var totalPadding=el*2*liPadding;
	var totalMargin=liMargin*2*ex;
	var lisW = 0;
	$('#mainMenu>li').each(function() {
		lisW += $(this).width();
	});
	var mainMenuW=lisW+totalMargin;
	var delta= mainMenuW<articleW ? 1 : -1 ;
	if(mainMenuW==articleW){
	 return false;
	}
	if(delta==-1){
	 return false;
	}
	var ulLiW=mainMenuW-totalMargin;
	dlimargin=((articleW-ulLiW)-totalPadding)/(2*ex);
	dlipadding=((articleW-ulLiW)-totalMargin)/(2*el);
	$('.mainMenu li').css('padding-left',dlipadding+'px').css('padding-right',dlipadding+'px');
	//For hover anim effect
	$('.mainMenu li:not(.accordionOpen)').hover(
	function () {
		$(this).animate({ backgroundColor: "#414141" }, "slow");
	},
	function () {
		$(this).animate({ backgroundColor: "#999999" }, "slow");
	});
}

 /*scrollbarPaper @author Henri MEDOT @version last revision 2009-12-01 */
/*$.fn.extend({
  scrollbarPaper: function() {
	//TODO custom bar lenght, custom position, moving content not by scrollTop, but jquery animation
    this.each(function(i) {
      var $this = $(this);
      //alert($this);
      //$('body').css('overflow','hidden');
      var paper = $this.data('paper');
      if (paper == null) {

        var barWidth = function() {
          var div = $('<div style="width:50px;height:50px;overflow:hidden;position:absolute;top:-200px;left:-200px;"><div style="height:100px;"></div></div>');
          $('body').append(div);
          var w1 = $('div', div).innerWidth();
          div.css('overflow-y', 'scroll');
          var w2 = $('div', div).innerWidth();
          div.remove();
          return Math.max(w1 - w2, 17);
        }.call();
        //TODO fixed-width to .articleScrolable
        //$('.articleScrolable').css('width',wW=$(window).width()-barWidth+'px');
		var scrollParent= $('body');
        scrollParent.append('<div class="scrollbarpaper-container" style="width:' + barWidth + 'px"><div class="scrollbarpaper-track"><div class="scrollbarpaper-drag"><div class="scrollbarpaper-drag-top"></div><div class="scrollbarpaper-drag-bottom"></div></div></div></div>');
        paper = $('.scrollbarpaper-container');
        $this.append('<div class="scrollbarpaper-clearer" style="clear:both;"></div>');
        var content = $('> :first', $this);
        //content.css('overflow', 'hidden');

        $this.data('barWidth',   barWidth);
        $this.data('paper',      paper);
        $this.data('track',      $('.scrollbarpaper-track', paper));
        $this.data('drag',       $('.scrollbarpaper-drag', paper));
        $this.data('dragTop',    $('.scrollbarpaper-drag-top', paper));
        $this.data('dragBottom', $('.scrollbarpaper-drag-bottom', paper));
        $this.data('content',    content);
        $this.data('clearer',    $('> :last', $this));
        paper.hide();
      }

      var barWidth =   $this.data('barWidth');
      var track =      $this.data('track');
      var drag =       $this.data('drag');
      var dragTop =    $this.data('dragTop');
      var dragBottom = $this.data('dragBottom');
      var content =    $this.data('content');
      var clearer =    $this.data('clearer');

      var contentHeight = clearer.position().top - content.position().top;
      $this.data('height', $this.height());
      $this.data('contentHeight', contentHeight);
      $this.data('offset', $this.offset());

      $this.unbind();
      var ratio = $this.height() / contentHeight;
      //alert(paper)
      if (ratio < 1) {

        paper.show();
        //alert('paPerShouldShow');
        content.addClass('scrollbarpaper-visible');
        //$this.css("margin-right", barWidth+"px");
        //content.css("padding-left", barWidth+"px");
        //content.width($this.width() - content.innerWidth() + content.width() - barWidth);
        //content.width($this.width() - content.innerWidth() + content.width() );
        paper.height($this.height());
        var offset = $this.offset();
        paper.css('left', (offset.left + $this.innerWidth() - paper.width()) + 'px').css('top', offset.top);
		//paper.css('right','0px');
		//paper.css('top','0px');
        var dragHeight = Math.max(Math.round($this.height() * ratio), dragTop.height() + dragBottom.height());
        //alert(dragHeight);
        drag.height(dragHeight);
        var updateDragTop = function() {
          drag.css('top', Math.min(Math.round($this.scrollTop() * ratio), $this.height() - dragHeight) + 'px');
        };
        updateDragTop();
		//alert(drag.css('top'));
        $this.scroll(function(event) {
          updateDragTop();
        });

        var unbindMousemove = function() {
          $('html').unbind('mousemove.scrollbarpaper');
        };
        drag.mousedown(function(event) {
          unbindMousemove();
          var offsetTop = event.pageY - drag.offset().top;
          $('html').bind('mousemove.scrollbarpaper', function(event) {
            $this.scrollTop((event.pageY - $this.offset().top - offsetTop) / ratio);
			//$this.animate({scrollTop: (event.pageY - $this.offset().top - offsetTop) / ratio}, 400);

            return false;
          }).mouseup(unbindMousemove);
          return false;
        });
      }
      else {
        $this.unbind();
        paper.hide();
        //alert('paPerShouldHide');
        content.removeClass('scrollbarpaper-visible');
        //content.width($this.width() - content.innerWidth() + content.width());
        //content.css("padding-left", "0px");
      }

      var setTimeout = function() {
        window.setTimeout(function() {
          var offset = $this.offset();
          var dataOffset = $this.data('offset');
          var contentH=clearer.position().top - content.position().top;
          //TODO see why scrollBarPaper fails
          //var msg=$this.height()+' >=::=< '+$this.data('height');
          //msg=msg+'<br/>'+($this.height() == $this.data('height'));
          //alert(msg);
          if (($this.height() != $this.data('height'))
           || (contentH != $this.data('contentHeight'))
           || (offset.top != dataOffset.top)
           || (offset.left != dataOffset.left)) {
           //alert('somethingChanged');
            $this.scrollbarPaper();

            var availableH=$this.height();

            if(contentH>availableH){
				//alert("height has changed ! "+contentH+' / '+availableH);
				//$this.css("margin-right", scrollWidth+"px");
            } else {
				//$this.css("margin-right", scrollWidth+"px");
            }

          }
          else {
            setTimeout();
          }
        }, 200);
      };
      setTimeout();
    });
  }
});*/
$.fn.extend({
  scrollbarPaper: function() {
    this.each(function(i) {
      var $this = $(this);
      var paper = $this.data('paper');
      if (paper == null) {

        var barWidth = function() {
          var div = $('<div style="width:50px;height:50px;overflow:hidden;position:absolute;top:-200px;left:-200px;"><div style="height:100px;"></div></div>');
          $('body').append(div);
          var w1 = $('div', div).innerWidth();
          div.css('overflow-y', 'scroll');
          var w2 = $('div', div).innerWidth();
          div.remove();
          return Math.max(w1 - w2, 17);
        }.call();

        $this.before('<div class="scrollbarpaper-container" style="width:' + barWidth + 'px"><div class="scrollbarpaper-track"><div class="scrollbarpaper-drag"><div class="scrollbarpaper-drag-top"></div><div class="scrollbarpaper-drag-bottom"></div></div></div></div>');
        paper = $this.prev();
        $this.append('<div style="clear:both;"></div>');
        var content = $('> :first', $this);
        content.css('overflow', 'hidden');

        $this.data('barWidth',   barWidth);
        $this.data('paper',      paper);
        $this.data('track',      $('.scrollbarpaper-track', paper));
        $this.data('drag',       $('.scrollbarpaper-drag', paper));
        $this.data('dragTop',    $('.scrollbarpaper-drag-top', paper));
        $this.data('dragBottom', $('.scrollbarpaper-drag-bottom', paper));
        $this.data('content',    content);
        $this.data('clearer',    $('> :last', $this));
        paper.hide();
      }

      var barWidth =   $this.data('barWidth');
      var track =      $this.data('track');
      var drag =       $this.data('drag');
      var dragTop =    $this.data('dragTop');
      var dragBottom = $this.data('dragBottom');
      var content =    $this.data('content');
      var clearer =    $this.data('clearer');

      var contentHeight = clearer.position().top - content.position().top;
      $this.data('height', $this.height());
      $this.data('contentHeight', contentHeight);
      $this.data('offset', $this.offset());

      $this.unbind();
      var ratio = $this.height() / contentHeight;
      if (ratio < 1) {

        paper.show();
        content.addClass('scrollbarpaper-visible');
        content.width($this.width() - content.innerWidth() + content.width() - barWidth);
        paper.height($this.height());
        var offset = $this.offset();
        paper.css('left', (offset.left + $this.innerWidth() - paper.width()) + 'px').css('top', offset.top);

        var dragHeight = Math.max(Math.round($this.height() * ratio), dragTop.height() + dragBottom.height());
        drag.height(dragHeight);
        var updateDragTop = function() {
          drag.css('top', Math.min(Math.round($this.scrollTop() * ratio), $this.height() - dragHeight) + 'px');
        };
        updateDragTop();

        $this.scroll(function(event) {
          updateDragTop();
        });

        var unbindMousemove = function() {
          $('html').unbind('mousemove.scrollbarpaper');
        };
        drag.mousedown(function(event) {
          unbindMousemove();
          var offsetTop = event.pageY - drag.offset().top;
          $('html').bind('mousemove.scrollbarpaper', function(event) {
            $this.scrollTop((event.pageY - $this.offset().top - offsetTop) / ratio);
            return false;
          }).mouseup(unbindMousemove);
          return false;
        });
      }
      else {
        $this.unbind();
        paper.hide();
        content.removeClass('scrollbarpaper-visible');
        content.width($this.width() - content.innerWidth() + content.width());
      }

      var setTimeout = function() {
        window.setTimeout(function() {
          var offset = $this.offset();
          var dataOffset = $this.data('offset');
          if (($this.height() != $this.data('height'))
           || (clearer.position().top - content.position().top != $this.data('contentHeight'))
           || (offset.top != dataOffset.top)
           || (offset.left != dataOffset.left)) {
            $this.scrollbarPaper();
          }
          else {
            setTimeout();
          }
        }, 200);
      };
      setTimeout();
    });
  }
});

/*
 * jQuery alignWith plug-in v1.0.2
 * Align two or more elements with each other
 *
 * @requires jQuery v1.2 or later
 *
 * Copyright (c) 2009 Gilmore Davidson
 *
 * Licensed under the MIT license:
 *   http://www.opensource.org/licenses/mit-license.php
 */
(function(a){a.fn.extend({alignWith:function(e,l,q){e=a(e);var o=e.offset(),c=o.left,r=o.top,d=e.outerWidth(),m=e.outerHeight(),g="",b="",k=[],n=/^([tbcm]{2}|lr|rl)$/i,j=/^r?[rtbcm]r?$/i,h=/^([lrcm]{2}|tb|bt)$/i,p=/^b?[lrbcm]b?$/i,f={position:"absolute",left:c,top:r},i={x:0,y:0,appendToBody:false};if(undefined!==q){a.extend(i,q)}if(!/^[tblrcm]{1,4}$/.test(l)){l="c"}k=l.split("");switch(k.length){case 1:g=b=""+l+l;break;case 2:g=b=l;break;case 3:g=""+k[0]+k[1];b=""+k[2]+k[2];break;case 4:g=""+k[0]+k[1];b=""+k[2]+k[3];break}return this.each(function(){var v=a(this),s=c,x=r,u=v.outerWidth(),w=v.outerHeight();if(n.test(g)){s-=(u/2)}else{if(j.test(g)){s-=u}}if(n.test(b)){s+=(d/2)}else{if(j.test(b)){s+=d}}if(h.test(g)){x-=(w/2)}else{if(p.test(g)){x-=w}}if(h.test(b)){x+=(m/2)}else{if(p.test(b)){x+=m}}s-=parseInt(v.css("margin-left"),10)||0;x-=parseInt(v.css("margin-top"),10)||0;if(0!==i.x){s+=parseInt(i.x,10)}if(0!==i.y){x+=parseInt(i.y,10)}f.left=s;f.top=x;v.css(f);if(i.appendToBody){v.appendTo("body")}})}})})(jQuery);

//TODO Add conditions, as URL and window dimensions
// Add resizing behaviors (stretch, etc)
layoutAlignConfig=[];
layoutCssConfig=[];
//var wwH=$(window).height();
//var contentAvailableH=wwH*.8;
function layout() {

	//var layoutAlignConfig=[];
	//var layoutCssConfig=[];
	var alayout='default';
	wW=$(window).width();
	wH=$(window).height();
	articleW=780;//$('article').width();
	wantedSideW=122;
	neededOptimalW=articleW+wantedSideW*2;
	neededMinW=articleW+wantedSideW;
	freeWidth=wW-(articleW+16);availableSideW=freeWidth/2;
	contentAvailableH=Math.floor(wH*.74);
	layoutCssConfig.push(['default','','.contenidos',{'height':contentAvailableH+'px'}]);
	//alert('contentAvailableH: '+wH);
	if(wW>=neededOptimalW){
		//back to defaults
		alayout='default';
//         var barWidth = function() {
//           var div = $('<div style="width:50px;height:50px;overflow:hidden;position:absolute;top:-200px;left:-200px;"><div style="height:100px;"></div></div>');
//           $('body').append(div);
//           var w1 = $('div', div).innerWidth();
//           div.css('overflow-y', 'scroll');
//           var w2 = $('div', div).innerWidth();
//           div.remove();
//           alert(Math.max(w1 - w2, 17));
//           return Math.max(w1 - w2, 17);
//         }.call();
        var barWidth=18;
        //TODO fixed-width to .articleScrolable
        //$('.articleScrolable').css('width',wW-barWidth+'px');
        //$('article').css('padding-left',((barWidth/2)+4)+'px');
		/*
		$('nav').css({'position':'fixed'});*/
	} else {
		//push all left
		//show toc menu and make contents visible one by one
		alayout='left';
		if(wW<=neededMinW){
			//hide toc menu and make all contents visible at once
			alayout='left min';
			//alert($('.tab:first').text());
		} /*else {

			layout='left';
		}*/
	}
	layoutAligns(alayout);
	layoutCss(alayout);
	//window.status=$(window).width()+'x'+$(window).height()+' '+alayout;
	//layoutAligns(layoutAlignConfig);
	//layoutCss(layoutCssConfig);
	/*if(neededFreeW>freeWidth){
		if(availableSideW>=minSideW){
			$('nav').css('width',availableSideW+'px');
			$('footer').css('margin-left','auto').css('right','0px').css('left','0px');
			$('article').css('margin-left','auto');
			$('nav').css('display','block');
			$('.mainMenu').show();
		} else {
			if(freeWidth>minSideW){
				$('footer').css('left','8px').css('right','auto').css('margin-left','0px');
				//exTODO shrink contenidos and remove former line
				$('.contenidos').css('width','64%');
			} else {
				$('footer').css('left','8px').css('right','auto').css('margin-left','0px');
				$('header').css('left','8px').css('right','auto').css('margin-left','0px');
				$('article').css('left','0px').css('margin-left','0px');
				$('.contenidos').css('width','50%');
			}
		}
	} else {
		$('nav').css('display','block');
		$('nav').css('width',availableSideW+'px');
		$('footer').css('margin-left','auto').css('right','0px').css('left','0px');
		$('header').css('margin-left','auto').css('right','0px').css('left','0px');
		$('article').css('margin-left','auto');
	}*/
}



function layoutAligns(alayout){
	for ( i=0; i < layoutAlignConfig.length; i++ )
	{
		var lo=layoutAlignConfig[i][0];
		//alert(layoutAlignConfig[i].toString());
		//if(layoutAlignConfig[i][2]=='.contactWrapper') alert(layoutAlignConfig[i][2]+' --layout: '+alayout+' -lOption: '+lo+' -isInString: '+lo.indexOf(alayout));
		if(lo=='default' || alayout.indexOf(lo)!=-1){
			//if(layoutAlignConfig[i][2]=='nav') alert(layoutAlignConfig[i].toString())
			doAlign(layoutAlignConfig[i]);
		}
	}
}
function layoutCss(alayout){
	for ( i=0; i < layoutCssConfig.length; i++ )
	{
		var lo=layoutCssConfig[i][0];
		//alert(layoutCssConfig[i][2]+' --layout: '+alayout+' -lOption: '+lo+' -isInString: '+lo.indexOf(alayout));
		if(lo=='default' || alayout.indexOf(lo)!=-1){
			doCss(layoutCssConfig[i]);
		}
	}
}
function doAlign(alignOptions){

	if(alignOptions[1]=='' || window.location.pathname.indexOf(alignOptions[1])!=-1){
		//alert(alignOptions.toString());
		$(alignOptions[2]).alignWith(alignOptions[3], alignOptions[4], alignOptions[5]);
	}
}
function doCss(cssOptions){
	if(cssOptions[1]=='' || window.location.pathname.indexOf(cssOptions[1])!=-1){
		//if(cssOptions[2]=='.tab') alert('before: '+$(cssOptions[2]).css('display'));
		$(cssOptions[2]).css(cssOptions[3]);
		//if(cssOptions[2]=='.tab') alert('after: '+$(cssOptions[2]).css('display'));
	}
}
/*---------------------------------------LAYOUT CONFIG----------------------------*/
//default
layoutAlignConfig.push(['default','contacto','.contactWrapper','body','b',{y:-134,appendToBody:true}]);
layoutAlignConfig.push(['default','a-la-carta','.alacartaCarta','body','bl',{y:-40,x:-60,appendToBody:true}]);
layoutAlignConfig.push(['default','trayectoria','.trayectoria-fondo','body','b',{appendToBody:true}]);
layoutAlignConfig.push(['default','trayectoria','.trayectoria-anim','.trayectoria-fondo','tr',{appendToBody:true}]);
layoutAlignConfig.push(['default','','inicio','body','b',{appendToBody:true}]);
//layoutAlignConfig.push(['default','','article','.mainMenu li:first','l']);
//layoutCssConfig.push(['default','','article',{'margin-left':'auto'}]);

layoutAlignConfig.push(['default','','nav','.mainMenu li:last','tltr',{y:36}]);
layoutAlignConfig.push(['default','espectaculos','nav','.mainMenu li:last','tltr',{x:-44,y:36}]);
layoutCssConfig.push(['default','','nav',{'position':'fixed','display':'block'}]);
layoutCssConfig.push(['default','','header',{'text-align':'center','margin-left':'auto'}]);
layoutCssConfig.push(['default','','footer',{'right':'0px'}]);

layoutAlignConfig.push(['default','','.event_calendar','nav','tl',{appendToBody:true}]);
//var avH=contentAvailableH+'px';
//alert('contentAvailableH: '+avH);
//layoutCssConfig.push(['default','','.contenidos',{'height':avH}]);



// //left
// layoutAlignConfig.push(['left','contacto','.contactWrapper','body','bl',{y:-134,appendToBody:true}]);
// layoutAlignConfig.push(['left','trayectoria','.trayectoria-fondo','body','bl',{appendToBody:true}]);
// layoutAlignConfig.push(['left','trayectoria','.trayectoria-anim','.trayectoria-fondo','tr',{appendToBody:true}]);
// layoutAlignConfig.push(['left','','nav','.mainMenu li:last','tltr',{y:64}]);
// //layoutAlignConfig.push(['left','','article','.mainMenu li:first','l']);
// layoutAlignConfig.push(['left','espectaculos','nav','.mainMenu li:last','tltr',{x:-44,y:64}]);
// layoutCssConfig.push(['left','','nav',{'position':'fixed','display':'block'}]);
// layoutCssConfig.push(['left','','footer',{'right':'auto'}]);
// layoutCssConfig.push(['left','','header',{'text-align':'left','margin-left':'0px'}]);
// layoutCssConfig.push(['left','','article',{'margin-left':'0px'}]);

//left min
//layoutCssConfig.push(['min','','nav',{'display':'none'}]);
//layoutCssConfig.push(['min','espectaculos','.tab',{'dislay':'block !important'}]);


/*---------------------------------------LAYOUT BIND----------------------------*/

$(window).resize(function() { layout(); });



function showArticle(){
	//alert('hi');
	$("article").fadeIn(1700);
}

$(document).ready(function() {
	if(window.location.pathname.indexOf('/la-visita')!=-1){
		$("body.la-visita article").fadeOut(100);
		$("article .flashbody").detach().prependTo(".articleWrapper");
	}
	spreadMainMenu();
	//$('.contenidos').scrollbarPaper();
	layout();
	layout();
	if(window.location==base_url){
		//alert(base_url);
		homeAnimation();
	}
	if(window.location.pathname.indexOf('/la-carpa')!=-1){
		calendarEventsColors();
		getEspectaculosTOC();
		getEventsTOC();
		return;
	}
	if(window.location.pathname.indexOf('/proximas-funciones')!=-1){
		getFuncionesTOC();
		return;
	}
	if(window.location.pathname.indexOf("espectaculos")!=-1){
		getEspectaculosTOC();
		return;
	}

	/*if(window.location.pathname.indexOf("contacto")!=-1){
		//movePhone();
		return;
	}*/
	getH2TOC();
});




