(function($)
{
	$.browserWarning = function(options)
	{
		// Set the options.
		options = $.extend({},$.browserWarning.defaults, options);
		// Go through the matched elements and return the jQuery object.
		if(badBrowser() && getBadBrowser(options.cookieName) != 'seen' ){
		
		$("<div id='"+ options.browserWarningClassId +"' class='"+ options.browserWarningClass +"'>"+ options.Warningtext +"[<a href='#' id='"+ options.warningCloseId +"'>"+ options.closeText +"</a>] </div>").prependTo("body");
			
			$('#'+ options.warningCloseId).click(function(){
				setBadBrowser(options.cookieName,'seen');
				$('#'+ options.browserWarningClassId).slideUp('slow');
				return false;
			});
		}
					
		
	};
	// Public defaults.
	$.browserWarning.defaults = {
		browserWarningClass:'browserWarning',
		browserWarningClassId:'browserWarning',
		warningCloseId:'warningClose',
		cookieName:'browserWarning',
		Warningtext:'You are using an unsupported browser. Please switch to <a href="http://getfirefox.com">FireFox</a>, <a href="http://www.opera.com/download/">Opera</a>, <a href="http://www.apple.com/safari/">Safari</a> or <a href="http://www.microsoft.com/windows/downloads/ie/getitnow.mspx">Internet Explorer 7 or above</a>. Thanks!&nbsp;&nbsp;&nbsp;',
		closeText:'close'
	};
	function badBrowser(){
		if($.browser.msie && parseInt($.browser.version) <= 6){ 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());
	}
	
	
	// Public functions.
})(jQuery);
