$(function() {
// SUBSCRIBE
	$("#sub_submit").click(function() {
		var dataString = $("#subscribe_form").parent("form").serialize();

		$("#sub_submit").hide();
		$('.sub_loading').show();

		$.ajax({
			type: "POST",
			url: "/forms/subscribe.php",
			data: dataString,
			success: function(data) {
				if (data == 'OK')	{
					$('.sub_loading').hide();
					$("#sub_submit").show();
					$("#sub_thanks").html('<p>Thank You</p>').show();
				} else {
					$("#sub_thanks").html('<p>'+data+'</p>').show();
				}
			}
		});
		return false;
	});

// accordion nav for employees
	if ($('#employees').length) {
		$('#emp_info').hide();
		$('#employees a').hover(
			function () {
				var href=$(this).attr('href');
				$('#emp_info div').hide();
				$('#emp_info').show();
//				alert(href);
				$(href).show('slow');
			}, 
			function () {
				$('#emp_info').hide();
				var href=$(this).attr('href');
				$(href).hide(0);
			}
		);
	}

// Our work creative scroller
	if ($('.showcase').length) {
		//Get our elements for faster access and set overlay width
		var div = $('div.showcase'),
			ul = $('ul.showcase'),
			ulPadding = 15;

		var divWidth = div.width();				// Get menu width
		div.css({overflow:'hidden'});				// Remove scrollbars	
		var lastLi = ul.find('li:last-child');	// Find last image container
		
		div.mousemove(function(e){		//When user move mouse over menu
			//As images are loaded ul width increases, so we recalculate it each time
			var ulWidth = lastLi[0].offsetLeft + lastLi.outerWidth() + ulPadding;	
			var left = (e.pageX - div.offset().left) * (ulWidth-divWidth) / divWidth;
			div.scrollLeft(left);
		});
	}

});

