var browser; var version;

// detect the browser and version
jQuery.each(jQuery.browser, function(i, val) {			
	if(i == "version") version = val.split(".")[0];
	else if(val) {
		browser = i;
	}
});

function processError(E,functionName)	{
	try {
		if(!outputErrors) return(false);
		var output = new Array(0);
		output.push(functionName + " ERROR:");
		output.push(E.name + ": " + E.number);
		output.push(E.description);
		alert(output.join("\r\n"));
	} catch (e) { processError(e,functionName); }
}

bannerTimer = false;
beingShown = false;
shown = false;
speed = 600;
bannerOffset = false;

function bannerTextOn() {
	if (bannerTimer) clearTimeout(bannerTimer);
	if (shown || beingShown) {
		return;
	} else {
		beingShown = true;
		if ($("body").hasClass("msie6") || $("body").hasClass("msie7")) {
			$(".pro-banner").show("slide", { direction: "left" },speed, function() { beingShown = false; shown = true; });
		} else {
			$(".pro-banner").show();
			$(".pro-banner").animate({ left: "0" }, speed, function() { beingShown = false; shown = true; });
		}
	}
}

function bannerTextOff() {
	if (bannerTimer) clearTimeout(bannerTimer);
	bannerTimer = setTimeout(function() {
		bannerTimer = null;
		if ($("body").hasClass("msie6") || $("body").hasClass("msie7")) {
			$(".pro-banner").hide("slide", { direction: "left" },speed, function() {  shown = false; });
		} else {
			if (!bannerOffset) bannerOffset = "325px";
			$(".pro-banner").animate({ left: bannerOffset }, speed, function() { shown = false; });
		}
	}, 250);
}

$(document).ready(function() {
	try {
		$("body").addClass(browser + version);
		if (browser.search(/msie/i) >= 0) $("body").addClass("msie");
		$("#pro-guts .weatherbug sup:first").css("display", "inline");
		$("#pro-guts-wrap .weatherbug sup:first").css("display", "inline");
		$("body:not(.campaign) *:last-child:not(a img)").css("margin-bottom", "0");
		//$(".pro-roundboxbody *:last-child:not(a img)").css("margin-bottom", "0");
		//$(".pro-box-body *:last-child:not(a img)").css("margin-bottom", "0");

		//	COLORBOX
		$(".colorbox").colorbox();
		$(".brightcove a.colorbox").colorbox({ photo: false, iframe: true, width: 550, height: 475, resize: false });
		$("a.colorbox.wmv").each(function() {
			jQuery(this).colorbox({ photo: false, iframe: true, width: 600, height: 500, resize: false, href: "/weatherbug-professional/_av/_embed-video.asp?type=wmv&file=" + jQuery(this).attr("href") });
		});
		$("a.colorbox.swf").each(function() {
			jQuery(this).colorbox({ photo: false, iframe: true, width: 600, height: 500, resize: false, href: "/weatherbug-professional/_av/_embed-video.asp?type=swf&file=" + jQuery(this).attr("href") });
		});
		$("a.colorbox.mov").each(function() {
			jQuery(this).colorbox({ photo: false, iframe: true, width: 600, height: 500, resize: false, href: "/weatherbug-professional/_av/_embed-video.asp?type=mov&file=" + jQuery(this).attr("href") });
		});
		$("a.colorbox.avi").each(function() {
			jQuery(this).colorbox({ photo: false, iframe: true, width: 600, height: 500, resize: false, href: "/weatherbug-professional/_av/_embed-video.asp?type=avi&file=" + jQuery(this).attr("href") });
		});
		$(".pdf a").colorbox({ photo: false, iframe: true, width: "90%", height: "90%", resize: false });
		$("a.pdf").colorbox({ photo: false, iframe: true, width: "90%", height: "90%", resize: false });

		
		$(".free-demo a.colorbox").colorbox({ photo: false, iframe: true, width: 783, height: 650, resize: false }) // ideal width is 733, for content with no scrollbar
		$(".more-info a.colorbox").colorbox({ photo: false, iframe: true, width: 783, height: 650, resize: false })
		$("a.colorbox.marplot-download").colorbox({ photo: false, iframe: true, width: 753, height: "95%", resize: false }, function() { loaded = 0; }) // ideal width is 733, for content with no scrollbar

		$("a.colorbox.interactive-lesson").colorbox({ photo: false, iframe: true, width: 802, height: 577, resize: false })
		$("a.colorbox.external").colorbox({ photo: false, iframe: true, width: "90%", height: "90%", resize: false })
		$("a.colorbox.owc").colorbox({ photo: false, iframe: true, width: 840, height: 800, resize: false })
		$("#contact-form-wrap a.colorbox").colorbox({ photo: false, inline: true, width: 350, href: "#recover-info-wrap" })

		$(".pro-poplink-anchor").colorbox({ photo: false, inline: true, width: 450, href: "#pro-related-content-view-all" });


		if ($("body").attr("id") != "login") {
			bannerOffset = $(".pro-banner").css("left");
			bannerTextOn();
			bannerTimer = setTimeout(bannerTextOff, 2000);
			$(".pro-banner-wrap").bind("mouseover", bannerTextOn);
			$(".pro-banner-wrap").bind("mouseout", bannerTextOff);
		}
	} catch (e) { }
});
