/*** j6rau: Extended to change effect duration ***/
$.extend($.ui.accordion, {
	animations: {
		ftpxslide: function(options, additions) {
			options = $.extend({
				easing: "swing",
				duration: 600
			}, options, additions);
			if ( !options.toHide.size() ) {
				options.toShow.animate({height: "show"}, options);
				return;
			}
			if ( !options.toShow.size() ) {
				options.toHide.animate({height: "hide"}, options);
				return;
			}
			var overflow = options.toShow.css('overflow'),
				percentDone,
				showProps = {},
				hideProps = {},
				fxAttrs = [ "height", "paddingTop", "paddingBottom" ],
				originalWidth;
			// fix width before calculating height of hidden element
			var s = options.toShow;
			originalWidth = s[0].style.width;
			s.width( parseInt(s.parent().width(),10) - parseInt(s.css("paddingLeft"),10) - parseInt(s.css("paddingRight"),10) - (parseInt(s.css("borderLeftWidth"),10) || 0) - (parseInt(s.css("borderRightWidth"),10) || 0) );
			
			$.each(fxAttrs, function(i, prop) {
				hideProps[prop] = 'hide';
				
				var parts = ('' + $.css(options.toShow[0], prop)).match(/^([\d+-.]+)(.*)$/);
				showProps[prop] = {
					value: parts[1],
					unit: parts[2] || 'px'
				};
			});
			options.toShow.css({ height: 0, overflow: 'hidden' }).show();
			options.toHide.filter(":hidden").each(options.complete).end().filter(":visible").animate(hideProps,{
				step: function(now, settings) {
					// only calculate the percent when animating height
					// IE gets very inconsistent results when animating elements
					// with small values, which is common for padding
					if (settings.prop == 'height') {
						percentDone = (settings.now - settings.start) / (settings.end - settings.start);
					}
					
					options.toShow[0].style[settings.prop] =
						(percentDone * showProps[settings.prop].value) + showProps[settings.prop].unit;
				},
				duration: options.duration,
				easing: options.easing,
				complete: function() {
					if ( !options.autoHeight ) {
						options.toShow.css("height", "");
					}
					options.toShow.css("width", originalWidth);
					options.toShow.css({overflow: overflow});
					options.complete();
				}
			});
		}
	}
});
/*** j6rau: Extended to change effect duration ***/

$(function(){
	
	function disableHomeOtrosToggler(){ // Desactiva para que cuando esté activado, enlace a la página
		$(".toggler").each(function(){ $(this).data('enabled', false); });
	}
	
	$(document).ready(function(){
		$("#otrosHomeLayer").accordion({active: -1, 
										animated: "ftpxslide",
										changestart: function(event, ui){
												$(".toggler").find(".otrosHomeSubTitle").addClass("rojo");
										}
		});
		$(".toggler").bind("click", function(){
			if( $(this).data('enabled') ){
				window.location = $(this).attr('href');
			}
			disableHomeOtrosToggler();
			$(this).find(".otrosHomeSubTitle").removeClass("rojo");
			$(this).data('enabled', true)
		});
		$("#fotoconcursoToggler").trigger("click");
	});
});