$("img[alt]").each(function () {
	$(this).attr("title", "");
});
(function (Math, window, original) {
	var id = $(original),
	resize = function () {
		var wind = window.height();
		id.height(Math.max(wind, original));
	};
	original = id.height();
	resize();
	window.resize(resize);
}(Math, $(window), "#everything"));
$("body").click(function (e) {
	var target = e.target;
	target = target.nodeName.toLowerCase() === "a" ? $(target) :
		$(target).parents("a");
	if (target.length && !target.attr("target")) {
		if (target.attr("rel") === "external") {
			target.attr("target", "_blank");
		} else {
			target.attr("target", "_self");
		}
	}
});

(function () {
	var url, json, ajax, whatsnew = document.getElementById("whatsnew");
	if (whatsnew) {
		url = "new.json?uid=" + new Date().getTime();
		ajax = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
		ajax.open("GET", url, true);
		ajax.onreadystatechange = function () {
			if (ajax.readyState === 4) {
				if (ajax.status === 200 || ajax.status === 304) {
					json = eval(ajax.responseText);
					whatsnew.getElementsByTagName("p")[0].innerHTML = json[0];
					if (json[1]) {
						whatsnew.getElementsByTagName("a")[0].href = json[1];
					} else {
						whatsnew.getElementsByTagName("h2")[0].innerHTML = "What's New?";
					}
				}
				ajax = null;
			}
		};
		ajax.send(null);
	}
	url = json = null;
}());

(function ($) {
	var links = {
		hblink: "<li><a class='nobottomborder' href='http://www.xpressoptical.com/default.aspx?AffiliateID=9157624' rel='external'>xpressOptics</a></li><li><a class='nobottomborder' href='http://www.trueessentials.net/index.asp?repid=9157624' rel='external'>True Essentials Nutritional Supplements</a></li><li><a class='nobottomborder' href='http://www.envyorganics.com/index.asp?repid=9157624' rel='external'>Envy Organics: Beauty</a></li><li><a class='nobottomborder' href='http://www.fabsfhtm.com/?repid=9157624' rel='external'>FABS CyberFitness</a></li><li><a class='nobottomborder' href='http://www.trueessentials.net/theflyingbasset/index.asp?repid=9157624' rel='external'>Flying Basset Organic Pet Food</a></li><li><a href='http://www.waterandairforlife.com/index.php?refid=9157624' rel='external'>Protection for Living Air &amp; Water Filters</a></li>",
		slink: "<li><a class='nobottomborder' href='http://www.homesavingsshop.com/frontpoint/frontpoint_home.cfm?sid=400027&subid=9157624' rel='external'>FrontPoint Security</a></li><li><a class='nobottomborder' href='go.php?title=IdentaShield+Identity+Protection&amp;url=http://fortune.identashield.com/' rel='external'>IdentaShield Identity Protection</a></li><li><a class='nobottomborder' href='go.php?title=Roadside+Assistance&amp;url=http://roadsideautoclub.com/' rel='external'>Roadside Assistance</a></li><li><a href='#' rel='external'>SocialShield</a></li>",
		elink: "<li><a class='nobottomborder' href='https://order.fhtmdishtv.com/index.php?rep_id=9157624' rel='external'>Dish Network</a></li><li><a class='nobottomborder' href='go.php?title=Magazines.com&amp;url=http://www.magazines.com/?siteID=TwiI6a2ZRy0-XsFBvk3syqDXC0SIRzs2BQ' rel='external'>Magazines.com Subscription Discounts</a></li><li><a href='go.php?title=Amusement+Pack&amp;url=http://www.amusementpack.com/' rel='external' class='nobottomborder'>Amusement Pack</a></li><li><a href='https://www.fhtm.net/n2u/new_acct.aspx?rep_no=9157624' rel='external'>N2U World Music</a></li>",
		clink: "<li><a class='nobottomborder' href='http://www.cellstores.com/mobile/?referringdomain=fortune&Eid=9157624' rel='external'>The Wireless Shop</a></li><li><a class='nobottomborder' href='https://fhtm.voiceconnectinc.com:10446/usa.php?repid=9157624' rel='external'>VoiceConnect Digital Voice</a></li><li><a class='nobottomborder' href='https://www.tcitel.com/new/?aid=5117&pid=r311&act=r&prod=op&repid=9157624' rel='external'>Total Call International Long Distance</a></li><li><a href='http://direct.digitallanding.com/?PromoID=5006070&option1=9157624' rel='external'>Digital Landing High-Speed Internet</a></li>"
	},
	menu = {
		del: function () {
			if (menu.parent) {
				menu.parent.unbind("mouseover", timer.clear);
				menu.parent.unbind("mouseout", timer.set);
			}
			if (menu.element) {
				menu.element.remove();
			}
		},
		build: function () {
			var th = $(this),
			pos = th.position(),
			content = links[this.id];
			if (content) {
				timer.clear();
				menu.del();
				menu.parent = th;
				menu.element = $("<ul id='subnav' style='top:" + (pos.top + 32) + "px; left:" + pos.left + "px'>" + content + "</ul>").appendTo("body").hover(timer.clear, timer.set);
				th.hover(timer.clear, timer.set);
			}
		}
	},
	timer = {
		clear: function () {
			clearTimeout(timer.time);
		},
		set: function () {
			timer.clear();
			timer.time = setTimeout(menu.del, 500);
		}
	};
	$(".dropdown").append(" ▼").mouseover(menu.build);
}($));
