
//
// Browser Detection 1.0
//
// Copyright 2011 MacWorks/Christopher Raymond
// Author: Christopher Raymond, christopher@macworks.biz
// http://www.macworks.biz
//
// Duplication all or in part is not permitted
// without express permission from the author.
//


	var IE4 = ( document.all && !document.getElementById ) ? true : false;
	var IE6 = ( document.all && document.getElementById ) ? true : false;
	var NS4 = ( document.layers ) ? true : false;
	var W3C = ( !document.all && document.getElementById ) ? true : false;
	
	function authorizeBrowser()
		{
			if ( !IE4 && !NS4 && ( W3C || IE6 ))
				{
					if ( parseInt( MSIE_V_Num()) < 7 ) displayError();
					if ( parseInt( FF_V_Num()) < 3 ) displayError();
					if ( parseInt( NS_V_Num())) displayError();
					
					return true;
				}
			
			displayError();
		}
	
	function displayError()
		{
			if ( document.write("<div style=\"padding:30px 0;\"><img src=\"/media/images/common/logo.jpg\" alt=\"Mary T Inc. logo\" width=\"285\" height=\"130\" /></div><div style=\"padding:0 45px;max-width:300px;\"><h3 style=\"color:#CC1122;\">BROWSER PROBLEM</h3><p>We're sorry. Our web site conforms to W3C web programming standards and it appears that your browser might not. Please try using another browser.</p><h4>To download a recommended browser, please select:</h4><a href=\"http://www.apple.com/safari/\" title=\"Select to download Safari\" target=\"Safari\">Safari</a>, <a href=\"http://www.firefox.com/\" title=\"Select to download Firefox\" target=\"Firefox\">Firefox</a>, <a href=\"http://www.google.com/chrome/\" title=\"Select to download Google Chrome\" target=\"Chrome\">Google Chrome</a>, or <a href=\"http://www.microsoft.com/ie/\" title=\"Select to download Internet Explorer\" target=\"IE\">Internet Explorer</a></div>")) window.stop();
			return false;
		}
	
	function Chrome_V_Num( major_only, minor_only )
		{
			if ( 0 < navigator.userAgent.indexOf( "Chrome" )) return B_V_Num( "Chrome", navigator.userAgent, major_only, minor_only );
			return false;
		}
	
	function Safari_V_Num( major_only, minor_only )
		{
			if ( 0 < navigator.userAgent.indexOf( "Safari" )) return B_V_Num( "Version", navigator.userAgent, major_only, minor_only );
			return false;
		}
	
	function MSIE_V_Num( major_only, minor_only )
		{
			if ( 0 < navigator.appVersion.indexOf( "MSIE" )) return B_V_Num( "MSIE", navigator.appVersion, major_only, minor_only );
			return false;
		}
	
	function NS_V_Num( major_only, minor_only )
		{
			if ( 0 < navigator.userAgent.indexOf( "Navigator" )) return B_V_Num( "Navigator", navigator.userAgent, major_only, minor_only );
			if ( 0 < navigator.userAgent.indexOf( "Netscape" )) return B_V_Num( "Netscape", navigator.userAgent, major_only, minor_only );
			return false;
		}
	
	function FF_V_Num( major_only, minor_only )
		{
			if ( 0 < navigator.userAgent.indexOf( "Firefox" )) return B_V_Num( "Firefox", navigator.userAgent, major_only, minor_only );
			return false;
		}

	
	function B_V_Num( browser, string, major_only, minor_only )
		{
			var index = string.indexOf( browser );

			if ( index > 0 )
				{
					var switc = false;
					var major_ver = '';
					var minor_ver = '';
					var string = string.substring( index + browser.length + 1 );
					
					while ( string.length > 0 )
						{
							bite = string.substring( 0, 1 );
							string = string.substring( 1 );
							
							if ( bite == "." ) { if ( switc ) minor_ver += "."; switc = true; }
							else if ( bite == "/" ) { continue; }
							else if ( major_ver.length > 0 && ( bite == " " || bite == ";" )) { break; }
							else { if ( !switc ) major_ver += bite; else minor_ver += bite; }
						}

					if ( minor_only ) return minor_ver;
					if ( major_only ) return major_ver;

					return major_ver + "." + minor_ver;
				}

			return false;
		}


