$(document).ready(function(){
 	/*------------------- Galeries ------------------------------------------------------------------------*/
	//----------- Main Slideshow
	
	$('#slideshow').cycle({ 
		fx:     'fade', 
		speed:   2500, 
		timeout: 5000, 
		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; });

	/*-----------------------------------------------------------------------------------------*/
	/*-----------------------------------------------------------------------------------------*/
	$.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;
		}
	};
	
	$("#mainNav ul").lavaLamp({
		fx: "custom",
		speed: 700
	});
	
	//--------------------------------- Sub Menu
	$('#subMenu ul li ul').hide();
	$('#subMenu ul li.active ul').show();

	$('#subMenu ul li:has(ul)').hoverIntent(function(){
		var target = $(this);
		target.addClass('active').find('ul').slideDown();
		$('#subMenu ul li:has(li)').not(target).removeClass('active').find('ul').slideUp();
		return true;
	}, function() {});

	//Home content slider
	$("#flowpanes").scrollable({
		size: 1,
		clickable: false,
		easing:	'custom',
		speed: 1000
	}).mousewheel(1000).navigator({ 
        navi: "#flowtabs", 
        naviItem: 'a', 
        activeClass: 'active'
    })

	$('.box:last').css({
		'margin-right': '0',
		'border': 'none'
		
	});
	$('table tr:first td').css('padding-top','0');

}); //Close document.ready

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

});
