var Site = {
	init: function() {
	$('.global-nav>li').hover(function(){
		if($(this).children('ul').length) {
			$(this).addClass('hover');
			$(this).removeClass('first');
		} else {
			$(this).addClass('mover');
			$(this).removeClass('first');
		}
	}, function(){
		if($(this).children('ul').length) {
			$(this).removeClass('hover');
			//$(this).addClass('first');
		} else {
			$(this).removeClass('mover');
		}
	});
	$('.global-nav>li:first-child').hover(function(){
		//$(this).removeClass('first');		
	}, function() {
		$(this).addClass('first');	
	});
	$('.global-nav>li:first-child>ul').mouseover(function(){
		$(this).parent('li').removeClass('first');
		
	});
	$('.big ul li.current').each(function() {
		$(this).parent().show();
		$(this).parent().parent().parent('ul').show();
	});
	$('.side-bar ul li.current').each(function() {
		$(this).parent().show();
		$(this).parent().parent().parent('ul').show();
	});
	$('.side-bar ul li.last ul:visible').parent().removeClass('last');
		
	},
	
	
	subscribe: function(form) {
		$('#newsletter_indicator').show();
		$.getJSON(form.action, {email: form.email.value}, function(data) {
			if(data.status) {
				$(form).children('p.error').html(data.msg).children('label').hide();
				$(form).children('button').attr('disabled', 'disabled');
				$(form).children('input').css('background', '#aeaeae').attr('disabled', 'disabled');
			} else {
				$(form).children('p.error').html('<label for="newsletter_email" class="error">'+data.msg+'</label>');
			}
			form.email.value = '';
			form.email.focus();
			$('#newsletter_indicator').hide();
		});
	}
};

$(function() {
	Site.init();
});


