// JavaScript Document
function GetInfo() {

  var pass = true;

  var adapter;
  var ssid;
  var bssid;
  var rssi;
  var channel;
  var ipaddress;
  var authmode;

  var adapterDisplay;
  var ssidDisplay;
  var bssidDisplay;
  var rssiDisplay;
  var channelDisplay;
  var ipaddressDisplay;
  var authmodeDisplay;

  var div_adapter = document.getElementById("div_adapter");
  var div_ssid = document.getElementById("div_ssid");
  var div_bssid = document.getElementById("div_bssid");
  var div_rssi = document.getElementById("div_rssi");
  var div_channel = document.getElementById("div_channel");
  var div_ipaddress = document.getElementById("div_ipaddress");
  var div_authmode = document.getElementById("div_authmode");
  
  var div_authmodeinfo1 = document.getElementById("div_authmodeinfo1");
  var div_authmodeinfo2 = document.getElementById("div_authmodeinfo2");
  var div_authmodeicon = document.getElementById("div_authmodeicon");
  var div_authmoderow = document.getElementById("div_authmoderow");

  var tempStr = 'Loading...';
  div_adapter.innerHTML = tempStr;
  div_ssid.innerHTML = tempStr;
  div_bssid.innerHTML = tempStr;
  div_rssi.innerHTML = tempStr;
  div_channel.innerHTML = tempStr;
  div_ipaddress.innerHTML = tempStr;
  div_authmode.innerHTML = tempStr;

  try {
    adapter = wlaninfo.GetAdapterName();

    if (adapter == 'Not Found') {

      adapterDisplay = 'N/A';
      ssidDisplay = 'N/A';
      bssidDisplay = 'N/A';
      rssiDisplay = 'N/A';
      channelDisplay = 'N/A';
      ipaddressDisplay = 'N/A';
      authmodeDisplay = 'N/A';
      pass = false;

    } else  {

      adapterDisplay = wlaninfo.GetAdapterName(); 

      ssid = wlaninfo.GetSSID();
      bssid = wlaninfo.GetBSSID();
      rssi = wlaninfo.GetRSSI();
      channel = wlaninfo.GetChannel();
      ipaddress = wlaninfo.GetIPaddress();
      authmode = wlaninfo.GetAuthMode();

      // ssid
      if( ssid == 'Not Found') {
        ssidDisplay = 'Unkown or hidden network';
      } else {
        ssidDisplay = ssid;
      }

      // bssid
      if( bssid == 'Not Found') {
        bssidDisplay = 'Disconnected';
      } else {
        bssidDisplay = bssid;
      }

      // signal strength
      if( (rssi == 'Excellent') || 
          (rssi == 'Very Good') ||
          (rssi == 'Good') ||
          (rssi == 'Fair') ||
          (rssi == 'Poor') ) {
        rssiDisplay = rssi;
      } else {
        rssiDisplay = 'N/A';
      }

      // channel
      if( channel == 'Not Found' ) {
        channelDisplay = 'N/A';
      } else {
        channelDisplay = channel;
      }
     
      // ipaddress
      if( (ipaddress == 'Not Found') || (ipaddress == '0.0.0.0') ) {
        ipaddressDisplay = 'N/A';
      } else {
        ipaddressDisplay = ipaddress;
      }

      // security
      if( authmode == 'Open' ) {
        authmodeDisplay = 'No Security Detected';
		authmodeinfo1Display = 'Not securing your Wi-Fi connection is the equivalent of leaving the front door of your house wide open. Without adequate protection, wireless intruders can download tools that are freely available on the Internet to eavesdrop on any information you transmit &quot;through the air&quot;.';
		authmodeinfo2Display = 'For a simple and inexpensive Wi-Fi security solution that requires no technical configuration, download <a href="hotspot-helper.htm" style="color:#36C;text-decoration:underline;">JiWire Hotspot Helper</a> to keep your personal information safe at public hotspots, at work, or even at home.';
		authmodeiconDisplay = 'visible';
		authmoderowDisplay = '#900';
      } else if ( authmode == 'WEP' ) {
        authmodeDisplay = 'WEP';
		authmodeinfo1Display = 'While better than using no security at all, WEP is easily cracked and offers minimal security protection. WEP is also unavailable at most public hotspots and offers little protection when everyone has the same key.';
		authmodeinfo2Display = 'Upgrade to <a href="hotspot-helper.htm" style="color:#36C;text-decoration:underline;">JiWire Hotspot Helper</a> to keep your personal information safe at public hotspots, at work, or even at home.';
		authmodeiconDisplay = 'visible';
		authmoderowDisplay = '#900';
      } else if ( authmode == 'WPA' ) {
        authmodeDisplay = 'WPA';
		authmodeinfo1Display = 'WPA is stronger than WEP and an adequate solution for your home network or small business as long as it has a good policy of changing the key regularly and your employees do not give out the passphrase.';
		authmodeinfo2Display = 'If you use Wi-Fi outside the home or office, upgrade to <a href="hotspot-helper.htm" style="color:#36C;text-decoration:underline;">JiWire Hotspot Helper</a> to keep your personal information safe from wireless thieves.';
		authmodeiconDisplay = 'hidden';
		authmoderowDisplay = '#333';
      } else {
        authmodeDisplay = 'Unknown';
		authmodeinfo1Display = 'Not securing your Wi-Fi connection is the equivalent of leaving the front door of your house wide open. Without adequate protection, wireless intruders can download tools that are freely available on the Internet to eavesdrop on any information you transmit &quot;through the air&quot;.';
		authmodeinfo2Display = 'For a simple and inexpensive Wi-Fi security solution that requires no technical configuration, download <a href="hotspot-helper.htm" style="color:#36C;text-decoration:underline;">JiWire Hotspot Helper</a> to keep your personal information safe at public hotspots, at work, or even at home.';
		authmodeiconDisplay = 'visible';
		authmoderowDisplay = '#900';
      }

    }

  } catch(e) {

    // error
    adapterDisplay = 'N/A';
    ssidDisplay = 'N/A';
    bssidDisplay = 'N/A';
    rssiDisplay = 'N/A';
    channelDisplay = 'N/A';
    ipaddressDisplay = 'N/A';
    authmodeDisplay = 'N/A';
    pass = false;
    document.location="wifi-security-test-plug-in.htm";

  }

  div_adapter.innerHTML = adapterDisplay;
  div_ssid.innerHTML = ssidDisplay;
  div_bssid.innerHTML = bssidDisplay;
  div_rssi.innerHTML = rssiDisplay;
  div_channel.innerHTML = channelDisplay;
  div_channelCopy.innerHTML = channelDisplay;
  div_ipaddress.innerHTML = ipaddressDisplay;
  div_authmode.innerHTML = authmodeDisplay;
  
  div_authmodeinfo1.innerHTML = authmodeinfo1Display;
  div_authmodeinfo2.innerHTML = authmodeinfo2Display;
  div_authmodeicon.style.visibility = authmodeiconDisplay;
  div_authmoderow.style.color = authmoderowDisplay;

}

