$(document).ready(function(){
// image slider
	$("#slider").easySlider({
		auto: true,
		continuous: true,
		numeric: true,
		numericId: 	'controls',
		speed: 800,
		pause: 2000
	});

//Portfolio Past Work - Caption Sliding (Hidden to Visible)
	$('.boxgrid.captionfull').hover(function(){
		$(".cover", this).stop().animate({top:'90px'},{queue:false,duration:160});
	}, function() {
		$(".cover", this).stop().animate({top:'162px'},{queue:false,duration:160});
	});
//Portfolio End Past Work

//Project detail viewer
	//object containing margin settings
	var margins = {
		panel1: 0,
		panel2: -576,
		panel3: -1152,
		panel4: -1728
	}
	//handle nav click
	$("#project-nav a").click(function(e){
		//stop browser default
		e.preventDefault();
		//remove on states for all nav links
		$("#project-nav a").removeClass("on");
		//add on state to selected nav link
		$(this).addClass("on");
		//set margin of slider to move
		$("#slider").animate({
			marginLeft: margins[$(this).attr("href").split("#")[1]]
		});					
	});
	//hide descriptive text
	$("#slider p").hide();
	//show descriptive text on mouseover (hide on mouseout)
	$("#slider img").hover(
		function() {
			$(this).next().slideDown();
		}, function() {
			$(this).next().slideUp();
	});
//End Project detail viewer				
// fancyzoom project detail images
	$('a[rel=lightbox]').fancybox({
		'hideOnContentClick': true,
		'speedIn'		:	300, 
		'speedOut'		:	200,
		'autoScale'		:	false,
		'titleShow'		:	false,
		'showNavArrows'	:	false
	});
// end fancy zoom
// contact page specific
 	$('#existing-site, #new-site').css({"display":"none"});
	
	$('#service-request').change(function() {
		if ($(this).val() == 'new-site'){
			$('#new-site').slideDown('fast');
			$('#existing-site').slideUp('fast');
			} else if ($(this).val() == 'existing-site') {
					$('#existing-site').slideDown('fast');
					$('#new-site').slideUp('fast');
				} else {
					$('#existing-site, #new-site').slideUp('fast');
				}
	});
	
// contact page specific
// ajaxy footer contact form thingy
	$("#footer-contact-submit").click(function(){
			  if ($("#footer-contact-form").validate({errorElement: "em"}).form()){
			  $('#footer-contact-form').slideUp('normal');
			  $("#footer-contact").addClass('sending');

			  var name = $('input[name=footer-name]');
			  var email = $('input[name=footer-email]');
			  var message = $('textarea[name=footer-message]');
			  
			  var dataset = 'footer-name=' + name.val() + '&footer-email=' + email.val() + '&footer-message=' + message.val();
			  //alert(dataset);
				
			  $.ajax({
			  type: "POST",
			  url: "../contact/footer-contact-script.php",	
			  data: dataset,
			  dataType: "html",
			  success: function(msg, status) {
										$('#footer-contact h4').slideUp('fast');
										$('#footer-contact').append(msg);
										$("#footer-contact").removeClass('sending');
			  		},
			  error: function(err) {
										alert('Arrrgh, there was an error. Please try again');
										$('#footer-contact-form').slideDown('fast');
										$("#footer-contact").removeClass('sending');
			  		}
			  });
			  }
		return false;
	});
// process slider
	$("#process").easySlider({
		auto: false,
		continuous: false,
		controlsBefore:	'<h3>',
		controlsAfter:	'</h3>',
		prevId: 'prevBtn',
		prevText: 'Previous Step',
		nextId: 'nextBtn',	
		nextText: 'Next Step',
		controlsShow: true,
		numeric: false,
		speed: 800,
		pause: 2000
	});


}); // end document ready
