///////////////////////////////////////////////////////
// IsDownlevelBrowser -
//	Uses an excludion list for browsers not supported
//  in JQuery.  Add any incompatible browser discoveries
//  to this list.
//
// return - true if detected as downlevel browser
function afIsDownlevelBrowser()
{
	var UserAgent = String(navigator.userAgent);
	
	/*
	// Code to alert browser product string variables
	var AppName = String(navigator.appName);
	var AppVer = String(navigator.appVersion);
	var Platform = String(navigator.platform);
	var Vendor = String(navigator.vendor);
	var Product = String(navigator.product);
	
	alert("AppName = " + AppName + "\r\n" +
	"AppVer = " + AppVer + "\r\n" +2
	"Platform = " + Platform + "\r\n" +
	"UserAgent = " + UserAgent + "\r\n" +
	"Vendor = " + Vendor + "\r\n" +
	"Product = " + Product + "\r\n");
	*/

	// MSIE 4/5/6 are considered downlevel
	if ((UserAgent.indexOf("MSIE 5") > -1) ||
		(UserAgent.indexOf("MSIE 4") > -1) ||
		(UserAgent.indexOf("MSIE 6") > -1))
	{
		return 1;
	}
	// AppleWebkit less than "500" is considered downlevel
	else if (UserAgent.indexOf("AppleWebKit") > -1)
	{
		//if(parseInt(UserAgent.match(/AppleWebKit\/(\d+(\.\d+)?)/)[1]) < 500)
		if (parseInt(UserAgent.substring(UserAgent.indexOf("AppleWebKit") + 12)) < 500)
		{
			return 1;
		}
	}
	// Opera MINI, as it is not quite there at rendering advanced designs.
	else if (UserAgent.indexOf("Opera Mini") > -1)
	{
		return 1;
	}
	// Opera less than 8 is considered downlevel
	else if (UserAgent.indexOf("Opera") > -1)
	{
		if (parseInt(UserAgent.substring(UserAgent.indexOf("Opera") + 6)) < 8)
		{
			return 1;
		}
	}
	// Firefox 1 (Gecko) is considered downlevel
	else if (UserAgent.indexOf("Gecko") > -1)
	{
		if (parseFloat(UserAgent.substring(UserAgent.indexOf("rv:") + 3)) < 1.8)
		{
			return 1;
		}
	}

	// Any browser that makes it through these checks will go on to load the JQuery code.
	//
	// The first thing the loaded JQuery code does is use jQuery's own browser feature
	// detection to decide if the CSS BoxModel is supported. If that check returns false,
	// the connected browser is downgraded dynamically.
	//
	// So, this function is a way to exclude known downlevel browsers (browser sniffing).
	// I would prefer not to do this at all, but there are instances where a browser will
	// load jQuery, but not function correctly.
	//
	// JQuery's CSS BoxModel detection is a method for inclusion for any browser capable of
	// passing the JQuery check.
	return 0;
}

///////////////////////////////////////////////////////
// afLoadJQuery -
//	Load all global assets for JQuery Support
function afLoadJQuery()
{
	//  adds the jquery library and the page layout logic ("master") library to the page
	document.write("<script type=\"text/javascript\" src=\"/shared/widgets/js/jquery-1.5.1.js\"></script>");

	// In order to obscure the page until it is finished rendering, this style sheet is added
	// that effectively hides the BODY element.
	// The page is displayed as the final step in the af js code
	document.write("<link rel=\"stylesheet\" type=\"text/css\" href=\"/shared/widgets/css/af.curtain.css\" />");
}

// If this browser has not been flagged as downlevel, proceed to load JQuery
if (!afIsDownlevelBrowser())
{
	afLoadJQuery();
}

