// -----------------------------------------------------------
// This function launches the popup windows required for news
// and reports.
// -----------------------------------------------------------

function popWindow(url,h,w) 
{
  window.open(url,"wData","height="+h+",width="+w+",screenX=10,left=10,screenY=10,top=10,menubar=0,scrollbars=yes,resizable=1,status=0,toolbar=0"); 
}

function popWindow1(url,h,w) 
{
  window.open(url,"wData1","fullscreen=yes");//,"wData","screenX=0,left=0,screenY=0,top=0,menubar=0,scrollbars=yes,resizable=1,status=0,toolbar=0"); 
}

// -----------------------------------------------------------
// This section of the file is responsible for the LED control
// -----------------------------------------------------------

// Setup boolean variable for timeout

var runningTimeout = "";

// Setup the javascript image variables for speed of transition

var ledredon  = new Image;
var ledredoff = new Image;
ledredon.src  = "images/datacell-led-red-on.gif";
ledredoff.src = "images/datacell-led-red.gif";

var ledamberon  = new Image;
var ledamberoff = new Image;
ledamberon.src  = "images/datacell-led-amber-on.gif";
ledamberoff.src = "images/datacell-led-amber.gif";

var ledgreenon  = new Image;
var ledgreenoff = new Image;
ledgreenon.src  = "images/datacell-led-green-on.gif";
ledgreenoff.src = "images/datacell-led-green.gif";

function alloffLED(ledarray) {                                //SWITCH ALL THE LEDS OFF ON A ROW 
  document.images["led" + ledarray + "a"].src = ledredoff.src;
  document.images["led" + ledarray + "b"].src = ledamberoff.src
  document.images["led" + ledarray + "c"].src = ledgreenoff.src
}

function onLED(ledselected) {                                 //SWITCH ON THE REQUESTED LED
  ledsrc = document.images[ledselected].src;                  //put the source of the led into a string
  if (ledsrc.indexOf('-red')!=-1) {                           //this section of code checks the value of
    document.images[ledselected].src = ledredon.src;          //the source of the led selected. depending
  } else if (ledsrc.indexOf('-amber')!=-1) {                  //on the results the script will replace the
    document.images[ledselected].src = ledamberon.src;        //source of either the red, amber or yellow
  } else if (ledsrc.indexOf('-green')!=-1) {                  //led.
    document.images[ledselected].src = ledgreenon.src;        //
  }
}

function cLED(ledarray, ledselected) {                        //CHANGE THE DEFAULT LED
  alloffLED(ledarray);                                        //switch all the leds off
  defaultLED[ledarray] = ledselected;                         //change the default led in the array
  setTimeout("onLED('" + ledselected + "')",60);              //switch the new default led on
  setTimeout("alloffLED('" + ledarray + "')",120);            //switch all the leds off
  setTimeout("onLED('" + ledselected + "')",180);             //switch the new default led on
  weatherAction(ledarray,ledselected);
}

function xLED() {
  ledTimeout = setTimeout("rLED();",5);                       //set the timeout to clear the leds in 20 milliseconds (solves onmouseout table cell crossover problem) 
  runningTimeout = "true";                                    //flag the timeout as running
}

function rLED() {                                             //RESTORE THE DEFAULT LED
  runningTimeout = "false";                                   //turn off the timeout
  for (i=0; i<defaultLED.length; i++) {
    alloffLED(i);                                             //switch all the leds off
    onLED(defaultLED[i]);                                     //switch the default led back on
  }
}

function sLED(ledarray, ledturnon) {                          //SWAP THE LED IMAGES
  if (runningTimeout == "true") {clearTimeout(ledTimeout);}   //if the timeout is running then clear it
  alloffLED(ledarray);                                        //switch all the leds off
  onLED(ledturnon);                                           //switch the one led on  
}

  
// ------------------------------------------------- 
// This section of the file is responsible for
// the text strings that appear above the data table
// -------------------------------------------------


function cHV(value) {
  if (document.layers) {
    document.layers["help"].document.open();
    document.layers["help"].document.write("<font class='helptext'><center>" + value + "</center></font>");
    document.layers["help"].document.close();
  } else if (document.all) {
    document.all.help.innerHTML = "<span class='helptext'>" + value + "</span>";;
  } else if (document.getElementById) {
    document.getElementById("help").innerHTML = "<span class='helptext'>" + value + "</span>";
  }
}

  
// ------------------------------------------------- 
// This section of code handles the default value
// of the date section on the claim form.
// -------------------------------------------------


function dForm(fh, txt) {
  if (fh.value == txt) {fh.value = "";}
  else if (fh.value == "") {fh.value = txt;}
}

// ------------------------------------------------- 
// This section of the file just tidies up how
// browsers handle refreshing pages and focusing of
// links.
// -------------------------------------------------


function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}

function ExplorerFix() {
	for (a in document.links) document.links[a].onfocus = document.links[a].blur;
}

if (document.all) {document.onmousedown = ExplorerFix;}

MM_reloadPage(true);
