$(document).ready(function() {
	// Contact Thanks
	function getQuerystring(key, default_)
	{
	  if (default_==null) default_=""; 
	  key = key.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
	  var regex = new RegExp("[\\?&]"+key+"=([^&#]*)");
	  var qs = regex.exec(window.location.href);
	  if(qs == null)
	    return default_;
	  else
	    return qs[1];
	}
	var redirectVal = getQuerystring('redirect');
	if(redirectVal == "thanks"){
		$.scrollTo('#contact', 1000, {easing:'swing'});
		$('#thanks-message').delay(1000).fadeIn();
	};
	// Contact Scrollto
	$('#contact-info a').click(function() {
		$.scrollTo('#contact', 1000, {easing:'swing'});
		return false;
	});
	
	// Slideshow
	$('#slideshow').cycle({
		fx: 'fade',
		timeout: 5000
	});
	// Before & After Launch ColorBox
	$('.thumb a').colorbox({
		maxHeight: "80%"
	});
	
	// Form Validation
	$("#contact form").RSV({
		displayType: "display-html",
		errorTextIntro: "<h3>Please fix the following errors.</h3>",
		errorFieldClass: "error",
		errorHTMLItemBullet: "&ordm; ",
		errorTargetElementId: "errors",
		rules: [
			"required,first_name,Please enter your first name.",
			"required,last_name,Please enter your last name.",
			"if:how_to_contact=Via Email,required,email_address,Please enter your email address.",
			"if:how_to_contact=By Phone,required,phone_number,Please enter your phone number.",
			"if:how_to_contact=Email or Phone,required,email_address,Please enter your email address.",
			"if:how_to_contact=Email or Phone,required,phone_number,Please enter your phone number."
		]
  	});
}); //end document.ready