//preload images for future cloning
var img_bad = new Image(30,30);
var img_good = new Image(30,30);
var img_waiting = new Image(30,30);
var img_question = new Image(30,30);
var img_caution = new Image(30, 30);
img_bad.src  = "./images/redx.gif";
img_good.src = "./images/greencheck.gif";
img_question.src = "./images/questionmark.jpg";
img_caution.src = "images/Caution.png";
img_waiting.src = "./images/wait30.gif";
var is_ie=false;
var mac, win, old, lin; 
var myVer = 'Unknown';
var verAction='Upgrade Current Browser';
var mediaType;
var realPlayer;
var flashPlayer;
//var baseURL = "http://services.choruscall.com.att-idns.net/systemtest/";
//var baseURL = "http://test.choruscall.com/services/systemtest/";
//var baseURL = "http://10.2.40.71/systemtest/";
var baseURL = "./";
var files=[baseURL+"200k.html",
           baseURL+"300k.html",
           baseURL+"400k.html",
           baseURL+"500k.html",
           baseURL+"750k.html",
           baseURL+"1MEG.html"];

var fileSizes=[200,300,400,500,750,1000];
var testRuns=0;

var detectableWithVB = false;

function setupPlayerVars(playerType,width,height,fileName,playerID,parentEle){
  var classID_Object="",classID_Embed="",mediaType="",player = null;
  if(playerType=='realplayer'){
    mediaType = "audio/x-pn-realaudio-plugin";
    classID_Object = "clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA";
    classID_Embed = "{CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA}";
  }
  else{
    if(playerType=='activex'){
      classID_Object = "CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6";
      classID_Embed="{6BF52A52-394A-11d3-B153-00C04F79FAA6}";
    }else{
      classID_Object = "clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA";
      classID_Embed="{CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA}";
    }
    mediaType="application/x-oleobject'";
  }
  if(playerType=='activex'){
    //Called when activeX rendering engine used
    //and or if browser is opera or netscape running as IE
    try{
    parentEle.innerHTML=[
      '<object classid = "',classID_Object,'" id = "',playerID,'"',
    	'width = "',width,'" height = "',height,'" ',
      'TYPE = "',mediaType,'" >',
    	'<PARAM NAME = "SRC" VALUE = "'+fileName+'">',
    	'<PARAM name = "Filename" value = "'+fileName+'">',
    	'<PARAM name = "url" value = "'+fileName+'">',
    	'<PARAM name = "ShowAudioControls" VALUE="false" >',
    	'<PARAM name = "ShowControls" VALUE="false" >',
    	'<PARAM name = "ShowStatusBar" value="false">',
    	'<PARAM name = "DisplayMode" value="false">',
    	'<PARAM name = "ShowDisplay" VALUE="false">',   
      '<PARAM name = "uiMode" value = "none">',
      '<PARAM name = "AutoStart" value = "true" >',
    	'<PARAM name = "AutoGotoURL" value = "false" >',
    	'<PARAM name = "PlayCount" value = "9999" >',
      '</object>'
    ].join('');
    }catch(err){
      var errstr=[''];
      for (var i in err)
        errstr.push(i,': ',err[i],'\n');
      alert("Error Creating Media Player Object: "+errstr.join(''));
    }
  }else {
    //Called if Browser is FireFox or Netscape running as FireFox
    player = document.createElement("embed");
    try{
      player.setAttribute("ID",playerID);
      player.setAttribute("NAME",playerID);
      player.setAttribute("TYPE",mediaType);
      player.setAttribute("HEIGHT",height);
      player.setAttribute("WIDTH",width);
      player.setAttribute("ClassID",classID_Embed);
      player.setAttribute("ShowControls","false");
      player.setAttribute("ShowAudioControls","false");
      player.setAttribute("ShowDisplay", "false");
      player.setAttribute("ShowStatusBar","false");
      player.setAttribute("SRC",fileName);
      player.setAttribute("loop","true");
      player.setAttribute("CONTROLS","ImageWindow");
      player.setAttribute("AutoStart","true");
      parentEle.appendChild(player);
    }catch(err){
      var errstr=[''];
      for (var i in err)
        errstr.push(i,': ',err[i],'\n');
      alert("Error Creating Media Player Embed Object: "+errstr.join(''));
    };
  }
}
function testBrowser(){
  var appAction='----------';
  var brow='';
  old=navigator.appVersion.substring(0,1)<4;
  mac=navigator.appVersion.indexOf('Mac')!=-1;
  win=(((navigator.appVersion.indexOf('Win')!=-1) || (navigator.appVersion.indexOf('NT')!=-1) ) && !mac);
  lin=(navigator.userAgent.indexOf('Linux')!=-1);
  var link='';
  var is_major = parseInt(navigator.appVersion);
  var is_minor = parseFloat(navigator.appVersion);
  // convert all characters to lowercase to simplify testing
  var agt=navigator.userAgent.toLowerCase();
     // *** PLATFORM ***
  var is_win   = ( (agt.indexOf("win")!=-1) || (agt.indexOf("16bit")!=-1) );
  var is_win95 = ((agt.indexOf("win95")!=-1) || (agt.indexOf("windows 95")!=-1));
  // is this a 16 bit compiled version?
  var is_win16 = ((agt.indexOf("win16")!=-1) ||
             (agt.indexOf("16bit")!=-1) || (agt.indexOf("windows 3.1")!=-1) ||
             (agt.indexOf("windows 16-bit")!=-1));
  var is_win31 = ((agt.indexOf("windows 3.1")!=-1) || (agt.indexOf("win16")!=-1) ||
                    (agt.indexOf("windows 16-bit")!=-1));
  var is_winme = ((agt.indexOf("win 9x 4.90")!=-1));
  var is_win2k = ((agt.indexOf("windows nt 5.0")!=-1));
  var is_win98 = ((agt.indexOf("win98")!=-1) || (agt.indexOf("windows 98")!=-1));
  var is_winnt = ((agt.indexOf("winnt")!=-1) || (agt.indexOf("windows nt")!=-1));
  var is_win32 = (is_win95 || is_winnt || is_win98 ||
                    ((is_major >= 4) && (navigator.platform == "Win32")) ||
                    (agt.indexOf("win32")!=-1) || (agt.indexOf("32bit")!=-1));
  var versionPass = 1;
  var appPass = 1;
  is_ie     = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1)&& agt.indexOf("netscape")==-1);
  var is_nav  = (agt.indexOf('netscape')!=-1);
  var is_aol   = (agt.indexOf("aol") != -1);
  var is_opera = (agt.indexOf("opera") != -1);
  var is_webtv = (agt.indexOf("webtv") != -1);
  var is_safari = (agt.indexOf("safari")!= -1);
  var is_camino = (agt.indexOf("camino")!= -1);
  var is_epiphany = (agt.indexOf("epiphany")!=-1 && agt.indexOf("firefox")==-1);
  var is_epiphany_and_ff = (agt.indexOf("epiphany")!=-1 && agt.indexOf("firefox")!=-1);
  var is_firefox_only = ((agt.indexOf("firefox") != -1)&&
                agt.indexOf("flock")==-1 &&
                agt.indexOf("swiftfox")==-1 &&
                agt.indexOf("epiphany")==-1);
  if(is_aol){
    brow='AOL';
    myVer = navigator.appVersion;
    if(mac)
      link='http://www.getfirefox.com/';
    else if(is_win)
      link='http://www.microsoft.com/windows/downloads/ie/getitnow.mspx';
    else if(lin)
      link='http://www.mozilla.com/en-US/firefox/all.html';
    appPass=0;
    versionPass=0;
  }else if(is_opera){
    brow='Opera';
    var ver = navigator.appVersion.replace("Opera/","");
    myVer = parseFloat(ver);
    if(mac)
      link='http://www.getfirefox.com/';
    else if(is_win)
      link='http://www.microsoft.com/windows/downloads/ie/getitnow.mspx';
    else if(lin)
      link='http://www.mozilla.com/en-US/firefox/all.html';
    appPass=0;
    versionPass=0;
  }else if(is_webtv){
    brow='Web TV';
    myVer = navigator.appVersion;
    if(mac)
      link='http://www.getfirefox.com/';
    else if(is_win)
      link='http://www.microsoft.com/windows/downloads/ie/getitnow.mspx';
    else if(lin)
      link='http://www.mozilla.com/en-US/firefox/all.html';
    appPass=0;
    versionPass=0;
  }else if(is_safari){
    brow = 'Safari';
    var agtArray = agt.split("/");
    var ver = parseFloat(agtArray[agtArray.length -1]);
    if(ver >419.3)
      myVer = 'Greater than 2.0.4';
    else if(ver > 417.8)
      myVer = '2.0.4';
    else if(ver > 417.3)
      myVer = '2.0.3';
    else if(ver >= 412)
      myVer = '2.0';
    else{
      myVer='Less than 2.0';
      versionPass=0;
      link='http://www.apple.com/macosx/safari/';
    }
  }else if(is_firefox_only){
    brow='Firefox';
    var agtArray = agt.split("/");
    var ver = parseFloat(agtArray[agtArray.length -1]);
    myVer = agtArray[agtArray.length -1];
    if(ver<1.5){
      link='http://www.mozilla.com/en-US/firefox/all.html';
      versionPass=0;
    }
  }else if(is_nav){
    brow='Netscape Navigator';
    var agtArray = agt.split("/");
    var ver = parseFloat(agtArray[agtArray.length -1]);
    myVer = agtArray[agtArray.length -1];
    if(ver<7.0){
      link='http://browser.netscape.com/ns8/';
      versionPass=0;
    }
  }else if(is_ie){
    brow='Internet Explorer';
    var agtArray = agt.split(";");
    myVer = agtArray[1].replace("msie","");
    var ver = parseInt(myVer);
    if(ver<6){
      link='http://www.microsoft.com/windows/downloads/ie/getitnow.mspx';
      versionPass=0;
    }
  }else if(is_camino){
    brow='Camino';
    var agtArray = agt.split("/");
    myVer = agtArray[agtArray.length -1];
    var ver = parseFloat(myVer);
    if(ver<1.0){
      versionPass = 0;
      link='http://www.caminobrowser.org/';
    }
  }else if(is_epiphany_and_ff){
    brow = 'Epiphany/Firefox'
    var ver = agt.split("/");
    var epVer = parseFloat(ver[3]);
    myVer = epVer+'/'+ver[4];
  }else {
    brow = 'Unknown';
    myVer='Unknown';
    if(mac)
      link='http://www.caminobrowser.org/';
    else if(is_win)
      link='http://www.microsoft.com/windows/downloads/ie/getitnow.mspx';
    else if(lin)
      link='http://www.mozilla.com/en-US/firefox/all.html';
    appPass=0;
    versionPass=0;
  }
  var osPass = 1;
  //If mac or linux os, fail mac || lin ||
  if( is_win95 || is_win16 || is_win31 || lin){
    osPass = 0;
  }
  var javaPass = 1;
  navigator.javaEnabled();
  //Display Browser Type
  if(appPass==0){
    if(mac)
      appAction='Install Camino for Mac';
    else if(is_win)
      appAction='Install IE';
    else if(lin)
      appAction='Install FireFox for Linux i686';
    verAction = appAction;
    addTableRow(2,img_bad,'Browser Name',brow,appAction, link ,'Download Browser');
  }
  else 
    addTableRow(2,img_good,'Browser Name',brow,'----------','----------');
  //Display Browser Version
  setTimeout(function(){
    if(!versionPass){
      addTableRow(3,img_bad,'Browser Version',myVer,verAction,link,'Upgrade Browser');
    }
    else
      addTableRow(3,img_good,'Browser Version',myVer,'----------','----------');
    setTimeout(function(){
      //Display Javascript Results
      if(!javaPass)
        addTableRow(4,img_bad,'Java Enabled?','No','Change Script Settings','----------')
      else
        addTableRow(4,img_good,'Java Enabled?','Yes','----------','----------')
      setTimeout(function(){
        if(osPass==0)
          addTableRow(5,img_bad,'Operating System',navigator.platform,'Windows PC or Mac','----------')
        else
          addTableRow(5,img_good,'Operating System',navigator.platform,'----------','----------')
      },500);
    },500);
  },500);
  //Display OS
}

function testPopUp(){
  //popup test
  var popUpsBlocked = "----------";
  var reslt = "Not Blocked";
  var popUpPass = 1;
  try {
    var mine = window.open('','','width=0,height=0,left=0,top=0,scrollbars=no');
    mine.close()
  } catch(err){
    popUpsBlocked = "Enable Pop-Ups, however this item is not critical for your event.";
    reslt = "Blocked";
    popUpPass = 0;
  }
  if(popUpPass==0){
    addTableRow(1,img_caution,"Pop-Ups",reslt,popUpsBlocked,"javascript:gotoLink('popupnotice')","How To...");
  }
  else
    addTableRow(1,img_good,"Pop-Ups",reslt,popUpsBlocked,"----------");
}

//Attempt to detect Real Player plugin
function QTDetect() {
  var pluginFound = detectPlugins('QuickTime');
  // if not found, try to detect with VisualBasic
  if(!pluginFound && detectableWithVB) {
    pluginFound = detectQuickTimeActiveXControl();
  }
  return pluginFound;
}

function FlashDetect() {
  var pluginFound = detectPlugins('Shockwave Flash');
  // if not found, try to detect with VisualBasic
/*  if(!pluginFound && detectableWithVB) {
    pluginFound = 
  }
  */
  return pluginFound;
}

function WMDetect() {
  var pluginFound = detectPlugins('Windows Media');
    // if not found, try to detect with VisualBasic
  if(!pluginFound && detectableWithVB) {
    pluginFound = detectActiveXControl('MediaPlayer.MediaPlayer.1');
  }
  return pluginFound;
}

function detectPlugins() {
  // allow for multiple checks in a single pass
  // consider pluginFound to be false until proven true
  var allFound = false,numFound=0,i=0,j=0,
      requestCt=arguments.length,pluginsArrayLength=0,
      currentPlugin=null,currentName='';
  // if plugins array is there and not fake
  if (navigator.plugins && navigator.plugins.length > 0) {
    pluginsArrayLength = navigator.plugins.length;
  }
  // for each plugin...
  for (i=0; (i < pluginsArrayLength)&&!allFound; i++) {
    currentPlugin=navigator.plugins[i];
    // loop through all desired names and check each against the current plugin name
    for(j=0; j < arguments.length; j++) {
      currentName=arguments[j];
      // if desired plugin name is found in either plugin name or description
      if((currentPlugin.name.indexOf(currentName) >= 0) ||
         (currentPlugin.description.indexOf(currentName) >= 0)) {
        // this name was found
        numFound++;
      }
    }
    // now that we have checked all the required names against this one plugin,
    // if the number we found matches the total number provided then we were successful
    allFound = (numFound == requestCt);
    numFound=0;
  }
  return allFound;
} // detectPlugins

function testPlayers(){
  var playerReport="";
  var playerPass=false;
  var wmp=null;
  var flash=null;
  if(canDetectPlugins()){
    wmp = WMDetect();
    flash = FlashDetect();
    if(!is_ie && !flash){
      playerReport="Must have Adobe's Flash Player installed with Non-IE Browser";
    }else if(!is_ie && flash){
      playerReport="Adobe's Flash Player";
      playerPass = true;
    }else if(wmp && is_ie){
      playerReport="WMP";
      playerPass = true;
      var player;
      try
      {
        if(window.ActiveXObject){
          player = new ActiveXObject("WMPlayer.OCX.7");
        }
      }
      catch(e){
        playerReport=playerReport+" Version-6.4";
        playerPass = false;
      }
      if (player){
        var versionString = player.versionInfo;
        playerReport=playerReport+" Version-"+versionString;
      }
    }else if(flash && !wmp){
      playerReport="Adobe Flash Player";
      playerPass = true;
    }else{
      playerReport = "No Compatible Player/Browser Combination Found."
    }
  }
  if(playerPass){
    addTableRow(8,img_good,"Media Player(s)",playerReport,"----------","----------");
  }else{
    var playerURL = "http://get.adobe.com/flashplayer/";
    var playerName = "Flash Player";
    if(is_ie){
     playerName = "Windows Media Player";
     playerURL = "http://download.microsoft.com/download/0/9/5/0953E553-3BB6-44B1-8973-106F1B7E5049/wmp11-windowsxp-x86-enu.exe";
    }
    addTableRow(8,img_bad,"Media Player(s)",playerReport,playerName,playerURL,"Download "+playerName);
  }
}

function canDetectPlugins() {
  return ( detectableWithVB || (navigator.plugins && navigator.plugins.length > 0) );
}
//speed test

/*
function testStreamingVideo(){
  var videobtn=document.getElementById('btn_video_start');
  var audiobtn=document.getElementById('btn_audio_start');
  videobtn.disabled=true;
  videobtn.innerHTML="Running...";
  if(audiobtn)audiobtn.disabled=true;
  document.getElementById("image9").src=img_waiting.src;
  var playertype='';
  if(!is_ie){
    fileName = "rtsp://st21g1.services.att-idns.net/v1/614/2606/video/diamond_test.rm";
    playertype='realplayer';
  }else{
    fileName = "mms://us-eu-st11g1.att-idns.net/v1/614/2606/video/diamond_test.asf";
    playertype='activex';
  }
  setupPlayerVars(playertype,50,74,fileName,"MediaPlayer1",document.getElementById("mediadiv"));
  setTimeout(function(){
      if(audiobtn)audiobtn.disabled=false;
      checkVideoPlaying();
  },20000);
}

function checkVideoPlaying(){
  addTableRow(9,img_question,"Streaming Video","",'Did you see the spinning Diamond?<br/><a href="javascript:changeToYes(\'image9\')">Yes, I did!</a>',"javascript:didNotCannot('image9','videonotice')","No, I did not.");
}


function testStreamingAudio(){
  var videobtn=document.getElementById('btn_video_start');
  var audiobtn=document.getElementById('btn_audio_start');
  audiobtn.disabled=true;
  audiobtn.innerHTML="Running...";
  if(videobtn)videobtn.disabled=true;
  document.getElementById("image10").src=img_waiting.src;
  var fileName='',playertype='';
  if(!is_ie){
    fileName="rtsp://st21g1.services.att-idns.net/v1/614/2606/audio/audio_systemtest.rm";
    playertype='realplayer';
    
  }else{
    fileName="mms://us-eu-st11g1.att-idns.net/v1/614/2606/audio/audio_systemtest.asf";
    playertype='activex';
  }
  setupPlayerVars(playertype,30,30,fileName,"MediaPlayer2",document.getElementById("mediadiv2"));
  setTimeout(function(){
      if(videobtn)videobtn.disabled=false;
      checkAudioPlaying();
  },20000);
}


function checkAudioPlaying(){
  addTableRow(10,img_question,"Streaming Audio","",'Can you hear the music?<br/><a href="javascript:changeToYes(\'image10\')">Yes, I can!</a>',"javascript:didNotCannot('image10','audionotice')","No, I cannot.");
}
*/
function gotoLink(link){
  document.getElementById(link).style.display='block';
  document.location.href='#'+link;
}

function writeSpeed(dt){
  var spd_kbits;                // Kb/sec rounded
  var spd_kbytes;                // KB/sec rounded
  var kbps;                  // Kb/sec rounded
  var linespeed;                // raw Kb/sec
  var dataSize = 50;               // data file size
  var dt = dt/1000;
  if(dt < .15 && testRuns<6){
    dataSize = fileSizes[testRuns];
    frames['speed'].location.href=files[testRuns]+"?rand="+Math.random();
    testRuns++;
  }else{
    linespeed = dataSize/dt;              // raw Kb/sec
    kbps = (Math.round((linespeed*8)*10))/10;      //round.KbPS
    spd_kbytes = (Math.round((dataSize*10)/dt))/10;    //round.KBPS
    spd_kbits = (Math.round(((dataSize*8)*10)/dt))/10;  //round.KbPS
    if(kbps<45){
      addTableRow(7,img_bad,"Download Speed",spd_kbits+" kbps : "+spd_kbytes+" KB/s","Increase Bandwidth","----------");
    }else{
      addTableRow(7,img_good,"Download Speed",spd_kbits+" kbps : "+spd_kbytes+" KB/s","----------","----------");
    }
  }
}

function testDownloadSpeed(){
  frames['speed'].location.href="50k.html?rand="+Math.random();
}

//Cookies
function setCookie(name, value, expires, path, domain, secure) {
  var testCookie = name + "= testCookie"  +
    ((expires) ? "; expires=" + expires.toGMTString() : "") +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    ((secure) ? "; secure" : "");
  document.cookie = testCookie;
}

// this function gets the cookie, if it exists
function getCookie( name ) {
  var start = document.cookie.indexOf( name + "=" );
  var len = start + name.length + 1;
  if ( ( !start ) &&( name != document.cookie.substring( 0, name.length ) ) ){
    return null;
  }
  if ( start == -1 ) return null;
  var end = document.cookie.indexOf( ";", len );
  if ( end == -1 ) end = document.cookie.length;
  var value = ( document.cookie.substring( len, end ) );
  setCookie("testCookie", "testCookie", null, false, false, false);
  return value;
}

function testCookie(){
  if(document.cookie.indexOf('testCookie') == -1){
    addTableRow(6,img_bad,"Session Cookies","Blocked","Enable Cookies","javascript:gotoLink('cookienotice')","How To...");
  }else{
    addTableRow(6,img_good,"Session Cookies","Not Blocked","----------","----------");
  }
}

//Test Passed or Test Does not require link
function addTableRow(){
  var tbl = document.getElementById('rt');
  var args = addTableRow.arguments;
  var tdOne,tdThree,tdFour,tdFive, image, nextImage;
  image = document.getElementById("image"+args[0]);
  if(image)
    image.src = args[1].src;
  if (args[0]<10)
    nextImage = document.getElementById("image"+(args[0]+1));
  tdThree = document.getElementById("r"+args[0]+"c3");
  tdFour = document.getElementById("r"+args[0]+"c4");
  tdFive = document.getElementById("r"+args[0]+"c5");
  tdThree.innerHTML=args[3];
  tdFour.innerHTML = args[4];
  if(args[5].indexOf("---")!=-1){
    // updates cell without link
    tdFive.innerHTML += args[5];
  }else{//Link
    // updates cell with link
    var nodeLink= document.createElement("a");
    nodeLink.href=args[5];
    nodeLink.appendChild(document.createTextNode(args[6]));
    tdFive.appendChild(nodeLink);
  }
}

function testStreaming(){
  var image1 = document.getElementById("image1");
  image1.src = img_waiting.src;
  image1.style.visibility = 'visible';
  //var audiobtn=document.getElementById('btn_audio_start');
  //var videobtn=document.getElementById('btn_video_start');
  //audiobtn.disabled=true;
  //videobtn.disabled=true;

  //Run Browser Stuff
  setCookie("testCookie", "testCookie", null, false, false, false);
  setTimeout(testDownloadSpeed,0);
  setTimeout(function(){
    testPopUp();
    setTimeout(
      function(){
        testCookie();
        setTimeout(function(){
          testBrowser();
          setTimeout(function(){
            testPlayers();  
            //audiobtn.disabled=false;
            //videobtn.disabled=false;
            document.getElementById("buttons").style.display = "block";
            document.getElementById("recomendedActions").style.display = "block";
            document.getElementById("optionalActions").style.display = "block";
          },500);
        },500);
      },500)
  },500);
}

function testPresenter(){
    var image1 = document.getElementById("image1");
    image1.src = img_waiting.src;
    image1.style.visibility = 'visible';

    //Run Browser Stuff
    setCookie("testCookie", "testCookie", null, false, false, false);
    setTimeout(testDownloadSpeed,0);
    setTimeout(function(){
      testPopUp();
      setTimeout(
        function(){
          testCookie();
          setTimeout(function(){
            testBrowser();
            setTimeout(function(){
              testApplet();  
            },500);
          },500);
        },500)
    },500);
  }

function changeToYes(imageID){
  document.getElementById(imageID).src = img_good.src;
  try{
    if(is_ie){
      if(document.MediaPlayer1)document.MediaPlayer1.Play();
      if(document.MediaPlayer2)document.MediaPlayer2.Play();
    }
  }
  catch(err)
  {  }
}
function didNotCannot(imageID,link){
  document.getElementById(imageID).src = img_bad.src;
  document.getElementById(link).style.display='block';
  document.location.href='#'+link;
}

var myVer = 'Unknown';
var link='http://browser.netscape.com/ns8/';
var appAction='----------';
var verAction='Upgrade Current Browser';

var version = null;
var vendor = null;

function setJVMVals(){
    var args = setJVMVals.arguments;
    version = args[0];
    vendor = args[1];
}

function testApplet(){


    var agt=navigator.userAgent.toLowerCase();
    var isTestable = false;


    if (agt.indexOf("msie") != -1 ||
	    agt.indexOf("netscape") != -1 ||
	    agt.indexOf("firefox") != -1 ||
	    agt.indexOf("safari")) {
	isTestable = true;
    }

    var verLink = "----------";
    var venLink = verLink;
    var sug1="----------";
    var sug2="----------";

    	if(version==null && vendor==null && isTestable){
    		try{

    		version = document.applets.sniff.getVersion();
    		vendor = document.applets.sniff.getVendor();
    		document.applets.sniff.stop();
    	
    		}catch(e){			
    			version = null;
    			vendor = null;
    		}
    	}

     if((vendor==null && version==null) ||(vendor.indexOf("null")!=-1 && version.indexOf("null")!=-1) ){
    	vendor = "JVM Not Found";
    	version = vendor;
    	sug1="Enable or Install JVM";
    	sug2="Not Detected";
    	verLink="http://jdl.sun.com/webapps/download/AutoDL?BundleId=10342";
    	venLink = verLink;
    	
    	addTableRow(11,img_bad,"JVM Vendor",vendor,sug1,verLink,"Download JVM");	
    	

    	
    	}else if((vendor.indexOf("Sun")!=-1 || vendor.indexOf("Apple") != -1) && version.indexOf("1.3")!=-1){		
    		
    		//Not Sun 1.3_? so it passes		
    		//Vendor Good		
    		//Version Bad
    		verLink="http://jdl.sun.com/webapps/download/AutoDL?BundleId=10342";
    		sug1="Sun JVM Good";
    		sug2="Version 1.3 Needs Upgraded.";		
    		venLink = verLink;				
    		
    		addTableRow(11,img_good,"JVM Vendor",vendor+" Version: "+version,venLink,venLink);		
    		
    		}else{
    			addTableRow(11,img_good,"JVM Vendor",vendor+" Version: "+version,venLink,venLink);
    			
    			}
    			
    	
    	
    	document.getElementById("buttons").style.display = "block";	
    }