/*
 * Copyright: Copyright (c) 2004-2006
 * @version $Revision: 0.0.0 $ $Date: xxxx/xx/xx xx:xx:xx $
 *
 * @ Revision History:
 * @    Creation Date:  2004/05/12 09:57:00
 *
 */

function getPopupWinHandle(
      loc,
      width,
      height,
      resizable,
      scrollbars,
      toolbar,
      dependent,
      winName,
      locationBar,
      statusBar,
      align )
{
  // Evaluate the window arguments.
  var alignValue = "top=1,left=1"

  if ( align== 'center' ) {
    LeftPosition = (screen.width) ? (screen.width-width)/2 : 0;
    TopPosition = (screen.height) ? (screen.height-height)/2 : 0;
    alignValue = "top=" + TopPosition + ",left=" + LeftPosition;
  }
  else if (align=='topright') {
    LeftPosition = (screen.width) ? (screen.width-width): 0;
    TopPosition = 1;
    alignValue = "top=" + TopPosition + ",left=" + LeftPosition;
  }
  else if ( align=='topcenter' ) {
    LeftPosition = (screen.width) ? (screen.width-width)/2 : 0;
    TopPosition = 1;
    alignValue = "top=" + TopPosition + ",left=" + LeftPosition;
  }
  else if ( align=='topleft' ) {
    alignValue = "top=1,left=1";
  }

  var win = eval("window.open(loc, '"
                    + winName
                    + "','width=" + width
                    + ",height=" + height
                    + ",resizable=" + resizable
                    +  ",scrollbars=" + scrollbars
                    +  ",toolbar=" + toolbar
                    +  ",dependent=" + dependent
                    +  ",screenX=1,screenY=1," + alignValue
                    +  ",location=" + locationBar
                    + ",status=" + statusBar + "')");
  //set the focus to the newly created window.
  win.focus();

  // Return a handle to the newly created window.
  return win;

} // function getPopupWinHandle

// Creates a popup window based on specified arguments.
function popupWin(
      loc,
      width,
      height,
      resizable,
      scrollbars,
      toolbar,
      dependent,
      winName,
      locationBar,
      statusBar,
      align)
{
  var newWin = getPopupWinHandle( loc, width, height, resizable, scrollbars, toolbar, dependent, winName,locationBar, statusBar, align );
}

function linkToTop(link)
{
  alert('link='+link);
  window.location.href = link;
}

function linkToTop(link, parameters)
{
  if (link == "#") {
    alert('Coming Soon...');
    return;
  }

  if (parameters == '?') {
//    alert(link + parameters);
    window.location.href = link + parameters;
  }
  else {
//    alert(link + '?' + parameters);
//    window.location.href = link + '?' + parameters;
    top.location.target = '_top';
    top.location.href = link + '?' + parameters;
  }
}
function linkTo(link)
{
  alert('link='+link);
  window.location.href = link;
}

function linkTo(link, parameters)
{
  if ( link == "#" ) {
    alert('Coming Soon...');
    return;
  }

  if ( parameters == '' ) {
    window.location.href = link;
  }
  else if ( parameters == '?' ) {
//    alert(link + parameters);
    window.location.href = link + parameters;
  }
  else {
//    alert(link + '?' + parameters);
    window.location.href = link + '?' + parameters;
  }
}

function goToURLTopToMain(link)
{
  parent.frames[2].location=link
}

function newItemNavTable(f)
{
  if (f.elements["newItem"].value == 4)
    return ''
  else
    return '#'
}

function openNewWindow(windowName, prefix, url)
{
  openNewWindow(windowName, prefix, url, '');
}
function openNewWindow(windowName, prefix, url, parameters)
{
  if (url == "#") {
    alert('This Feature was Not Set Up for Demonstration');
  }
  else {
    var printWindow=window.open('',windowName,'status=yes,scrollbars=yes,resizable=yes,top=10,left=10,screenX=10,screenY=10,width=800,height=700');
    if (window.screen)
    {
      printWindow.moveTo(0,0);
      printWindow.outerHeight = screen.availHeight;
      printWindow.outerWidth = screen.availWidth;
      printWindow.resizeTo(screen.availWidth,screen.availHeight);
    }
    printWindow.focus();
    printWindow.location.replace(prefix + url + '?' + parameters);
  }
}

function openPrintWindow(windowName, prefix, url, parameters)
{
  if (url == "#") {
    alert('This Feature was Not Set Up for Demonstration');
  }
  else {
    var printWindow=window.open('',windowName,'status=no,scrollbars=yes,resizable=yes,top=10,left=10,screenX=10,screenY=10,width=800,height=600');
    if (window.screen)
      printWindow.moveTo(0,0);
    printWindow.focus();
    printWindow.location.replace(prefix + url + '?' + parameters);
  }
}

function showDate()
{
  var dayarray=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
//  var montharray=new Array("January","February","March","April","May","June","July","August","September","October","November","December")
  var montharray=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")

  var mydate=new Date()

  var year=mydate.getYear()
  var day=mydate.getDay()
  var month=mydate.getMonth()
  var daym=mydate.getDate()
  if (daym<10)
    daym="0"+daym
  var hours=mydate.getHours()

  var dn = "AM";
  if ( hours >= 12 )
    dn = "PM";

//  document.write(dayarray[day] + ', ' + montharray[month] + ' ' + daym + ', ' + year);
  document.write(montharray[month] + ' ' + daym + ', ' + year);
}

function confirmDelete( message )
{
  var agree=confirm(message + "  Click OK for YES and CANCEL for NO")
  if (agree)
    return true
  else
    return false
}

function padTime( num ) {
  return ( num < 10 ) ? "0" + num : num;
}

function clock(timeZone)
{
  day = new Date();

  hour = day.getHours();
  ampm = (hour >= 0 && hour < 12) ? " AM" : " PM";
  if (hour > 12) hour = hour - 12;
  if (hour == 0) hour = 12;

  minute = padTime(day.getMinutes());
  seconds = padTime(day.getSeconds());

  document.getElementById("clock").firstChild.nodeValue =
    hour + ":" + minute + ampm + timeZone;
//    hour + ":" + minute + ":" + seconds + ampm + timeZone;
  setTimeout('clock(timeZone)', 10000);
}

function getTimeZoneDisplay(dst)
{
  HAWAII   = ( dst ) ? 540 : 600;
  ALASKA   = ( dst ) ? 480 : 540;
  PACIFIC  = ( dst ) ? 420 : 480;
  MOUNTAIN = ( dst ) ? 360 : 420;
  CENTRAL  = ( dst ) ? 300 : 360;
  EASTERN  = ( dst ) ? 240 : 300;
  ATLANTIC = ( dst ) ? 180 : 240;
  GMT  = 0;

  rightNow = new Date();
  clientZone = rightNow.getTimezoneOffset();

  if (clientZone == HAWAII)
    timeZone = " H";
  else if (clientZone == ALASKA)
    timeZone = " A";
  else if (clientZone == PACIFIC)
    timeZone = " P";
  else if (clientZone == MOUNTAIN)
    timeZone = " M";
  else if (clientZone == CENTRAL)
    timeZone = " C";
  else if (clientZone == EASTERN)
    timeZone = " E";

  timeZone += (dst) ? "DT" : "ST";

  if (clientZone == GMT)
    timeZone = " GMT";

  return timeZone;
}

function checkAll(f)
{
  for (i = 0; i < f.length; i++) {
    f[i].checked = true;
  }
}
function unCheckAll(f)
{
  for (i = 0; i < f.length; i++) {
    f[i].checked = false;
  }
}

function unCheckAllViewer(iFrameForm)
{
  for (i = 0; i < iFrameForm.document.commonForm.length; i++) {
    iFrameForm.document.commonForm[i].checked = false;
  }
}

function checkAllViewer(iFrameForm)
{
  for (i = 0; i < iFrameForm.document.commonForm.length; i++) {
    iFrameForm.document.commonForm[i].checked = true;
  }
}

function setDispatch(f, target)
{
  f.dispatch.value = target;
}

function submitOnce(f)
{
  //if IE 4+ or NS 6+
  if (f.all || f.getElementById)  {
    //screen thru every element in the form, and hunt down "submit" and "reset"
    for (i=0; i < f.length; i++) {
      var tempobj=f.elements[i]
      if ( tempobj.type.toLowerCase() == "submit" ||
           tempobj.type.toLowerCase() == "reset"  ||
           tempobj.type.toLowerCase() == "button"   ) {
        //disable em
        tempobj.disabled=true;
      }
    } // for
  } // if
}

