

$(document).ready(function(){

/*** Slider ***/

	//@see http://flesler.demos.com/jquery/scrollTo/
	$.localScroll.defaults.axis = 'x';
	 
	// Scroll initially if there's a hash (#something) in the url 
	$.localScroll.hash({
		target: '#slider', // Could be a selector or a jQuery object too.
		queue:true,
		duration:400
	});
	
	/**
	 * NOTE: I use $.localScroll instead of $('#navigation').localScroll() so I
	 * also affect the >> and << links. I want every link in the page to scroll.
	 */
	$.localScroll({
		target: '#slider', // could be a selector or a jQuery object too.
		queue:true,
		duration:777,
		hash:true,
		onBefore:function( e, anchor, $target ){
			// The 'this' is the settings object, can be modified
		},
		onAfter:function( anchor, settings ){
			// The 'this' contains the scrolled element (#content)
		}
	});
	
	// On a thumbnail click
	$('#homeMenu ul li a').click(function(e,keepScroll){

		// Toggle act/inact classes
		$('li.menuItem').removeClass('act').addClass('inact');
		$(this).parent().addClass('act');
	});
	
	// On nav click
	$('#globalMenu a').click(function(e,keepScroll){
		// Toggle act/inact classes
		$('li.menuItem').removeClass('act').addClass('inact');
		
		$('#globalMenu li').removeClass('current');
		$(this).parent().addClass('current');	
	});
});
/*** END Slider ***/


/**** Form Validation ***/
//	 Resource Used: 
//	 http://www.askaboutphp.com/213/php-and-jquery-submit-a-form-without-refreshing-the-page.html

	$("#contact-form").validate({
		debug: false,
		rules: {
			sFirstName: "required",
			sLastName:  "required",
			sEmail: {
				required: true,
				email: true
			}
		},
		messages: {
			sFirstName: "Please enter your first name.",
			sLastName:  "Please enter your last name.",
			sEmail: 	"Please enter a valid email.",
		},
		submitHandler: function(form) {
			// do other stuff for a valid form
			$.post('http://selectivemkt.com/highriseContactForm.php', $("#contact-form").serialize(), function(data) {
				$('#notification').html("<p id='notification-text'>Thank you for contacting us.</p>").fadeOut(10000);
			});
			
			//Clear form on submit
			$(':input','#contact-form')
			 .not(':button, :submit, :reset, :hidden')
			 .val('')
			 .removeAttr('checked')
			 .removeAttr('selected'); 
			}
		});
		
	$("#application").validate({
		debug: false,
		/*rules: {
			sFirstName: "required",
			sLastName:  "required",
			sPosition:  "required",
			sLinkedIn:  "required",
			sTwitter:  	"required",
			sEmail: {
				required: true,
				email: true
			}			
		},
		
		messages: {
			sFirstName: "What is your first name?",
			sLastName: 	"What is your last name?",
			sEmail: 	"What is your email address?",
			sPosition:  "Which position you are applying for?",
			sLinkedIn:  "What is your linkedIn profile?",
			sTwitter:  	"What is your Twitter profile?",
		},
		*/
		submitHandler: function(form) {
			// do other stuff for a valid form
			
			
			$.post('http://selectivemkt.com/highriseApply.php', $("#application").serialize(), function(data) {
				$('#notification').html("<p id='notification-text'>Thank you for contacting us.</p>").fadeOut(10000);
			});
			
			/*
			$.post('http://selectivemkt.com/highriseApply.php', $("#application").serialize(), function(data) {
				$("#freeow").freeow("", "Thank you for contacting us.", {
				    classes: ["smokey", "notification"],
				    autoHide: true
				});
			});
			*/
			
			//Clear form on submit
			$(':input','#application')
			 .not(':button, :submit, :reset, :hidden')
			 .val('')
			 .removeAttr('checked')
			 .removeAttr('selected');
			}	
	});
/**** End Form Validation ***/

