var browserName;
var browserVersion;
var browserVersionSmall;
var newline = String.fromCharCode(10);
var crazyBrowserText="Crazy Browser";
var crazyBrowserInstalled=false;
var crazyBrowserErrorMsg="The Ecommcorporate application has detected the presence of the \"Crazy Browser\" browser on this machine." + newline + "The  Ecommcorporate application will not function normally with \"Crazy Browser\" installed." + newline + "Please close all Internet Explorer browser windows and the \"Crazy Browser\" browser and uninstall \"Crazy Browser\" from this machine. Re-launch a new Internet Explorer browser and access the Ecommcorporate application again." + newline;

var useragent;

useragent = navigator.userAgent;
browserName = (useragent.indexOf('Opera') > -1) ? 'Opera' : navigator.appName;

CheckBrowserVersion();

if(browserName == "Netscape" || (browserName == "Microsoft Internet Explorer" && browserVersionSmall == "4.0") )
{
	strMsg = "The Ecommcorporate application supports only the Microsoft Internet Explorer browser platform with the following versions - 5.0, 5.5 SP1, 5.5 SP2 and 6.0. Please ensure you access Ecommcorporate from the Microsoft Internet Explorer browser platform running one of these versions only.";
	alert(strMsg);

	window.close();
}



function CheckBrowserVersion()
{
	useragent = navigator.userAgent;
	browserName = (useragent.indexOf('Opera') > -1) ? 'Opera' : navigator.appName;
	
	var pos = useragent.indexOf('MSIE');
	
	if (pos > -1) 
	{
		browserVersion = useragent.substring(pos + 5);
		var pos = browserVersion.indexOf(';');
		browserVersion = browserVersion.substring(0,pos);
	}
	
	var pos = useragent.indexOf('Opera');
	
	if (pos > -1)	
	{
		browserVersion = useragent.substring(pos + 6);
		var pos = browserVersion.indexOf(' ');
		browserVersion = browserVersion.substring(0, pos);
	}
	
	if (browserName == "Netscape") 
	{
		var browserVersion = useragent.substring(8);
		var pos = browserVersion.indexOf(' ');
		browserVersion = browserVersion.substring(0, pos);
	}
	
	if (browserName == "Netscape" && parseInt(navigator.appVersion) >= 5) 
	{
		var pos = useragent.lastIndexOf('/');
		browserVersion = useragent.substring(pos + 1);
	}

	browserVersionSmall = browserVersion.slice(0,3);

	pos = useragent.indexOf(crazyBrowserText);
	if (pos > -1)	
		crazyBrowserInstalled=true;
	
}