$(function() {
	
	//Capture email
	$('#capture-email-submit').hide();
	$('#capture-email-ok').show()
	.click(function() {
		$('#capture-email').submit();
		return false;
	});
	$('#capture-email').submit(function() {
		var $form = $(this);
		$.post($form.attr('action'), $form.serialize(), function(data) {
			alert(data);
		});
		return false;
	});
	var capture_email_placeholder = $('#capture-email-field').val();
	$('#capture-email-field')
	.focus(function() { if (this.value == capture_email_placeholder) {this.value=''}; $('#capture-email input[name=robot]').val('sugar'); })
	.blur(function() { if(this.value == '') { this.value=capture_email_placeholder}; });
	
	// Update gradient position
	$(window).resize(function() {
		$('body').css({backgroundPosition: 'left '+($(window).height()/5*4)+'px'});
	}).resize();
	
	// Active menu item
	$('#menu').bind('highligh_service', function(e,href) {
		href = href.replace(/http:\/\/[^\/]*/, '');
		$(this).find('.marker').removeClass('active-marker')
		.end().find('a[href='+href+']').next().addClass('active-marker');
	}).trigger('highligh_service', [document.location.pathname]);
	
	// Submenu animation
	/*
	var submenu_timeout;
	$('#submenu').hover(function() {
		clearTimeout(submenu_timeout);
		$(this).find('a').show().animate({fontSize: '11px'}, 150);
	}, function() {
		var $$ = $(this).find('a');
		submenu_timeout = setTimeout(function() {
			$$.animate({fontSize: '0px'}, 150, function() { $$.hide(); });
		}, 400);
	});*/
	
	// Logos rollover
	$('.client-logo').mouseenter(function() {
		$(this).find('.client-logo-over').stop(true,true).fadeIn();
	}).mouseleave(function() {
		$(this).find('.client-logo-over').stop(true,true).fadeOut();
	});
	
	// Our reach hot spots
	$('.reach-dot').hover(function() {
		var $next = $(this).next();
		var reach_diff = Math.max($('.about-titles').height()-234, 0);
		$('.about-footer-left, .about-footer-right').css({top: -Math.max($next.height()-reach_diff,0)+'px'});
		$next.stop(true,true).fadeIn('fast');
	}, function() {
		var $next = $(this).next();
		$next.stop(true,true).hide();
		$('.about-footer-left, .about-footer-right').css({top: '0px'});
	});
	
});
