$(document).ready(function() {
	var browserWidth = $(window).width();
	if (browserWidth >= 721) {
		$.getScript("/js/jquery.validate.min.js");
		$.getScript("/js/jquery.form.js");
		$.getScript("/js/jquery.scrollTo-min.js");
		$.getScript("/js/jquery.localscroll-min.js");
		
		$("#form1").validate({
		rules: {
			yourName: {
				required: true,
				minlength: 2
			},
			yourEmail: {
				required: true,
				email: true
			},
			yourMessage: {
				required: true,
				minlength: 6
			}
		},
		messages: {
			yourName: {
				required: "<br />Please enter your name",
				minlength: "<br />Your name can't be that short!"
			},
			yourMessage: {
				required: "<br />To get an answer, you need to ask a question!",
				minlength: "<br />Something tells me that's not a proper question..."
			},
			yourEmail: "<br />Please enter a valid email address"
		}
	});
	

	//Activate FancyBox
	$("a#beatlesLink").fancybox({
		'type': 'iframe',
		'zoomSpeedIn': 0,
		'zoomSpeedOut': 0,
		'width': 560,
		'height': 410
	});
	
	$("a#wdysLink").fancybox({
		'type': 'iframe',
		'zoomSpeedIn': 0,
		'zoomSpeedOut': 0,
		'width': 560,
		'height': 410
	});
	
	$("a#libertyLink, a#getsetLink").fancybox({
		'type': 'iframe',
		'zoomSpeedIn': 0,
		'zoomSpeedOut': 0,
		'width': 810,
		'height': 460
	});
	
	$("a#unkleLink").fancybox({
		'type': 'iframe',
		'zoomSpeedIn': 0,
		'zoomSpeedOut': 0,
		'width': 610,
		'height': 310
	});
	
	$("a#rvLink").fancybox({
		'type': 'iframe',
		'zoomSpeedIn': 0,
		'zoomSpeedOut': 0,
		'width': 650,
		'height': 490
	});

	$('#mainPageHolder').attr({scrollTop:0,scrollLeft:0});
	$('#subNav').attr({scrollTop:0,scrollLeft:0});
		
	var $last = $([]);//save the last link
		
	$('#mainPageHolder').localScroll({
		target: '#mainPageHolder', //could be a selector or a jQuery object too.
		axis:'xy', //the default is 'y'
		queue:true,
		duration:1000,
		hash:false,
		onBefore:function( e, anchor, $target ){//'this' is the clicked link
			$last.removeClass('scrolling');
			$last = $(this).addClass('scrolling');
			if( this.blur )
				this.blur();//remove the awful outline
		},
		onAfter:function( anchor ){
			$last.removeClass('scrolling');
		}
	});
	
	$('#mainMenu').localScroll({
		target: '#mainPageHolder', //could be a selector or a jQuery object too.
		axis:'xy', //the default is 'y'
		queue:true,
		duration:1000,
		hash:false,
		onBefore:function( e, anchor, $target ){//'this' is the clicked link
			$last.removeClass('scrolling');
			$last = $(this).addClass('scrolling');
			if( this.blur )
				this.blur();//remove the awful outline
		},
		onAfter:function( anchor ){
			$last.removeClass('scrolling');
		}
	});
	
	$('.portfolio').localScroll({
		target: '#mainPageHolder', //could be a selector or a jQuery object too.
		axis:'xy', //the default is 'y'
		queue:true,
		duration:1000,
		hash:false,
		onBefore:function( e, anchor, $target ){//'this' is the clicked link
			$last.removeClass('scrolling');
			$last = $(this).addClass('scrolling');
			if( this.blur )
				this.blur();//remove the awful outline
		},
		onAfter:function( anchor ){
			$last.removeClass('scrolling');
		}
	});

	
	$('.thePortfolio').localScroll({
		target: '#mainPageHolder', //could be a selector or a jQuery object too.
		axis:'xy', //the default is 'y'
		queue:true,
		duration:1000,
		hash:false,
		onBefore:function( e, anchor, $target ){//'this' is the clicked link
			$last.removeClass('scrolling');
			$last = $(this).addClass('scrolling');
			if( this.blur )
				this.blur();//remove the awful outline
		},
		onAfter:function( anchor ){
			$last.removeClass('scrolling');
		}
	});
	
	$('.anarrow').localScroll({
		target: '#subNav', //could be a selector or a jQuery object too.
		axis:'x', //the default is 'y'
		queue:true,
		duration:1000,
		hash:false
	});

	}
});
