/*
function detectIE(ClassID,name)
function Test_acrobat(Is_IE)
function Test_browser()
function Test_cookie_return(Cookies_enabled)
function Test_cookie()
function Test_js()
function Test_screen()
function Test_compliance()
function allow_access()
*/

//var
var _Acrobat_answer=false;
var _Browser_answer=false;
var _Cookie_answer=false;
var _Js_answer=false;
var _Screen_answer=false;
//var

document.write('<SCR' + 'IPT LANGUAGE=VBScript>\n');
document.write('function TestPDF(Version)\n');
document.write('	on error resume next\n');
document.write('	TestPDF = IsObject(CreateObject(Version))\n');
document.write('end function\n');
document.write('</SCR' + 'IPT>\n');

function detectIE(ClassID,name)
{
	result = false;
	document.write('<SCR' + 'IPT LANGUAGE=VBScript>\n on error resume next \n result = IsObject(CreateObject("' + ClassID + '"))</SCR' + 'IPT>\n');
	if (result)
		return name+',';
	else
		return '';
};
	
function Test_acrobat(Is_IE)
{
	//var
	var PDF=false;
	var IE_PDFtest=false;
	//var
	
	if(navigator.mimeTypes.length>0)
	{
		if(navigator.mimeTypes["application/pdf"]!=undefined)
			PDF=true;
	}else{
		//TestPDF is a VBScript function at the top
		if(TestPDF("PDF.PdfCtrl.1")!=undefined || TestPDF("PDF.PdfCtrl.5")!=undefined || TestPDF("PDF.PdfCtrl.6")!=undefined || TestPDF("acroPDF.PDF")!=undefined)
			PDF=true;
	};

	if(PDF)
		document.getElementById('acrobat').innerHTML="<font color=#00bb00>Installed</font>";
	else
		document.getElementById('acrobat').innerHTML="<b><font color=#ff0000>Not Installed</font> - <a href=http://www.adobe.com/products/acrobat/readstep2.html target=_blank>Install</a></b>";

	return PDF;
};

function Test_browser()
{
	//var
	var User_agent = navigator.userAgent.toLowerCase();
	//User_agent="Mozilla/4.0 (compatible; MSIE 5.23; Mac_PowerPC)".toLowerCase();
	//User_agent="mozilla/5.0 (windows; u; windows nt 5.1; en-us; rv:1.7.10) gecko/20050716 firefox/1.0";
	//User_agent="mozilla/5.0 (windows; u; windows nt 5.1; en-us; rv:1.7.10) gecko/20050716 firefox/1.0.6";
	//User_agent="Mozilla/4.0 (compatible; MSIE 6.0; AOL 9.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)".toLowerCase();
	//User_agent="Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 1.1.4322)".toLowerCase();
	//User_agent="Mozilla/4.0 (compatible; MSIE 6.0; Windows 98)".toLowerCase();
	//User_agent="Mozilla/4.0 (compatible; MSIE 6.0; Windows 98; Win 9x 4.90)".toLowerCase();
	//User_agent="Mozilla/4.0 (compatible; MSIE 6.0; AOL 9.0; Windows 98)".toLowerCase();
	//User_agent="Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en) AppleWebKit/312.5 (KHTML, like Gecko) Safari/312.3".toLowerCase();
	//User_agent="Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:0.9.4.2) Gecko/20021112 CS 2000 7.0/7.0".toLowerCase();
	//User_agent="Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.1.4322)".toLowerCase();
	//User_agent="Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)".toLowerCase();
	//User_agent="Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.2) Gecko/20040804 Netscape/7.2 (ax)".toLowerCase();
	//User_agent="Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.10) Gecko/20050909 Red Hat/1.0.6-1.4.2 Firefox/1.0.6".toLowerCase();
	//User_agent="Mozilla/4.0 (compatible; MSIE 6.0; Windows NT; Hotbar 4.4.0.0)::ELNSB50::00008115064004b002a002dc000000000507000900000000".toLowerCase();
	//User_agent="AUDIOVOX-SMT5600/1.2 Mozilla/4.0 (compatible; MSIE 4.01; Windows CE; Smartphone; 176x220)".toLowerCase();
	//User_agent="Mozilla/4.0 (compatible; MSIE 5.0; AOL 7.0; Windows 95; DigExt)".toLowerCase();
	//User_agent="Mozilla/4.0 (compatible; MSIE 5.0; WinNT Service Pack 2; ATHMWWW1.1;)".toLowerCase();
	//User_agent="Mozilla/5.0 (compatible; Konqueror/3.3; Linux) (KHTML, like Gecko)".toLowerCase();
	//User_agent="Mozilla/5.0 (compatible; Konqueror/3.4; Linux) KHTML/3.4.2 (like Gecko)".toLowerCase();
	//User_agent="Mozilla/5.0 (compatible; Konqueror/3.1-rc3; i686 Linux; 20020119)".toLowerCase();
	//User_agent="Mozilla/2.0 (compatible; MSIE 3.0B; Windows NT)".toLowerCase();
	//User_agent="Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)".toLowerCase();
	//User_agent="LocalcomBot/1.2 (+http://www.local.com/bot.htm)".toLowerCase();
        var Is_IE  = (User_agent.indexOf("msie") != -1);
        var Is_AOL = (User_agent.indexOf("aol") != -1);
        var Is_NS  = (navigator.appName.indexOf("Netscape") != -1);
        var Is_WIN = ((User_agent.indexOf("win")!=-1) || (User_agent.indexOf("32bit")!=-1));
        var Is_MAC = (User_agent.indexOf("mac")!=-1);
        var Is_NIX = (User_agent.indexOf("nux")!=-1);
        var OS_ver = "";
        var Browser_ver = "";
        var Browser_subver = "";
        var Browser = "";
        //var
        
        try{
	        if(Is_IE)
	        {
		        Browser_ver=User_agent.match(/msie ([\d\.]+)/)[1];
			Browser="IE " + Browser_ver;
		}else{
			if(User_agent.match(/ ([\w\.]+)\/(\d+\.\d+)\.?\d?( \(ax\))?$/)!=null)
			{
			        Browser_ver=User_agent.match(/ ([\w\.]+)\/(\d+\.\d+)\.?\d?( \(ax\))?$/)[2];
				Browser=User_agent.match(/ ([\w\.]+)\/(\d+\.\d+)\.?\d?( \(ax\))?$/)[1];
			}else{
//				alert(User_agent);
			        Browser_ver=User_agent.match(/ ([\w\.]+)\/(\d+\.\d+)\.?\d?( \(ax\))?(-[\w\d]+)?;?/)[2];
				Browser=User_agent.match(/ ([\w\.]+)\/(\d+\.\d+)\.?\d?( \(ax\))?(-[\w\d]+)?;?/)[1];
			};
			Browser=Browser.charAt(0).toUpperCase() + Browser.substring(1,Browser.length) + " " + Browser_ver;
		};
	}catch(e){
		Browser_ver=0;
		Browser="Undetectable";
	};
	if(Is_AOL)
	{
	        Browser_subver=User_agent.match(/aol ([\d\.]+)/)[1];
		Browser+=" (AOL " + Browser_subver + ")";
	};
	if(Is_WIN)
	{
		OS_ver=User_agent.match(/win(\w\w )?\w* ?\w* ([\w\.]+)/);
		if(OS_ver[1]!=undefined && OS_ver[1].substring(2,3)==" ")
			OS_ver=OS_ver[1];
		else
			OS_ver=OS_ver[2];
	        switch(OS_ver)
	        {
	        	case '98': OS_ver="Windows 98"; break;
	        	case '3.1': OS_ver="Windows NT 3.1"; break;
	        	case '3.5': OS_ver="Windows NT 3.5"; break;
	        	case '3.51': OS_ver="Windows NT 3.51"; break;
	        	case '4.0': OS_ver="Windows NT 4.0"; break;
	        	case '5.0': OS_ver="Windows 2000"; break;
	        	case '5.1': OS_ver="Windows XP"; break;
	        	case '5.2': OS_ver="Windows Server 2003"; break;
	        	case '6.0': OS_ver="Vista"; break;
	        	case '6.1': OS_ver="Windows 7"; break;
	        	default: OS_ver="Windows " + OS_ver.toUpperCase(); break;
	        };
	}else if(Is_MAC){
		OS_ver="Macintosh";
	}else if(Is_NIX){
		OS_ver="Linux";
	}else{
		OS_ver="Other";
	};
	        
        //if((Is_IE && Browser_ver>5.5) && Is_WIN)
        //{
		document.getElementById('browser').innerHTML="<font color=#00bb00>" + OS_ver + " - " + Browser + "</font>";
		return true;
	//}else{
	//	document.getElementById('browser').innerHTML="<font color=#ff0000><b>" + OS_ver + " - " + Browser + "</b></font>";
	//	return false;
	//};

};

function Test_cookie_return(Cookies_enabled)
{
	//This function is ran from the postback of the "Test_cookie()" JS function
        if(Cookies_enabled)
        {
		document.getElementById('cookie').innerHTML="<font color=#00bb00>Enabled</font>";
		_Cookie_answer=true;
	}else{
		document.getElementById('cookie').innerHTML="<font color=#ff0000><b>Disabled</b></font>";
		_Cookie_answer=false;
	};

	allow_access();
};

function Test_cookie()
{
	//var
	var Js_post=new postback("test_cookies_enabled.asp");
	//var

	Js_post.Retrieve();

	return false;
};

function Test_js()
{
	document.getElementById('js').innerHTML="<font color=#00bb00>Enabled</font>";
	return true;
};

function Test_screen()
{
	if(screen.width >= 1024 && screen.height >= 768)
	{
		document.getElementById('screen').innerHTML="<font color=#00bb00>" + screen.width + "x" + screen.height + "</font>";
		return true;
	}else{
		document.getElementById('screen').innerHTML="<font color=#ff0000><b>" + screen.width + "x" + screen.height + "</b></font>";
		return false;
	};
};

function Test_compliance()
{
	//Don't crash on older browser like Netscape 4 or so.
	if(document.getElementById!=undefined)
	{
		//The "testing..." basically IS the JS test. Otherwise it's default HTML is "failed".
		document.getElementById('acrobat').innerHTML="<font color=#0000bb>testing...</font>";
		document.getElementById('browser').innerHTML="<font color=#0000bb>testing...</font>";
		document.getElementById('cookie').innerHTML="<font color=#0000bb>testing...</font>";
		document.getElementById('js').innerHTML="<font color=#0000bb>testing...</font>";
		//document.getElementById('screen').innerHTML="<font color=#0000bb>testing...</font>";
	
		//I normally init the vars in the decarations, but wanted to specifically
		//show the "testing..." incase something was taking longer.
		_Acrobat_answer=Test_acrobat();
		_Browser_answer=Test_browser();
		_Cookie_answer=Test_cookie();
		_Js_answer=Test_js();
		//_Screen_answer=Test_screen();
	
		allow_access();
	};
};

function allow_access()
{
	if(_Js_answer && _Cookie_answer)
	{
		document.Login_form.username.disabled=false;
		document.Login_form.password.disabled=false;
		document.getElementById('login_button').style.visibility="visible";
		if(document.Login_form.username.value.length==0)
			document.Login_form.username.focus();
		else
			document.Login_form.password.focus();
	};
};
