jQuery.fn.extend({
  slideRightShow: function() {
	/*	$(".overlaybg").remove();*/
        $(this).show('slide', {direction: 'right'}, 500);
		$("#slider").css({height: "500px"});
/*		$("#wrapper").append("<a href='#' class='overlaybg'></a>");*/
		return false;

  },
  slideLeftHide: function() {
      $(this).hide('slide', {direction: 'left'}, 500, function() {
			alert('Animation complete.');
		  });
  },
  slideRightHide: function() {
    return this.each(function() {
/*	 $(".overlaybg").remove();*/
      $(this).hide('slide', {direction: 'right'}, 500);
    });
  },
  slideLeftShow: function() {
	/*	$(".overlaybg").remove();*/
      $(this).show('slide', {direction: 'left'}, 500);
/*		$("#wrapper").append("<a href='#' class='overlaybg'></a>");*/
		return false;

  }
});



$.validator.addMethod(
		'noPlaceholder', function (value, element) {
			return value !== element.defaultValue;
		}, 'Please enter your reasons.'
);



$(document).ready(function(){
				
				
/* ######### form stuff ################ */
	/*setup validation*/
		var options={
			errorLabelContainer: "#messageBox",	
			errorClass: "invalid",
			 rules: {
					email: {
						email:true,
						required: true	
					}
				},
					
			 messages: {	
					email: "Please double check your email address."		
			},
			
			 submitHandler: function(form) {
				 $.ajax({
						url: 'newsletter-signup.php',
						data: 'email=' + $(form).find('.email').val(),						
						beforeSend: function() { 		
								$("#signup-form").hide();
								$('#status').html("<p class='wait'><img src='images/loading.gif' alt='Your submission is being processed. Please wait' /> Please wait...</p>");  									
								$('#status').fadeIn();

						},
						
						complete: function() {	
															
								$('#status').html("<p id='form-success'>Your email address was submitted. Thank you!</p><a href='#' id='again'>Submit another email address</a>");  
						
								$("#again").click(function() {
										$('#status').hide();
										$('.email').val("Enter Your Email Here");
										$('#signup-form').fadeIn();
									});
							
							}							
							
						});
				return false;
			   } /*end submitHandler*/
		};		
		
		$("#signup-form").validate(options);  
		
		
	
		
		
		$("#ux-form").validate({
			  rules: {
				uxemail: {
				  required: true,
				  email: true
				},
				reasons:{
					noPlaceholder: true
				}
			  },
			  
				 submitHandler: function(form) {
					email = $(form).find('.email').val()
					name = $(form).find('.name').val()
					reasons = $(form).find('.reasons').val()
					   // do other stuff for a valid form
					  $.ajax({
						url: 'ux.php',
						data: 'email=' + email + '&name=' + name + '&reasons=' + reasons, 
						complete: function() {	
								$("#mxmessagebox").html("<p class='success'>Form sent successfully! Thank you!</p>");
								}
						});				
				   }
			   
		});




		
		$("#site-assessment-form").validate({
			  rules: {
				fullname: {
				  	required: true,
					noPlaceholder: true
				},
				email: {
				  required: true,
				  email: true
				},
				phone: {
				  digits: true
				},
				reasons:{
					noPlaceholder: true
				}
			  },			  
				 submitHandler: function(form) {
					   // do other stuff for a valid form
					  $.ajax({
						url: 'test.html',
						complete: function() {	
								$("#sitemessagebox").html("<p class='success'>Form sent successfully! Thank you!</p>");
								}
						});				
				   }
			   
		});
	


		
		$("#contact-form").validate({
			  rules: {
				fullname: {
				  	required: true,
					noPlaceholder: true
				},
				email: {
				  required: true,
				  email: true
				},
				phone: {
				  digits: true
				},
				reasons:{
					noPlaceholder: true
				}
			  },			  
				 submitHandler: function(form) {
					   // do other stuff for a valid form
					  $.ajax({
						url: 'test.html',
						complete: function() {	
								$("#contactmessagebox").html("<p class='success'>Form sent successfully! Thank you!</p>");
								}
						});				
				   }
			   
		});



		$("#hire-form").validate({
			  rules: {
				fullname: {
				  	required: true,
					noPlaceholder: true
				},
				email: {
				  required: true,
				  email: true
				},
				phone: {
				  digits: true
				},
				reasons:{
					noPlaceholder: true
				}
			  },			  
				 submitHandler: function(form) {
					   // do other stuff for a valid form
					  $.ajax({
						url: 'test.html',
						complete: function() {	
								$("#hire-form").html("<p class='success'>Form sent successfully! Thank you!</p>");
								}
						});				
				   }
			   
		});


						   
/* ## page slider ### */						   
			
			$("#explore").click(function(){	
					$("#home").slideLeftHide();		
					$("#explore-content").slideRightShow();		
					return false;
						
			 });
			
			$("#interact").click(function(){						
					$("#home").slideLeftHide();		
					$("#interact-content").slideRightShow();
					return false;
						
			 });
			
			$("#begin").click(function(){
					$("#home").slideLeftHide();		
					$("#begin-content").slideRightShow();	
					return false;
						
			 });
			
			

			
			$(".next, .free-site-assessment").click(function(){	
				
					if( !$(this).parent().parent().hasClass("last")){
						$(this).parent().parent().next(".content").slideRightShow();		
					} else {
						$("#home").slideRightShow();
						$("#slider").delay(500).animate({height: "400px"}, "fast");
					};
										
					$(this).parent().parent(".content").slideLeftHide();					
					
					return false;
											
			 });
			
			
			$(".prev").click(function(){

									
					if( !$(this).parent().parent().hasClass("first")){												
						$(this).parent().parent().prev(".content").slideLeftShow();	
					} else {
						$(".content:last").slideLeftShow();						
					};				
											  
					$(this).parent().parent(".content").slideRightHide();
									
			 });
			
						
			$("#explore-content .close").click(function(){																
					$("#home").slideRightShow();				
					$("#slider").animate({height: "400px"}, "fast");
					$(this).parent().parent().slideLeftHide();		
			 });
			
			
			$(".gohome").click(function(){	
				if( $("#home").is(':hidden')){
					$("#home").slideRightShow();
					$(".content").slideLeftHide();	
					$("#slider").animate({height: "400px"}, "fast");					
					
				}

			 });
			
			
		
			
			
			
			$(".overlaybg").live("click", function(){	
				$(this).remove();		
				$("#home").show('slide', {direction: 'right'}, 500);												   
				$(".content").fadeOut();
				
			});
							 
							 
							 
});
