var detect, OS, browser, version, thestring, place;
var COULD_NOT_DETECT = "Could not Detect";

function launchDD() {
   window.open("https://gfx-pp.bankofamerica.com/servlet/deploy/roundtriptest/launch");
}

function getBrowserTime() {
     var today = new Date();
     return((today) ? (today) : COULD_NOT_DETECT);
}

function getTimeZoneDifference() {
     var today = new Date();
    try {
    	var offset = "GMT ";
    	offset += (today.getTimezoneOffset()>0)? "+":"";
    	offset += (today.getTimezoneOffset()/60) +" hours";
    } catch (exc) {
   	offset = COULD_NOT_DETECT;
    }
    return offset;
    //(today.getTimezoneOffset) ? ((today.getTimezoneOffset()/60 + " hours ")+((today.getTimeZoneOffset()>0)?"after":"before") +" GMT") : COULD_NOT_DETECT;
	//return COULD_NOT_DETECT;
     
}

function isJavaScriptEnabled() {
     return "Yes";
}

function isCookieEnabled() {
     return(navigator.cookieEnabled?"Yes":"No");
}

function checkIt(s) {
	var detect = navigator.userAgent.toLowerCase();
	place = detect.indexOf(s) + 1;
	thestring = s;
	return place;
}


function getBrowserFullName(){

	detect = navigator.userAgent.toLowerCase();

	if (checkIt('konqueror')) {
	browser = "Konqueror";
	OS = "Linux";
	thestring = "konqueror";
	} else if (checkIt('safari')) {
		browser = "Safari";
	} else if (checkIt('omniweb')) {
		browser = "OmniWeb";
	} else if (checkIt('k-meleon')) {
		browser = "K-Meleon";
		var rv = detect.match(/k-meleon ([\w.]+)/);
		if (rv) {
			rv = rv[0];
			version = rv.substr(3);
		}
	}
	else if (checkIt('opera')) browser = "Opera";
	else if (checkIt('webtv')) browser = "WebTV";
	else if (checkIt('icab')) browser = "iCab"
	else if (checkIt('msie')) browser = "Internet Explorer";
	else if (!checkIt('compatible')) {
		browser = "Netscape Navigator"
		version = detect.charAt(8);
		if (typeof(navigator.product) != "undefined") {
			browser = "Mozilla";
			rv = navigator.userAgent.match(/([Mozilla ]?Fire\w+)\/([\w|\+.]+)/);
			if (rv) {
				browser = rv[1];
				version = rv[2];
			} else {
				rv = navigator.userAgent.match(/rv:([\w|\+.]+)/);
				if (rv) {
					rv = rv[0];
					version = rv.substr(3);
				}
			}
		}
	} else browser = "An unknown browser";

	if (!version) {
		version = detect.charAt(place + thestring.length);
	}

	var browsername = "";
	if (browser)
		browsername += browser;
	if (version)
		browsername += " " + version;

	return (browsername) ? browsername : COULD_NOT_DETECT;
}

function getOperatingSystem(){
	var i_win;
	var v_win;
	var agt=navigator.userAgent.toLowerCase();
	if (agt.indexOf("win")!=-1 || agt.indexOf("16bit")!=-1)
	i_win = true;
	if (i_win) {
	if (agt.indexOf("win95")!=-1 || agt.indexOf("windows 95")!=-1)
	v_win = "Windows 95";
	if (agt.indexOf("win98")!=-1 || agt.indexOf("windows 98")!=-1)
	v_win = "Windows 98";
	if (agt.indexOf("win 9x 4.90")!=-1)
	v_win = "Windows ME";
	if (agt.indexOf("winnt")!=-1 || agt.indexOf("windows nt")!=-1)
	v_win = "Windows NT";
	if (agt.indexOf("windows nt 5.0")!=-1)
	v_win = "Windows 2000";
	if (agt.indexOf("windows nt 5.1")!=-1)
	v_win = "Windows XP";
	if (!v_win)
	v_win = "Unknown Windows";
	}
	if (!OS) {
	if (checkIt('linux')) OS = "Linux";
	else if (checkIt('x11')) OS = "Unix";
	else if (checkIt('mac')) OS = "Mac"
	else if (checkIt('win')) OS = "Windows"
	else OS = "an unknown operating system";
	}

	var theOS = (typeof(navigator.oscpu) != "undefined" && navigator.oscpu != "") ? navigator.oscpu : OS;
	if (i_win)
	 theOS = theOS +" - " + v_win;

	 return theOS;
}



function getUserAgent(){
	return (typeof(navigator.userAgent) != "undefined") ? navigator.userAgent : "Not Supported";
}

function getScreenSize(){
	if (typeof(screen.width) != "undefined")
	return (screen.width && screen.height) ? screen.width + ' x ' + screen.height : COULD_NOT_DETECT;
	else
	return COULD_NOT_DETECT;
}


function getBrowserSize(){
	var inw = false;
	var inh = false;

	if (window.innerWidth){
		inw = window.innerWidth;
	}else if (document.body){
		if (document.body.offsetWidth){
			inw = document.body.offsetWidth;
		}
	}


	if (window.innerHeight){
		inh = (window.innerHeight);
	} else if (document.body) {
		if (document.body.offsetHeight){
			inh = document.body.offsetHeight;
		}
	}


	return (inw && inh) ?(inw + ' x ' + inh) : COULD_NOT_DETECT;
}

function getPlatform(){
if (typeof(navigator.platform) != "undefined") {
		switch (navigator.platform) {
			case "Win32" : return "Windows 32-bit"; break;
			case "Windows" : return "Windows 32-bit"; break;
			case "Win16" : return "Windows 16-bit"; break;
			case "WinCE" : return "Windows CE"; break;
			default : return(""); break;
		}
	}
	return "";
}

function getJavaSupported() {
	if (!navigator.javaEnabled() ){
		return ("No");
	}
    if (document.bda){
        return("Yes");
    }
    return ("No");
}

function getJavaVersion() {
	if (getJavaSupported() == "No"){
		return "-";
	} else {
        try{
           return document.bda.getVersion();
        } catch (exc){
            return COULD_NOT_DETECT;
        }
	}
}

function getDownloadSpeed() {
	if (getJavaSupported() == "No"){
		return "-";
	} else {
        try{
           return document.speed.getDownloadSpeed();
        } catch (exc){
            return COULD_NOT_DETECT;
        }
	}
}

function getJavaVendor() {
	if (getJavaSupported() == "No"){
		return "-";
	} else {
	    try{
                return document.bda.getVendor();
        } catch (exc){
            return COULD_NOT_DETECT;
        }
	}
}

function getColorDepth() {
	if (typeof(screen.colorDepth) != "undefined"){

		if (!screen.colorDepth){
			return COULD_NOT_DETECT;
		}
		switch (screen.colorDepth) {
			case 15: return screen.colorDepth+"-bit Color"+" (32,768 Colors, HiColor)";break;
			case 16:return screen.colorDepth+"-bit Color"+" (65,536 Colors, HiColor)";break;
			case 24: return screen.colorDepth+"-bit Color"+" (16.77 Million Colors, TrueColor)";break;
			case 32: return screen.colorDepth+"-bit Color"+" (16.77 Million Colors)";break;
			default: return screen.colorDepth+"-bit Color";
		}
	} else {
		return COULD_NOT_DETECT;
	}
}


function isDefined(property) {
  return (typeof property != 'undefined');
}

var flashVersion = 0;
function getFlashVersion() {
   var latestFlashVersion = 8;
   var agent = navigator.userAgent.toLowerCase();

   // NS3 needs flashVersion to be a local variable
   if (agent.indexOf("mozilla/3") != -1 && agent.indexOf("msie") == -1) {
      flashVersion = 0;
   }

   // NS3+, Opera3+, IE5+ Mac (support plugin array):  check for Flash plugin in plugin array
   if (navigator.plugins != null && navigator.plugins.length > 0) {
      var flashPlugin = navigator.plugins['Shockwave Flash'];
      if (typeof flashPlugin == 'object') {
         for (var i = latestFlashVersion; i >= 3; i--) {
            if (flashPlugin.description.indexOf(i + '.') != -1) {
               flashVersion = i;
               break;
            }
         }
      }
   }

   // IE4+ Win32:  attempt to create an ActiveX object using VBScript
   else if (agent.indexOf("msie") != -1 && parseInt(navigator.appVersion) >= 4 && agent.indexOf("win")!=-1 && agent.indexOf("16bit")==-1) {
      var doc = '<scr' + 'ipt language="VBScript"\> \n';
      doc += 'On Error Resume Next \n';
      doc += 'Dim obFlash \n';
      doc += 'For i = ' + latestFlashVersion + ' To 3 Step -1 \n';
      doc += '   Set obFlash = CreateObject("ShockwaveFlash.ShockwaveFlash." & i) \n';
      doc += '   If IsObject(obFlash) Then \n';
      doc += '      flashVersion = i \n';
      doc += '      Exit For \n';
      doc += '   End If \n';
      doc += 'Next \n';
      doc += '</scr' + 'ipt\> \n';
      document.write(doc);
   }

   // WebTV 2.5 supports flash 3
   else if (agent.indexOf("webtv/2.5") != -1) flashVersion = 3;

   // older WebTV supports flash 2
   else if (agent.indexOf("webtv") != -1) flashVersion = 2;

   // Can't detect in all other cases
   else {
      flashVersion = COULD_NOT_DETECT;
   }

   return flashVersion;
}

flashVersion_DONTKNOW = COULD_NOT_DETECT;

var quicktimeVersion = "-";
function getQuicktimeVersion() {
   var agent = navigator.userAgent.toLowerCase();

   // NS3+, Opera3+, IE5+ Mac (support plugin array):  check for Quicktime plugin in plugin array
   if (navigator.plugins != null && navigator.plugins.length > 0) {
      for (i=0; i < navigator.plugins.length; i++ ) {
         var plugin =navigator.plugins[i];
         if (plugin.name.indexOf("QuickTime") > -1) {
            quicktimeVersion = parseFloat(plugin.name.substring(18));
         }
      }
   }

   // IE4+ Win32:  attempt to create an ActiveX object using VBScript
   else if (agent.indexOf("msie") != -1 && parseInt(navigator.appVersion) >= 4 && agent.indexOf("win")!=-1 && agent.indexOf("16bit")==-1) {
     document.write('<scr' + 'ipt language="VBScript"\> \n');
      document.write('on error resume next \n');
      document.write('dim obQuicktime \n');
      document.write('set obQuicktime = CreateObject("QuickTimeCheckObject.QuickTimeCheck.1") \n');
      document.write('if IsObject(obQuicktime) then \n');
      document.write('   if obQuicktime.IsQuickTimeAvailable(0) then \n');
      document.write('      quicktimeVersion = CInt(Hex(obQuicktime.QuickTimeVersion) / 1000000) \n');
      document.write('   end if \n');
      document.write('end if \n');
      document.write('</scr' + 'ipt\> \n');
  }

   // Can't detect in all other cases
   else {
      quicktimeVersion = COULD_NOT_DETECT;
   }

   return quicktimeVersion;
}

quicktimeVersion_DONTKNOW = COULD_NOT_DETECT;

var acrobatVersion = "-";
function getAcrobatVersion() {
   var agent = navigator.userAgent.toLowerCase();

   // NS3+, Opera3+, IE5+ Mac, Safari (support plugin array):  check for Acrobat plugin in plugin array
   if (navigator.plugins != null && navigator.plugins.length > 0) {
      for (i=0; i < navigator.plugins.length; i++ ) {
         var plugin = navigator.plugins[i];
         if (plugin.name.indexOf("Adobe Acrobat") > -1) {
            acrobatVersion = parseFloat(plugin.description.substring(30));
         }
      }
   }

   // IE4+ Win32:  attempt to create an ActiveX object using VBScript
   else if (agent.indexOf("msie") != -1 && parseInt(navigator.appVersion) >= 4 && agent.indexOf("win")!=-1 && agent.indexOf("16bit")==-1) {
      document.write('<scr' + 'ipt language="VBScript"\> \n');
      document.write('on error resume next \n');
      document.write('dim obAcrobat \n');
      document.write('set obAcrobat = CreateObject("PDF.PdfCtrl.5") \n');
      document.write('if IsObject(obAcrobat) then \n');
      document.write('acrobatVersion = 5 \n');
      document.write('else set obAcrobat = CreateObject("PDF.PdfCtrl.1") end if \n');
      document.write('if acrobatVersion < 5 and IsObject(obAcrobat) then \n');
      document.write('acrobatVersion = 4 \n');
      document.write('end if');
      document.write('</scr' + 'ipt\> \n');
  }

   // Can't detect in all other cases
   else {
      acrobatVersion = COULD_NOT_DETECT;
   }

   return acrobatVersion;
}

acrobatVersion_DONTKNOW = COULD_NOT_DETECT;

