/** v1 bythink2loud.com, v1.4 by www.team-noir.net */

function badBrowser() {
	var userAgent = navigator.userAgent.toLowerCase();
	if ($.browser.msie && parseInt($.browser.version, 10) < 8) {
		return true;
	}
	if ($.browser.opera && ($.browser.version *10) <= 95) {
		return true;
	}
	if (/firefox[\/\s](\d+\.\d+)/.test(userAgent)) {
		var ffversion = Number(RegExp.$1);
		if (ffversion < 3) {
			return true;
		}
	}
	if (/safari[\/\s](\d+\.\d+)/.test(userAgent) && !/chrome[\/\s](\d+\.\d+)/.test(userAgent)) {
		var safari = userAgent.indexOf('version');
		if (safari > -1) {
			var snip1 = safari+8;
			var version = userAgent.substring(snip1, (snip1+1));
			if (version < 4) {
				return true;
			}
		}
	}
	var chrome = userAgent.indexOf('chrome');
	if (chrome > -1) {
		var snip1 = chrome+7;
		var version = userAgent.substring(snip1, (snip1+1));
		if (version < 3) {
			return true;
			}
	}
    return false;
}
function getBadBrowser(c_name) {
	if (document.cookie.length > 0) {
		c_start = document.cookie.indexOf(c_name + "=");
		if (c_start != -1) {
			c_start = c_start + c_name.length + 1;
			c_end   = document.cookie.indexOf(";",c_start);
			if (c_end == -1) {
				c_end = document.cookie.length;
			}
			return unescape(document.cookie.substring(c_start,c_end));
		} 
	}
	return "";
}
function setBadBrowser(c_name,value,expiredays) {
	var exdate = new Date();
	exdate.setDate(exdate.getDate() + expiredays);
	document.cookie = c_name + "=" + escape(value) + ((expiredays === null) ? "" : ";expires=" + exdate.toGMTString());
}
if(badBrowser() && getBadBrowser('browserWarning') != 'seen') {
	$(function() {
	$("<div id='browserWarning'><strong>WARNING:</strong> Many websites, including this one, will not work as they should on excessively old browsers. Please upgrade to <a href='http://getfirefox.com'>FireFox</a>, <a href='http://opera.com/download/'>Opera</a>, <a href='http://apple.com/safari/'>Safari</a>, or <a href='http://google.com/chrome?&brand=CHMA&utm_campaign=en&utm_source=en-ha-na-us-bk&utm_medium=ha'>Google Chrome</a>, all superior to your current browser and completely free of charge. You can continue viewing this site, keeping in mind the shortcomings of this browser.&nbsp;&nbsp;&nbsp;<a href='#' id='warningClose'><img src='img/close.gif' alt='Close this box' /></a></div>")
			.prependTo("body");
	$('#warningClose').click(function(){
			setBadBrowser('browserWarning','seen');
	$('#browserWarning').slideUp('slow');
			return false;
		});
	});
}

