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() {
	$("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");
	$(".pro-roundboxbody *:last-child:not(a img)").css("margin-bottom", "0");
	$(".pro-box-body *:last-child:not(a img)").css("margin-bottom", "0");

	//	COLORBOX
	$("a.colorbox").colorbox({  })

	$("a.colorbox.wmv").colorbox({ photo: false, iframe: true, width: 600, height: 500, resize: false, href: "/weatherbug-professional/_av/_embed-video.asp?type=wmv" })
	$("a.colorbox.swf").colorbox({ photo: false, iframe: true, width: 600, height: 500, resize: false, href: "/weatherbug-professional/_av/_embed-video.asp?type=swf" })
	$("a.colorbox.mov").colorbox({ photo: false, iframe: true, width: 600, height: 500, resize: false, href: "/weatherbug-professional/_av/_embed-video.asp?type=mov" })
	$("a.colorbox.avi").colorbox({ photo: false, iframe: true, width: 600, height: 500, resize: false, href: "/weatherbug-professional/_av/_embed-video.asp?type=avi" })

	$(".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 })

	$(".msie8 .pdf a").colorbox({ photo: false, iframe: true, width: "90%", height: "90%", resize: false, href: "/weatherbug-professional/_docs/_embed-docs.asp?type=pdf" })
	$(".msie8 a.pdf").colorbox({ photo: false, iframe: true, width: "90%", height: "90%", resize: false, href: "/weatherbug-professional/_docs/_embed-docs.asp?type=pdf" })

	$(".free-demo a.colorbox").colorbox({ photo: false, iframe: true, width: 753, height: 650, resize: false }) // ideal width is 733, for content with no scrollbar
	$(".more-info a.colorbox").colorbox({ photo: false, iframe: true, width: 753, height: 650, resize: false })
	$("a.colorbox.marplot-download").colorbox({ photo: false, iframe: true, width: 753, height: "95%", resize: false }) // 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: 830, height: 800, resize: false })
	$("#contact-form-wrap a.colorbox").colorbox({ photo: false, inline: true, width: 350, href: "#recover-info-wrap" })


	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);
	}
});