$(document).ready(function() {
	var dropDown = $("div#dropDown");
	var subMenus = $("div.subNav");
	
	subMenus.each(function() {
		$(this).hide();
	});
	
	dropDown.hide();
	
	$("input.calendarPopupDatePicker").datepicker({
		dateFormat : 'dd/mm/yy',
		maxDate : '+6m',
		minDate : '0'
	});
	
	$("li#menu_newcars a").click(function() {
		$("div#overlay").fadeIn(500, function() {
			dropDown.show();
		});
		return false;
	});
	
	$("div.closeButton a").click(function() {
		$("div#overlay").fadeOut();
		dropDown.hide();
		return false;
	});
	
	$("div#header ul#menu li").hover(function() {
		var subMenu = $(this).find("div.subNav");
		if (subMenu.length > 0) {
			subMenu.show();
		}
	}, function() {
		subMenus.each(function() {
			$(this).hide();
		});
	});
	
	$("div#header ul#menu2 li").hover(function() {
		var subMenu = $(this).find("div.subNav");
		if (subMenu.length > 0) {
			subMenu.show();
		}
	}, function() {
		subMenus.each(function() {
			$(this).hide();
		});
	});
	
	var allHomeThumbs = $("a.icon");
	allHomeThumbs.hover(
		function() {
			allHomeThumbs.css("opacity", "0.25");
			$(this).css("opacity", "1");
		}, function() {
			allHomeThumbs.css("opacity", "1");
		}
	);
	
	/* subnav safari width fix */
	subMenus.each(function() {
		if (! $("body").hasClass("ie") ) {
			if ($(this).width() % 2 == 1) {
				$(this).width($(this).width() + 1);
			}
		}
	});
});
