/*######################
	SilverLining
	© 2011 Atedrake
	JS File for DOM
	Created : 6.4.2010 by Mike Kivikoski
	
	Please keep Last Modified up to date
	
	Table of Contents
		
		When DOM is ready:
			1. Form Validation
########################*/

$(document).ready(function(){
						   
	// 1.
	$('#contact-form').validate({
		rules: {
			email: {required: true,minlength:2,email: true},
			name: {required: true,minlength: 3},
			message: {required: true,minlength: 10}	
		},
		messages:{
			email: "Please enter a valid email",
			name: "Please enter your name",
			message: "Please enter your message (min 10 characters)"
		 },
		 submitHandler: function(form){
	 		 $(form).ajaxSubmit({
		 		 success: function() { 
	                $('#contact-form').hide();
	                $('#contact-container').append("<div id='contact-thanks'><h2>Thanks for contacting SilverLining.</h2> <p>We will be in touch with you shortly.</p></div>"); 
	             }
	         });
		 }						 
	 });

						

$(function(){
	$('a[href*=#]').click(function() {
		 if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
		 && location.hostname == this.hostname) {
			 var $target = $(this.hash);
			 $target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');
				 if ($target.length) {
					 var targetOffset = $target.offset().top;
					 $('html,body').animate({scrollTop: targetOffset}, 2000);
					 return false;
				 }
		 }
	})
}); 						   
						   
						   
});//End jQuery
