$(document).ready(function(){

	/*---- Carousel and services menu----*/
	$('#servicesNav ul li.active a').addClass('active');
	$('#flowtabs li:first').addClass('first');
	$('#flowtabs li:last').addClass('last');
	$("#flowpanes").scrollable({
		size: 1,
		clickable: false,
		easing:	'easeOutExpo',
		speed: 1000
	}).mousewheel(1000).navigator({ 
        navi: "#flowtabs", 
        naviItem: 'a', 
        activeClass: 'active'
    })

	/*---- Slideshow----------------------------*/
	$('#slideshow').cycle();

	/*---- Content manipulation --------------------*/
	$('#content ol li').wrapInner('<span></span>');
	
	if ($('#subNav').length) {
		$('#content').css({
			width : '462px',
			padding : '5px 0 0 20px'
		});
	}
	
	/*---- Date picker---*/
	$('.date-pick-noback').datePicker({
			clickInput:true
	});

	/*---- Request callback ajax form --------------*/
	$("#lowcall a").overlay({ 
        expose: '#cab3d1', 
        opacity: '0.8',    
		closeOnClick: false,
        onBeforeLoad: function() { 
            var wrap = this.getContent().find(".request").empty();
            wrap.load(this.getTrigger().attr("href")); 
        } 
    }); 

	$('#overlay #enquiry_form').live('submit',function() {
		data = $(this).serialize();
		url = 'index.php?id=155';
		$.ajax({
		  type: "POST",    
		  url: url,
		  data: data,
		  success: function(msg){
			$('#overlay div.request').html(msg);
		   }
		});   
		return false;										   
	});

	
	$('#listenNowButton').toggle(function () {
		$('#playerWrapper').animate({ right: '0' }, 500, function() { 
			//$(o.target).find('#trigger').html(o.textOpen);
		});		
	}, function() {
		$('#playerWrapper').animate({ right: '-400px' }, 500, function() { 
			//$(o.target).find('#trigger').html(o.textOpen);
		});	
	});	
	
	
	/*---------- Paypal form -------------------------------------*/

	$('#paypal_form').submit(function() {	
		$('input[name="item_name"]').val('Payment for ' + $('input[name="name"]').val());
		$('input[name="amount"]').val($('input[name="amount_one"]').val() +'.'+ $('input[name="amount_two"]').val());
	});

	
}); //Close document.ready

$(window).bind("load", function() {		
									
	$('.loading').hide();
	$('#flowpanes, #slideshow').fadeTo('slow', 0.9999, function() {
		$('#flowpanes, #slideshow').css('filter', 'none');
	});

});

/*------- 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(url) {
	$('body').append('<div id="alert"><span class="close">Close</span></div>');
	$("#alert").load(url);
	$("#alert").overlay({ 
		top: 200, 
		expose: { 
			color: '#6c98b9', 
			loadSpeed: 500, 
			opacity: 0.6,
			effect: 'apple'			
		}, 
		closeOnClick: false,
		api: true 
	}).load();
}

