// +----------------------------------------------------------------------------+
// | File:         CommonFunctions.js                                           |
// | Description:  Common JavaScript Functions                                  |
// | Author:       Trevor Harris <trevorharris@comcast.net>                     |
// | Created:      November, 2002                                               |
// +----------------------------------------------------------------------------+
// | Copyright (c) 2002 - 2006 Datum Management Services. All rights reserved.  |
// +----------------------------------------------------------------------------+
// $Id: CommonFunctions.js, v1.0.2 2005/1/20 $

var whitespace    = " \t\n\r";
var hXMLRequest; 

function initCurrentWindow( cWindowName) {
  if( cWindowName != '') {
    window.name = cWindowName;
    window.id   = cWindowName;
  }
//  if( window.XMLRequestHandle) {
//    hXMLRequest = window.XMLRequestHandle();
//  }
}

function isEmpty( cField)
{
  if( (cField == null) || (cField.length == 0)) {
    return true;  }

  var iIdx;
  for (iIdx = 0; cField.length; i++)
  {
    var cChar = cField.charAt(iIdx);
    if( whitespace.indexOf(cChar) == -1)
      return false;
  }

  return true;
}

function newWindow( cURL,cName,cAttributes) {
  if( cAttributes == '') {
    cAttributes = "menubar=yes,toolbar=yes,resizable=yes,scrollbars=yes,alwaysRaised=no,dependent=yes,hotkeys=no,z-lock=no";
  }
  var hWindow = window.open( cURL,cName,cAttributes);
  hWindow.focus();
}

function writeCookie( cCookieName, cCookieValue) {
  var expiration = new Date();
  expiration.setYear( expiration.getYear() + 1);
  document.cookie = cCookieName + "=" + cCookieValue + "; expires=" + expiration.toGMTString();
}

function removeCookie( cCookieName) {
  document.cookie = cCookieName + "; expires=Sun, 01-Jan-2002 00:00:01 GMT";
}

function submitMenuItem( hForm, iMenuItem) {
  hForm.MenuItemID.value = iMenuItem;
  hForm.submit();
}

function submitPageID( hForm, iPageID) {
  if (window.initXMLRequestHandle) {
  }
  else {
    hForm.NextPageID.value = iPageID;
    hForm.submit();
  }
}

function submitPageName( hForm, cPageName) {
  hForm.PageName.value   = cPageName;
  hForm.MenuItemID.value = '';
  hForm.PageID.value = '';
  hForm.submit();
}