jQuery.easing.def = "easeOutExpo";

var newsletterTimer = null;
var youw8Timer = null;
var corporateteTimer = null;
var roosterTimer = null;
var corporateCounter = 0;
var offerTimer = null;

$(document).ready(function() {
	
	$("#offer #info").animate({ width:"300px"}, 500);
	offerTimer = setTimeout("flashOffer()", 10000);
	
	
	$("#offer #info").click(function() {
		location.href = 'http://www.clubsportive.nl/actie/';
	});
	
	$("#newsletter").hide();
	
	$("#newsletter-link, #newsletter").hover(
		function() {
			clearTimeout(newsletterTimer);
			$("#newsletter").fadeIn(300);
		},
		function() {
			newsletterTimer = setTimeout("hideNewsletter()", 500);
		}
	);
	
	$("#youw8").hide();
	
	$("#youw8-link, #youw8").hover(
		function() {
			clearTimeout(youw8Timer);
			$("#youw8").fadeIn(300);
		},
		function() {
			youw8Timer = setTimeout("hideYouw8()", 500);
		}
	);
		
	$("#subMenuRoosters").hide();
	
	$("#roosters-link, #subMenuRoosters").hover(
		function() {
			clearTimeout(roosterTimer);
			$("#subMenuRoosters").fadeIn(300);
			$('a#roosters-link').addClass("active");
		},
		function() {
			roosterTimer = setTimeout("hideSubMenuRoosters()", 200);
			$('a#roosters-link').removeClass("active");
		}
	);
		
	$(".trainer").click(function() {
		if($(this).css("height") == "100px") {
			$(".trainer").css("height", "100px");
			$(this).css("height", "auto");
		} else {
			$(".trainer").css("height", "100px");
			$(this).css("height", "100px");
		}
	});
	
	$("#quote .quote").hide();
	$("#quote .quote#0").show();
	$(".about-hover").hover(function() {
		$("#carousel #arrow").css("left", this.id*118);
		$("#quote .quote").hide();
		$("#quote .quote#"+this.id).show();
	});
	
	$("#carousel .logo").hide();
	$("#carousel .logo#0").show();
	corporateteTimer = setTimeout("rotateCorporateCarousel()", 2500);
	
});

function hideNewsletter() {
	$("#newsletter").fadeOut();
}

function hideSubMenuRoosters() {
	$("#subMenuRoosters").fadeOut();
}

function hideYouw8() {
	$("#youw8").fadeOut();
}

function flashOffer() {
	$("#offer #info").animate({ width:"0"}, 250).animate({ width:"300px"}, 250);
	offerTimer = setTimeout("flashOffer()", 10000);
	//$("#offer").animate({ opacity:"0.5"}, 500);
}

function rotateCorporateCarousel() {
	$("#carousel .logo#"+corporateCounter).fadeOut(function() {
		corporateCounter++;
		if(corporateCounter == $("#carousel .logo").length) {
			corporateCounter = 0;
		}
		$("#carousel .logo#"+corporateCounter).fadeIn();
		corporateteTimer = setTimeout("rotateCorporateCarousel()", 2500);
	});
}

function submitContact() {
	var name = $("#form #name").val();
	var email = $("#form #email").val();
	var phone = $("#form #phone").val();
	var location = $("#form #location").val();
	var comment = $("#form #comment").val();
	var knowfrom = $("#form #knowfrom").val();
	if(name !== '' && email !== '' && phone !== '' && location !== '' && knowfrom !== '') {
		$("#form").submit();
	} else {
		alert("U dient alle verplichte velden in te vullen.");
	}
}

function submitMembership() {
	var name = $("#form #name").val();
	var email = $("#form #email").val();
	var phone = $("#form #phone").val();
	var location = $("#form #location").val();
	var day = $("#form #day").val();
	var month = $("#form #month").val();
	var year = $("#form #year").val();
	var comment = $("#form #comment").val();
	var card = $("#form #card").attr("checked");
	if(name !== '' && email !== '' && phone !== '' && location !== '' && day !== '' && month !== '' && year !== '') {
		$("#form").submit();
	} else {
		alert("U dient alle verplichte velden in te vullen.");
	}
}

function submitAction() {
	var action = $("#form #action").val();
	var name = $("#form #name").val();
	var email = $("#form #email").val();
	var phone = $("#form #phone").val();
	var location = $("#form #location").val();
	if(name !== '' && email !== '' && phone !== '' && location !== '') {
		$("#form").submit();
	} else {
		alert("U dient alle verplichte velden in te vullen.");
	}
}