// ----------------------------------------------------------------
// Project:  Wireless Data Lookup Chart
// Module:   Statistics
// ----------------------------------------------------------------
// Filename: stats.js
// URL:      http://www.classaxe.com/wireless/data/stats.js
// Version:  1.0
// Date:     28th October 2000
// Author:   Martin Francis
//
// Purpose: 1) Defines object used to track and display statistics
//          2) The object has many properties and one method popup()
//          3) Creates instance of STATS object called 'count'
//           
// ----------------------------------------------------------------
  

// *************
// *   STATS   *
// *************
function STATS()
{ this.sets=0            // Number of sets
  this.setReferences=0   // Number of set references
  this.hasFM=0           // Number of sets with FM
  this.hasMG=0           // Number of sets with Manual Gramophone
  this.hasAG=0           // Number of sets with Auto Gramophone deck
  this.hasTI=0           // Number of sets with Tuning Indicator ("Magic Eye")
  this.hasCL=0           // Number of sets with built in clock
  this.hasPIC=0          // Number of sets with at least one photograph
  this.devices=0         // Number of devices
  this.devicesNoSubs=0   // Number of devices (excliding subsitutes)
  this.setsNoDevices=0   // Number of sets without record of devices used
  this.devicesUnique=0   // Number of unique devices listed
  this.setsNoPower=0     // Number of sets without record of power used
  this.setsAC=0          // Number of sets working on AC mains
  this.setsDC=0          // Number of sets working on DC mains
  this.setsB=0           // Number of sets working on Batteries
  this.setsCar=0         // Number of sets designed for in-car use
  this.makers=0 }        // Number of makers


// ********************
// * Statistics Popup *
// ********************
STATS.prototype.popup   = function()
{ var setsWithDevices   = this.sets-this.setsNoDevices
  var setsWithDevicesPC = Math.round((setsWithDevices*1000)/this.sets)/10
  var setsWithPower     = this.sets-this.setsNoPower
  var setsWithPowerPC   = Math.round((setsWithPower*1000)/this.sets)/10
  var devicesPerSet     = Math.round((this.devicesNoSubs*10)/setsWithDevices)/10
  var hasMGPC           = Math.round((this.hasMG/this.sets)*1000)/10
  var hasAGPC           = Math.round((this.hasAG/this.sets)*1000)/10
  var hasFMPC           = Math.round((this.hasFM/this.sets)*1000)/10
  var hasTIPC           = Math.round((this.hasTI/this.sets)*1000)/10
  var hasCLPC           = Math.round((this.hasCL/this.sets)*1000)/10
  var hasPIC            = Math.round((this.hasPIC/this.sets)*1000)/10
  var AC                = Math.round((this.setsAC/setsWithPower)*1000)/10
  var DC                = Math.round((this.setsDC/setsWithPower)*1000)/10
  var BA                = Math.round((this.setsB/setsWithPower)*1000)/10
  var CA                = Math.round((this.setsCar/setsWithPower)*1000)/10

  Statistics=window.open('','Statistics', 'width=420,height=334,resizable=1,menubar=0,location=0,toolbar=0')
  out= "<html>\n<head>\n<title>British Wireless Database Statistics</title>\n"
  out= "<STYLE TYPE='text/css'>\n"
  out+="  input      { font-family: Arial, sans-serif; font-size: 8pt }\n"
  out+="  table      { border-width: 2px ; border-color: Black}\n"
  out+="  td.heading { font-size: 12pt; font-weight: bold;\n"
  out+="               text-align: center; padding-left: 6px; padding-right: 6px;\n"
  out+="               border-top-width: 1px; border-bottom-width: 1px; border-style: solid }\n"
  out+="  td.r       { text-align: right}\n"
  out+="  td.spacer  { border-top-width: 1px}\n"
  out+="  td.category{ }\n"
  out+="  td.graph   { padding-left: 0; padding-right: 0;}\n"
  out+="  td         { background-color: rgb(255,255,200); font-family: Arial; font-size: 8pt;\n"
  out+="               vertical-align: top; border-bottom-width:0; border-top-width: 0;\n"
  out+="               border-left-width: 0;border-right-width: 0; padding-top: 0;padding-bottom: 0;\n"
  out+="               padding-left: 6px; padding-right:6px; border-style: solid; border-color: Black;}\n"
  out+="</STYLE>\n</head>\n\n"
  out+="<body BGCOLOR='#e0ffe0' background='wallpaper.gif' topmargin='5'>\n"
  out+="<table border='1' cellspacing='0' cellpadding='0' width='400'>\n"
  out+="  <tr><td class='heading' colspan='3'><u>Database Statistics</u></td></tr>\n"
  out+="  <tr><td class='category' colspan='2'><b>Last Updated:</b></td>\n"
  out+="      <td class='r'>"+document.lastModified+"</td></tr>\n"
  out+="  <tr><td class='category' colspan='2'><b>Sets listed:</b></td>\n"
  out+="      <td class='r'>"+this.sets+"</td></tr>\n"
  out+="  <tr><td class='category' colspan='2'><b>Makers represented:</b></td>\n"
  out+="      <td class='r'>"+this.makers+"</td></tr>\n"
  out+="  <tr><td class='category' colspan='2'><b>Set References:</b></td>\n"
  out+="      <td class='r'>"+this.setReferences+"</td></tr>\n"
  out+="  <tr><td class='category' colspan='2'><b>Devices listed:</b></td>\n"
  out+="      <td class='r'>"+  this.devices+"</td></tr>\n"
  out+="  <tr><td class='category' colspan='2'><b>Devices listed (no subs):</b></td>\n"
  out+="      <td class='r'>"+ this.devicesNoSubs+"</td></tr>\n"
  out+="  <tr><td class='category' colspan='2'><b>Unique Device types listed:</b></td>\n"
  out+="      <td class='r'>"+ this.devicesUnique+"</td></tr>\n"
  out+="  <tr><td class='category' colspan='2'><b>Devices per set:</b><br>(From the\n"
  out+="        <b>"+setsWithDevicesPC+"% / "+setsWithDevices+"</b> listing devices)</td>\n"
  out+="      <td class='r'>"+devicesPerSet+"</td></tr>\n"
  out+="  <tr><td class='spacer' colspan='3'><img src='spacer.gif' height='1'></td>\n"
  out+="  <tr><td class='category'><b>Sets with:</b></td>\n"
  out+="      <td colspan='2' class='graph'>\n"
  out+="        <table cellspacing='0' cellpadding='0' border='0' width='100%'>\n"
  out+="          <tr><td class='category'>"+IMG_MG+"</td>\n"
  out+="              <td class='graph' align='left'>"+barGraph(hasMGPC,50,8)+"</td>\n"
  out+="              <td class='r'>"+this.hasMG+"</td></tr>\n"
  out+="          <tr><td class='category'>"+IMG_AG+"</td>\n"
  out+="              <td class='graph' align='left'>"+barGraph(hasAGPC,50,8)+"</td>\n"
  out+="              <td class='r'>"+this.hasAG+"</td></tr>\n"
  out+="          <tr><td class='category'>"+IMG_FM+"</td>\n"
  out+="              <td class='graph' align='left'>"+barGraph(hasFMPC,50,8)+"</td>\n"
  out+="              <td class='r'>"+this.hasFM+"</td></tr>\n"
  out+="          <tr><td class='category'>"+IMG_TI+"</td>\n"
  out+="              <td class='graph' align='left'>"+barGraph(hasTIPC,50,8)+"</td>\n"
  out+="              <td class='r'>"+this.hasTI+"</td></tr>\n"
  out+="          <tr><td class='category'>"+IMG_CL+"</td>\n"
  out+="              <td class='graph' align='left'>"+barGraph(hasCLPC,50,8)+"</td>\n"
  out+="              <td class='r'>"+this.hasCL+"</td></tr>\n"
  out+="          <tr><td class='category'>"+IMG_PIC+"</td>\n"
  out+="              <td class='graph' align='left'>"+barGraph(hasPIC,50,8)+"</td>\n"
  out+="              <td class='r'>"+this.hasPIC+"</td></tr>\n"
  out+="        </table></td></tr>\n"
  out+="  <tr><td class='spacer' colspan='3'><img src='spacer.gif' height='1'></td>\n"
  out+="  <tr><td class='category'><b>Power Supplies used:</b><br>\n"
  out+="        (From the <b>"+setsWithPowerPC+"% / "+setsWithPower+"</b> listing power)<br>"
  out+="         Sets can use several power sources.</td>\n"
  out+="      <td colspan='2' class='graph'>\n"
  out+="        <table cellspacing='0' cellpadding='0' border='0' width='100%'>\n"
  out+="          <tr><td class='category'><img src='spacer.gif' width='10'>"+IMG_AC+" </td>\n"
  out+="              <td class='graph' align='left'>"+barGraph(AC,50,8)+"</td>\n"
  out+="              <td class='r'>"+this.setsAC+"</td></tr>\n"
  out+="          <tr><td class='category'><img src='spacer.gif' width='10'>"+IMG_DC+" </td>\n"
  out+="              <td class='graph' align='left'>"+barGraph(DC,50,8)+"</td>\n"
  out+="              <td class='r'>"+this.setsDC+"</td></tr>\n"
  out+="          <tr><td class='category'><img src='spacer.gif' width='3'>"+IMG_BA+" </td>\n"
  out+="              <td class='graph' align='left'>"+barGraph(BA,50,8)+"</td>\n"
  out+="              <td class='r'>"+this.setsB+"</td></tr>\n"
  out+="          <tr><td class='category'><img src='spacer.gif' width='6'>"+IMG_CA+" </td>\n"
  out+="              <td class='graph' align='left'>"+barGraph(CA,50,8)+"</td>\n"
  out+="              <td class='r'>"+this.setsCar+"</td></tr>\n"
  out+="        </table></td>\n"
  out+="  </tr>\n"
  out+="  <tr><td class='heading' colspan='3'><img src='spacer.gif' height='3'><br>\n"
  out+="        <a href='javascript:window.close()'><img\n"
  out+="         src='but_close.gif' width='40' height='21' border='0' alt='Close'></a>\n"
  out+="      </td></tr>\n"
  out+="</table>\n"
  out+="</body>\n</html>"
  Statistics.focus()
  Statistics.document.write(out)
  Statistics.document.close()
}

count=new STATS()        // invoke instance now (avoids NS3 bug when assigning prototypes)

Loading.document.write("#")

