//************************************************************************

 function TimeTick() {
   var NowTime = new Date();
   return '&TickTock='+NowTime.getTime();
 }

//************************************************************************

 function METIMEyyyymmddhh_mm() {
    var NowTime = new Date();
    var TimeUTC = NowTime.toGMTString();
    var aTimeUTC = TimeUTC.split(" ");
    var yyyy = aTimeUTC[3];
    var mmm = aTimeUTC[2];
    var mm = "01";
    if (mmm == "Feb") { mm = "02"; }
    if (mmm == "Mar") { mm = "03"; }
    if (mmm == "Apr") { mm = "04"; }
    if (mmm == "May") { mm = "05"; }
    if (mmm == "Jun") { mm = "06"; }
    if (mmm == "Jul") { mm = "07"; }
    if (mmm == "Aug") { mm = "08"; }
    if (mmm == "Sep") { mm = "09"; }
    if (mmm == "Oct") { mm = "10"; }
    if (mmm == "Nov") { mm = "11"; }
    if (mmm == "Dec") { mm = "12"; }
    var dd = aTimeUTC[1];
    if (dd.length == 1) { dd = "0" + dd; }
    var hhmm = aTimeUTC[4].substr(0,5);
    var hh = hhmm.substr(0,2);
    var mn = hhmm.substr(3,2);
    var ResultTime = yyyy+mm+dd+hh+"00";
    return ResultTime;
 }

function METIME() {
    var NowTime = new Date();
    var TimeUTC = NowTime.toGMTString();
    var aTimeUTC = TimeUTC.split(" ");
    var yyyy = aTimeUTC[3];
    var mmm = aTimeUTC[2];
    var mm = "01";
    if (mmm == "Feb") { mm = "02"; }
    if (mmm == "Mar") { mm = "03"; }
    if (mmm == "Apr") { mm = "04"; }
    if (mmm == "May") { mm = "05"; }
    if (mmm == "Jun") { mm = "06"; }
    if (mmm == "Jul") { mm = "07"; }
    if (mmm == "Aug") { mm = "08"; }
    if (mmm == "Sep") { mm = "09"; }
    if (mmm == "Oct") { mm = "10"; }
    if (mmm == "Nov") { mm = "11"; }
    if (mmm == "Dec") { mm = "12"; }
    var dd = aTimeUTC[1];
    if (dd.length == 1) { dd = "0" + dd; }
    var hhmm = aTimeUTC[4].substr(0,5);
    var hh = hhmm.substr(0,2);
    var mn = hhmm.substr(3,2);
    var ResultTime = "( " +yyyy+mm+dd+hh+mn +" or " +dd+"-"+hhmm +" ) ... " + TimeUTC;
    return ResultTime;
 }

//************************************************************************

//

var VersionNumber = parseInt(navigator.appVersion); // Browser version
var BrowserNetscape = (navigator.appName == "Netscape");

//************************************************************************
//
// Add or remove a string from a string field
//
// Arguments
//   newString         - input value to be added/removed
//   valueStringObject - field holding the current list of values
//
// Returns nothing
//
function AddOrRemove(valueStringObject, newValue, aComment)
{
  if (VersionNumber < 4)
  {
    alert("Your version of browser is too old to use some of the features of this form - they have been disabled");
  }
  else
  {
    // Create an array to hold the current list of values
    var currentValues = new Array();

    // Split the current string if it is not empty
    // Splitting an empty string returns an element depending on browser (bad)
    if (valueStringObject.value != "")
    {
      // Split on the determined separator
      valueStringObject.value = valueStringObject.value.toUpperCase();
      currentValues = valueStringObject.value.split(" ");
    }

    var dupIndex = _findElement(currentValues, newValue);

    // Add new element if dupIndex == -1 (i.e. new value already present)
    if (dupIndex == -1)
    {
      // Note IE does not like push()
      //currentValues.push(newValue);
      currentValues = currentValues.concat(newValue);
      if (aComment.length > 0) {
    	alert(aComment);
      }
    }
    else
    {
      // Remove the duplicate element
      currentValues = _removeElement(currentValues, dupIndex);
    }

    // Reform into string and place into field
    valueStringObject.value = currentValues.join(" ");
  }
}

function AddOrRemoveNCC(valueStringObject, newValue, aComment) { // No Case Change
  if (VersionNumber < 4) {
    alert("Your version of browser is too old to use some of the features of this form - they have been disabled");
  } else {
    var currentValues = new Array();
    if (valueStringObject.value != "") {
////      valueStringObject.value = valueStringObject.value.toUpperCase(); // no upperCase translate
      currentValues = valueStringObject.value.split(" ");
    }
    var dupIndex = _findElement(currentValues, newValue);
    if (dupIndex == -1) {
      currentValues = currentValues.concat(newValue);
      if (aComment.length > 0) {
    	alert(aComment);
      }
    } else {
      currentValues = _removeElement(currentValues, dupIndex);
    }
    valueStringObject.value = currentValues.join(" ");
  }
}

function AddOnlyNCC(valueStringObject, newValue, aComment) { // No Case Change
  if (VersionNumber < 4) {
    alert("Your version of browser is too old to use some of the features of this form - they have been disabled");
  } else {
    var currentValues = new Array();
    if (valueStringObject.value != "") {
////      valueStringObject.value = valueStringObject.value.toUpperCase(); // no upperCase translate
      currentValues = valueStringObject.value.split(" ");
    }
    var dupIndex = _findElement(currentValues, newValue);
    if (dupIndex == -1) {
      currentValues = currentValues.concat(newValue);
      if (aComment.length > 0) {
    	alert(aComment);
      }
////    } else {
////      currentValues = _removeElement(currentValues, dupIndex);
    }
    valueStringObject.value = currentValues.join(" ");
  }
}

function RemoveOnlyNCC(valueStringObject, newValue, aComment) { // No Case Change
  if (VersionNumber < 4) {
    alert("Your version of browser is too old to use some of the features of this form - they have been disabled");
  } else {
    var currentValues = new Array();
    if (valueStringObject.value != "") {
////      valueStringObject.value = valueStringObject.value.toUpperCase(); // no upperCase translate
      currentValues = valueStringObject.value.split(" ");
    }
    var dupIndex = _findElement(currentValues, newValue);
    if (dupIndex == -1) {
////      currentValues = currentValues.concat(newValue);
////      if (aComment.length > 0) {
////    	alert(aComment);
////      }
    } else {
      currentValues = _removeElement(currentValues, dupIndex);
    }
    valueStringObject.value = currentValues.join(" ");
  }
}

function AddOnlyList(valueStringObject, newValues, aComment) {
  if (VersionNumber < 4) {
    alert("Your version of browser is too old to use some of the features of this form - they have been disabled");
  } else {
    var currentValues = new Array();
    if (newValues != "") {
      currentValues = newValues.split(" ");
    }
    for (var ii =0; ii < currentValues.length; ii++) {
      AddOnly(valueStringObject, currentValues[ii], aComment);
    }
  }
}

function AddOnly(valueStringObject, newValue, aComment) {
  if (VersionNumber < 4) {
    alert("Your version of browser is too old to use some of the features of this form - they have been disabled");
  } else {
    // Create an array to hold the current list of values
    var currentValues = new Array();
    // Split the current string if it is not empty
    // Splitting an empty string returns an element depending on browser (bad)
    if (valueStringObject.value != "") {
      // Split on the determined separator
      valueStringObject.value = valueStringObject.value.toUpperCase();
      currentValues = valueStringObject.value.split(" ");
    }
    var dupIndex = _findElement(currentValues, newValue);
    // Add new element if dupIndex == -1 (i.e. new value already present)
    if (dupIndex == -1) {
      // Note IE does not like push()
      //currentValues.push(newValue);
      currentValues = currentValues.concat(newValue);
      if (aComment.length > 0) {
    	alert(aComment);
      }
////    } else { // Don't Remove the duplicate element
////      currentValues = _removeElement(currentValues, dupIndex);
    }
    // Reform into string and place into field
    valueStringObject.value = currentValues.join(" ");
  }
}

function CheckBoxAddOrRemove(valueCheckBoxObject, valueStringObject, newValue, aComment)
{
	// Add of remove string object with newValue depending on whether CheckBox object is "checked" or not
  if (VersionNumber < 4)
  {
    alert("Your version of browser is too old to use some of the features of this form - they have been disabled");
  }
  else
  {

		//if (valueCheckBoxObject.checked==true) {
		//	alert("Checkbox is checked!");
		//} else {
		//	alert("Checkbox is not checked!");
		//}

    // Create an array to hold the current list of values
    var currentValues = new Array();

    // Split the current string if it is not empty
    // Splitting an empty string returns an element depending on browser (bad)
    if (valueStringObject.value != "")
    {
      // Split on the determined separator
      valueStringObject.value = valueStringObject.value.toUpperCase();
      currentValues = valueStringObject.value.split(" ");
    }

    var dupIndex = _findElement(currentValues, newValue);

    // Add new element if dupIndex == -1 (i.e. new value already present)
    if ( (dupIndex == -1) && (valueCheckBoxObject.checked==true) )
    {
      // Note IE does not like push()
      //currentValues.push(newValue);
      currentValues = currentValues.concat(newValue);
      if (aComment.length > 0) {
    	alert(aComment);
      }
    }
    else
    {
      // Remove the duplicate element
      currentValues = _removeElement(currentValues, dupIndex);
    }

    // Reform into string and place into field
    valueStringObject.value = currentValues.join(" ");
  }
}

//************************************************************************
//
// Puts/Overwrites a string into a string field
//
// Arguments
//   newString         - input value to be replaced
//   valueStringObject - field for the value
//
// Returns nothing
//
function PutList(valueStringObject, newValue)
{
  if (VersionNumber < 4)
  {
    alert("Your version of browser is too old to use some of the features of this form - they have been disabled");
  }
  else
  {

    if (1 == 1) {
//      valueStringObject.value = "";
//      AddOrRemove(valueStringObject, newValue, "");
/****/
      if (valueStringObject.value == newValue) {
    	  valueStringObject.value = "";
      } else {    	// Put string into field
      	valueStringObject.value = newValue.concat();
      }
/****/
    }
    else
    {
      var theValue = newValue.split(" ");
      for (var ii =0; ii < theValue.length; ii++) {
        AddOrRemove(valueStringObject, theValue[ii], "");
      }
    }
  }
}

function CheckBoxPutList(valueCheckBoxObject, valueStringObject, newValue1, newValue2)
{
	// Sets/Removes valueStringObject to newValue1, and also adds/subtracts newValue2 to same if valueCheckBoxObject
	// is checked
  if (VersionNumber < 4)
  {
    alert("Your version of browser is too old to use some of the features of this form - they have been disabled");
  }
  else
  {

    if (1 == 1) {
//      valueStringObject.value = "";
//      AddOrRemove(valueStringObject, newValue, "");
/****/
			if (valueCheckBoxObject.checked==true) {
      	var newValue = newValue1 + " " + newValue2;
      } else {
      	var newValue = newValue1;
      }
      if (valueStringObject.value == newValue) {
    	  valueStringObject.value = "";
				if (valueCheckBoxObject.checked==true) {
					valueCheckBoxObject.checked=false;
				}
      } else {    	// Put string into field
      	valueStringObject.value = newValue.concat();
      }
/****/
    }
    else
    {
      var theValue = newValue.split(" ");
      for (var ii =0; ii < theValue.length; ii++) {
        AddOrRemove(valueStringObject, theValue[ii], "");
      }
    }
  }
}

//************************************************************************
//
// Find the first element in an array to match a value
//
// Arguments
//   inputArray - array to search for value
//   checkValue - value to look for in array
//
// Returns index of first matching element if one exists, -1 otherwise
//
function _findElement(inputArray, checkValue)
{
  var elementIndex = -1;

  for (i = 0; elementIndex == -1 && i < inputArray.length; i++)
  {
    if (inputArray[i] == checkValue)
    {
      elementIndex = i;
    }
  }

  return elementIndex;
}


//************************************************************************
//
// Remove specified element from an array, returning the updated array
// Note cannot use splice() as this is only supported in IE5.5 and upward
//
// Arguments :
//   inputArray - the unprocessed array
//   index      - the index of the element to be removed
//
// Returns an updated array with the element removed
//
function _removeElement(inputArray, index)
{
  var start;  // Holds items from start of array to index-1
  var end;    // Holds items from index+1 to end of array

  if (index > 0)
  {
    start = inputArray.slice(0, index);
  }
  else
  {
    start = new Array(0);
  }

  if (index < inputArray.length - 1)
  {
    end = inputArray.slice(index + 1);
  }
  else
  {
    end = new Array(0);
  }

  // Concatenate the two parts
  return start.concat(end);
}


//************************************************************************
//
// Checks string field for not null - if null display message
//
// Arguments
//   msgString         - string when object is empty
//   valueStringObject - field holding the values
//
// Returns true or false
//
function CheckNotNull(valueStringObject)    //, msgString)
{
  if (valueStringObject.value == "") {
//  	alert(msgString);
  	return false;
  }
  else {
  	return true;
  }

}


//************************************************************************

//
// Start up a graphics viewer
//
// Arguments
//   ViewerURL      - the target viewer
//   ViewerType     - the viewer type for the images to display
//   ViewerOptions  - the viewer window options
//
// Returns nothing
//
function GraphicsViewer(ViewerURL,ViewerType,ViewerOptions) {
  var ViewerTitleBar = "Wx_" + ViewerType + "_Viewer";
//alert("URL="+ViewerURL);
//alert("Type="+ViewerType);
//alert("Options="+ViewerOptions);
//alert("Title="+ViewerTitleBar);
  window.open(ViewerURL,ViewerTitleBar,ViewerOptions);
}

//************************************************************************
//
// Start up a text viewer processor
//
// Arguments
//   ViewerURL      - the target viewer
//   ViewerOptions  - the viewer window options
//
// Returns nothing
//
function TextViewer(ViewerURL,ViewerOptions) {
//alert(ViewerURL);
//alert(ViewerOptions);
  window.open(ViewerURL,"Wx_Text_VIEWER",ViewerOptions);
}

function TextViewerMenu(ViewerURL,ViewerOptions) {
// For when calling MetJetMenu for individual window
//alert(ViewerURL);
//alert(ViewerOptions);
  window.open(ViewerURL,"Wx_Text_MENU",ViewerOptions);
}

//************************************************************************
//
// Start up a help viewer
//
// Arguments
//   ViewerURL      - the target viewer
//   ViewerTitle    - the viewer type for the images to display
//   ViewerOptions  - the viewer window options
//
// Returns nothing
//
function HelpViewer(ViewerURL,ViewerType,ViewerOptions) {
//alert(ViewerURL);
//alert(ViewerType);
//alert(ViewerOptions);
  var ViewerName = "Wx_" + ViewerType + "_Help";
  window.open(ViewerURL,ViewerName,ViewerOptions);
}

//************************************************************************

//
// Start up a Menu
//
// Arguments
//   MenuURL      - the target menu
//   MenuType     - the menu type for the menu to display
//   MenuOptions  - the menu window options
//
// Returns nothing
//
function MetJetMenu(MenuURL,MenuType,MenuOptions) {
  var MenuTitleBar = "MetJet_" + MenuType + "_Menu";
  window.open(MenuURL,MenuTitleBar,MenuOptions);
}

//************************************************************************
//
// Determines an Ok To Go status - and load a URL form
//
// Arguments
//   ActionForm     - the source form for the action
//
// Returns logical (true/false) [false]
//
function OkToGo(ActionForm,UserName) {
  var DoPDF = false;
  if (ActionForm.indexOf("!PDF") >= 0) {
    DoPDF = true;
    ActionForm = ActionForm.slice(0,-4);
  }
  if (ActionForm == "ROFOR") {
//    var RoforVersion = 0.1;     // *** DEMO 1 *** "2 gif logic"
//    var RoforVersion = 0.5;     // *** DEMO 2 *** "smarter 2 route multi gif logic"
    var RoforVersion = 1.0;     // *** "SYSTEM" *** "route construction and gif created logic"

    switch (RoforVersion) {
      case 0.1: // *** DEMO 1 *** "2 gif logic"
          var Args = "MetJetROFOR.php";             // demo 1
              Args += "?ROFOR=" + document.MetJetControlForm.Areas.value + "&User="+UserName + "&UserName="+UserName;
          GraphicsViewer(Args,"ROFOR","WIDTH=762,HEIGHT=418,left=0,top=0,resizable,scrollbars,status");
          break;
      case 0.5: // *** DEMO 2 *** "smarter 2 route multi gif logic"
          alert("New System coming Soon - Watch this space");
          var Args = "MetJetROFOR2.php";            // demo 2
              Args += "?ROFOR=" + document.MetJetControlForm.Areas.value + "&User="+UserName + "&UserName="+UserName;
          GraphicsViewer(Args,"ROFOR","WIDTH=762,HEIGHT=418,left=0,top=0,resizable,scrollbars,status");
          break;
      case 1.0: // *** "SYSTEM" *** "route construction and gif created logic"
          alert("New System Under Development - Warning = Data Accuracy May Vary");
          var Args = "MetJetROFOR.html.php";        // "live system"
              Args += "?ROFOR=" + document.MetJetControlForm.Areas.value + "&User="+UserName + "&UserName="+UserName;
          GraphicsViewer(Args,"ROFOR","WIDTH=762,HEIGHT=418,left=0,top=0,resizable,scrollbars,status");
          break;
    }
    return false;
  }
  if (ActionForm == "MetJetWxBrief") {
    if ((document.MetJetControlForm.Areas.value != "") ||
        (document.MetJetControlForm.ExtraTAF.value != "") || (document.MetJetControlForm.AdviseRegion.value != " ") ||
        (document.MetJetControlForm.ROFOR_Product.value != "0")
       ) {
	  var Args = "MetJetBrief.php";
	  Args += "?BRIEFING=GET";
	  Args += "&session=" + document.MetJetControlForm.session.value;
	  Args += "&User="+UserName + "&UserName="+UserName;
	  if (document.MetJetControlForm.VolAsh.checked) { Args += "&VOLASH=Yes"; } else { Args += "&VOLASH="; }
	  if (document.MetJetControlForm.Cyclone.checked) { Args += "&CYCLONE=Yes"; } else { Args += "&CYCLONE="; }
	  if (document.MetJetControlForm.FIR.checked) { Args += "&FIR=" + document.MetJetControlForm.FIR.value; } else { Args += "&FIR="; }
	  if (document.MetJetControlForm.TAF.checked) { Args += "&TAF=" + document.MetJetControlForm.TAF.value; } else { Args += "&TAF="; }
	  if (document.MetJetControlForm.METAR.checked) { Args += "&METAR=" + document.MetJetControlForm.METAR.value; } else { Args += "&METAR="; }
	  if (document.MetJetControlForm.AdviseRegion.value != "") { Args += "&AdviseRegion=" + document.MetJetControlForm.AdviseRegion.value; } else { Args += "&AdviseRegion="; }
	  Args += "&METARhours=" + document.MetJetControlForm.METARhours.value;
//	  if (document.MetJetControlForm.GAWX.checked) { Args += "&GAWX=" + document.MetJetControlForm.GAWX.value; } else { Args += "&GAWX="; }
	  Args += "&GAWX=" + document.MetJetControlForm.GAWX.value;
	  Args += "&PackageProduct=" + document.MetJetControlForm.Package_Product.value;
	  Args += "&ROFORProduct=" + document.MetJetControlForm.ROFOR_Product.value;
	  Args += "&TOdd=" + document.MetJetControlForm.TOdd.value;
	  Args += "&TOhh=" + document.MetJetControlForm.TOhh.value;
	  Args += TimeTick();
	  Args += "&Areas=" + document.MetJetControlForm.Areas.value;
	  Args += "&ExtraTAF=" + document.MetJetControlForm.ExtraTAF.value;
	  if (DoPDF) { Args += "&PDF=Yes"; }
//      TextViewer(Args,"WIDTH=546,HEIGHT=600,resizable,scrollbars,status");
//      TextViewer(Args,"WIDTH=565,HEIGHT=600,left=0,top=0,resizable,scrollbars,status");
//      TextViewer(Args,"WIDTH=580,HEIGHT=600,left=0,top=0,resizable,scrollbars,status");
      TextViewer(Args,"WIDTH=600,HEIGHT=600,left=0,top=0,resizable,scrollbars,status");
      return false;
    } else {
	  alert("You need to supply at least one of\n ... Country\n ... or FIR Area Name\n ... or Other TAF\n ... or ROFOR");
      return false;
	}
  }
  return  alert('Error - form request was ' + ActionForm);
}

//************************************************************************
//
// Just goes and does it
//
// Arguments
//   ActionForm     - the source form for the action
//
// Returns logical (true/false) [false]
//
function DoIt(ActionForm,UserName,CheckOnly,MenuPackage) {
//  if (! CheckOnly) {
//    CheckingOnly = false;
//  } else {
//    CheckingOnly = CheckOnly;
//  }
  if (ActionForm == "OTHERRECMARINEMET") {
    if (document.MetJetMenuForm.RecMarineFCST.value == "") {
      alert("Sorry = Pick an InShore Area");
      return (false);
    } else {
      var Args = "MetJetBrief.php";
      Args += "?BRIEFING=Marine";
	  Args += "&session=" + document.MetJetMenuForm.session.value;
      Args += "&MarineFCST=" + document.MetJetMenuForm.RecMarineFCST.value;
      Args += "&User=" + UserName + "&UserName=" + UserName;
      if (! CheckOnly) TextViewer(Args,"WIDTH=540,HEIGHT=600,left=0,top=0,resizable,scrollbars,status");
    }
    return (true);
  }
  if (ActionForm == "OTHERHIGHSEASMET") {
    if (document.MetJetMenuForm.HighSeasFCST.value == "") {
      alert("Sorry = Pick a High Seas Area");
      return (false);
    } else {
      var Args = "MetJetBrief.php";
      Args += "?BRIEFING=Marine";
	  Args += "&session=" + document.MetJetMenuForm.session.value;
      Args += "&MarineFCST=" + document.MetJetMenuForm.HighSeasFCST.value;
      Args += "&User=" + UserName + "&UserName=" + UserName;
      if (! CheckOnly) TextViewer(Args,"WIDTH=540,HEIGHT=600,left=0,top=0,resizable,scrollbars,status");
    }
    return (true);
  }
  if (ActionForm == "OTHERMARINEMET") {
    if (document.MetJetMenuForm.MarineFCST.value == "") {
      alert("Sorry = Pick a Coastal Area");
      return (false);
    } else {
      var Args = "MetJetBrief.php";
      Args += "?BRIEFING=Marine";
	  Args += "&session=" + document.MetJetMenuForm.session.value;
      Args += "&MarineFCST=" + document.MetJetMenuForm.MarineFCST.value;
      Args += "&User=" + UserName + "&UserName=" + UserName;
      if (! CheckOnly) TextViewer(Args,"WIDTH=540,HEIGHT=600,left=0,top=0,resizable,scrollbars,status");
    }
    return (true);
  }
  if (ActionForm == "OTHERREGIONALMET") {
    if (document.MetJetMenuForm.RegionalFCST.value == "") {
      alert("Sorry = Pick a Regional");
      return (false);
    } else {
      var Args = "MetJetBrief.php";
      Args += "?BRIEFING=Regional";
	  Args += "&session=" + document.MetJetMenuForm.session.value;
      Args += "&RegionalFCST=" + document.MetJetMenuForm.RegionalFCST.value;
      Args += "&User=" + UserName + "&UserName=" + UserName;
      if (! CheckOnly) TextViewer(Args,"WIDTH=540,HEIGHT=600,left=0,top=0,resizable,scrollbars,status");
    }
    return (true);
  }
  if (ActionForm == "OTHERADVISORYVOLASH") {
    if (document.MetJetMenuForm.AdviseArea.value == "") {
      alert("Sorry = Pick a Zone");
      return (false);
    } else {
      var Args = "MetJetBrief.php";
      Args += "?BRIEFING=GET&VOLASH=Yes";
	  Args += "&session=" + document.MetJetMenuForm.session.value;
      Args += "&AdviseRegion=" + document.MetJetMenuForm.AdviseArea.value;
      Args += "&User=" + UserName + "&UserName=" + UserName;
      if (! CheckOnly) TextViewer(Args,"WIDTH=540,HEIGHT=600,left=0,top=0,resizable,scrollbars,status");
    }
    return (true);
  }
  if (ActionForm == "OTHERADVISORYTCYCLONE") {
    if (document.MetJetMenuForm.AdviseArea.value == "") {
      alert("Sorry = Pick a Zone");
      return (false);
    } else {
      var Args = "MetJetBrief.php";
      Args += "?BRIEFING=GET&CYCLONE=Yes";
	  Args += "&session=" + document.MetJetMenuForm.session.value;
      Args += "&AdviseRegion=" + document.MetJetMenuForm.AdviseArea.value;
      Args += "&User=" + UserName + "&UserName=" + UserName;
      if (! CheckOnly) TextViewer(Args,"WIDTH=600,HEIGHT=600,left=0,top=0,resizable,scrollbars,status");
    }
    return (true);
  }
  if (ActionForm == "SST") {
    var Args = "MetJetBrief.php";
    Args += "?BRIEFING=SST";
    Args += "&session=" + document.MetJetMenuForm.session.value;
//    Args += "&SST=" + document.MetJetMenuForm.SST_PIC.value;
    Args += "&SST=NZ";
    var WinWid = "620";
//    if (document.MetJetMenuForm.SST_PIC.value == "SAT") {
//      WinWid = "565";
//    }
    Args += "&User=" + UserName + "&UserName=" + UserName;
//    TextViewer(Args,"WIDTH=650,HEIGHT=600,resizable,scrollbars,status");
    if (! CheckOnly) TextViewer(Args,"WIDTH=" + WinWid + ",HEIGHT=600,left=0,top=0,resizable,scrollbars,status");
    return (true);
  }
  if (ActionForm == "NZSWW") {
    var Args = "MetJetBrief.php";
    Args += "?BRIEFING=NZSWW";
    Args += "&session=" + document.MetJetMenuForm.session.value;
    Args += "&NZSWW=Yes";
    Args += "&User=" + UserName + "&UserName=" + UserName;
    if (! CheckOnly) TextViewer(Args,"WIDTH=650,HEIGHT=600,left=0,top=0,resizable,scrollbars,status");
    return (true);
  }
  if (ActionForm == "NZSIGWX") {
    var Args = "MetJetBrief.php";
    Args += "?BRIEFING=NZSIGWX";
    Args += "&session=" + document.MetJetMenuForm.session.value;
    Args += "&NZSigWx=Yes";
    Args += "&User=" + UserName + "&UserName=" + UserName;
    if (! CheckOnly) TextViewer(Args,"WIDTH=605,HEIGHT=600,left=0,top=0,resizable,scrollbars,status");
    return (true);
  }
  if (ActionForm == "NZTX") {
    var Args = "MetJetBrief.php";
    Args += "?BRIEFING=NZTX";
    Args += "&NZTx=Yes";
    Args += "&session=" + document.MetJetMenuForm.session.value;
    Args += "&User=" + UserName + "&UserName=" + UserName;
    if (! CheckOnly) TextViewer(Args,"WIDTH=605,HEIGHT=600,left=0,top=0,resizable,scrollbars,status");
    return (true);
  }
  if (ActionForm == "TCPOTENTIAL") {
    var Args = "MetJetBrief.php";
    Args += "?BRIEFING=TCPOTENTIAL";
    Args += "&session=" + document.MetJetMenuForm.session.value;
    Args += "&TCPOTENTIAL=Yes";
    Args += "&User=" + UserName + "&UserName=" + UserName;
    if (! CheckOnly) TextViewer(Args,"WIDTH=650,HEIGHT=650,left=0,top=0,resizable,scrollbars,status");
    return (true);
  }
  if (ActionForm == "NZGWX") {
    var Args = "MetJetBrief.php";
    Args += "?BRIEFING=NZGWX";
    Args += "&NZGWX=Yes";
    Args += "&session=" + document.MetJetMenuForm.session.value;
    Args += "&User=" + UserName + "&UserName=" + UserName;
    if (! CheckOnly) TextViewer(Args,"WIDTH=605,HEIGHT=600,left=0,top=0,resizable,scrollbars,status");
    return (true);
  }
  if (ActionForm == "UK60MSLP") {
    var Args = "MetJetBrief.php";
    Args += "?BRIEFING=UK60MSLP";
    Args += "&UK60MSLP=Yes";
    Args += "&session=" + document.MetJetMenuForm.session.value;
    Args += "&User=" + UserName + "&UserName=" + UserName;
    if (! CheckOnly) TextViewer(Args,"WIDTH=500,HEIGHT=600,left=0,top=0,resizable,scrollbars,status");
    return (true);
  }
  if (ActionForm == "UK60H500") {
    var Args = "MetJetBrief.php";
    Args += "?BRIEFING=UK60H500";
    Args += "&UK60H500=Yes";
    Args += "&session=" + document.MetJetMenuForm.session.value;
    Args += "&User=" + UserName + "&UserName=" + UserName;
    if (! CheckOnly) TextViewer(Args,"WIDTH=500,HEIGHT=600,left=0,top=0,resizable,scrollbars,status");
    return (true);
  }
  if (ActionForm == "DZMET") {
    var Args = "MetJetBrief.php";
    Args += "?BRIEFING=DZMET";
    Args += "&session=" + document.AreaControl.session.value;
    Args += "&DropZone=Yes";
    Args += "&User=" + UserName + "&UserName=" + UserName;
    if (! CheckOnly) TextViewer(Args,"WIDTH=565,HEIGHT=600,left=0,top=0,resizable,scrollbars,status");
    return (true);
  }
  if (ActionForm == "SSMET") {
    var Args = "MetJetBrief.php";
////    Args += "?SIGWXCharts=SSCharts";
    Args += "?BRIEFING=SSMET";
    Args += "&session=" + document.MetJetMenuForm.session.value;
    Args += "&SSMET=Yes";
    Args += "&User=" + UserName + "&UserName=" + UserName;
////    TextViewer(Args,"WIDTH=845,HEIGHT=600,resizable,scrollbars,status");
////    TextViewer(Args,"WIDTH=645,HEIGHT=600,resizable,scrollbars,status");
    if (! CheckOnly) TextViewer(Args,"WIDTH=565,HEIGHT=600,left=0,top=0,resizable,scrollbars,status");
    return (true);
  }
  if (ActionForm == "STHSSMET") {
    var Args = "MetJetBrief.php";
////    Args += "?SIGWXCharts=SSCharts";
    Args += "?BRIEFING=STHSSMET";
    Args += "&session=" + document.MetJetMenuForm.session.value;
    Args += "&STHSSMET=Yes";
    Args += "&User=" + UserName + "&UserName=" + UserName;
////    TextViewer(Args,"WIDTH=845,HEIGHT=600,resizable,scrollbars,status");
////    TextViewer(Args,"WIDTH=645,HEIGHT=600,resizable,scrollbars,status");
    if (! CheckOnly) TextViewer(Args,"WIDTH=765,HEIGHT=710,left=0,top=0,resizable,scrollbars,status");
    return (true);
  }
  if (ActionForm == "SIGWXCharts") {
    if (document.MetJetMenuForm.Validity.value == "?") {
      alert("Error = You need to pick a chart");
      return (false);
    } else if (document.MetJetMenuForm.Validity.value == "") {
      alert("Sorry = Charts not Available");
      return (false);
    } else {
      var Args = "MetJetBrief.php";
//      Args += "?SIGWXCharts=" + document.MetJetMenuForm.Chart.value;
//      Args += "&Validity=" + document.MetJetMenuForm.Validity.value;
      Args += "?SIGWXCharts=" + document.MetJetMenuForm.Validity.value;
      Args += "&session=" + document.MetJetMenuForm.session.value;
      Args += "&User=" + UserName + "&UserName=" + UserName;
      Args += "&MapName=" + document.MetJetMenuForm.MapName.value;
      Args += "&colour=" + document.MetJetMenuForm.SIGWXChartColour.value;
      if (! CheckOnly) TextViewer(Args,"WIDTH=800,HEIGHT=600,left=0,top=0,resizable,scrollbars,status");
    }
    return (true);
  }
  if (ActionForm == "MSLCharts") {
    if ((document.MetJetMenuForm.AnalValidity.value == "0") && (document.MetJetMenuForm.ProgValidity.value == "0")) {
      alert("Error = You need to pick a chart");
      return (false);
    } else {
      var Args = "MetJetBrief.php";
      Args += "?MSLCharts=Yes";
//      Args += "&ProgPeriod=" + document.MetJetMenuForm.ProgPeriod.value;
      Args += "&session=" + document.MetJetMenuForm.session.value;
      Args += "&PValidity=" + document.MetJetMenuForm.ProgValidity.value;
      Args += "&AValidity=" + document.MetJetMenuForm.AnalValidity.value;
      Args += "&User=" + UserName + "&UserName=" + UserName;
      Args += "&MapName=" + document.MetJetMenuForm.MapName.value;
      if (! CheckOnly) TextViewer(Args,"WIDTH=800,HEIGHT=750,left=0,top=0,resizable,scrollbars,status");
    }
    return (true);
  }
  if (ActionForm == "WINTEMCharts") {
    if (document.MetJetMenuForm.Validity.value == "?") {
      alert("Error = You need to pick a chart");
      return (false);
    } else if (document.MetJetMenuForm.Validity.value == "") {
      alert("Sorry = Charts not Available");
      return (false);
    } else {
      var Args = "MetJetBrief.php";
      Args += "?WINTEMCharts=Yes";
      Args += "&session=" + document.MetJetMenuForm.session.value;
      Args += "&Validity=" + document.MetJetMenuForm.Validity.value;
      Args += "&FlightLevel=" + document.MetJetMenuForm.FlightLevel.value;
      Args += "&User=" + UserName + "&UserName=" + UserName;
      Args += "&MapName=" + document.MetJetMenuForm.MapName.value;
      if (! CheckOnly) TextViewer(Args,"WIDTH=800,HEIGHT=600,left=0,top=0,resizable,scrollbars,status");
    }
    return (true);
  }
  if (ActionForm == "SIGWXChartsMultiple") {
    var Args = "MetJetBrief.php";
  	Args += "?BRIEFING=SIGWXCHARTSMULTIPLE";
    Args += "&SIGWXCHARTSMULTIPLE=Yes";
    Args += "&session=" + document.MetJetMenuForm.session.value;
    Args += "&User=" + UserName + "&UserName=" + UserName;
    Args += "&colour=" + document.MetJetMenuForm.SIGWXChartColour.value;
    Args += "&NumCharts=" + document.MetJetMenuForm.NumCharts.value;
		// Get the chart filenames from any ticked checkboxes
		var inputboxes = document.MetJetMenuForm.getElementsByTagName("input");
		var nchecked = 0;
    for (ichk = 0; ichk<inputboxes.length; ichk++) {
    	if (inputboxes[ichk].type == "checkbox") {
    		if (inputboxes[ichk].checked == true) {
    			//alert("Found a checked one = "+inputboxes[ichk].value);
					Args += "&checkchart" + nchecked + "=" + inputboxes[ichk].value;
					nchecked++;
    		}
    	}
    }
		//alert("nchecked = "+nchecked);
    if (! CheckOnly) TextViewer(Args,"WIDTH=800,HEIGHT=600,left=0,top=0,resizable,scrollbars,status");
    return (true);
  }
  if (ActionForm == "WINTEMChartsMultiple") {
    var Args = "MetJetBrief.php";
  	Args += "?BRIEFING=WINTEMCHARTSMULTIPLE";
    Args += "&WINTEMCHARTSMULTIPLE=Yes";
    Args += "&session=" + document.MetJetMenuForm.session.value;
    Args += "&User=" + UserName + "&UserName=" + UserName;
    Args += "&NumCharts=" + document.MetJetMenuForm.NumCharts.value;
		// Get the chart filenames from any ticked checkboxes
		var inputboxes = document.MetJetMenuForm.getElementsByTagName("input");
		var nchecked = 0;
    for (ichk = 0; ichk<inputboxes.length; ichk++) {
    	if (inputboxes[ichk].type == "checkbox") {
    		if (inputboxes[ichk].checked == true) {
    			//alert("Found a checked one = "+inputboxes[ichk].value);
					Args += "&checkchart" + nchecked + "=" + inputboxes[ichk].value;
					nchecked++;
    		}
    	}
    }
		//alert("nchecked = "+nchecked);
    if (! CheckOnly) TextViewer(Args,"WIDTH=800,HEIGHT=600,left=0,top=0,resizable,scrollbars,status");
    return (true);
  }
  if (ActionForm == "MSLAnalChartsMultiple") {
    var Args = "MetJetBrief.php";
  	Args += "?BRIEFING=MSLANALCHARTSMULTIPLE";
    Args += "&MSLANALCHARTSMULTIPLE=Yes";
    Args += "&session=" + document.MetJetMenuForm.session.value;
    Args += "&User=" + UserName + "&UserName=" + UserName;
    Args += "&NumCharts=" + document.MetJetMenuForm.NumCharts.value;
		// Get the chart filenames from any ticked checkboxes
		var inputboxes = document.MetJetMenuForm.getElementsByTagName("input");
		var nchecked = 0;
    for (ichk = 0; ichk<inputboxes.length; ichk++) {
    	if (inputboxes[ichk].type == "checkbox") {
    		if (inputboxes[ichk].checked == true) {
    			//alert("Found a checked one = "+inputboxes[ichk].value);
					Args += "&checkchart" + nchecked + "=" + inputboxes[ichk].value;
					nchecked++;
    		}
    	}
    }
		//alert("nchecked = "+nchecked);
    if (! CheckOnly) TextViewer(Args,"WIDTH=800,HEIGHT=600,left=0,top=0,resizable,scrollbars,status");
    return (true);
  }
  if (ActionForm == "MSLProgChartsMultiple") {
    var Args = "MetJetBrief.php";
  	Args += "?BRIEFING=MSLPROGCHARTSMULTIPLE";
    Args += "&MSLPROGCHARTSMULTIPLE=Yes";
    Args += "&session=" + document.MetJetMenuForm.session.value;
    Args += "&User=" + UserName + "&UserName=" + UserName;
    Args += "&NumCharts=" + document.MetJetMenuForm.NumCharts.value;
		// Get the chart filenames from any ticked checkboxes
		var inputboxes = document.MetJetMenuForm.getElementsByTagName("input");
		var nchecked = 0;
    for (ichk = 0; ichk<inputboxes.length; ichk++) {
    	if (inputboxes[ichk].type == "checkbox") {
    		if (inputboxes[ichk].checked == true) {
    			//alert("Found a checked one = "+inputboxes[ichk].value);
					Args += "&checkchart" + nchecked + "=" + inputboxes[ichk].value;
					nchecked++;
    		}
    	}
    }
		//alert("nchecked = "+nchecked);
    if (! CheckOnly) TextViewer(Args,"WIDTH=800,HEIGHT=600,left=0,top=0,resizable,scrollbars,status");
    return (true);
  }
  if (ActionForm == "SIGWXChartsMultipleMenu") {
    var Args = "MetJetMenu.php";
  	Args += "?MetJetMenu=SIGWXCHARTSMULTIPLE";
    Args += "&MetJetHeading=SIGWX+Charts";
    Args += "&session=" + document.MetJetMenuForm.session.value;
    Args += "&User=" + UserName + "&UserName=" + UserName;
    if (MenuPackage!='') Args += "&MenuPackage=" + MenuPackage;
    //if (MenuPackage) Args += "&MenuPackage=!";
    if (! CheckOnly) TextViewerMenu(Args,"WIDTH=850,HEIGHT=800,left=0,top=0,resizable,scrollbars,status");
    return (true);
  }
  if (ActionForm == "WINTEMChartsMultipleMenu") {
    var Args = "MetJetMenu.php";
  	Args += "?MetJetMenu=WINTEMCHARTSMULTIPLE";
    Args += "&MetJetHeading=WINTEM+Charts";
    Args += "&session=" + document.MetJetMenuForm.session.value;
    Args += "&User=" + UserName + "&UserName=" + UserName;
    if (MenuPackage!='') Args += "&MenuPackage=" + MenuPackage;
    if (! CheckOnly) TextViewerMenu(Args,"WIDTH=1050,HEIGHT=800,left=0,top=0,resizable,scrollbars,status");
    return (true);
  }
  if (ActionForm == "MSLAnalChartsMultipleMenu") {
    var Args = "MetJetMenu.php";
  	Args += "?MetJetMenu=MSLANALCHARTSMULTIPLE";
    Args += "&MetJetHeading=MSLANAL+Charts";
    Args += "&session=" + document.MetJetMenuForm.session.value;
    Args += "&User=" + UserName + "&UserName=" + UserName;
    if (MenuPackage!='') Args += "&MenuPackage=" + MenuPackage;
    if (! CheckOnly) TextViewerMenu(Args,"WIDTH=850,HEIGHT=200,left=0,top=0,resizable,scrollbars,status");
    return (true);
  }
  if (ActionForm == "MSLProgChartsMultipleMenu") {
    var Args = "MetJetMenu.php";
  	Args += "?MetJetMenu=MSLPROGCHARTSMULTIPLE";
    Args += "&MetJetHeading=MSLPROG+Charts";
    Args += "&session=" + document.MetJetMenuForm.session.value;
    Args += "&User=" + UserName + "&UserName=" + UserName;
    if (MenuPackage!='') Args += "&MenuPackage=" + MenuPackage;
    if (! CheckOnly) TextViewerMenu(Args,"WIDTH=850,HEIGHT=200,left=0,top=0,resizable,scrollbars,status");
    return (true);
  }
  if (ActionForm == "SEAsiaCharts") {
    var Args = "MetJetMenu.php";
  	Args += "?MetJetMenu=SEASIACHARTS";
    Args += "&MetJetHeading=MSL+SouthEastAsiaCharts";
    Args += "&session=" + document.MetJetMenuForm.session.value;
    Args += "&User=" + UserName + "&UserName=" + UserName;
    if (MenuPackage!='') Args += "&MenuPackage=" + MenuPackage;
    if (! CheckOnly) TextViewerMenu(Args,"WIDTH=390,HEIGHT=180,left=0,top=0,resizable,scrollbars,status");
    return (true);
  }
  if (ActionForm == "OLDSATPIX") { // this one is actually done from the button onClick
    var Args = "MetJetBrief.php";
    Args += "?SATPIX=Yes";
    Args += "&session=" + document.MetJetMenuForm.session.value;
    Args += "&SAT_IR=" + document.MetJetMenuForm.SAT_IR.value;
    Args += "&SAT_CT=" + document.MetJetMenuForm.SAT_CT.value;
    Args += "&SAT_VIS=" + document.MetJetMenuForm.SAT_VIS.value;
    Args += "&User=" + UserName + "&UserName=" + UserName;
    if (! CheckOnly) TextViewer(Args,"WIDTH=800,HEIGHT=600,left=0,top=0,resizable,scrollbars,status");
    return (true);
  }
  if (ActionForm == "SATPIX") {
    var Args = "MetJetBrief.php";
    Args += "?SATPIX=Yes";
    Args += "&session=" + document.MetJetMenuForm.session.value;
    Args += "&SAT_CT=" + document.MetJetMenuForm.SAT_CT.value;
    Args += "&User=" + UserName + "&UserName=" + UserName;
    if (! CheckOnly) TextViewer(Args,"WIDTH=800,HEIGHT=600,left=0,top=0,resizable,scrollbars,status");
    return (true);
  }
  if (ActionForm == "RADAR") {
    var Args = "MetJetBrief.php";
	Args += "?SATPIX=Yes";
    Args += "&session=" + document.MetJetMenuForm.session.value;
	Args += "&InfraRed=" + document.MetJetMenuForm.InfraRed.value;
	Args += "&CloudTops=" + document.MetJetMenuForm.CloudTops.value;
	Args += "&CloudTops=" + document.MetJetMenuForm.FlightLevel.value;
	Args += "&User=" + UserName + "&UserName=" + UserName;
    if (! CheckOnly) TextViewer(Args,"WIDTH=800,HEIGHT=600,left=0,top=0,resizable,scrollbars,status");
    return (true);
  }
  if (ActionForm == "WINDFCSTTOM") {
    var Args = "MetJetBrief.php";
	  Args += "?BRIEFING=WINDFCSTTOM";
    Args += "&WINDFCSTTOM=Yes";
    Args += "&session=" + document.MetJetMenuForm.session.value;
	  Args += "&User=" + UserName + "&UserName=" + UserName;
    if (! CheckOnly) TextViewer(Args,"WIDTH=945,HEIGHT=845,left=0,top=0,resizable,scrollbars,status");
    return (true);
  }
  if (ActionForm == "WINDFCSTTOMNI") {
    var Args = "MetJetBrief.php";
	  Args += "?BRIEFING=WINDFCSTTOMNI";
    Args += "&WINDFCSTTOMNI=Yes";
    Args += "&session=" + document.MetJetMenuForm.session.value;
	  Args += "&User=" + UserName + "&UserName=" + UserName;
    if (! CheckOnly) TextViewer(Args,"WIDTH=945,HEIGHT=845,left=0,top=0,resizable,scrollbars,status");
    return (true);
  }
  if (ActionForm == "NZDN_WINDSHEAR") {
    var Args = "MetJetBrief.php";
	  Args += "?BRIEFING=NZWINDSHEAR";
    Args += "&NZWINDSHEAR=NZDN";
    Args += "&session=" + document.MetJetMenuForm.session.value;
	  Args += "&User=" + UserName + "&UserName=" + UserName;
    if (! CheckOnly) TextViewer(Args,"WIDTH=900,HEIGHT=845,left=0,top=0,resizable,scrollbars,status");
    return (true);
  }
  if (ActionForm == "BRACK_NZ_PROG") {
    if (document.MetJetMenuForm.ProgValidity.value == "0") {
      alert("Error = You need to pick a chart");
      return (false);
    } else {
      var Args = "MetJetBrief.php";
  	  Args += "?BRIEFING=BRACK_NZ_PROG";
      Args += "&BRACK_NZ_PROG=Yes";
      Args += "&session=" + document.MetJetMenuForm.session.value;
      Args += "&PValidity=" + document.MetJetMenuForm.ProgValidity.value;
  	  Args += "&User=" + UserName + "&UserName=" + UserName;
      if (! CheckOnly) TextViewer(Args,"WIDTH=975,HEIGHT=845,left=0,top=0,resizable,scrollbars,status");
      return (true);
    }
  }


// --------------------------------------------------------------- //
  alert('Error - Don\'t know what to do with "' + ActionForm + '"');
// --------------------------------------------------------------- //
}

//************************************************************************
//

function MakePassword(TheValue,ResultPassword) {  // ***** create a random password of a set size *****
//  srand(time());
  var TheAlphaNumbs = "123456789ABCDEFGHJKLMNPQRSTUVWXYZ";
  var ThePassword = "";
  var TheLetter = "";
  var NumbOfChar = 0 + TheValue;
  if (1 == 2) {       // ***** make password fixed *****
    ThePassword = "12345678";
  } else {
    for (var ii=0; ii < NumbOfChar; ii++) {
      TheLetter = TheAlphaNumbs.charAt(Math.round(Math.random()*(TheAlphaNumbs.length-1)))
      ThePassword += TheLetter;
    }
  }
  ResultPassword.value = ThePassword;
  return false;
}

//************************************************************************

function WindowMaxiMize() {
//    window.moveTo(0,0);
//    window.outerWidth = screen.availWidth;
//    window.outerHeight = screen.availHeight;
//    window.outerWidth = screen.width - 50;
//    window.outerHeight = screen.height - 50;
    if (document.all || document.layers) { self.moveTo(0,0); self.resizeTo(screen.availWidth,screen.availHeight); }
}

//************************************************************************

function WindowMaxiMizeHeight() {
//    window.moveTo(0,0);
//    window.outerWidth = screen.availWidth;
//    window.outerHeight = screen.availHeight;
//    window.outerWidth = screen.width - 50;
//    window.outerHeight = screen.height - 50;
    if (document.all || document.layers) { self.moveTo(0,0); self.resizeTo(document.body.clientWidth,screen.availHeight); }
}

//************************************************************************

function GraphicsImage(ViewerURL,ViewerOptions) {
    var ViewerTitleBar = "Wx_Grafix_Viewer";
    window.open(ViewerURL,ViewerTitleBar,ViewerOptions);
}

//************************************************************************

function DZmailRequest(MailRequester,MailTarget) {
    var mailMessage = "mailto:" + MailTarget;
    mailMessage += "?subject=MetJet: DZ Request from " + MailRequester;
    mailMessage += "&body=Please supply:-\n\f\n\f";
    mailMessage += "1) Contact Name: \n\f";
    mailMessage += "2) Contact Phone: \n\f";
    mailMessage += "3) Validity(s): \n\f";
    mailMessage += "4) DZ Area required: \n\f";
    mailMessage += "5) Required when: \n\f. \n\f";
    open(mailMessage,parent.name);
}

//************************************************************************

function DefaultUserOptionsList(defOptions) {
  var TheOptions = '';

 // picked options Left= "b","c","e","g","i","n","q","u","v","y"
 // picked options Left= "E","G","I","J","K","N","Q","U","X"
 // picked options Left= "0","1","2","3","4","6","7","8","9"
  if (defOptions.length == 0) { TheOptions += '<option value=""' + ((defOptions.length == 0) ? " SELECTED" : "") + '>- none -</option>'; }
//  if (defOptions.indexOf("Z") >= 0) { TheOptions += '<option value="Z" SELECTED>NZ Map (MetFlight)</option>'; }
//  if (defOptions.indexOf("a") >= 0) { TheOptions += '<option value="a" SELECTED>Australia-NZ only</option>'; }
  if (defOptions.indexOf("d") >= 0) { TheOptions += '<option value="d" SELECTED>Drop Zones</option>'; }
  if (defOptions.indexOf("s") >= 0) { TheOptions += '<option value="s" SELECTED>Special Met</option>'; }
  if (defOptions.indexOf("R") >= 0) { TheOptions += '<option value="R" SELECTED>ROFORs</option>'; }
  if (defOptions.indexOf("S") >= 0) { TheOptions += '<option value="S" SELECTED>Scheduling</option>'; }
  if (defOptions.indexOf("H") >= 0) { TheOptions += '<option value="H" SELECTED>Ok4 HN OH inTAF</option>'; }
  if (defOptions.indexOf("D") >= 0) { TheOptions += '<option value="D" SELECTED>DN Wind-shear</option>'; }
  if (defOptions.indexOf("Y") >= 0) { TheOptions += '<option value="Y" SELECTED>Airways NOTAM link</option>'; }
  if (defOptions.indexOf("j") >= 0) { TheOptions += '<option value="j" SELECTED>Jeppesen link</option>'; }
  if (defOptions.indexOf("V") >= 0) { TheOptions += '<option value="V" SELECTED>VAAC link</option>'; }
  if (defOptions.indexOf("P") >= 0) { TheOptions += '<option value="P" SELECTED>Packaging</option>'; }
  if (defOptions.indexOf("x") >= 0) { TheOptions += '<option value="x" SELECTED>-Package SatPix</option>'; }
  if (defOptions.indexOf("r") >= 0) { TheOptions += '<option value="r" SELECTED>-Package Radar</option>'; }
  if (defOptions.indexOf("O") >= 0) { TheOptions += '<option value="O" SELECTED>-Package ROFORs</option>'; }
  if (defOptions.indexOf("A") >= 0) { TheOptions += '<option value="A" SELECTED>Alerts</option>'; }
  if (defOptions.indexOf("C") >= 0) { TheOptions += '<option value="C" SELECTED>Colour Charts</option>'; }
  if (defOptions.indexOf("M") >= 0) { TheOptions += '<option value="M" SELECTED>Marine Met</option>'; }
  if (defOptions.indexOf("m") >= 0) { TheOptions += '<option value="m" SELECTED>Recreational Marine</option>'; }
  if (defOptions.indexOf("h") >= 0) { TheOptions += '<option value="h" SELECTED>High Seas</option>'; }
  if (defOptions.indexOf("W") >= 0) { TheOptions += '<option value="W" SELECTED>Wind Forecast</option>'; }
  if (defOptions.indexOf("L") >= 0) { TheOptions += '<option value="L" SELECTED>Wind Fcast Tom NI</option>'; }
  if (defOptions.indexOf("B") >= 0) { TheOptions += '<option value="B" SELECTED>Bracknell NZ Prog</option>'; }
  if (defOptions.indexOf("f") >= 0) { TheOptions += '<option value="f" SELECTED>PDF outputs</option>'; }
  if (defOptions.indexOf("F") >= 0) { TheOptions += '<option value="F" SELECTED>FTP directory</option>'; }
  if (defOptions.indexOf("T") >= 0) { TheOptions += '<option value="T" SELECTED>FTP Access ONLY</option>'; }
  if (defOptions.indexOf("k") >= 0) { TheOptions += '<option value="k" SELECTED>AWS Pick Map</option>'; }
  if (defOptions.indexOf("o") >= 0) { TheOptions += '<option value="o" SELECTED>AWS Display Custom</option>'; }
  if (defOptions.indexOf("w") >= 0) { TheOptions += '<option value="w" SELECTED>AWS Display RNZAF</option>'; }
  if (defOptions.indexOf("z") >= 0) { TheOptions += '<option value="z" SELECTED>Graphical NZ Weather</option>'; }
  if (defOptions.indexOf("p") >= 0) { TheOptions += '<option value="p" SELECTED>UK60 MSLP NZ Progs</option>'; }
  if (defOptions.indexOf("5") >= 0) { TheOptions += '<option value="5" SELECTED>UK60 H500 NZ Progs</option>'; }
  if (defOptions.indexOf("l") >= 0) { TheOptions += '<option value="l" SELECTED>Multiple Charts</option>'; }
  if (defOptions.indexOf("t") >= 0) { TheOptions += '<option value="t" SELECTED>TC Potential</option>'; }

 // not picked options
  if (defOptions.length != 0) { TheOptions += '<option value="">- none -</option>'; }
//  if (defOptions.indexOf("Z") < 0) { TheOptions += '<option value="Z">NZ Map (MetFlight)</option>'; }
//  if (defOptions.indexOf("a") < 0) { TheOptions += '<option value="a">Australia-NZ only</option>'; }
  if (defOptions.indexOf("d") < 0) { TheOptions += '<option value="d">Drop Zones</option>'; }
  if (defOptions.indexOf("s") < 0) { TheOptions += '<option value="s">Special Met</option>'; }
  if (defOptions.indexOf("R") < 0) { TheOptions += '<option value="R">ROFORs</option>'; }
  if (defOptions.indexOf("S") < 0) { TheOptions += '<option value="S">Scheduling</option>'; }
  if (defOptions.indexOf("H") < 0) { TheOptions += '<option value="H">Ok4 HN OH inTAF</option>'; }
  if (defOptions.indexOf("D") < 0) { TheOptions += '<option value="D">DN Wind-shear</option>'; }
  if (defOptions.indexOf("Y") < 0) { TheOptions += '<option value="Y">Airways NOTAM link</option>'; }
  if (defOptions.indexOf("j") < 0) { TheOptions += '<option value="j">Jeppesen link</option>'; }
  if (defOptions.indexOf("V") < 0) { TheOptions += '<option value="V">VAAC link</option>'; }
  if (defOptions.indexOf("P") < 0) { TheOptions += '<option value="P">Packaging</option>'; }
  if (defOptions.indexOf("x") < 0) { TheOptions += '<option value="x">-Package SatPix</option>'; }
  if (defOptions.indexOf("r") < 0) { TheOptions += '<option value="r">-Package Radar</option>'; }
  if (defOptions.indexOf("O") < 0) { TheOptions += '<option value="O">-Package ROFORs</option>'; }
  if (defOptions.indexOf("A") < 0) { TheOptions += '<option value="A">Alerts</option>'; }
  if (defOptions.indexOf("C") < 0) { TheOptions += '<option value="C">Colour Charts</option>'; }
  if (defOptions.indexOf("M") < 0) { TheOptions += '<option value="M">Marine Met</option>'; }
  if (defOptions.indexOf("m") < 0) { TheOptions += '<option value="m">Recreational Marine</option>'; }
  if (defOptions.indexOf("h") < 0) { TheOptions += '<option value="h">High Seas</option>'; }
  if (defOptions.indexOf("W") < 0) { TheOptions += '<option value="W">Wind Forecast</option>'; }
  if (defOptions.indexOf("L") < 0) { TheOptions += '<option value="L">Wind Fcast Tom NI</option>'; }
  if (defOptions.indexOf("B") < 0) { TheOptions += '<option value="B">Bracknell NZ Prog</option>'; }
  if (defOptions.indexOf("f") < 0) { TheOptions += '<option value="f">PDF outputs</option>'; }
  if (defOptions.indexOf("F") < 0) { TheOptions += '<option value="F">FTP directory</option>'; }
  if (defOptions.indexOf("T") < 0) { TheOptions += '<option value="T">FTP Access ONLY</option>'; }
  if (defOptions.indexOf("k") < 0) { TheOptions += '<option value="k">AWS Pick Map</option>'; }
  if (defOptions.indexOf("o") < 0) { TheOptions += '<option value="o">AWS Display Custom</option>'; }
  if (defOptions.indexOf("w") < 0) { TheOptions += '<option value="w">AWS Display RNZAF</option>'; }
  if (defOptions.indexOf("z") < 0) { TheOptions += '<option value="z">Graphical NZ Weather</option>'; }
  if (defOptions.indexOf("p") < 0) { TheOptions += '<option value="p">UK60 MSLP NZ Progs</option>'; }
  if (defOptions.indexOf("5") < 0) { TheOptions += '<option value="5">UK60 H500 NZ Progs</option>'; }
  if (defOptions.indexOf("l") < 0) { TheOptions += '<option value="l">Multiple Charts</option>'; }
  if (defOptions.indexOf("t") < 0) { TheOptions += '<option value="t">TC Potential</option>'; }

  document.write(TheOptions);
}

//************************************************************************

function DefaultUserMapsList(defOptions) {
  var TheOptions = '';

 // picked options
//  if (defOptions.length == 0) { TheOptions += '<option value=""' + ((defOptions.length == 0) ? " SELECTED" : "") + '>none</option>'; }
  if (defOptions.indexOf("Z") >= 0) { TheOptions += '<option value="Z" SELECTED>NZ Map (metflight)</option>'; }
  if (defOptions.indexOf("a") >= 0) { TheOptions += '<option value="a" SELECTED>Australia-NZ</option>'; }
//  if (defOptions.indexOf("N") >= 0) { TheOptions += '<option value="N" SELECTED>Australia-NZ</option>'; }
  if (defOptions.indexOf("W") >= 0) { TheOptions += '<option value="W" SELECTED>World</option>'; }
  if (defOptions.indexOf("E") >= 0) { TheOptions += '<option value="E" SELECTED>Europe</option>'; }
  if (defOptions.indexOf("C") >= 0) { TheOptions += '<option value="C" SELECTED>China</option>'; }
  if (defOptions.indexOf("m") >= 0) { TheOptions += '<option value="m" SELECTED>Middle East</option>'; }
  if (defOptions.indexOf("s") >= 0) { TheOptions += '<option value="s" SELECTED>SE Asia</option>'; }
  if (defOptions.indexOf("P") >= 0) { TheOptions += '<option value="P" SELECTED>N Pacific</option>'; }
  if (defOptions.indexOf("p") >= 0) { TheOptions += '<option value="p" SELECTED>S Pacific</option>'; }
  if (defOptions.indexOf("F") >= 0) { TheOptions += '<option value="F" SELECTED>Pacific</option>'; }
  if (defOptions.indexOf("1") >= 0) { TheOptions += '<option value="1" SELECTED>N America</option>'; }
  if (defOptions.indexOf("2") >= 0) { TheOptions += '<option value="2" SELECTED>S America</option>'; }
  if (defOptions.indexOf("R") >= 0) { TheOptions += '<option value="R" SELECTED>Antarctic</option>'; }

 // not picked options
//  if (defOptions.length != 0) { TheOptions += '<option value="">none</option>'; }
  if (defOptions.indexOf("Z") < 0) { TheOptions += '<option value="Z">NZ Map (metflight)</option>'; }
  if (defOptions.indexOf("a") < 0) { TheOptions += '<option value="a">Australia-NZ</option>'; }
//  if (defOptions.indexOf("N") < 0) { TheOptions += '<option value="N">Australia-NZ</option>'; }
  if (defOptions.indexOf("W") < 0) { TheOptions += '<option value="W">World</option>'; }
  if (defOptions.indexOf("E") < 0) { TheOptions += '<option value="E">Europe</option>'; }
  if (defOptions.indexOf("C") < 0) { TheOptions += '<option value="C">China</option>'; }
  if (defOptions.indexOf("m") < 0) { TheOptions += '<option value="m">Middle East</option>'; }
  if (defOptions.indexOf("s") < 0) { TheOptions += '<option value="s">SE Asia</option>'; }
  if (defOptions.indexOf("P") < 0) { TheOptions += '<option value="P">N Pacific</option>'; }
  if (defOptions.indexOf("p") < 0) { TheOptions += '<option value="p">S Pacific</option>'; }
  if (defOptions.indexOf("F") < 0) { TheOptions += '<option value="F">Pacific</option>'; }
  if (defOptions.indexOf("1") < 0) { TheOptions += '<option value="1">N America</option>'; }
  if (defOptions.indexOf("2") < 0) { TheOptions += '<option value="2">S America</option>'; }
  if (defOptions.indexOf("R") < 0) { TheOptions += '<option value="R">Antarctic</option>'; }

  document.write(TheOptions);
}

//************************************************************************
var timerID = null;
var timerRunning = false;
function stopclock (targetform) {
  if(timerRunning)
  clearTimeout(timerID);
  timerRunning = false;
}
function showtime (targetform) {
  var now = new Date();
//	var hours = now.getHours();
//	var minutes = now.getMinutes();
//	var seconds = now.getSeconds()
//	var timeValue = "" + ((hours >12) ? hours -12 :hours)
//	timeValue += ((minutes < 10) ? ":0" : ":") + minutes
//	timeValue += ((seconds < 10) ? ":0" : ":") + seconds
//	timeValue += (hours >= 12) ? " P.M." : " A.M."
  var timeValue = now.toGMTString();  // "Tue, 2 Sep 2003 21:03:45 UTC"
  var timeItems = timeValue.split(" ");
  document.clock.face.value = timeItems[1] + " " + timeItems[2] + " " + timeItems[3] + " " + timeItems[4];
//  targetform.face.value = timeItems[1] + " " + timeItems[2] + " " + timeItems[3] + " " + timeItems[4];

  // you could replace the above with this
  // and have a clock on the status bar:
  // window.status = timeValue;

  timerID = setTimeout("showtime()",1000);
  timerRunning = true;
}
function startclock (targetform) {
  // Make sure the clock is stopped
  stopclock(targetform);
  showtime(targetform);
}

//************************************************************************
ebaFadeObjects = new Object();
ebaFadeTimers = new Object();

function ebaFade(object, destOp, rate, delta){
  if (!document.all) return
  if (object != "[object]"){
    setTimeout("ebaFade("+object+","+destOp+","+rate+","+delta+")",0);
    return;
  }
  clearTimeout(ebaFadeTimers[object.sourceIndex]);
  diff = destOp-object.filters.alpha.opacity;
  direction = 1;
  if (object.filters.alpha.opacity > destOp){
    direction = -1;
  }
  delta = Math.min(direction*diff,delta);
  object.filters.alpha.opacity += direction*delta;
  if (object.filters.alpha.opacity != destOp){
    ebaFadeObjects[object.sourceIndex] = object;
    ebaFadeTimers[object.sourceIndex] = setTimeout("ebaFade(ebaFadeObjects["+object.sourceIndex+"],"+destOp+","+rate+","+delta+")",rate);
  }
}

//************************************************************************
function hL(E) {
  while (E.tagName!="TR") {
    E=E.parentElement;
  }
  E.className="H";
}
function dL(E) {
  while (E.tagName!="TR") {
    E=E.parentElement;
  }
  E.className="";
}
function CCA(CB,noHL) {
  if (!noHL) {
    if (CB.checked)
      hL(CB);
    else
      dL(CB);
  }
}

//************************************************************************
function ReplaceAll(StringIn,oldChar,newChar) {
  if ((oldChar.length > 0) && (newChar.length > 0)) {
    while (StringIn.search(oldChar) > 0) {
      StringIn = StringIn.replace(oldChar,newChar);
    }
  }
  return (StringIn);
}

//************************************************************************
function HPA_2_FL(inHPA) {
  switch (inHPA) {
    case "200": return ("385"); break;
    case "250": return ("340"); break;
    case "300": return ("300"); break;
    case "400": return ("240"); break;
    case "500": return ("185"); break;
    case "700": return ("100"); break;
    case "850": return ("050"); break;
    default: return ("?"+inHPA+"?");
  }
}
function FL_2_HPA(inFL) {
  switch (inFL) {
    case "050": return ("850"); break;
    case "100": return ("700"); break;
    case "185": return ("500"); break;
    case "240": return ("400"); break;
    case "300": return ("300"); break;
    case "340": return ("250"); break;
    case "385": return ("200"); break;
    default: return ("?"+inFL+"?");
  }
}

//************************************************************************
//************************************************************************
//************************************************************************
//************************************************************************
//************************************************************************
//************************************************************************
