$(document).ready(
	function () {
		if ($.browser.msie){
			// IE doesn't support :last-child, so we need to use jQuery to set those styles
			$("#topNav li:last").css({border:"none"});
			$("#blogText #breadCrumbs li:last").css({background: "none", padding: "2px 10px 0", height: "34px"});
			if ($.browser.version == "6.0") {
				// IE6 doesn't support :first-child, so we need to set the background with jQuery
				// IE6 also doesn't support alpha layer transparency, and our bg image is a 24b PNG, so we need to use the DXImage filter
				var topMenuFix = function () {return "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/images/menuTop-trans.png', sizingMethod='crop')";}
				$("#menu .rightMenu:first, #menu ul:first").css({
													filter: topMenuFix,
													backgroundImage: "none"
												});
				// Our menu has a transparent PNG as the background, but it's positioned, and the DXImage filter doesn't support
				// background-position, so we need to remove the background from the menu, create a new element that is the same
				// size as the background image, use the DXImage filter on our new element, and append the new element to #menu
				var ie6MenuBottom = $('<div>');
				var bottomMenuFix = function () {return "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/images/menuBottom-trans.png', sizingMethod='crop')";}
				$(ie6MenuBottom).css({
										height: "15px",
										width: "257px",
									 	filter: bottomMenuFix,
									 	backgroundImage: "none"
									 });
				$("#menu").append(ie6MenuBottom);
				$("#menu").css({backgroundImage: "none"});
			}
		}
		// The breadcrumb nav has a curved front edge that looks weird when the first item is :hover, so we need to fix that...
		$("#blogText #breadCrumbs li:first a")
			.hover(
				function () {
					// Select the parent (UL) of the anchor's parent (LI), and shift the background up 85px
					$($($(this).parent().get(0)).parent().get(0)).css({backgroundPosition: "0 -45px"});
				},
				function () {
					// Select the parent (UL) of the anchor's parent (LI), and set the background position back to default
					$($($(this).parent().get(0)).parent().get(0)).css({backgroundPosition: "0 0"});
				}
			);
		// message arrow
		var arrow = $('<div>');
		var arrowBG = function () {
			var BG = "transparent url(/images/";
			if ($(".message").hasClass("error")) {BG = BG + "error";}
			else if ($(".message").hasClass("success")) {BG = BG + "success";}
			else {BG = BG + "error";}
			BG = BG + "Arrow-trans.png) 0 0 no-repeat"
			return BG;
		}
		arrow.css({
				  	position: "absolute",
					top: "-15px",
					left: "-2px",
					width: "40px",
					height: "15px",
					background: arrowBG
				  });
		if (($.browser.msie) && ($.browser.version == "6.0")) {
			var arrowFix = function () {
					var filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/images/";
					if ($(".message").hasClass("error")) {filter = filter + "error";}
					else if ($(".message").hasClass("success")) {filter = filter + "success";}
					else {filter = filter + "error";}
					filter = filter + "Arrow-trans.png', sizingMethod='crop')";
					return filter;
				}
			arrow.css({
						filter: arrowFix,
						backgroundImage: "none"
					  });
		}
		$("#menu .rightMenu .menuBody .message").prepend(arrow).fadeIn(400);
		$("#menu .rightMenu .menuBody input")
			.focus(
				   function() {
						var message = $(".message", $(this).parents("div.menuBody"));
						if (message.is(":visible")) {
							if ($.browser.msie) {$(".menuBody p").css({opacity: "1"});}
							message.fadeOut(200);
						}
				   }
			);
		// IE Fixes...
		if ($.browser.msie) {
			if ($(".message").is(":visible")) {
				$(".menuBody p").css({opacity: "0"});
			}
		}
		
		// open all external links in new windows, since target is no longer a valid attirbute
		$("a[href^='http://']").click(function (e) {var target = $(this).attr("href");if(target.indexOf("gamingatlantic") > 15) {window.open(target, "", "");e.preventDefault();}});
	}
);