jQuery(document).ready(function() {
		
	jQuery(".submenu li:first-child").addClass('first');
	//jQuery(".submenu li:last-child").addClass('last'); //This is added auto by Structure

	initDropdown();
	
	function initDropdown(){
		var _hoverClass = 'hover';
		var _animSpeed = 500;
		$('.menu').each(function(){
			var _holder = $(this);
			var _links = $('>li', _holder);
			
			_links.each(function(){
				var _link = $(this);
				var _drop = false;
				if (_link.find('.submenu').length) {
					_drop = _link.find('.submenu');
					_drop.data('height', _drop.height());
					_drop.data('top', 45);
					function resetDrop(){
						if ($.browser.msie){
							_drop.css({
								'display': 'block',
								'top': -99999,
								'height':0
							});
						}
						else _drop.css({
								'display': 'block',
								'top': -99999,
								'height':0,
								'opacity':0.5
							});
					}
					setTimeout(resetDrop, 500);
				}
				
				_link.mouseenter(function(){
					_link.addClass("over");
					if (_drop){
						_link.removeClass("over");
						_link.addClass(_hoverClass);
						_drop.css('top', _drop.data('top'))
						if ($.browser.msie)
							_drop.stop().animate({
								'height':_drop.data('height')
							}, _animSpeed)
							else _drop.stop().animate({
								'opacity' : 1,
								'height':_drop.data('height')
							}, _animSpeed);
					}
				}).mouseleave(function(){
					if (_drop){
						_drop.hide();
						resetDrop();
						_link.removeClass(_hoverClass);
					}
					if (!_drop) {
						_link.removeClass("over");
						_link.removeClass(_hoverClass);
					}
				});
			})
		})
	}
	
	// header background
	
	var theWindow        = $(window),
		$bg              = $(".header-bg img"),
		aspectRatio      = $bg.width() / $bg.height();

	function resizeBg() {
		if ($(window).width() > 1352) {
			$bg.addClass('bgwidth');
		}
		else {
			$bg.removeClass('bgwidth').addClass('fixed');
		}
	}

	theWindow.resize(function() {
			resizeBg();
	}).trigger("resize");
		
});
	
	
