/* Author: 
	Justin Holt - Current 1 27 11
*/

$('document').ready(function(){
	
	
	/* slideshow gallery */
	$('.gallery-slide').css('display','block').css('visibility','visible');
	$('#gallery').cycle({
		fx: 'scrollLeft',
		speedIn:  1300, 
    	speedOut: 500, 
    	easeIn:  'bounceout', 
    	easeOut: 'backin', 
    	delay:   -1000,
    	timeout: 14000,
    	pause: 1,
    	pager: '#gallery-navigation',
    	cleartypeNoBg: true,
    	cleartype: true
	});
	/* scroll on link click */
	$(".header-center a, .main h2 a").click(function(event){
		//prevent the default action for the click event
		event.preventDefault();		 
		//get the full url - like mysitecom/index.htm#home
		var full_url = this.href;		 
		//split the url by # and get the anchor target name - home in mysitecom/index.htm#home
		var parts = full_url.split("#");
		var trgt = parts[1];
				 
		//get the top offset of the target anchor
		var target_offset = $("#"+trgt).offset();
		var target_top = target_offset.top;
				 
		//goto that anchor by setting the body scroll top to anchor top
		$('html, body').animate({scrollTop:target_top}, 500);
	});
	/* form and error handling */
	$(".submit").click(function(){
  		$(".error").hide();
  		var hasError = false;
  		var nameVal = $("#name").val();
  		if(nameVal == '') {
  		 $("#name").before('<span class="error">You forgot to enter your name.</span>');
  		 hasError = true;
  		}   		
  		var contactVal = $("#contact").val();
  		if(contactVal == '') {
  		 $("#contact").before('<span class="error">You forgot to enter an email address or phone number.</span>');
  		 hasError = true;
  		} 
  		var commentVal = $('.comment').val();

  		
  		if(hasError == false) {
  			
 			$(".submit").append('<img src="/images/template/loading.gif" alt="Loading" id="loading" />');
 			$.post("//www.justinholt.com/sendemail.php",
			   { name: nameVal, email: contactVal, content: commentVal },
			    function(data){
			  $("#emailForm .submit").fadeOut("normal", function() {
			
			   $("#emailForm").after('<span>Success! Your email was sent! I will be in touch with your soon.</span>');
			  });
			 }
			);
		}
		return false;
 	});
 	  
	/*end form handling with error messages included */
	
});
jQuery(function($){
	/* video player */
	VideoJS.setupAllWhenReady();
});   
				























