
$(document).ready(function() {		
	var slideObj = $('#slideshow');
	$('img', slideObj).css({opacity: 0.0});
	gallery();
	var num = $("#slideshow img").length;
	if (num > 1)
		setInterval(gallery,5000);

	function gallery() {
		
		//if no IMGs have the show class, grab the first image
		var current = ($('img.show', slideObj)?  $('img.show', slideObj) : $('img:first', slideObj));
	
		//Get next image, if it reached the end of the slideshow, rotate it back to the first image
		var next = ((current.next().length) ? ((current.next().hasClass('caption'))? $('img:first', slideObj) :current.next()) : $('img:first', slideObj));	
		//Set the fade in effect for the next image, show class has higher z-index
		
		next.css({opacity: 0.0})
		.addClass('show')
		.animate({opacity: 1.0}, 1000);
	
		//Hide the current image
		current.animate({opacity: 0.0}, 1000)
		.removeClass('show');
	}


	$("#register").submit(function(){
		if (validate()) {
			$.ajax({
				type: "POST",
				data:  $("#register").serialize(),
				url: "/contact_mailer.php",
				success: function(msg){
					$(".content").html("Thank you for sending your comments/questions. <br /> We will get back to you soon.")
				}
			});
		}
		return false;
	});


	$("#party-form").submit(function(){
		if (validate()) {
			$.ajax({
				type: "POST",
				data:  $("#party-form").serialize(),
				url: "/mailer.php",
				success: function(msg){
					$(".content").html("Thank you for sending your party information. <br /> We will get back to you soon.")
				}
			});
		}
		return false;
	});



});




function validate_party() 
{

	if ($('#firstname').val() == '') 
	{
    alert('Please enter your name.');
  	return false; 
	}

	if ($('#email').val() == '') 
	{
    alert('Please enter your email address.');
  	return false; 
	}

  if($('#email').val() != "")
	{
		var str = $('#email').val();
		var reg1 = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/; // not valid
		var reg2 = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/; // valid

		if (!reg1.test(str) && reg2.test(str))
	  { 			
			return true;
	  }
		else
	 	{
			alert ("Please enter a valid email address");
			return false;
	 	}
	}
}


function validate() 
{

   if (document.register.firstname.value =='') 
       {
        alert('Missing Required Fields!!\nPlease Enter the Name');
        document.register.firstname.focus();
         return false; 
	   }
   if(document.register.txtEmail.value =='')
     {
	    alert("Enter a valide email address");
		document.register.txtEmail.focus();
		return false;
     } 
   if (document.register.comment.value == '') 
	{
        alert('Missing Required Fields!!\nPlease Enter Your comments or questions:');
        document.register.comment.focus();
         return false; 
	}
   if(document.register.txtEmail.value!="")
	{
	var str = document.register.txtEmail.value;
	var reg1 = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/; // not valid
	var reg2 = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/; // valid

	if (!reg1.test(str) && reg2.test(str))
	       { 			
		    return true;
	       }
	 {
			alert ("Please enter valid Email in the \"Email\" field.");
			document.register.txtEmail.focus();
			return false;
	 }
	}
}


