$(document).ready(function(){
 	/*------------------- Galeries ------------------------------------------------------------------------*/
	//----------- Main Slideshow
	
	$('#slideshow').cycle({ 
		fx:     'fade', 
		speed:   2500, 
		timeout: 5000, 
		next:   '#next',
        prev:   '#prev',
		before:  onBefore, 
		after:   onAfter,
		cleartype:  1,
		pager:  '#nav', 
		    	// callback fn that creates a thumbnail to use as pager anchor 
		pagerAnchorBuilder: function(idx, slide) { 
			return '<li><a href="#"><img src="' + slide.src + '"  width="70" height="70"/></a></li>'; 
		} 
	 });
	
	$('#slideshow_pages').cycle({ 
		fx:     'fade', 
		speed:   2500, 
		timeout: 5000, 
		next:   '#next',
        prev:   '#prev',
		before:  onBefore, 
		after:   onAfter,
		cleartype:  1
	 });
	

	$('#nav li').click(function() {
		$('#slideshow').cycle('pause'); return false;
		onAfter();
		return true;
	});

	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; });

	/*-----------------------------------------------------------------------------------------*/
	/*-----------------------------------------------------------------------------------------*/
	$.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;
		}
	};
	
	var options = {
		height : '0.35',
		opacity : '0.3'
	}
	$("#feature_box.project img").reflect(options);
	
	if ($('#slideshow').length) {
				
		$('.thumbs').show();
		$('.thumbs #nav li:odd').addClass('odd');
	}
	

}); //Close document.ready

$(window).bind("load", function() {							
    //-----------  Preload images for 
	$('#loading').hide();
	$('#slideshowWrapper').fadeIn('slow');

});
