$(document).ready(function() {
	//$("#content").hide();
	//$("#content").fadeIn();
	$(document).pngFix();
	//Preload CSS Background Images
	$.preloadCssImages();
	
	//Sticky Footer
	//Home Cycle
	$("#home-cycle").cycle({ fx: 'fade',speed: 1300, timeout: 6000, random:  1 });
	$("#home-quotes").cycle({ fx: 'fade',speed: 1300, timeout: 6000, random:  1 });
	$("#home1").click(function() {
		top.location='testimonials/alistair-ong.php';
	});
	$("#home2").click(function() {
		top.location='testimonials/alicia-jones.php';
	});
	$("#home3").click(function() {
		top.location='testimonials/trish-balbert.php';
	});
	$("#home4").click(function() {
		top.location='testimonials/stephen-chen.php';
	});
	$("#home5").click(function() {
		top.location='testimonials/kelly_dwyer.php';
	});
	//Sidebar Image Cycle
	$("#quotes").cycle({ fx: 'fade',speed: 2000, timeout: 8000, random:  1 });
	
	//2 Column tab Structure
	$(".what-we-do, .coach-box").hide();
	$(".what-we-do:first, .coach-box:first").fadeIn();
	$("#sidebar li a:first").addClass("selected");
	$('#sidebar li a:not(.all-programs)').click(function(event){
	var imgHref = $(this).attr('href');
	$("#sidebar a").removeClass("selected");  //remove .selected class from all other links
	$(this).addClass("selected");
	$(".what-we-do, .coach-box").hide();
	$(imgHref).fadeIn();
	return false;
	});
	
	//Callouts Clickable Blocks
	$("#callout1, #callout2, #callout4, #callout5").click(function(){
    	window.location=$(this).find("a").attr("href");return false;
	});

	 
	//Sucess Stories
	 $("blockquote").cycle({ fx: 'fade',speed: 700, timeout: 8000, random:  1 });
	 $("#mycarousel").jcarousel();
	
	//FAQ Accordion
	$('#faqs').accordion({ 
			active: false,
    			autoheight: false,
			header: 'a.main'
	});	
	
	//CONTACT FORM
	jQuery(function() {
		// show a simple loading indicator
		var loader = jQuery('<div id="loader">loading...</div>')
			.appendTo("form")
			.hide();
		jQuery().ajaxStart(function() {
			loader.show();
		}).ajaxStop(function() {
			loader.hide();
		}).ajaxError(function(a, b, e) {
			throw e;
		});
		
		var v = jQuery("#contact-form").validate({
			submitHandler: function(form) {
				jQuery(form).ajaxSubmit({
					target: "#form-results"
				});
			}
		});
	});
	jQuery(function() {
		// show a simple loading indicator
		var loader = jQuery('<div id="loader">loading...</div>')
			.appendTo("#form-results")
			.hide();
		jQuery().ajaxStart(function() {
			loader.show();
		}).ajaxStop(function() {
			loader.hide();
		}).ajaxError(function(a, b, e) {
			throw e;
		});
		
		var w = jQuery("#newsletter-form2").validate({
			submitHandler: function(form) {
				jQuery(form).ajaxSubmit({
					target: "#form-results"
				});
			}
		});
	});
	jQuery(function() {
		// show a simple loading indicator
		var loader = jQuery('<div id="loader">loading...</div>')
			.appendTo("#form-results")
			.hide();
		jQuery().ajaxStart(function() {
			loader.show();
		}).ajaxStop(function() {
			loader.hide();
		}).ajaxError(function(a, b, e) {
			throw e;
		});
		
		var y = jQuery("#upload-testimonial").validate({
			submitHandler: function(form) {
				jQuery(form).ajaxSubmit({
					target: "#form-results"
				});
			}
		});
	});
});	