// ***********************************************************************
// * FILE HEADER:                                                        *
// ***********************************************************************
// * Filename:  globals.js                                               *
// * Owner:     Martin Francis                                           *
// * Created:   11/06/2001 (MF)                                          *
// * Revised:   03/11/2002 (MF, assistance from Dave Thomas)             *
// ***********************************************************************

// ***********************************************************************
// * DESCRIPTION:                                                        *
// ***********************************************************************
//  Sets up environment for system


// ************************************
// * detect debug mode                *
// ************************************
debugMode =		document.URL.match(/c:\\/i)||document.URL.match(/127\.0\.0\.1/i);

// ************************************
// * Loading Message Progress Bar     *
// ************************************
// Loading message:
   Loading =	window.open('','Loading', 'width=400,height=247,resizable=0,scrollbars=0,menubar=0,location=0,toolbar=0');
   var out =	"<html>\n<head>\n<title>Loading Database... Please wait"+
      ".................................................."+
      "</title>\n<style TYPE='text/css'>\n"+
      "BODY { font-family: Arial, sans-serif;font-size: 10pt; background: url('splash.gif');}\n</style>\n</head>\n\n"+
      "<body><p align='center'><font color='Red'><b><i>Version: 2<sup>nd</sup> June, 2003</i><br>"+
      "<img src='spacer.gif' width='1' height='128'><br>"+
      "<img src='progress.gif' width='320' height='6' border='2'><br>"+
      "<img src='spacer.gif' width='1' height='15'><br>"+
      "Loading Database - please wait:<br><font color='red'>##############</font><br><font color='blue'>"
   centerPopup(Loading,400,247);
   Loading.focus();Loading.document.write(out);



// ************************************
// * Globals                          *
// ************************************

selectedColumns =	"make,model,date,price,bandNo,IF,devices,deviceNo,icons,pic";

// Image references:
IMG_AC   = "<IMG SRC='ac.gif'    width='13' height='8' alt='AC mains'>"
IMG_DC   = "<IMG SRC='dc.gif'    width='13' height='8' alt='DC mains'>"
IMG_BA   = "<IMG SRC='bat.gif'   width='22' height='6' alt='Battery'>"
IMG_CA   = "<IMG SRC='car.gif'   width='19' height='8' alt='Car Radio'>"
IMG_FM   = "<IMG SRC='fm.gif'    width='13' height='8' alt='FM Waveband'>"
IMG_TI   = "<IMG SRC='ti.gif'    width='13' height='11' alt='Tuning indicator'>"
IMG_CL   = "<IMG SRC='clock.gif' width='13' height='11' alt='Clock Radio'>"
IMG_MG   = "<IMG SRC='mg.gif'    width='13' height='11' alt='Manual Gramophone'>"
IMG_AG   = "<IMG SRC='ag.gif'    width='13' height='11' alt='Auto Gramophone'>"
IMG_PIC  = "<IMG SRC='photo.gif' width='13' height='11' border='0' alt='Photo Available'>"
IMG_DIAG = "<IMG SRC='diag.gif'  width='11' height='12' border='0' alt='Diagram Available'>"

IMG_0AC  = "<IMG SRC='spacer.gif' width='13' height='8' alt='(Not for use with AC mains)'>"
IMG_0DC  = "<IMG SRC='spacer.gif' width='13' height='8' alt='(Not for use with DC mains)'>"
IMG_0BA  = "<IMG SRC='spacer.gif' width='22' height='6' alt='(Not for use with batteries)'>"
IMG_0CA  = "<IMG SRC='spacer.gif' width='19' height='8' alt='(Not designed for in-car use)'>"
IMG_0FM  = "<IMG SRC='spacer.gif' width='13' height='8' alt='(No FM/VHF band)'>"
IMG_0TI  = "<IMG SRC='spacer.gif' width='13' height='11' alt='(No Tuning Indicator)'>"
IMG_0CL  = "<IMG SRC='spacer.gif' width='13' height='11' alt='(No Clock)'>"
IMG_0G   = "<IMG SRC='spacer.gif' width='13' height='11' alt='(No Gramophone)'>"
IMG_0DIAG= "<IMG SRC='spacer.gif' width='11' height='11' alt=''>"

IMG_B2G      = "<IMG SRC='bases/b2g.gif'  width='85'  height='17' alt='British B2G wire ended base'>"
IMG_B3G      = "<IMG SRC='bases/b3g.gif'  width='85'  height='18' alt='British B3G pin ended base'>"
IMG_B7       = "<IMG SRC='bases/b7.gif'   width='70'  height='70' alt='British B7 base'>"
IMG_B7G      = "<IMG SRC='bases/b7g.gif'  width='40'  height='40' alt='B7G base'>"
IMG_B8A      = "<IMG SRC='bases/b8a.gif'  width='40'  height='42' alt='B8A base (Loctal)'>"
IMG_B8G      = "<IMG SRC='bases/b8g.gif'  width='66'  height='66' alt='B8G base'>"
IMG_B9A      = "<IMG SRC='bases/b9a.gif'  width='127' height='67' alt='B9A base'>"
IMG_ES       = "<IMG SRC='bases/es.gif'   width='110' height='90' alt='Edison Screw Base'>"
IMG_GT3      = "<IMG SRC='bases/gt3.gif'  width='70'  height='48' alt='GT-3 Base'>"
IMG_IO       = "<IMG SRC='bases/io.gif'   width='142' height='80' alt='International Octal base'>"
IMG_MO       = "<IMG SRC='bases/mo.gif'   width='60'  height='60' alt='Mazda Octal base'>"
IMG_TO1      = "<IMG SRC='bases/to1.gif'  width='80'  height='48' alt='TO1 Base'>"

IMG_2A       = "<IMG SRC='diagrams/diode1.gif' width='58' height='96' alt='Diode'>"
IMG_2B       = "<IMG SRC='diagrams/diode2.gif' width='64' height='96' alt='Diode (Centre-tapped heaters)'>"
IMG_2_2A     = "<IMG SRC='diagrams/double-diode1.gif' width='100' height='100' alt='Double Diode'>"
IMG_2_2B     = "<IMG SRC='diagrams/double-diode2.gif' width='88'  height='100' alt='Double Diode (Directly heated).'>"
IMG_2_2C     = "<IMG SRC='diagrams/double-diode3.gif' width='104' height='104' alt='Double Diode (Screened).'>"
IMG_2_2D     = "<IMG SRC='diagrams/double-diode4.gif' width='104' height='108' alt='Double Diode (Screened, independent cathodes).'>"
IMG_2_2_3A   = "<IMG SRC='diagrams/double-diode-triode1.gif'  width='132' height='104' alt='Double-Diode Triode'>"
IMG_2_2_3B   = "<IMG SRC='diagrams/double-diode-triode2.gif'  width='136' height='108' alt='Double-Diode Triode (Screened)'>"
IMG_2_2_3C   = "<IMG SRC='diagrams/double-diode-triode3.gif'  width='132' height='108' alt='Double-Diode Triode (2 cathodes)'>"
IMG_2_2_3D   = "<IMG SRC='diagrams/double-diode-triode4.gif'  width='136' height='112' alt='Double-Diode Triode (Screened, 2 cathodes)'>"
IMG_2_2_5A   = "<IMG SRC='diagrams/double-diode-pentode1.gif' width='156' height='104' alt='Double-Diode Pentode'>"
IMG_2_2_5B   = "<IMG SRC='diagrams/double-diode-pentode2.gif' width='160' height='108' alt='Double-Diode Pentode (Screened)'>"
IMG_2_2_2_3A = "<IMG SRC='diagrams/triple-diode-triode1.gif'  width='148' height='108' alt='Triple-Diode Triode'>"
IMG_2_2_2_3B = "<IMG SRC='diagrams/triple-diode-triode2.gif'  width='152' height='114' alt='Triple-Diode Triode (Screened)'>"
IMG_2_2_2_3C = "<IMG SRC='diagrams/triple-diode-triode3.gif'  width='148' height='112' alt='Triple-Diode Triode (2 cathodes)'>"
IMG_2_2_2_3D = "<IMG SRC='diagrams/triple-diode-triode4.gif'  width='152' height='116' alt='Triple-Diode Triode (Screened, 2 cathodes)'>"
IMG_2_2_2_3E = "<IMG SRC='diagrams/triple-diode-triode5.gif'  width='148' height='112' alt='Triple-Diode Triode (2 cathodes)'>"

IMG_2_3A     = "<IMG SRC='diagrams/diode-triode1.gif'   width='96'  height='104' alt='Diode Triode (Directly heated)'>"
IMG_2_5A     = "<IMG SRC='diagrams/diode-pentode1.gif'  width='124' height='100' alt='Diode Pentode (Directly heated)'>"
IMG_2_5B     = "<IMG SRC='diagrams/diode-pentode2.gif'  width='128' height='104' alt='Diode Pentode (Screened, Directly heated)'>"
IMG_2_5C     = "<IMG SRC='diagrams/diode-pentode3.gif'  width='136' height='100' alt='Diode Pentode'>"
IMG_2_5D     = "<IMG SRC='diagrams/diode-pentode4.gif'  width='140' height='104' alt='Diode Pentode (Screened)'>"

IMG_3_3A     = "<IMG SRC='diagrams/double-triode1.gif'  width='116' height='104' alt='Double Triode'>"
IMG_3_3B     = "<IMG SRC='diagrams/double-triode2.gif'  width='120' height='108' alt='Screened Double Triode'>"
IMG_3_3C     = "<IMG SRC='diagrams/double-triode3.gif'  width='116' height='108' alt='Double Triode (2 cathodes)'>"
IMG_3_3D     = "<IMG SRC='diagrams/double-triode4.gif'  width='120' height='112' alt='Screened Double Triode (2 cathodes)'>"
IMG_3_3E     = "<IMG SRC='diagrams/double-triode5.gif'  width='116' height='108' alt='Double Triode (2 cathodes, centre tapped heaters)'>"

IMG_3_5A     = "<IMG SRC='diagrams/triode-pentode1.gif' width='128' height='104' alt='Triode Pentode (Directly heated)'>"
IMG_3_5B     = "<IMG SRC='diagrams/triode-pentode2.gif' width='144' height='116' alt='Triode Pentode (Screened, independent cathode connections)'>"
IMG_3_5C     = "<IMG SRC='diagrams/triode-pentode3.gif' width='140' height='112' alt='Triode Pentode (Independent cathode connections)'>"
IMG_3_5D     = "<IMG SRC='diagrams/triode-pentode4.gif' width='132' height='108' alt='Triode Pentode (Screened, directly heated)'>"
IMG_3_5E     = "<IMG SRC='diagrams/triode-pentode5.gif' width='144' height='112' alt='Triode Pentode (Screened, common cathode)'>"

IMG_3_6A     = "<IMG SRC='diagrams/triode-hexode1.gif'  width='152' height='104' alt='Triode Hexode'>"
IMG_3_6B     = "<IMG SRC='diagrams/triode-hexode2.gif'  width='156' height='108' alt='Triode Hexode (Screened)'>"
IMG_3_6C     = "<IMG SRC='diagrams/triode-hexode3.gif'  width='152' height='104' alt='Triode Hexode (Centre-tapped heaters)'>"

IMG_3_7A     = "<IMG SRC='diagrams/triode-heptode1.gif' width='164' height='104' alt='Triode-Heptode'>"
IMG_3_7B     = "<IMG SRC='diagrams/triode-heptode2.gif' width='168' height='108' alt='Triode-Heptode (Screened)'>"

IMG_4A       = "<IMG SRC='diagrams/tetrode1.gif' width='82'  height='96' alt='Tetrode'>"
IMG_4B       = "<IMG SRC='diagrams/tetrode2.gif' width='86'  height='98' alt='Tetrode (Screened)'>"

IMG_5A       = "<IMG SRC='diagrams/pentode1.gif' width='94'  height='96' alt='Pentode'>"
IMG_5B       = "<IMG SRC='diagrams/pentode2.gif' width='100' height='98' alt='Pentode (Screened)'>"
IMG_5C       = "<IMG SRC='diagrams/pentode3.gif' width='86'  height='98' alt='Pentode (Screened, Directly heated)'>"
IMG_5D       = "<IMG SRC='diagrams/pentode4.gif' width='92'  height='96' alt='Pentode (Screened, Directly heated, Centre-tapped heaters)'>"
IMG_5E       = "<IMG SRC='diagrams/pentode5.gif' width='82'  height='98' alt='Pentode (Directly heated)'>"
IMG_5F       = "<IMG SRC='diagrams/pentode6.gif' width='88'  height='96' alt='Pentode (Directly heated, Centre-tapped heaters)'>"

IMG_7A       = "<IMG SRC='diagrams/heptode1.gif' width='118' height='96' alt='Heptode'>"
IMG_7B       = "<IMG SRC='diagrams/heptode2.gif' width='122' height='98' alt='Heptode (Screened)'>"
IMG_7C       = "<IMG SRC='diagrams/heptode3.gif' width='106' height='96' alt='Heptode (Directly heated)'>"

IMG_BAR      = "<IMG SRC='diagrams/barretter.gif' width='58' height='100' alt='Barretter'>"

IMG_MR1      = "<IMG SRC='diagrams/pn.gif'       width='26'  height='36'  alt='Metal rectifier'>"
IMG_MR4      = "<IMG SRC='diagrams/mr4.gif'      width='47'  height='47'  alt='Metal rectifier (4 diode bridge)'>"
IMG_PN       = "<IMG SRC='diagrams/pn.gif'       width='26'  height='36'  alt='PN Diode'>"
IMG_PNP      = "<IMG SRC='diagrams/pnp.gif'      width='66'  height='72'  alt='PNP Transistor'>"
IMG_ZENNER   = "<IMG SRC='diagrams/zenner.gif'   width='26'  height='36'  alt='Zenner Diode'>"

IMG_TIA      = "<IMG SRC='diagrams/ti_1.gif'     width='100' height='100' alt='Tuning Indicator (double triode)'>"
IMG_TIB      = "<IMG SRC='diagrams/ti_2.gif'     width='136' height='104' alt='Tuning Indicator (twin-anode triode and triple-anode triode)'>"
IMG_BULB     = "<IMG SRC='diagrams/bulb.gif'    width='30'  height='46'  alt='Tuning Bulb Indicator'>"
IMG_METER    = "<IMG SRC='diagrams/meter.gif'    width='30'  height='46'  alt='Mechanical Tuning Indicator'>"

var makerArray = new Array()                          // Holds names of makers in the database

// Regular expressions:
  var RegExpPSD =/\£([0-9]+)\.([0-9]+)s\.([0-9]+)d/   // For splitting prices in £.s.d
  var RegExpGN  =/([0-9]+)GN/                         // For splitting prices in GN
  var RegExpMakers = new RegExp("dummyValue")         // Create regular expression for finding new makers
  var RegExpTI     = new RegExp("1629|6E5GT|6M1|6M2|6U5|6U5G|10M2|12U5G|65ME|DM70|EM34|EM37|EM840|EM80|EM81|EM84|EM85|ME41|UM4|UM34|UM80|Y63")
// 1934-1951: AC/ME|ME920|VME4|ME41|ME91|A39A|EFM1|EM1|EM3|EM4|ME4S|ME6S|TV4|TV4A|TV6|6AD6G|6AF6G|6AF7G|6AL7GT|
//            6G5G|6M1|6U5G|6X6G|12U5G|63ME|64ME|1629|EM31|EM34|EM35|FT4|UM34|VFT4|VFT6|Y61/3|Y62/4|Y65|Y73|
//            2E5|2G5|6AB5|6N5|6E5|6H5|6T5|6U5|6G5
// 1951-1954: AM1|AM2|C/EM2|EM2|EM5|6CD7|6S5|DM21|OM5|PM5|UM4|EM71|EM72|EM85|HM85|UM85|EFM11|EM11|UFM11|UM11|
//            EM171|UM171
// 1954-1956: 6M2|10M1|10M2|12CD7|EM35|HM34|UM35|6355|HM71|6BR5|19BR5|E82M|EM80|EM81|EM83|UM80|UM83|65ME
// 1956-1960: IM90|6DA5|6DL7|6DU6|6FG6|6M40|12FG6|19DA5|5624|EM84|EM840|EMM801|PM84|UM81|UM84|Y119
// 1960-1963: 6M-E5|6M-E10|6355|6GX8|6M1|9FG6|E7046|E7047|E7082|EAM86|EM84A|EM87|EMM802|6G-E7|19G5G|19U5G
// 1934-1963: AC/ME|ME920|VME4|ME41|ME91|A39A|EFM1|EM1|EM3|EM4|ME4S|ME6S|TV4|TV4A|TV6|6AD6G|6AF6G|6AF7G|6AL7GT|
//            6G5G|6M1|6U5G|6X6G|12U5G|63ME|64ME|1629|EM31|EM34|EM35|FT4|UM34|VFT4|VFT6|Y61/3|Y62/4|Y65|Y73|2E5|
//            2G5|6AB5|6N5|6E5|6H5|6T5|6U5|6G5|AM1|AM2|C/EM2|EM2|EM5|6CD7|6S5|DM21|OM5|PM5|UM4|EM71|EM72|EM85|
//            HM85|UM85|EFM11|EM11|UFM11|UM11|EM171|UM171|6M2|10M1|10M2|12CD7|EM35|HM34|UM35|6355|HM71|6BR5|
//            19BR5|E82M|EM80|EM81|EM83|UM80|UM83|65ME|IM90|6DA5|6DL7|6DU6|6FG6|6M40|12FG6|19DA5|5624|EM84|EM840|
//            EMM801|PM84|UM81|UM84|Y119|6M-E5|6M-E10|6355|6GX8|6M1|9FG6|E7046|E7047|E7082|EAM86|EM84A|EM87|
//            EMM802|6G-E7|19G5G|19U5G


// ************************************
// * Bargraph writing routine         *
// ************************************
function barGraph(percentage,x,y){
  var a=Math.ceil(x*percentage/100);
  var b=x-a
  var out="";
  if (percentage) {
    out+="<img src='ff0000.gif' border='1' width='" + a + "' HEIGHT='"+y+"'>";
  }
  if (percentage != 100) {
    out+="<img src='ff8080.gif' border='1' width='" + b + "' HEIGHT='"+y+"'>";
  }
  out+=" <font color='#ff0000'><b> " + percentage + "%</b></font>";
  return out;
}

// ************************************
// * Number Padding routine           *
// ************************************
function pad(number,len) {			// FUNCTION: Returns zero-padded number
  var numberLength=number.toString().length;	// INPUT:    Number and length when padded
  var outString="";				// OUTPUT:   Padded string
  for (var i=0; i<(len-numberLength); i++) {	// EXAMPLE:  a=pad(15,6)
    outString+="0";				//           a="000015"
  }
  outString+=number;
  return(outString);
}

// ************************************
// * Regular expression search        *
// * modification routine             *
// ************************************
function buildRegExp(criteria) {
  var RegExpMod0 = /[^0-9a-zA-Z\\(\\)\\|\\?\\*\\+\:\-\/]/g //D Thomas 14 May 2001
  var RegExpMod1 = new RegExp("\\?","g")        // For replacing ? in searches with .  (any one but newline)
  var RegExpMod2 = new RegExp("\\*","g")        // For replacing * in searches with .* (0 or more characters anything but newline)
  var RegExpMod3 = new RegExp("\\(","g")        // For replacing ( in searches with \(
  var RegExpMod4 = new RegExp("\\)","g")        // For replacing ) in searches with \)

// D Thomas 15 May 2001, modified to take +
  criteria=criteria.replace(RegExpMod0,"").toUpperCase().split("+").sort().join(".\+").replace(RegExpMod1,".").replace(RegExpMod2,"[^\,]*").replace(RegExpMod3,"\\(").replace(RegExpMod4,"\\)")
  return criteria
}


// ************************************
// * centerPopup()                    *
// ************************************
function centerPopup(popup,width,height) {
  if (popup.screen) {
    var x = (screen.availWidth-width)/2;
    var y = (screen.availHeight-height)/2;
    popup.moveTo(x,y);
  }
}

function tool(imgoff,imgon) {
  this.on =		new Image();
  this.on.src =		imgon
  this.off =		new Image();
  this.off.src =	imgoff;
}

tools =			new Array();
tools[0] =		new tool("tool_print.gif","tool_print2.gif");

Loading.document.write("#");

