$(document).ready( function() {
	page.init();
});

var page = {	
	init : function() {
			
		$.sifr({ path: "swf/", save: true });  
		$("#head h1").sifr({ font: "Eras Medium ITC" });
		if(getUrl.isSubmit()) {
			$("#contact_fdb").text("Your question has been received. We will contact you as soon as possible.");
			$("#contact_fdb").addClass("success");
		}
		
		$('.mediascroll').cycle({ 
		    fx:			      	'fade', 
		    speed:    			600,
		    timeout:			10000,
			pager:				'.medianav',
			pagerAnchorBuilder: function(idx, slide){
                return '<a href="#"></a>';
			}
		});
		$("#contact").validate({
			rules: {
				contact_email: {
					required: true,
					email: true
				},
				contact_msg: {
					required: true,
					minlength: 10
				}
			},
			messages: {
				contact_email: "Please enter a valid email address",
				contact_msg: "Your question has to be at least 10 characters long"
			}
		});
		
	}
}
var getUrl = {	
	isSubmit : function() {
		var vars = [], hash;
		var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
		for(var i = 0; i < hashes.length; i++){
			hash = hashes[i].split('=');
		  	if(hash == "contactsent") {
			 	return true;
		  	}
		}
		return false;
	 }
}