//------------------------------------------------------------------------------
// General functions
//-------------------------------------------------------------------------------

// Swap image function
  function ChangeImage (ImageName, FileName) {
    if (document.images) {
      document[ImageName].src = eval(FileName + ".src");
    }
  }

// Swap two images function
  function ChangeImages (ImageName,FileName,SecImageName,SecFileName) {
    if (document.images) {
      document[ImageName].src = eval(FileName + ".src");
      document[SecImageName].src = eval(SecFileName + ".src");
    }
  }

// Swap three images function
  function ChangeThreeImages (ImageName,FileName,SecImageName,SecFileName,ThirdImageName,ThirdFileName) {
    if (document.images) {
      document[ImageName].src = eval(FileName + ".src");
      document[SecImageName].src = eval(SecFileName + ".src");
      document[ThirdImageName].src = eval(ThirdFileName + ".src");
    }
  }

// Popup window function
  function openWindow(url, name, size, scroll)
  {
      popupWin=window.open(url, name, '"toolbar=no,' + size +',left=10,top=10,status=no,' + scroll +',resize=no,menubar=no"');
  }

// Close window function
function closeWin() {
  popupWin.close();
}

// Array function
  function makeArray(len) {
    for (var i = 0 ; i < len; i++) this[i] = null;
    this.length = len;
  }

// Checks for browser type (returns ns4 or ie4)
  function check() {
    browsertype = "";
    //
    if (document.layers) {
      browsertype = "ns4";
    } else if (document.all) {
      browsertype = "ie4";
    }
    return browsertype;
}

// Prints window
  function printPage() {
    print();
  }


//-------------------------------------------------------------------------------
// Date functions
//-------------------------------------------------------------------------------

// Array of day names
  var dayNames=new makeArray(7);
  dayNames[0] = "Sunday";
  dayNames[1] = "Monday";
  dayNames[2] = "Tuesday";
  dayNames[3] = "Wednesday";
  dayNames[4] = "Thursday";
  dayNames[5] = "Friday";
  dayNames[6] = "Saturday";

// Array of month names
  var monthNames = new makeArray(12);
  monthNames[0] = "January";
  monthNames[1] = "February";
  monthNames[2] = "March";
  monthNames[3] = "April";
  monthNames[4] = "May";
  monthNames[5] = "June";
  monthNames[6] = "July";
  monthNames[7] = "August";
  monthNames[8] = "September";
  monthNames[9] = "October";
  monthNames[10] = "November";
  monthNames[11] = "December";

// Elements of Date object assigned to variables
  var now = new Date();
  var day = now.getDay();
  var month = now.getMonth();
  var year = now.getYear();
  if (year == 99)
    year = 1999;
  else if (year > 99 && year < 2000)
    year = 1900 + year;
  var date = now.getDate();

//-------------------------------------------------------------------------------
// Full screen functions
//-------------------------------------------------------------------------------

function openAWindow( pageToLoad, winName, width, height, center) {
/* Opens a new window on the users desktop.
   Arguments:
    pageToLoad - The URL of a page to load in the browser window.
                 This can be a relative URL or fully qualified.
    winName - 	 Name of the new window.
    width - 	 The horizontal size of the new window.
    height - 	 The vertical size of the new window.
    center -     toggle centering on 4.0 browsers.
                  1=centered window 0=no centering

    Values in the "args" section below can all be toggled in the
    same fashion as the center toggle.  Just modify the appropriate
    value in the args section to be either 0 or 1.

    A call to this function might look like this:
    <a href="javascript:openAWindow('ice.html','ice',375,250,1)">Ice</a>

   Created by Glenn Davis of Project Cool, Inc. for general use.  If
   you use this routine please leave all comments in place so that
   others may benefit as well.
*/

    xposition=0; yposition=0;
    if ((parseInt(navigator.appVersion) >= 4 ) && (center)){
        xposition = (screen.width - width) / 2;
        yposition = (screen.height - height) / 2;
    }
    args = "width=" + width + ","
    + "height=" + height + ","
    + "location=0,"
    + "menubar=0,"
    + "resizable=1,"
    + "scrollbars=1,"
    + "status=0,"
    + "titlebar=0,"
    + "toolbar=0,"
    + "hotkeys=0,"
    + "screenx=" + xposition + ","  //NN Only
    + "screeny=" + yposition + ","  //NN Only
    + "left=" + xposition + ","     //IE Only
    + "top=" + yposition;           //IE Only

    window.open( pageToLoad,winName,args );
}

function openAFullWindow( pageToLoad, winName, width, height, center) {
/* Opens a new window on the users desktop.
   Arguments:
    pageToLoad - The URL of a page to load in the browser window.
                 This can be a relative URL or fully qualified.
    winName - 	 Name of the new window.
    width - 	 The horizontal size of the new window.
    height - 	 The vertical size of the new window.
    center -     toggle centering on 4.0 browsers.
                  1=centered window 0=no centering

    Values in the "args" section below can all be toggled in the
    same fashion as the center toggle.  Just modify the appropriate
    value in the args section to be either 0 or 1.

    A call to this function might look like this:
    <a href="javascript:openAFullWindow('ice.html','ice',375,250,1)">Ice</a>

   Created by Glenn Davis of Project Cool, Inc. for general use.  If
   you use this routine please leave all comments in place so that
   others may benefit as well.
*/

    var larg = screen.availWidth - 10;
    var alt = screen.availHeight - 30;

    xposition=0; yposition=0;
    //if ((parseInt(navigator.appVersion) >= 4 ) && (center)){
    //   xposition = (screen.width - width) / 2;
    //    yposition = (screen.height - height) / 2;
    //}
    args = "width=" + larg + ","
    + "height=" + alt + ","
    + "location=0,"
    + "menubar=0,"
    + "resizable=1,"
    + "scrollbars=1,"
    + "status=0,"
    + "titlebar=0,"
    + "toolbar=0,"
    + "hotkeys=0,"
    + "screenx=" + xposition + ","  //NN Only
    + "screeny=" + yposition + ","  //NN Only
    + "left=" + xposition + ","     //IE Only
    + "top=" + yposition + ","     //IE Only
    + "fullscreen=1";             //IE Only

    window.open( pageToLoad,winName,args );
}

//if (document.layers) {
//    window.captureEvents(Event.MOUSEMOVE);
    //window.onmousemove=move;
//}
//else if (document.all)
//   document.onmousemove=move;

function openAPositionedWindow( pageToLoad, winName, width, height, center, e) {

    var xposition=yposition=0;
    if (e != '') {
        xposition = e.screenX + 10;
        yposition = e.screenY + 10;
    }

    //if ((parseInt(navigator.appVersion) >= 4 ) && (center)){
    //  xposition = (screen.width - width) / 2;
    //  yposition = (screen.height - height) / 2;
    //}
    args = "width=" + width + ","
    + "height=" + height + ","
    + "location=0,"
    + "menubar=0,"
    + "resizable=1,"
    + "scrollbars=1,"
    + "status=0,"
    + "titlebar=0,"
    + "toolbar=0,"
    + "hotkeys=0,"
    + "screenx=" + xposition + ","  //NN Only
    + "screeny=" + yposition + ","  //NN Only
    + "left=" + xposition + ","     //IE Only
    + "top=" + yposition;           //IE Only

    newwindow = window.open( pageToLoad,winName,args );
}
