$(document).ready(function() {
	// ---------------------------------------------------
	//	Code for simple sub menu
	// ---------------------------------------------------
	// SlideUp and SlideDown has problems when rollover and out happens very quickly 
	// found that little fix on the web
	$("#navigation li.has-subnav").hover(function(){
		//without delay, animation gets queued. stop() doesn't work properly with the slide functions
		$(".subnav",this).delay(150).stop(true,true).fadeIn(110);
	},function(){
		//without delay, animation gets queued. stop() doesn't work properly with the slide functions
		$(".subnav",this).delay(150).stop(true,true).fadeOut(110);
	})
	$(".subnav").hide();
	$("#navigation li.has-subnav").mouseout();

	//Adding class for last and last item of sub navigation links
	$(".subnav li:last").addClass("last");
	$(".subnav li:first").addClass("first");
	
	
	//Newsletter stuff
	$(".zoom_newsletter").fancybox({
		'titleShow'     : false,
		'overlayColor'	: '#0F282D',
		'padding'		: 0

	});
	
	$('#form_newsletter').validate({	
		submitHandler:	function() {
			
			$('#form_newsletter').ajaxSubmit({								   
				url: '/ajax.html',
				data: {context: 'Site_Ajax', action: 'newsletter'},
				type: 'POST',
				dataType: 'json',
				success: function(data) {
					if (data.status == 'OK') {
						$('#form_newsletter').fadeOut(function() {
							$('#confirmation').html(data.html).show();
						});
					} else {
						$('#error').html(dictionary['newsletter_error']);
						$('#error').fadeIn();
					}
				}
			});	
		}
	});
	
});
