function initHome() {
  $('#slideshow').cycle({ 
    timeout: 3000,
    sync: 1
  });
}

function initImageGallery() {
  $('#contentInner').append('<div id="imageView"><img alt="gallery main" src="'+$('#jsp-carousel li img').get(0).src+'" id="mainImage" /><img id="imageBlanket" alt="" src="http://jshumwayphotos.com/img/filler.gif" /></div>');
  initCarousel();
  $('#jsp-carousel li img').bind('click', function() {
	$('#jsp-carousel li img').removeClass('active');
	$(this).addClass('active');
	$('#mainImage').attr("src", this.src);
  });
}

function initClientGallery() {
  firstImgSrc = $('#jsp-carousel li img').get(0).src;
  $('#contentInner').append('<div id="imageView"><img alt="gallery main" src="'+firstImgSrc+'" id="mainImage" /><img id="imageBlanket" alt="" src="http://jshumwayphotos.com/img/filler.gif" /><div id="imageName">now viewing: '+firstImgSrc.substring(firstImgSrc.lastIndexOf('/')+1, firstImgSrc.lastIndexOf('.'))+'</div></div>');
  initCarousel();
  $('#jsp-carousel li img').bind('click', function() {
	$('#jsp-carousel li img').removeClass('active');
	$(this).addClass('active');
	$('#mainImage').attr("src", this.src);
	$('#imageName').html('now viewing: ' + this.src.substring(this.src.lastIndexOf('/')+1, this.src.lastIndexOf('.')));
  });
}

function initCarousel() {
  $('#jsp-carousel').jcarousel({
    wrap: 'both',
    scroll: 9
  });
}

function initContact() {
  $('.error').hide();
  $("#contactForm #submit").click(function() {
    $('.error').hide();  
    var name = $("input#name"),
        email = $("input#email"),
        phone = $("input#phone"),
        subject = $("input#subject"),
        message = $("textarea#message"),
        form = $('#contactForm'),
        submitForm = true;  
    if(message.val() == "") {
      $("span#message_error").show();
      submitForm = false;
      message.focus();  
    }
    if(email.val().search(/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/) == -1 && phone.val().replace(/[^0-9]/g,"").length < 10) {  
      $("span.email_phone_error").show();
      submitForm = false;
      email.focus();  
    }
    if(name.val() == "") {  
      $("span#name_error").show();  
      submitForm = false;
      name.focus();  
    }  

    if(submitForm) {
      var dataString = 'name='+ name.val() + '&email=' + email.val() + '&phone=' + phone.val() + '&subject=' + subject.val() + '&message=' + message.val();  
      $.ajax({  
        type: "POST",  
        url: form.action,  
        data: dataString,  
        success: function() {  
          form.fadeOut('slow').html("<div id='confirmation'><p>Thank you for your inquiry, " + name.val() + "!</p><p>I will get back with you shortly at the contact information you provided.</p><p>Thanks again, <br />Jessica</p></div>").fadeIn('slow');   
        }  
      });  
      return false;  
    } else {
	  return false;
    }
  });  
}

