$(document).ready(function() {
	$("#email").focus(function() {
		if ($("#email").val() == 'Enter your Email Address...') {
			$("#email").val('');
		}
	});

	$("form#form_subscribe").validate({
	    errorLabelContainer: "#messageBox",
//	    wrapper: "span",
	    rules: {
	        email: { required: true, email: true }
	    },
	    messages: {
	        email: { required: 'You must enter your email', email: 'Please enter a vaild email address' }
	    }
	});
	
	$("form#form_subscribe").submit(function(){
		if (!$("#form_subscribe").valid()) {
			return;
		}
		
		$("#form_subscribe").hide();
		$("#loader").show();
		
		//TODO: remove form and change to loading image
		ajax('ajaxEmail','subscribe', {
			'email': $("#email").val()
		}, 'emailCallback', 1);
	
		return false;
	});
	
	$("div#Fun").show();
	$("ul#quizzes_box_header li").mouseover(function() {
		$("div.category").not($(this)).hide();
	
		var cat = $(this).text();
		$("div#" + cat).show();
	});
	
	//quizmule.com
	$("#navigation ul li").click(function() {
		$("div.category").not($(this)).hide();
	
		var cat = $(this).text();
		$("div#" + cat).show();
	});

});

function emailCallback(value) 
{
	$("#loader").html('<p>Your email has been subscribed!</p>');
}

