$(document).ready(function(){
	
	//----------- Main Slideshow
	$('#slideshow').cycle({ 
		fx:     'fade', 
		speed:   2000, 
		timeout: 4000, 
		next:   '#next',
        prev:   '#prev',
		before:  onBefore, 
		after:   onAfter,
		cleartype:  1
	 });
	
	function onBefore() { 
		$('#output').animate({  
			height: "0"
		}, 500 );
		$('#output').html("");
	}
	
	function onAfter(curr,next,opts) { 
		if (this.alt != '') {
			$('#output').animate({ 
				height: "36px"
			}, 800 );
			//console.log(opts.slideCount);
			$('#output').append('<p>' + this.alt + '</p>'); 

		}
		if (opts.slideCount==1) {
			$('#slideshow').cycle('stop');
			return false;
		}
	}
		
	$('#pause').click(function() { $('#slideshow').cycle('pause'); return false; });
    $('#play').click(function() { $('#slideshow').cycle('resume'); return false; });
	
	
	//Banners
	$('.bannerAdd').cycle({ 
		fx:     'scrollUp', 
		speed:   1000, 
		timeout: 14000,
		random:  1
	 });
	
	//Hot topics scrollable
	$(".scrollable").scrollable({ vertical: true, mousewheel: true, circular: true }).autoscroll({ autoplay: true, interval: 5000 });	

	( !$('a.ditto_page').length ) ? $('span.ditto_currentpage').css('display','none') : '';


}); //Close document.ready

$(window).bind("load", function() {								
	//Slideshows
	$('.loading').each(function () {
		$(this).hide();
	});
	$('#slideshowWrapper').fadeIn('slow');

	
});

/*------- Equal hights ---------------------------------------------------------*/
function equalHeight(group) {
	tallest = 0;
	group.each(function() {
		thisHeight = $(this).height();
		if(thisHeight > tallest) {
			tallest = thisHeight;
		}
	});
	group.height(tallest);
}
/*------- Toggle animation (open - close) --------------------------------------*/
(function($) {
	$.fn.animPanel = function(options) {
		var opts = $.extend({}, $.fn.animPanel.defaults, options);
		return this.each(function() {
			$this = $(this);
			var o = $.meta ? $.extend({}, opts, $this.data()) : opts;				
			$this.toggle(function() {
				$(o.target).animate({ top: o.topStart }, 300, "easeOutBounce", function() { 
					$(o.target).find('#trigger').html(o.textOpen);
				});						   
			},function() {
				$(o.target).animate({ top: o.topEnd }, 300, "easeOutBounce", function() { 
					$('#topPanelOne ul li ul:visible').slideUp();	
					$(o.target).find('#trigger').html(o.textClose);
				});						   	
			})	
			
		});
	};
})(jQuery);
/*------ Easing animations -----------------------------------------------------*/
(function($) {
	$.easing.custom = function (x, t, b, c, d) { 
		var s = 1.70158;  
		if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b; 
		return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b; 
	}
	$.easing.easeOutExpo = function (x, t, b, c, d) {
		return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
	};
	$.easing.easeOutBounce = function (x, t, b, c, d) {
		if ((t/=d) < (1/2.75)) {
			return c*(7.5625*t*t) + b;
		} else if (t < (2/2.75)) {
			return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
		} else if (t < (2.5/2.75)) {
			return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
		} else {
			return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
		}
	};
})(jQuery);
/*----- Custom alert popup -----------------------------------------------------*/
function my_alert(alert_content) {
	$('body').append('<div id="alert">'+alert_content+'<br /> <span class="close">Close</span></div>');
	$("#alert").overlay({ 
		top: 200, 
		expose: { 
			color: '#fff', 
			loadSpeed: 500, 
			opacity: 0.6 
		}, 
		closeOnClick: true,
		api: true 
	}).load();
}
