$(function() {
	$("#tabbar a").click(function() {
		$(this).addClass("activetab").siblings().removeClass("activetab");
		var c = $("#c" + this.id.substring(1));
		c.siblings(".channel:visible").hide(); //.fadeOut(function() {
		//c.fadeIn();
		//});
		c.show();
		$("#viewall a").html((c.is(".domsopen") ? "Collapse" : "View") + " All Offers");
		this.blur();
		return false;
	});
	var pi = function(el) {
		$("a", el).each(function() {
			var i = new Image();
			i.src = this.img;
		});
	};
	$("h5 a").click(function() {
		if ($(this).hasClass("open")) {
			$(this).removeClass("open").parent().siblings().slideUp().parent().prev().slideUp();
		} else {
			$(this).addClass("open").parent().siblings().slideDown().parent().prev().slideDown();
			pi($(this).parent().siblings());
		}
		return false;
	});
	$("#viewall a").click(function() {
		if ($(this).html().indexOf("View") > -1) {
			$(this).html("Collapse All Offers");
			$(".channel:visible h5 a:not(.open)").click().parents(".channel").addClass("domsopen");
		} else {
			$(this).html("View All Offers");
			$(".channel:visible h5 a.open").click().parents(".channel").removeClass("domsopen");
		}
		return false;
	});
	$("#content div.fulllabelbox a").each(function() {
		this.img = this.title;
		$(this).removeAttr("title");
	}).hoverIntent(function() {
		var me = this;
		var h = me.href;
		$(this).parents(".fulllabelbox").each(function() {
			var o = $(this).offset();
			var po = $(this).parent().offset();
			$(this).parent().prev().animate({ paddingTop: ((o.top - po.top) + 24) + "px" }, { queue: false }).each(function() {
				if (me.img.substring(me.img.length - 4) == ".swf") {
					$(this).children("img").hide().siblings(".flholder").remove();
					var fid = "f" + (new Date()).toString();
					$(this).prepend("<div class='flholder'><div id='" + fid + "'></div></div>");
					swfobject.embedSWF(me.img, fid, "430", "600", "6.0.0");
				} else
					$(this).children("img").attr("src", me.img).show().siblings(".flholder").remove();
			}).find("a").each(function() {
				if (h.substring(h.length - 1) == "#")
					$(this).hide();
				else
					$(this).attr("href", h).css("display", "inline");
			});
		});
	}, function() { });
	$("#content div.emailboxholder a").click(function(){
		return false;
	});
	setTimeout(function() {
		pi($("#content div.domain:eq(0) div.emailboxholder"));
	}, 3000);
});