// JavaScript Document
$(document).ready(function(){

	$("#slider").nivoSlider({directionNav:false, effect:'random', pauseTime:5000});	
	
	$("#newsletter>input[type=text]").focus(function(){
		if($(this).val() == "your email"){
			$(this).val("");
			$(this).css("color", "#000");
		}
	}).blur(function(){
		if($(this).val() == ""){
			$(this).val("your email");
			$(this).css("color", "#999");
		}
	});
	
	$("#newsletter>div").click(function(){
		emailVal = $("#newsletter>input[type=text]").val();
		$("#newsletter>input[type=text]").css("color", "#999");
		$("#newsletter>input[type=text]").val("Registering...");
		$.ajax({
		   type: "POST",
		   url: "essentials/ajax/newsletterAdd.php",
		   data: "email="+emailVal,
		   success: function(msg){
			   switch(msg){
				   	case "0":
						$("#newsletter>input[type=text]").val("your email");
				 		apprise("<b>ERROR!</b><br/>Something went wrong, please try again in a little while.", {'animate': true});	
						break;
					case "1":
						$("#newsletter>input[type=text]").val("your email");
				 		apprise("You successfully subscribed yourself to our newsletter", {'animate': true});	
						break;
					case "2":
						$("#newsletter>input[type=text]").val("your email");
				 		apprise("<b>Notice!</b><br/>This email adress is already registered.", {'animate': true});	
						break;					
					case "3":
						$("#newsletter>input[type=text]").val("your email");
				 		apprise("<b>ERROR!</b><br/>Your email adress did not pass our <i>valid email</i> check.", {'animate': true});
						break; 
					default:
						$("#newsletter>input[type=text]").val("your email");
				 		apprise("<b>ERROR!</b><br/>Something went wrong, please try again in a little while or report the following error to the webmaster.<br/><span style=\"color:red;\">"+msg+"</span>", {'animate': true});
						break; 
			   }
		   }
		});
	});	
	

	
	$(".stadCont>p").click(function(){
		id = "#"+$(this).attr("class");
		if($(id + ">div").is(':visible')){
			$(id + ">div").slideUp();
			$(id + " .open").hide().html("+").fadeIn('slow');
		}else{
			$(id + ">div").slideDown();
			$(id + " .open").hide().html("-").fadeIn('slow');
		}		
	});
	
});
