$(document).ready(function() {

// Navigation Scripts

	var $headerSlide  = $("#pageHeaders");
	var $contentSlide = $("#pageContent");
	var $speed  = 800;
	var $messageDelay = 200;


	function gotoHome(e)
	{
		e.preventDefault();
		
		$headerSlide.stop().scrollTo( $("#homeHeader"), $speed+300, {axis:'x'});
		$contentSlide.stop().scrollTo( $("#home"), $speed, {axis:'x'});
		$("#prevControl").removeClass("goto_home goto_middle goto_end").addClass("endNav");
		$("#nextControl").removeClass("endNav goto_home goto_end").addClass("goto_middle");
	}

	function gotoWork(e)
	{
		e.preventDefault();
		
		$headerSlide.stop().scrollTo( $("#workHeader"), $speed+300, {axis:'x'});
		$contentSlide.stop().scrollTo( $("#work"), $speed, {axis:'x'});
		$("#prevControl").removeClass("endNav goto_middle").addClass("goto_home");
		$("#nextControl").removeClass("endNav goto_home goto_middle").addClass("goto_end");
	}
	
	function gotoAbout(e)
	{
		e.preventDefault();
		
		$headerSlide.stop().scrollTo( $("#aboutHeader"), $speed+300, {axis:'x'});
		$contentSlide.stop().scrollTo( $("#about"), $speed, {axis:'x'});
		$("#prevControl").removeClass("goto_home endNav goto_end").addClass("goto_middle");
		$("#nextControl").removeClass("goto_middle goto_home goto_end").addClass("endNav");
	}
	
	function gotoContact(e)
	{
		e.preventDefault();
		
		$headerSlide.stop().scrollTo( $("#contactHeader"), $speed+300, {axis:'x'});
		$contentSlide.stop().scrollTo( $("#contact"), $speed, {axis:'x'});
		$("#prevControl").removeClass("goto_home endNav goto_end").addClass("goto_middle");
		$("#nextControl").removeClass("goto_middle goto_home goto_end").addClass("endNav");
	}


//Gallery Video Scripts

	$("#springPhoto").fancybox({
	    'padding'       : 0,
	    'autoScale'     : false,
	    'transitionIn'  : 'none',
	    'transitionOut' : 'none',
	    'width'         : 720,
	    'height'        : 405,
	    'href'          : 'http://vimeo.com/moogaloop.swf?clip_id=22237339&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=00adef&amp;fullscreen=1&amp;autoplay=1&amp;loop=0',
	    'type'          : 'swf',
	    'swf'			: { 'allowfullscreen' : 'true' }
	});
	
	$("#danAndKim").fancybox({
	    'padding'       : 0,
	    'autoScale'     : false,
	    'transitionIn'  : 'none',
	    'transitionOut' : 'none',
	    'width'         : 720,
	    'height'        : 405,
	    'href'          : 'http://vimeo.com/moogaloop.swf?clip_id=15913980&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=00adef&amp;fullscreen=1&amp;autoplay=1&amp;loop=0',
	    'type'          : 'swf',
	    'swf'			: { 'allowfullscreen' : 'true' }
	});

	$("#billAndAshley").fancybox({
	    'padding'       : 0,
	    'autoScale'     : false,
	    'transitionIn'  : 'none',
	    'transitionOut' : 'none',
	    'width'         : 720,
	    'height'        : 405,
	    'href'          : 'http://vimeo.com/moogaloop.swf?clip_id=17237113&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=00adef&amp;fullscreen=1&amp;autoplay=1&amp;loop=0',
	    'type'          : 'swf',
	    'swf'			: { 'allowfullscreen' : 'true' }
	});


	$("#charAndHolly").fancybox({
	    'padding'       : 0,
	    'autoScale'     : false,
	    'transitionIn'  : 'none',
	    'transitionOut' : 'none',
	    'width'         : 720,
	    'height'        : 405,
	    'href'          : 'http://vimeo.com/moogaloop.swf?clip_id=17591211&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=00adef&amp;fullscreen=1&amp;autoplay=1&amp;loop=0',
	    'type'          : 'swf',
	    'swf'			: { 'allowfullscreen' : 'true' }
	});


	$("#eveline").fancybox({
	    'padding'       : 0,
	    'autoScale'     : false,
	    'transitionIn'  : 'none',
	    'transitionOut' : 'none',
	    'width'         : 720,
	    'height'        : 405,
	    'href'          : 'http://vimeo.com/moogaloop.swf?clip_id=12291163&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=00adef&amp;fullscreen=1&amp;autoplay=1&amp;loop=0',
	    'type'          : 'swf',
	    'swf'			: { 'allowfullscreen' : 'true' }
	});
	
	
	$("#mattMayfield").fancybox({
	    'padding'       : 0,
	    'autoScale'     : false,
	    'transitionIn'  : 'none',
	    'transitionOut' : 'none',
	    'width'         : 720,
	    'height'        : 405,
	    'href'          : 'http://vimeo.com/moogaloop.swf?clip_id=23962993&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=00adef&amp;fullscreen=1&amp;autoplay=1&amp;loop=0',
	    'type'          : 'swf',
	    'swf'			: { 'allowfullscreen' : 'true' }
	});
//	$('#springPhoto').fancybox( {
//			
//			'type' : 'swf'
//		
//		});
//	
//	$('#danAndKim').fancybox( {
//			
//			'type' : 'swf'
//		
//		});
//	
//	$('#billAndAshley').fancybox( {
//			
//			'type' : 'swf'
//		
//		});
//		
//	$('#charAndHolly').fancybox( {
//			
//			'type' : 'swf'
//		
//		});
//		
//	$('#eveline').fancybox( {
//			
//			'type' : 'swf'
//		
//		});
//		
//	$('#mattMayfield').fancybox( {
//			
//			'type' : 'swf'
//		
//		});
		
//Contact Form Scripts
	
	$(init);
	
	function init() {
		$('#contactForm').submit(submitForm);
	}
	
	function submitForm() {
	  var contactForm = $(this);
	 
	  // Are all the fields filled in?
	 
	  if ( !$('#senderName').val() || !$('#senderEmail').val() || !$('#message').val() ) {
	 
	    // No; display a warning message and return to the form
	    $('#incompleteMessage').fadeIn().delay(messageDelay).fadeOut();
	    contactForm.fadeOut().delay(messageDelay).fadeIn();
	 
	  } else {
	 
	    // Yes; submit the form to the PHP script via Ajax
	 
	    //$('#sendingMessage').fadeIn();
	    contactForm.fadeOut();
	 
	    $.ajax( {
	      url: contactForm.attr( 'action' ) + "?ajax=true",
	      type: contactForm.attr( 'method' ),
	      data: contactForm.serialize(),
	      success: submitFinished
	    } );
	  }
	 
	  // Prevent the default form submission occurring
	  return false;
	}
	
	function submitFinished( response ) {
	  response = $.trim( response );
	  //$('#sendingMessage').fadeOut();
	 
	  if ( response == "success" ) {
	 
	    // Form submitted successfully:
	    // 1. Display the success message
	    // 2. Clear the form fields
	    // 3. Fade the content back in
	 
	    $('#successMessage').fadeIn().delay(4500).fadeOut('fast', showForm);
	    $('#senderName').val( "" );
	    $('#senderEmail').val( "" );
	    $('#message').val( "" );
	    
	    
	 
	  } else {
	 
	    // Form submission failed: Display the failure message,
	    // then redisplay the form
	    $('#failureMessage').fadeIn().delay(1500).fadeOut();
	    $('#contactForm').delay(500).fadeIn();
	  }
	}
	
	function showForm() {
		$('#contactForm').fadeIn('fast');
	}
	
	$('#show_form').click(showForm);
	
	$(".homeLink").live("click", gotoHome);
	$(".workLink").live("click", gotoWork);
	$(".aboutLink").live("click", gotoAbout);
	$(".contactLink").live("click", gotoContact);

});
