/*

  General Functions for eLinkCart
  Copyright (c) 1998 - 2010 by TRJ Designs, Inc.
  All rights reserved.
  No part of this script may be used, altered in any way, or distributed
  without the express written consent of the authors.

*/


// Misc Page Vars
  
// For the subModal arrays built later
var aryLoading = new Array(10);

//For the Softcare Menus
var states = ['mout', 'mover', 'mdown']; 

var objNavWin;
var blnExit = true;
var _editor_url="../Source/"; 
var message="";
var noRightClick=0;
var catTree;
var domainName = GetDomain();

var MONTH_NAMES=new Array('January','February','March','April','May','June','July','August','September','October','November','December','Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
var DAY_NAMES=new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sun','Mon','Tue','Wed','Thu','Fri','Sat');


var currentDate = new Date();
var currentYear = formatDate(currentDate,"yyyy");
var shortDate = formatDate(currentDate,"MM/dd/yyyy");
var longDate = formatDate(currentDate,"MMM dd, yyyy");
var displayDate = shortDate;

//var browseHome = '../CustomerScripts/page.aspx' - set in pageFunctions.headJava
var timer;
var sessionTimeout;

var browserVersion = 0;
var loadMyAccount = '<div id="modalContent" ><table align="center" border="0" cellpadding="0" cellspacing="0" width="200px"><tr><td align="center"><br/></td></tr><tr><td align="center"><DIV id="modalContent"><TABLE align="center" border="0" cellpadding="0" cellspacing="0" width="200px"><TR><TD id="loadingMsg" align="center"><span style="font-size:10pt;font-weight:bold;">Loading Account Information.</span></TD></TR><TR><TD align="center"><img src="../images/loading.gif" alt="" border="0" style="margin-top:5px;"/></TD></TR></TABLE></DIV></td></tr></table></div>';
var querystring = new Array;
 
//This requires browser.js
try {
    
    if (is_ie)
      browserVersion = 1; //Simply means IE > 6.x
      
    if (is_chrome)
      browserVersion = 2; //Google Chrome
      
    if (is_safari)
      browserVersion = 3; //Safari

    if (is_opera)
      browserVersion = 4; //opera7 has a good DOM
      
    if (is_fx)
      browserVersion = 5; //other, possibly without DHTML  

    // Check the browser version
    if (!is_ie7up && !is_saf4up && !is_opera9up && !is_fx3up && !is_chrome4up) {
      browserUpgrade();
    }
    
}
catch (e) {
  // No Error
}

//Parse The QuerySgtring for Later
getQueryString();

//Set the Page Width
//Event Handlers
window.onerror = stopError;

function browserUpgrade() {
    location.replace("../Includes/browserUpgrade.html");
};

function setNoRightClick(noRightClick)
{

  if ( noRightClick == '1' )
  {
    if (document.layers) 
    {
      document.captureEvents(Event.MOUSEDOWN);
      document.onmousedown=clickNS;
    }
    else
    {
      document.onmouseup=clickNS;
      document.oncontextmenu=clickIE;
    }

    document.oncontextmenu=new Function("return false")
  }

};

// function placeholder
function doOnLoad() { };
function masterLoad() { };

function checkDoOnLoad() {

  try {
    
    addeLinkCartDivs();
    
    if (xhtmlHeight != null && typeof xhtmlHeight == "function")
      xhtmlHeight();
    
    if (masterLoad != null && typeof masterLoad == "function")
      masterLoad();

    if (doOnLoad != null && typeof doOnLoad == "function")
      doOnLoad();

  }
  catch (e) { }
}
;
function addeLinkCartDivs() {

  var newDiv;
  var divIdName;

  try {  

    if (!document.getElementById('preview_div')) {  
      newdiv = document.createElement('div');
      divIdName = 'preview_div';
      newdiv.setAttribute('id',divIdName);
      newdiv.style.display = 'none';
      newdiv.style.position = 'absolute';
      newdiv.style.zIndex = '110';
      document.body.appendChild(newdiv);
    }
    
    if (!document.getElementById('ajaxDetailLink')) {
      newdiv = document.createElement('div');
      divIdName = 'ajaxDetailLink';
      newdiv.setAttribute('id',divIdName);
      newdiv.setAttribute('rel','text');
      newdiv.style.display = 'none';
      newdiv.style.marginTop = '-75px';
      document.body.appendChild(newdiv);
    }
    
    if (!document.getElementById('pageLink1')) {
      newdiv = document.createElement('div');
      divIdName = 'pageLink1';
      newdiv.setAttribute('id',divIdName);
      newdiv.style.display = 'none';
      document.body.appendChild(newdiv);
    }
    
    if (!document.getElementById('pageLink2')) {
      newdiv = document.createElement('div');
      divIdName = 'pageLink2';
      newdiv.setAttribute('id',divIdName);
      newdiv.style.display = 'none';
      document.body.appendChild(newdiv);
    }

    if (!document.getElementById('pageLink')) {
      newdiv = document.createElement('div');
      divIdName = 'pageLink';
      newdiv.setAttribute('id',divIdName);
      newdiv.style.display = 'none';
      document.body.appendChild(newdiv);
    }
  }
  catch (e) { }

};

function clickIE() 
{
  if (document.all) 
  {
    //(message);
    return false;
  }
};

function clickNS(e) 
{
  if (document.layers || (document.getElementById && !document.all)) 
  { 
    if (e.which==2 || e.which==3) 
    {
      //(message);
      return false;
    }
  }
};

function stopError() { return true; };

function refreshWindow()
{

  window.location.reload = null;
  blnExit = false;
  location.reload();
  
};

function ClearTimer(){
  try {
    clearTimeout(timer);
  }
  catch (e) { }
};

function xhtmlHeight() {

  try {
    if (document.getElementById("top")!=null && document.getElementById("bottom")!=null) {
      var top=document.getElementById("top").offsetTop;
      var bottom=document.getElementById("bottom").offsetTop;
      var height=bottom-top;

      if(height<680 && document.getElementById("bodyCenter")!=null)
        document.getElementById("bodyCenter").style.height=680+'px';
    }
  }
  catch (e) { }
};

function WarnUserTimeout()
{
  if (window.confirm('Your session will expire in 1 minutes. Do you want To continue working?'))
  {
    window.history.go(0);
  }
};

//
//This is to correct a rendering bug in FireFox when using DHTMLX controls
//
function setStylesheet(title, randomize){ //Main stylesheet switcher function. Second parameter if defined causes a random alternate stylesheet (including none) to be enabled
  var i, cacheobj, altsheets=[""];

  for(i=0; (cacheobj=document.getElementsByTagName("link")[i]); i++) {
    if(cacheobj.getAttribute("rel").toLowerCase()=="alternate stylesheet" && cacheobj.getAttribute("title")) { //if this is an alternate stylesheet with title
      cacheobj.disabled = true;
      if(cacheobj.getAttribute("title") == title) { //enable alternate stylesheet with title that matches parameter
        cacheobj.disabled = false; //enable chosen style sheet
      }
    }
  };
    
  return true;
}

function Pause(milliseconds) 
{
  var date = new Date();
  var curDate = null;

  do { curDate = new Date(); } 
  while(curDate-date < milliseconds);
} ;

//Query String Parsing function
function getQueryString()
{
 // parse current url into an array with the keys/values
 var q = String (document.location).split ('?')[1];
 if (!q) return false;
 q = q. split ('&');

 for (var i = 0 ; i < q.length; i++)
 {
   // for each key/value, split them at the '='
   // and add them to the qerystring array
   var o = q[i].split('=');
   querystring[o[0]] = o[1];
 };

 // return the querystring
 return querystring;
};

//This is to correct IE bug w/getElementsByName function
//document.getElementsByName uses 'id' tag in IE not 'name' tag
function getElementsByName(tag, name) {

  var arr = new Array();

  if ( browserVersion == 1 ) {
    var elem = document.getElementsByTagName(tag);
    for(i = 0,iarr = 0; i < elem.length; i++) {
      att = elem[i].getAttribute("name");
      if(att == name) {
        arr[iarr] = elem[i];
        iarr++;
      }
    };
  }
  else {
    arr = document.getElementsByName(name);
  }
  return arr;
};

function CreateArray( size ) {
  // Validate parameter value
  if (size+'' == 'undefined' || size == null) 
    return null;
  
  this.length = size;
  for (var i = 0; i < size; i++) {
    this[i] = null; 
  }
  return this;
} // end CreateArray


function IsAlpha( str ) {
  // Return immediately if an invalid value was passed in
  if (str+'' == 'undefined' || str+'' == 'null' || str+'' == '')  
    return false;

  var isValid = true;

  str += '';  // convert to a string for performing string comparisons.

  // Loop through string one character at time,  breaking out of for
  // loop when an non Alpha character is found.
    for (i = 0; i < str.length; i++) {
    // Alpha must be between 'A'-'Z', or 'a'-'z'
    if ( !( ((str.charAt(i) >= 'a') && (str.charAt(i) <= 'z')) ||
            ((str.charAt(i) >= 'A') && (str.charAt(i) <= 'Z')) ) ) {
                isValid = false;
                break;
            }
   }; // end for loop
   
  return isValid;
};  // end IsAlpha 


function IsAlphaNum( str ) {
  // Return immediately if an invalid value was passed in
  if (str+'' == 'undefined' || str+'' == 'null' || str+'' == '')  
    return false;

  var isValid = true;
  
  // convert to a string for performing string comparisons.
    str += '';  

  // Loop through length of string and test for any alpha numeric 
  // characters
    for (i = 0; i < str.length; i++)
    {
      // Alphanumeric must be between '0'-'9', 'A'-'Z', or 'a'-'z'
        if (!(((str.charAt(i) >= '0') && (str.charAt(i) <= '9')) || 
            ((str.charAt(i) >= 'a') && (str.charAt(i) <= 'z')) ||
            ((str.charAt(i) >= 'A') && (str.charAt(i) <= 'Z'))))
      {
        isValid = false;
        break;
      } 
    }; // END for   
   
    return isValid;
};  // end IsAlphaNum


function IsAlphaNumOrUnderscore( str ) {
  // Return immediately if an invalid value was passed in
  if (str+'' == 'undefined' || str+'' == 'null' || str+'' == '')  
    return false;

  var isValid = true;

  str += '';  // convert to a string for performing string comparisons.
  // Loop through string one character at a time. If non-alpha numeric
  // is found then, break out of loop and return a false result

  for (i = 0; i < str.length; i++)
    {
    // Alphanumeric must be between '0'-'9', 'A'-'Z', or 'a'-'z'
          if ( !( ((str.charAt(i) >= '0') && (str.charAt(i) <= '9')) || 
            ((str.charAt(i) >= 'a') && (str.charAt(i) <= 'z')) ||
            ((str.charAt(i) >= 'A') && (str.charAt(i) <= 'Z')) ||
            (str.charAt(i) == '_') ) )
          {
          isValid = false;
            break;
          }

  }; // END for   
   
  return isValid;

};  // end IsAlphaNumOrUnderscore

function IsBlank( str ) {
  var isValid = false;

  if ( IsNull(str) || IsUndef(str) || (str+'' == '') )
    isValid = true;
    
  return isValid;
};  // end IsBlank


function IsInt( numstr, allowNegatives ) {
  // Return immediately if an invalid value was passed in
  if (numstr+'' == 'undefined' || numstr+'' == 'null' || numstr+'' == '') 
    return false;

  // Default allowNegatives to true when undefined or null
  if (allowNegatives+'' == 'undefined' || allowNegatives+'' == 'null')  
    allowNegatives = true;

  var isValid = true;

  // convert to a string for performing string comparisons.
  numstr += ''; 

  // Loop through string and test each character. If any
  // character is not a number, return a false result.
  // Include special case for negative numbers (first char == '-').   
  for (i = 0; i < numstr.length; i++) {
      if (!((numstr.charAt(i) >= '0') && (numstr.charAt(i) <= '9') || (numstr.charAt(i) == '-'))) {
        isValid = false;
        break;
    } else if ((numstr.charAt(i) == '-' && i != 0) || 
        (numstr.charAt(i) == '-' && !allowNegatives)) {
        isValid = false;
        break;
      }
                           
   }; // END for   
   
    return isValid;
};  // end IsInt

function IsNull( val ) {
  var isValid = false;

  if (val+'' == 'null')
    isValid = true;
    
  return isValid;
};  // end IsNull

function IsNum( numstr ) {
  // Return immediately if an invalid value was passed in
  if (numstr+'' == 'undefined' || numstr+'' == 'null' || numstr+'' == '') 
    return false;

  var isValid = true;
  var decCount = 0;   // number of decimal points in the string

  // convert to a string for performing string comparisons.
  numstr += ''; 

  // Loop through string and test each character. If any
  // character is not a number, return a false result.
  // Include special cases for negative numbers (first char == '-')
  // and a single decimal point (any one char in string == '.').   
  for (i = 0; i < numstr.length; i++) {
    // track number of decimal points
    if (numstr.charAt(i) == '.')
      decCount++;

      if (!((numstr.charAt(i) >= '0') && (numstr.charAt(i) <= '9') || 
        (numstr.charAt(i) == '-') || (numstr.charAt(i) == '.'))) {
        isValid = false;
        break;
    } else if ((numstr.charAt(i) == '-' && i != 0) ||
        (numstr.charAt(i) == '.' && numstr.length == 1) ||
        (numstr.charAt(i) == '.' && decCount > 1)) {
        isValid = false;
        break;
      }                            
//if (!((numstr.charAt(i) >= '0') && (numstr.charAt(i) <= '9')) || 
   }; // END for   
   
    return isValid;
};  // end IsNum

function IsUndef( val ) {
  var isValid = false;

  if (val+'' == 'undefined')
    isValid = true;
    
  return isValid;
};  // end IsUndef

function IsValidEmail( str ) {
  // Return immediately if an invalid value was passed in
  if (str+'' == 'undefined' || str+'' == 'null' || str+'' == '')  
    return false;

  var isValid = true;

  str += '';

  namestr = str.substring(0, str.indexOf('@'));  // everything before the '@'
  domainstr = str.substring(str.indexOf('@')+1, str.length); // everything after the '@'

  // Rules: namestr cannot be empty, or that would indicate no characters before the '@',
  // domainstr must contain a period that is not the first character (i.e. right after
  // the '@').  The last character must be an alpha.
    if (IsBlank(str) || (namestr.length == 0) || 
      (domainstr.indexOf('.') <= 0) ||
      (domainstr.indexOf('@') != -1) ||
      !IsAlpha(str.charAt(str.length-1)))
    isValid = false;
   
    return isValid;
}; // end IsValidEmail

function IsValidPhone( str, incAreaCode ) {
  // Return immediately if an invalid value was passed in
  if (str+'' == 'undefined' || str+'' == 'null' || str+'' == '')  
    return false;

  // Set default value for incAreaCode to false, if undefined or null
  if (incAreaCode+'' == 'undefined' || incAreaCode+'' == 'null')  
    incAreaCode = false;

  var isValid = true;

  str += '';

  // After stripping out non-numeric characters, such as dashes, the
  // phone number should contain 7 digits (no area code) or 10 digits (area code)
  str = StripNonNumeric(str+'');
  if (incAreaCode && str.length != 10)
    isValid = false;
   if (!incAreaCode && str.length != 7)
    isValid = false;

    return isValid;
}; // end IsValidPhone

//function IsDate (dteDate)
//{ if ( isNaN(Date.parse(dteDate)) )
//  {
//    return false;
//  }
//  return true;
//}

function DaysInFebruary(year) {
  // February has 29 days in any year evenly divisible by four,
  // EXCEPT for centurial years which are not also divisible by 400.
  return (((year % 4 == 0) && ((!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28);
}
function DaysArray(n) {
  for (var i = 1; i <= n; i++) {
    this[i] = 31;
    if (i == 4 || i == 6 || i == 9 || i == 11) { this[i] = 30; }
    if (i == 2) { this[i] = 29; }
  }
  return this;
};

function IsDate(dtStr) {

  var dtCh = "";
  var minYear = 1900;
  var maxYear = 2100;
  var daysInMonth = DaysArray(12);
  var pos1;
  var pos2;
  var strMonth;
  var strDay;
  var strYear;
  var rtn = true;

  try {
    if (dtStr.indexOf('/') != -1)
      dtCh = '/';
    else {
      if (dtStr.indexOf('-') != -1)
        dtCh = '-';
    }

    if (dtCh != "") {
      pos1 = dtStr.indexOf(dtCh);
      pos2 = dtStr.indexOf(dtCh, pos1 + 1);
      strMonth = dtStr.substring(0, pos1);
      strDay = dtStr.substring(pos1 + 1, pos2);
      strYear = dtStr.substring(pos2 + 1);
      strYr = strYear;
    }
    else {
      if (dtStr.length == 8) {
        strMonth = dtStr.substring(4, 6);
        strDay = dtStr.substring(6, 8);
        strYear = dtStr.substring(0, 4);
        strYr = strYear;
      }
    }

    if (strDay.charAt(0) == "0" && strDay.length > 1) strDay = strDay.substring(1);
    if (strMonth.charAt(0) == "0" && strMonth.length > 1) strMonth = strMonth.substring(1);
    for (var i = 1; i <= 3; i++) {
      if (strYr.charAt(0) == "0" && strYr.length > 1) strYr = strYr.substring(1);
    };
    month = parseInt(strMonth);
    day = parseInt(strDay);
    year = parseInt(strYr);

    if (pos1 == -1 || pos2 == -1) {
      rtn = false;
    }
    if (strMonth.length < 1 || month < 1 || month > 12) {
      rtn = false;
    }
    if (strDay.length < 1 || day < 1 || day > 31 || (month == 2 && day > DaysInFebruary(year)) || day > daysInMonth[month]) {
      rtn = false;
    }
    if (strYear.length != 4 || year == 0 || year < minYear || year > maxYear) {
      rtn = false;
    }
    if (dtCh!="" && dtStr.indexOf(dtCh, pos2 + 1) != -1 || isInteger(stripCharsInBag(dtStr, dtCh)) == false) {
      rtn = false;
    }
  }
  catch (e) {
    rtn = false;
  }

  return rtn;
};

function FilterNullNum( value ) {

  var result = value;
  if (value+'' == 'undefined' || value+'' == 'null')
    result = 0;
    
  return result;
}; // end function FilterNullNum

function FilterNullStr( value ) {

  var resultStr = value;
  if (value+'' == 'undefined' || value+'' == 'null')
    resultStr = '';
  else
    resultStr += '';  // convert to a string before returning
        
  return resultStr;
}; // end FilterNullStr


function DayList( listname, size, month, isLeapYear, selectValue, handlerText ) {
  var numDays = 31;
  var resultStr = '';

  // Default to the string 'DaysOfMonth'
  if (listname+'' == 'undefined' || (listname == null))
    listname = 'DaysOfMonth';
  // Default to a drop-down list
  if (size+'' == 'undefined' || (size == null))
    size = 1;
  // Return null to report an error if no valid month entered
  if (month+'' == 'undefined' || (month == null))
    return null;
  // Default to a non-leap year
  if (isLeapYear+'' == 'undefined' || (isLeapYear == null))
    isLeapYear = false;

  // Call out to external Script Library function, DaysInMonth
  numDays = DaysInMonth(month, isLeapYear);
      
  // Construct the SELECT tag
  resultStr += '<SELECT NAME=\'' + listname + '\' SIZE=' + size;
  if (handlerText+'' != 'undefined' && (handlerText != null))
    resultStr += ' ' + handlerText;
  resultStr += '>\n';
  
  // Write out the options array
  for (var i=1; (i <= 31 && i <= numDays); i++) {
    resultStr += '<OPTION VALUE=' + i + ' ' + 
        ((i == selectValue) ? 'SELECTED' : '') + 
        '>' + 
        i + '\n';
  }
    
  //Close the SELECT block
  resultStr += '</SELECT>\n';

  return resultStr;
}; // end DayList

function DaysInMonth( monthNum, isLeapYear ) {
  var days = 31;
  
  // Return null to report an error if parameter not specified
  if (monthNum+'' == 'undefined' || (monthNum == null))
    return null;
  // Default to a non-leap year if not specified
  if (isLeapYear+'' == 'undefined' || (isLeapYear == null))
    isLeapYear = false; 

  if (monthNum == 1)
    days = 31;
  else if (monthNum == 2)
    if (isLeapYear)
      days = 29;
    else
      days = 28;
  else if (monthNum == 3)
    days = 31;
  else if (monthNum == 4)
    days = 30;
  else if (monthNum == 5)
    days = 31;
  else if (monthNum == 6)
    days = 30;
  else if (monthNum == 7)
    days = 31;
  else if (monthNum == 8)
    days = 31;
  else if (monthNum == 9)
    days = 30;
  else if (monthNum == 10)
    days = 31;
  else if (monthNum == 11)
    days = 30;
  else if (monthNum == 12)
    days = 31;
    
  return days;
}; // end DaysInMonth

function MonthList( listname, size, selectValue, handlerText ) {
  var resultStr = '';
  var mth = '';
  var monthArr = new Array(12);
  var optsOnly=false;
  if (MonthList.arguments.length>4)
    optsOnly=MonthList.arguments[4];
  else
    optsOnly=false;
  
  // Initialize month array
  monthArr[0] = 'Jan';
  monthArr[1] = 'Feb';
  monthArr[2] = 'Mar';
  monthArr[3] = 'Apr';
  monthArr[4] = 'May';
  monthArr[5] = 'Jun';
  monthArr[6] = 'Jul';
  monthArr[7] = 'Aug';
  monthArr[8] = 'Sep';
  monthArr[9] = 'Oct';
  monthArr[10] = 'Nov';
  monthArr[11] = 'Dec';
  
  // Default to name of 'Months'
  if (listname+'' == 'undefined' || (listname == null))
    listname = 'Months';
  // Default to a drop-down list
  if (size+'' == 'undefined' || (size == null))
    size = 1; 

  // Construct the SELECT tag
  if (!optsOnly) {
    resultStr += '<SELECT id=\'' + listname + '\' name=\'' + listname + '\' SIZE=' + size;
    if (handlerText+'' != 'undefined' && (handlerText != null))
      resultStr += ' ' + handlerText;
    resultStr += '>\n';
  }  
  // Write out the options array
  for (var i=1; (i <= 12); i++) {
    mth = i;mth=Trim(mth);

    if ( mth.length < 2 )
      mth = PadLeft(mth,'0', 1);

    resultStr += '<OPTION VALUE=' + mth + ' ' + 
        ((mth == selectValue) ? 'SELECTED' : '') + 
        '>' + 
        monthArr[i-1] + '\n';
  }
    
  //Close the SELECT block
  if (!optsOnly)
    resultStr += '</SELECT>\n';

  return resultStr;
}; // end MonthList

function YearList( listname, size, startYear, numYears, selectValue, handlerText ) {
  var resultStr = '';
  var thisYear = (new Date()).getYear();
  var optsOnly=false;
  if (YearList.arguments.length>6)
    optsOnly=YearList.arguments[6];
  else
    optsOnly=false;
  
  // JavaScript reports years less than 2000 as a 2-digit year, e.g. year - 1900.
  // Years >= 2000 are reported as a full 4-digit year, so check the current
  // year and adjust accordingly.
  if (thisYear < 400)
    thisYear += 1900; 

  // Default to the string 'Years'
  if (listname+'' == 'undefined' || listname == null)
    listname = 'Years';
  // Default to a drop-down list
  if (size+'' == 'undefined' || size == null)
    size = 1;
  // Default to start at the current year
  if (startYear+'' == 'undefined' || startYear == null)
    startYear = thisYear;   
  // Default to displaying one year
  if (numYears+'' == 'undefined' || numYears == null || numYears < 1)
    numYears = 1;

  // Construct the SELECT tag
  if (!optsOnly) {
    resultStr += '<SELECT id=\'' + listname + '\' name=\'' + listname + '\' SIZE=' + size;
    if (handlerText+'' != 'undefined' && (handlerText != null))
      resultStr += ' ' + handlerText;
    resultStr += '>\n';
  }
  
  // Write out the options array
  for (var i=0; i < numYears; i++) {
    resultStr += '<OPTION VALUE=' + (startYear+i) + ' ' + 
        ((startYear+i == selectValue) ? 'SELECTED' : '') + 
        '>' + 
        (startYear+i) + '\n';
  }
    
  //Close the SELECT block
  if (!optsOnly)
    resultStr += '</SELECT>\n';

  return resultStr;
}; // end YearList

function CCList( listname, size, selectValue, handlerText ) {
  var resultStr = '';
  var ccArr = new Array(4);
  var ccArr1 = new Array(4);
  var optsOnly=false;
  if (CCList.arguments.length>4)
    optsOnly=CCList.arguments[4];
  else
    optsOnly=false;


  // Initialize CC array
  ccArr[0] = 'Select One';
  ccArr[1] = 'Visa';
  ccArr[2] = 'MasterCard';
  ccArr[3] = 'American Express';
  ccArr[4] = 'Discover';

  ccArr1[0] = '';
  ccArr1[1] = 'VISA';
  ccArr1[2] = 'MASTERCARD';
  ccArr1[3] = 'AMERICANEXPRESS';
  ccArr1[4] = 'DISCOVER';

  // Default to the string 'Years'
  if (listname+'' == 'undefined' || listname == null)
    listname = 'CCType';
  // Default to a drop-down list
  if (size+'' == 'undefined' || size == null)
    size = 1;

  // Construct the SELECT tag
  if (!optsOnly){
    resultStr += '<SELECT id=\'' + listname + '\' name=\'' + listname + '\' SIZE=' + size;
    if (handlerText+'' != 'undefined' && (handlerText != null))
      resultStr += ' ' + handlerText;
    resultStr += '>';
  }
  
  // Write out the options array
  for (var i=0; (i <= 4); i++) {
    resultStr += '<OPTION VALUE="' + ccArr1[i] + '" ' + 
        ((selectValue == ccArr1[i]) ? 'SELECTED' : '')+ 
        ((selectValue == i) ? 'SELECTED' : '')+ '>' + 
        ccArr[i] + '';
  };
    
  //Close the SELECT block
  if (!optsOnly){
    resultStr += '</SELECT>';
  }
  return resultStr;
}; // end CCList


function IsPropInObj ( str, obj, partialMatch ) {
  var result = false;

  // Return immediately if an invalid value was passed in
  if (str+'' == 'undefined' || str == null) 
    return null;
  if (obj+'' == 'undefined' || obj == null) 
    return null;
    
  // Default partialMatch to false if undefined or null
  if (partialMatch+'' == 'undefined'  || partialMatch == null)  
    partialMatch = false;

  // Make sure the string argument is a string
  str += '';
  
  if (partialMatch) 
    for (var firProp in obj) {
      if (firProp.indexOf(str) != -1) {
        result = true;
      }
    }
        
  else 
    for (var firProp in obj) {
      if (firProp == str) {
        result = true;
      }
    }
  return result;
  
}; // end IsPropInObj

function ViewObject (obj, objName) {
  var outputStr = '';

  // Return immediately if an invalid value was passed in
  if (obj+'' == 'undefined' || obj == null) 
    return null;
  // Set default object name if none is provided
  if (objName+'' == 'undefined' || objName == null) 
    objName = '[Object]';
  
    outputStr = '<BR><HR><BR>\n';
    outputStr += '\n<BR><B>'+objName+' Properties: </B><BR>';
    for (prop in obj) {
    outputStr += '\n<BR>'+objName+'.'+prop+' = '+obj[prop];
    }
    outputStr += '<BR><HR><BR>\n';
    
    return outputStr;
}; // end ViewObject

function GetRadioValue( radioControl ) { 

  var value = null;

  var radioObject;
  if (typeof radioControl != 'object')
    radioObject = document.getElementById(radioControl);
  else
    radioObject = radioControl;

  // Validate parameter value
//*** if (radioObject+'' == 'undefined' || radioObject == null)
  if (radioObject == null)
    return value;

  for (var i=0; i < radioObject.length; i++) { 
    if (radioObject[i].checked) { 
      value = radioObject[i].value;
      break;
    } 
  }; // end for loop 
  
  return value;
}; // end GetRadioValue

function SetRadioValue( radioControl, option ) { 

  var radioObject;
  if (typeof radioControl != 'object')
    radioObject = document.getElementById(radioControl);
  else
    radioObject = radioControl;

  // Validate parameter value
  if (radioObject == null || option == null) {
    return false;
  }

  try {
    option = parseInt(option);
    for (var i=0; i < radioObject.length; i++) { 
      if (i==option) { 
        radioObject[i].checked=true;
        break;
      } 
    }; // end for loop 
  
  }
  catch (e) {alert(e.message) }
  
  return true;
}; // end GetRadioValue

function GetSelectValue( selectObject ) {
  var selectedObject;
  if (typeof selectObject != 'object')
    selectedObject = document.getElementById(selectObject);
  else
    selectedObject = selectObject;

  // Validate parameter value
  
  if (selectedObject == null)
    return null;

  if (selectedObject.selectedIndex+'' == 'undefined' || 
        selectedObject.selectedIndex == null ||
        selectedObject.selectedIndex < 0)
    return null;

  return selectedObject.options[selectedObject.selectedIndex].value.toString();
}; // end GetSelectValue 

function ClearSelect(selectObject) {

  var selectedObject;
  if (typeof selectObject != 'object')
    selectedObject = document.getElementById(selectObject);
  else
    selectedObject = selectObject;

  // Validate parameter value
  if (selectedObject == null)
    return null;
  
  if (selectedObject.selectedIndex+'' == 'undefined' || 
        selectedObject.selectedIndex == null ||
        selectedObject.selectedIndex < 0)
    return null;

  for (var i=0; i<selectedObject.options.length; i++){
   selectedObject.options[i] = null;
  }

};

function LoadSelect(selectObject, options) {
  var selectedObject;
  if (typeof selectObject != 'object')
    selectedObject = document.getElementById(selectObject);
  else
    selectedObject = selectObject;

  // Validate parameter value
  if (selectedObject == null)
    return null;
  
  if (selectedObject.selectedIndex+'' == 'undefined' || 
        selectedObject.selectedIndex == null ) //|| selectedObject.selectedIndex < 0)
    return null;

  if (options.length == 0 )
    return null;
  
  var opts = options.split("|",50);
  var vals;
  
  for (var i=0; i<opts.length; i++){
   vals = opts[i].split("~",10);
   selectedObject.options[i] = new Option(vals[0]);
   selectedObject.options[i].value = vals[1];
  };
  
  selectedObject.options[0].selected = true;
};

function ClearSelectValue(selectObject) {

  var selectedObject;
  if (typeof selectObject != 'object')
    selectedObject = document.getElementById(selectObject);
  else
    selectedObject = selectObject;

  // Validate parameter value
  if (selectedObject == null)
    return null;
  
  if (selectedObject.selectedIndex+'' == 'undefined' || 
        selectedObject.selectedIndex == null ||
        selectedObject.selectedIndex < 0)
    return null;

  for (var i=0; i<selectedObject.options.length; i++){
   selectedObject.options[i].selected = false;
  };
}; // end ClearSelectValue


function SetSelectValue(selectObject, selectValue ) {

  var selectedObject;
  if (typeof selectObject != 'object')
    selectedObject = document.getElementById(selectObject);
  else
    selectedObject = selectObject;

  // Validate parameter value
  if (selectedObject == null)
    return null;
    
  if (selectedObject.selectedIndex+'' == 'undefined' || 
        selectedObject.selectedIndex == null ||
        selectedObject.selectedIndex < 0)
    return null;
  ClearSelectValue(selectedObject);

  for (var i=0; i<selectedObject.options.length; i++){
    if ( selectedObject.options[i].value.toString() == selectValue.toString() ){
      selectedObject.options[i].selected = true;
      break;
    }
  };
}; // end SetSelectValue


function OpenNavWin( sourceFile, width, height ) {

  // get center of browser window
  var X = getbrowserwidth() / 2;
  var Y = getbrowserheight() / 2;

  obj_winNavWin = window.open(sourceFile,'NavWin','toolbar=no,width=' + width + 
        ',height=' + height + ',directories=no,status=no,scrollbars=yes' + 
        ',resizable=yes,menubar=no' +
        ',top=' + (window.screenTop + (Y - (height/2))) + ' ' +
        ',left=' + (window.screenLeft + (X - (width/2))) );

  obj_winNavWin.focus();
}; // end OpenNavWin

function closeNavWin()
{
  if ( window.obj_winNavWin )
  {
    window.obj_winNavWin.close();
  }
};

function HistoryNav(domain, name, size, maxItems) {
  // 'Public' Properties - can be modified by outside world
  this.domain = (domain+'' != 'undefined' && domain != null) ? domain.toUpperCase() : '';
  this.firstLabel = 'There are currently no items in the history navigator.';
  this.name = (name+'' != 'undefined' && name != null) ? name : 'HistoryNav';
  this.size = (size+'' != 'undefined' && size != null) ? size : 1;

  // 'Private' Properties - should not be modified except by object methods
  this.labels = new Array();
  this.lastLink = '';
  this.links = new Array();
  this.maxItems = (maxItems+'' != 'undefined' && maxItems != null) ? maxItems : 25;
  this.numItems = 0;

  // 'Public' Methods - can be called by outside world
  this.addLink = hnAddLink;
  this.getOpenerURL = hnGetOpenerURL;
  this.isDuplicateURL = hnIsDuplicateURL;
  this.render = hnRender;
  this.update = hnUpdate;

  // 'Private' Methods - should not be called except by other methods
  this.refreshLinks = hnRefreshLinks;
  this.validateLocation = hnValidateLocation;

  // Initialize this.lastLink
  this.lastLink = this.getOpenerURL();  
}; // end HistoryNav constructor


function hnValidateLocation() {
  var locn = this.getOpenerURL().toUpperCase();
  // Make sure the location is not empty and the domain is valid
   if (locn != '') {
    // Do not attempt to add link unless domains are the same
    if(locn.indexOf(this.domain) != -1) 
      this.addLink(); 
  }
  else { // close history tracker if opener URL cannot be found (i.e. opener is closed)
      window.close(); 
  } 
}; // end hnValidateLocation


function hnAddLink() {
  var url = '';
  var label = '';
  
  url = this.getOpenerURL();

  if (url != this.lastLink && url != '') {
    // Set lastLink to the url just detected
    this.lastLink = url;
    
    // Only add link if it doesn't already exist in the history list
    label = window.opener.document.title;
    if (!this.isDuplicateURL(url)) {
      this.numItems++;
      
      // If the number of items exceeds max allowed, strip off the old URL
      if (this.numItems > this.maxItems)
        this.refreshLinks();
        
      this.links[this.numItems-1] = url;
      // Add the label.  If no label was given, make the label the same as the link
      this.labels[this.numItems-1] = (label != null || label+'' != 'undefined') ? label : url;
      // Update the options list
        this.update();
    } // end inner if
   } // end outer if
}; // end hnAddLink

function hnRender() {
  document.writeln('<FORM NAME="' + this.name + '" >');
   document.writeln('<SELECT NAME="' + this.name + '" onChange="window.opener.location.href = this.options[this.selectedIndex].value">');
  // Initialize options array up to maxItems.
  // This sets the width
  for (var i=0; i < this.maxItems; i++) {
    document.writeln('<OPTION>' + this.firstLabel);
  }
  document.writeln('</SELECT>');
  document.writeln('</FORM>');    
  
  // Blank out all items but the first
  for (var j=this.maxItems-1; j > 0; j--) {
    document.forms[this.name].elements[this.name].options[j] = null;
  }
      
  this.update();
}; // end hnRender


function hnUpdate() {
  if (this.numItems > 0) {
    with (document.forms[this.name].elements[this.name]) {
      // Blank out all options
      for(var i=this.numItems-1; i >= 0; i--) 
          options[i] = null;
         // Fill array with most recently trapped at top of list
      for (j=0; j < this.numItems; j++)  
            options[j] = new Option((j + 1) + ') ' + this.labels[j], this.links[j]);
    } // end with 

    // Select the most recent entry
    document.forms[this.name].elements[this.name].options[this.numItems-1].selected = true;
  } // end if
  else
    document.forms[this.name].elements[this.name].options[0].selected = true;
}; // end hnUpdate


function hnIsDuplicateURL( url ) {
  var isDuplicate = false;
  
  for(i=0; i < this.numItems; i++)
    if (this.links[i].indexOf(url) != -1)
      isDuplicate = true;
  
  return isDuplicate;
}; // end hnIsDuplicateURL


function hnGetOpenerURL() {
  var result = '';
  if (window.opener.location+'' != 'undefined' && window.opener.location != null) 
    result = window.opener.location.href+'';

  return result;
}; // end hnGetOpenerURL


function hnRefreshLinks() {

  for (var i=0; i < this.numItems; i++) {
    this.links[i] = this.links[i+1];
    this.labels[i] = this.labels[i+1];
  }
  this.numItems--;

}; // end hnRefreshLinks

function HistoryListener( objName, histNavObj ) {
  // Start the recursive timer
  listenerTimer = setTimeout('HistoryListener("' + objName + '", ' + objName + ')', 1000);
  // Check locations of pages that the listener 'hears'
  histNavObj.validateLocation();
}; // end HistoryListener

function SelectNav (name, size) {

  // 'Public' Properties - can be modified by outside world
  this.name = (name) ? name : 'SelectNav';
  this.size = (size) ? size : 1;
  //this.firstLabel = (firstLabel) ? firstLabel : 'Select a link';
  
  // 'Private' Properties - should not be modified except by object methods
  this.links = new Array();
  this.labels = new Array();
  this.numItems = 0;
  
  // 'Public' Methods - can be called by outside world
  this.addLink = snAddLink;
  this.deleteLink = snDeleteLink;
  this.gotoURL = snGotoURL;
  this.render = snRender;
  
}; // end SelectNav constructor

    
function snAddLink(url, label) {
  this.numItems++;
  this.links[this.numItems-1] = url;
  // Add the label.  If no label was given, make the label the same as the link
  this.labels[this.numItems-1] = (label != null || label+'' != 'undefined') ? label : url;
}; // end snAddLink

function snDeleteLink(linkidx) {
  var tempLinks = new Array();
  var tempLabels = new Array();
  var count = 0;
  
  if (linkidx+'' == 'undefined' || linkidx == null) {
    this.numItems = 0;  
    linkidx = 0;
  }
  
  // Copy all but the deleted link & label into new arrays
  for(var i=0; i < this.numItems; i++)
    if (i != linkidx) {
      document.write(i + ', ' + linkidx);
      tempLinks[count] = this.links[i];
      tempLabels[count] = this.labels[i];
      count++;
    }
  
  this.numItems = count;
  this.links = tempLinks;
  this.labels = tempLabels;
}; // end snDeleteLink
  
  
function snGotoURL(linkidx) {
  // redirect to the selected location
  window.location.href = this.links[linkidx];
}; // end snGotoURL

function snRender( useOpener ) {

  // default to using same window instead of opening window
  if (useOpener+'' == 'undefined' || useOpener == null) 
     useOpener = false;
  
  document.write('<FORM NAME="' + this.name + '">');
  if (useOpener)
    document.write('<SELECT NAME="' + this.name + '" SIZE=' + this.size + ' onChange="window.opener.location.href = this.options[this.selectedIndex].value">');
  else
    document.write('<SELECT NAME="' + this.name + '" SIZE=' + this.size + ' onChange="window.location.href = this.options[this.selectedIndex].value">');

  // Write out all of the options in the list
  for (var i=0; i < this.numItems; i++)
    document.write('<OPTION VALUE="' + this.links[i] + '">' + this.labels[i]);
    document.write('</SELECT>');

     document.write('</FORM>');
}; // end snRender

function ShowSelectedItems( selectObject ) {
  var list = '';

  // Validate parameter value
  if (selectObject == null)
    return null;

  for (var i=0; i < selectObject.length; i++) { 
    if (selectObject.options[i].selected) { 
      list += '<B>Item #' + i + ':</B> ' + selectObject.options[i].text + 
            '; <B>Value #' + i + ':</B> ' + selectObject.options[i].value + '<br>';
    } 
  };

  // If the string is still empty, no selected items were found
  if (list == '')
    list = 'No items selected.<br>';
      
  return list;
}; // end ShowSelectedItems

function StateList( name, size, multiple, selectValue, handlerText ) {
  var outputStr = '';
  var optsOnly=false;
  if (StateList.arguments.length>5)
    optsOnly=StateList.arguments[5];
  else
    optsOnly=false;

  // Return immediately if an invalid value for a required argument was passed
  if (name+'' == 'undefined' || name == null || name == '') 
    return null;
  if (size+'' == 'undefined' || size+'' == 'null' || size < 1)  
    return null;

  // Handle invalid values for optional arguments
  if (multiple+'' == 'undefined' || multiple == null) 
    multiple = false;
  if (selectValue+'' == 'undefined' || selectValue == null) 
    selectValue = '';
  if (handlerText|| handlerText == null)  
    handlerText = '';
  
  if (!optsOnly){
    
    // Construct the SELECT tag
    outputStr = '<SELECT id="' + name + '" name="' + name + '" size=' + size;

    // If the drop downdown list allows multiple states, insert that HTML value here
    if (multiple) 
      outputStr += ' MULTIPLE ';

    // Write out handlerText if present   
    outputStr += ' ' + handlerText;

    // Close the <SELECT> tag
    outputStr += '>';
  }  
  
  //Write out the options array

  outputStr += '<OPTION VALUE=NONE ' + ((selectValue == '') ? 'SELECTED' : '')   + '></OPTION>';
  outputStr += '<OPTION VALUE=AL ' + ((selectValue == 'AL') ? 'SELECTED' : '')   + '>Alabama</OPTION>';
  outputStr += '<OPTION VALUE=AK ' + ((selectValue == 'AK') ? 'SELECTED' : '')   + '>Alaska</OPTION>';
  outputStr += '<OPTION VALUE=AZ ' + ((selectValue == 'AZ') ? 'SELECTED' : '')   + '>Arizona</OPTION>';
  outputStr += '<OPTION VALUE=AR ' + ((selectValue == 'AR') ? 'SELECTED' : '')   + '>Arkansas</OPTION>';
  outputStr += '<OPTION VALUE=CA ' + ((selectValue == 'CA') ? 'SELECTED' : '')   + '>California</OPTION>';
  outputStr += '<OPTION VALUE=CO ' + ((selectValue == 'CO') ? 'SELECTED' : '')   + '>Colorado</OPTION>';
  outputStr += '<OPTION VALUE=CT ' + ((selectValue == 'CT') ? 'SELECTED' : '')   + '>Connecticut</OPTION>';
  outputStr += '<OPTION VALUE=DE ' + ((selectValue == 'DE') ? 'SELECTED' : '')   + '>Delaware</OPTION>';
  outputStr += '<OPTION VALUE=FL ' + ((selectValue == 'FL') ? 'SELECTED' : '')   + '>Florida</OPTION>';
  outputStr += '<OPTION VALUE=GA ' + ((selectValue == 'GA') ? 'SELECTED' : '')   + '>Georgia</OPTION>';

  outputStr += '<OPTION VALUE=HI ' + ((selectValue == 'HI') ? 'SELECTED' : '')   + '>Hawaii</OPTION>';
  outputStr += '<OPTION VALUE=ID ' + ((selectValue == 'ID') ? 'SELECTED' : '')   + '>Idaho</OPTION>';
  outputStr += '<OPTION VALUE=IL ' + ((selectValue == 'IL') ? 'SELECTED' : '')   + '>Illinois</OPTION>';
  outputStr += '<OPTION VALUE=IN ' + ((selectValue == 'IN') ? 'SELECTED' : '')   + '>Indiana</OPTION>';
  outputStr += '<OPTION VALUE=IA ' + ((selectValue == 'IA') ? 'SELECTED' : '')   + '>Iowa</OPTION>';
  outputStr += '<OPTION VALUE=KS ' + ((selectValue == 'KS') ? 'SELECTED' : '')   + '>Kansas</OPTION>';
  outputStr += '<OPTION VALUE=KY ' + ((selectValue == 'KY') ? 'SELECTED' : '')   + '>Kentucky</OPTION>';
  outputStr += '<OPTION VALUE=LA ' + ((selectValue == 'LA') ? 'SELECTED' : '')   + '>Louisiana</OPTION>';
  outputStr += '<OPTION VALUE=ME ' + ((selectValue == 'ME') ? 'SELECTED' : '')   + '>Maine</OPTION>';
  outputStr += '<OPTION VALUE=MD ' + ((selectValue == 'MD') ? 'SELECTED' : '')   + '>Maryland</OPTION>';

  outputStr += '<OPTION VALUE=MA ' + ((selectValue == 'MA') ? 'SELECTED' : '')   + '>Massachusetts</OPTION>';
  outputStr += '<OPTION VALUE=MI ' + ((selectValue == 'MI') ? 'SELECTED' : '')   + '>Michigan</OPTION>';
  outputStr += '<OPTION VALUE=MN ' + ((selectValue == 'MN') ? 'SELECTED' : '')   + '>Minnesota</OPTION>';
  outputStr += '<OPTION VALUE=MS ' + ((selectValue == 'MS') ? 'SELECTED' : '')   + '>Mississippi</OPTION>';
  outputStr += '<OPTION VALUE=MO ' + ((selectValue == 'MO') ? 'SELECTED' : '')   + '>Missouri</OPTION>';
  outputStr += '<OPTION VALUE=MT ' + ((selectValue == 'MT') ? 'SELECTED' : '')   + '>Montana</OPTION>';
  outputStr += '<OPTION VALUE=NE ' + ((selectValue == 'NE') ? 'SELECTED' : '')   + '>Nebraska</OPTION>';
  outputStr += '<OPTION VALUE=NH ' + ((selectValue == 'NH') ? 'SELECTED' : '')   + '>New Hampshire</OPTION>';
  outputStr += '<OPTION VALUE=NJ ' + ((selectValue == 'NJ') ? 'SELECTED' : '')   + '>New Jersey</OPTION>';
  outputStr += '<OPTION VALUE=NM ' + ((selectValue == 'NM') ? 'SELECTED' : '')   + '>New Mexico</OPTION>';

  outputStr += '<OPTION VALUE=NV ' + ((selectValue == 'NV') ? 'SELECTED' : '')   + '>Nevada</OPTION>';
  outputStr += '<OPTION VALUE=NY ' + ((selectValue == 'NY') ? 'SELECTED' : '')   + '>New York</OPTION>';
  outputStr += '<OPTION VALUE=NC ' + ((selectValue == 'NC') ? 'SELECTED' : '')   + '>North Carolina</OPTION>';
  outputStr += '<OPTION VALUE=ND ' + ((selectValue == 'ND') ? 'SELECTED' : '')   + '>North Dakota</OPTION>';
  outputStr += '<OPTION VALUE=OH ' + ((selectValue == 'OH') ? 'SELECTED' : '')   + '>Ohio</OPTION>';
  outputStr += '<OPTION VALUE=OK ' + ((selectValue == 'OK') ? 'SELECTED' : '')   + '>Oklahoma</OPTION>';
  outputStr += '<OPTION VALUE=OR ' + ((selectValue == 'OR') ? 'SELECTED' : '')   + '>Oregon</OPTION>';
  outputStr += '<OPTION VALUE=PA ' + ((selectValue == 'PA') ? 'SELECTED' : '')   + '>Pennsylvania</OPTION>';
  outputStr += '<OPTION VALUE=RI ' + ((selectValue == 'RI') ? 'SELECTED' : '')   + '>Rhode Island</OPTION>';
  outputStr += '<OPTION VALUE=SC ' + ((selectValue == 'SC') ? 'SELECTED' : '')   + '>South Carolina</OPTION>';

  outputStr += '<OPTION VALUE=SD ' + ((selectValue == 'SC') ? 'SELECTED' : '')   + '>South Dakota</OPTION>';
  outputStr += '<OPTION VALUE=TN ' + ((selectValue == 'TN') ? 'SELECTED' : '')   + '>Tennessee</OPTION>';
  outputStr += '<OPTION VALUE=TX ' + ((selectValue == 'TX') ? 'SELECTED' : '')   + '>Texas</OPTION>';
  outputStr += '<OPTION VALUE=UT ' + ((selectValue == 'UT') ? 'SELECTED' : '')   + '>Utah</OPTION>';
  outputStr += '<OPTION VALUE=VT ' + ((selectValue == 'VT') ? 'SELECTED' : '')   + '>Vermont</OPTION>';
  outputStr += '<OPTION VALUE=VA ' + ((selectValue == 'VA') ? 'SELECTED' : '')   + '>Virginia</OPTION>';
  outputStr += '<OPTION VALUE=WA ' + ((selectValue == 'WA') ? 'SELECTED' : '')   + '>Washington</OPTION>';
  outputStr += '<OPTION VALUE=WV ' + ((selectValue == 'WV') ? 'SELECTED' : '')   + '>West Virginia</OPTION>';
  outputStr += '<OPTION VALUE=WI ' + ((selectValue == 'WI') ? 'SELECTED' : '')   + '>Wisconsin</OPTION>';
  outputStr += '<OPTION VALUE=WY ' + ((selectValue == 'WY') ? 'SELECTED' : '')   + '>Wyoming</OPTION>';

  outputStr += '<OPTION VALUE=DC ' + ((selectValue == 'DC') ? 'SELECTED' : '')   + '>Washington D.C.</OPTION>';

  if (!optsOnly){    
    //Close the SELECT block
    outputStr += '</SELECT>';
  }  
  return outputStr;
};  // END FUNCTION StateList

function StateListAbbr( name, size, multiple, selectValue, handlerText ) {
  // Return immediately if an invalid value for a required argument was passed
  if (name+'' == 'undefined' || name == null || name == '') 
    return null;
  if (size+'' == 'undefined' || size+'' == 'null' || size < 1)  
    return null;

  // Handle invalid values for optional arguments
  if (multiple+'' == 'undefined' || multiple == null) 
    multiple = false;
        
  if (selectValue+'' == 'undefined' || selectValue == null) 
    selectValue = '';
  if (handlerText+'' == 'undefined' || handlerText == null) 
    handlerText = '';
  
  // Construct the SELECT tag
  outputStr = '<SELECT id="' + name + '" name="' + name + '" size=' + size;

  // If the drop downdown list allows multiple states, insert that HTML value here
  if (multiple) 
    outputStr += ' MULTIPLE ';

  // Write out handlerText if present   
  outputStr += ' ' + handlerText;

  // Close the <SELECT> tag
  outputStr += '> ';
  
  //Write out each state as a list item
  outputStr += '<OPTION VALUE=AK ' + ((selectValue == 'AK') ? 'SELECTED' : '')   + '>AK</OPTION>';
  outputStr += '<OPTION VALUE=AL ' + ((selectValue == 'AL') ? 'SELECTED' : '')   + '>AL</OPTION>';
  outputStr += '<OPTION VALUE=AR ' + ((selectValue == 'AR') ? 'SELECTED' : '')   + '>AR</OPTION>';
  outputStr += '<OPTION VALUE=AZ ' + ((selectValue == 'AZ') ? 'SELECTED' : '')   + '>AZ</OPTION>';
  outputStr += '<OPTION VALUE=CA ' + ((selectValue == 'CA') ? 'SELECTED' : '')   + '>CA</OPTION>';
  outputStr += '<OPTION VALUE=CO ' + ((selectValue == 'CO') ? 'SELECTED' : '')   + '>CO</OPTION>';
  outputStr += '<OPTION VALUE=CT ' + ((selectValue == 'CT') ? 'SELECTED' : '')   + '>CT</OPTION>';
  outputStr += '<OPTION VALUE=DE ' + ((selectValue == 'DE') ? 'SELECTED' : '')   + '>DE</OPTION>';
  outputStr += '<OPTION VALUE=FL ' + ((selectValue == 'FL') ? 'SELECTED' : '')   + '>FL</OPTION>';
  outputStr += '<OPTION VALUE=GA ' + ((selectValue == 'GA') ? 'SELECTED' : '')   + '>GA</OPTION>';

  outputStr += '<OPTION VALUE=HI ' + ((selectValue == 'HI') ? 'SELECTED' : '')   + '>HI</OPTION>';
  outputStr += '<OPTION VALUE=IA ' + ((selectValue == 'IA') ? 'SELECTED' : '')   + '>IA</OPTION>';
  outputStr += '<OPTION VALUE=ID ' + ((selectValue == 'ID') ? 'SELECTED' : '')   + '>ID</OPTION>';
  outputStr += '<OPTION VALUE=IL ' + ((selectValue == 'IL') ? 'SELECTED' : '')   + '>IL</OPTION>';
  outputStr += '<OPTION VALUE=IN ' + ((selectValue == 'IN') ? 'SELECTED' : '')   + '>IN</OPTION>';
  outputStr += '<OPTION VALUE=KS ' + ((selectValue == 'KS') ? 'SELECTED' : '')   + '>KS</OPTION>';
  outputStr += '<OPTION VALUE=KY ' + ((selectValue == 'KY') ? 'SELECTED' : '')   + '>KY</OPTION>';
  outputStr += '<OPTION VALUE=LA ' + ((selectValue == 'LA') ? 'SELECTED' : '')   + '>LA</OPTION>';
  outputStr += '<OPTION VALUE=MA ' + ((selectValue == 'MA') ? 'SELECTED' : '')   + '>MA</OPTION>';
  outputStr += '<OPTION VALUE=MD ' + ((selectValue == 'MD') ? 'SELECTED' : '')   + '>MD</OPTION>';

  outputStr += '<OPTION VALUE=ME ' + ((selectValue == 'ME') ? 'SELECTED' : '')   + '>ME</OPTION>';
  outputStr += '<OPTION VALUE=MI ' + ((selectValue == 'MI') ? 'SELECTED' : '')   + '>MI</OPTION>';
  outputStr += '<OPTION VALUE=MN ' + ((selectValue == 'MN') ? 'SELECTED' : '')   + '>MN</OPTION>';
  outputStr += '<OPTION VALUE=MO ' + ((selectValue == 'MO') ? 'SELECTED' : '')   + '>MO</OPTION>';
  outputStr += '<OPTION VALUE=MS ' + ((selectValue == 'MS') ? 'SELECTED' : '')   + '>MS</OPTION>';
  outputStr += '<OPTION VALUE=MT ' + ((selectValue == 'MT') ? 'SELECTED' : '')   + '>MT</OPTION>';
  outputStr += '<OPTION VALUE=NC ' + ((selectValue == 'NC') ? 'SELECTED' : '')   + '>NC</OPTION>';
  outputStr += '<OPTION VALUE=ND ' + ((selectValue == 'ND') ? 'SELECTED' : '')   + '>ND</OPTION>';
  outputStr += '<OPTION VALUE=NE ' + ((selectValue == 'NE') ? 'SELECTED' : '')   + '>NE</OPTION>';
  outputStr += '<OPTION VALUE=NH ' + ((selectValue == 'NH') ? 'SELECTED' : '')   + '>NH</OPTION>';

  outputStr += '<OPTION VALUE=NJ ' + ((selectValue == 'NJ') ? 'SELECTED' : '')   + '>NJ</OPTION>';
  outputStr += '<OPTION VALUE=NM ' + ((selectValue == 'NM') ? 'SELECTED' : '')   + '>NM</OPTION>';
  outputStr += '<OPTION VALUE=NV ' + ((selectValue == 'NV') ? 'SELECTED' : '')   + '>NV</OPTION>';
  outputStr += '<OPTION VALUE=NY ' + ((selectValue == 'NY') ? 'SELECTED' : '')   + '>NY</OPTION>';
  outputStr += '<OPTION VALUE=OH ' + ((selectValue == 'OH') ? 'SELECTED' : '')   + '>OH</OPTION>';
  outputStr += '<OPTION VALUE=OK ' + ((selectValue == 'OK') ? 'SELECTED' : '')   + '>OK</OPTION>';
  outputStr += '<OPTION VALUE=OR ' + ((selectValue == 'OR') ? 'SELECTED' : '')   + '>OR</OPTION>';
  outputStr += '<OPTION VALUE=PA ' + ((selectValue == 'PA') ? 'SELECTED' : '')   + '>PA</OPTION>';
  outputStr += '<OPTION VALUE=RI ' + ((selectValue == 'RI') ? 'SELECTED' : '')   + '>RI</OPTION>';
  outputStr += '<OPTION VALUE=SC ' + ((selectValue == 'SC') ? 'SELECTED' : '')   + '>SC</OPTION>';

  outputStr += '<OPTION VALUE=SD ' + ((selectValue == 'SC') ? 'SELECTED' : '')   + '>SD</OPTION>';
  outputStr += '<OPTION VALUE=TN ' + ((selectValue == 'TN') ? 'SELECTED' : '')   + '>TN</OPTION>';
  outputStr += '<OPTION VALUE=TX ' + ((selectValue == 'TX') ? 'SELECTED' : '')   + '>TX</OPTION>';
  outputStr += '<OPTION VALUE=UT ' + ((selectValue == 'UT') ? 'SELECTED' : '')   + '>UT</OPTION>';
  outputStr += '<OPTION VALUE=VA ' + ((selectValue == 'VA') ? 'SELECTED' : '')   + '>VA</OPTION>';
  outputStr += '<OPTION VALUE=VT ' + ((selectValue == 'VT') ? 'SELECTED' : '')   + '>VT</OPTION>';
  outputStr += '<OPTION VALUE=WA ' + ((selectValue == 'WA') ? 'SELECTED' : '')   + '>WA</OPTION>';
  outputStr += '<OPTION VALUE=WI ' + ((selectValue == 'WI') ? 'SELECTED' : '')   + '>WI</OPTION>';
  outputStr += '<OPTION VALUE=WV ' + ((selectValue == 'WV') ? 'SELECTED' : '')   + '>WV</OPTION>';
  outputStr += '<OPTION VALUE=WY ' + ((selectValue == 'WY') ? 'SELECTED' : '')   + '>WY</OPTION>';

  outputStr += '<OPTION VALUE=DC ' + ((selectValue == 'DC') ? 'SELECTED' : '')   + '>D.C.</OPTION>';

  //Close the SELECT block
  outputStr += '</SELECT>';

  return outputStr;
}; // END FUNCTION StateListAbbr

function StatusScroll(msg, width, rate)
{
  // Use the hidden 4th parameter to 'save' the initial width during the multiple
  // iterations of the function.  If it's not specified, as is the case when called
  // for the first time by the user, initialize  it to the width param.  
  var CWIDTH = (StatusScroll.arguments[3]) ? StatusScroll.arguments[3] : width;

  var ch = ' ';
  var outputStr = '';
  var command = '';

  // Check validity of parameters 
  if (msg+'' == 'undefined' || msg == null) 
    return null;
  if (width+'' == 'undefined' || width == null) 
    return null;
  if (rate+'' == 'undefined' || rate == null) 
    return null;
  

  // If the current width is greater than the initial width,
  // whittle it down.
  if (width > CWIDTH) 
    width--;
  else if (width <= CWIDTH && width > 0) {
    // If the current width is less than the initial width, 
    // but still greater than zero, the message is being
    // displayed between the status-bar boundaries.
    
    // Pad the msg string with spaces
    for (var i=0 ; i < width ; i++) 
      outputStr+=' ';
    outputStr += msg;
    
    // Decrement the width to keep the string moving from right to left
    width--;
  }
  else if (width <= 0) {
    // If the width is less than zero, then the string is
    // being 'swallowed up' but the left border of the 
    // margin.  Execute the code to swallow up one character
    // at a time.
    if (-width < msg.length) {
      outputStr += msg.substring(-width, msg.length);
      width--;
    }
    else {
      outputStr = ' ';
      width = CWIDTH;
    }
  } // end else if (width <= 0) 
        
   window.status = outputStr;

  // Set the timer to call this function with the newly decremented width
  // parameter.  Continue to pass the msg and rate parameters.  Also pass
  // the CWIDTH parameter so the original width is always known.  This is 
  // needed to continually loop through the sequence.
  command = 'StatusScroll("' + msg + '", ' + width + ', ' + rate + ', ' + CWIDTH + ')';
  scrollTimer = window.setTimeout(command, rate);
  
  return outputStr;

}; // end StatusScroll

function GetFileName(path) {
  var arr = path.split("\\");
  return arr[arr.length - 1];
};

function NumToString( number )  {
   number += '';
   return number;
} // end NumToString

function Pad( str, ch, num ) {
  var resultStr = '';
  
  resultStr = PadLeft(str, ch, num);
  resultStr = PadRight(resultStr, ch, num);
  
  return resultStr;
}; // end Pad

function PadLeft( str, ch, num ) {
  // Return immediately if an invalid value was passed in
  if (str+'' == 'undefined' || str == null) 
    return null;
  if (ch+'' == 'undefined' || ch == null) 
    return null;
  if (typeof(num) != typeof(0)) // check to see if num is numeric
    return null;  

  // Make sure the string arguments are strings
  str += '';
  ch += '';

  var resultStr = str;

  // Make sure the argument is a string
  str += '';

  for (var i=0; i < num; i++)
    resultStr = ch + resultStr;

  return resultStr;
}; // end PadLeft

function PadRight( str, ch, num ) {
  // Return immediately if an invalid value was passed in
  if (str+'' == 'undefined' || str == null) 
    return null;
  if (ch+'' == 'undefined' || ch == null) 
    return null;
  if (typeof(num) != typeof(0)) // check to see if num is numeric
    return null;  

  // Make sure the string arguments are strings
  str += '';
  ch += '';

  var resultStr = str;
    
  for (var i=0; i < num; i++)
    resultStr += ch;

  return resultStr;
}; // end PadRight

// Make StringReplace a method of all String objects 
//String.prototype.replace = StringReplace;
function StringReplace( strString, findText, replaceText ) { 
  var originalString = strString;   //new String(this);
  var pos = 0;
  var i = 0;
  var preString = "";
  var postString = "";

  // Validate parameter values
  if (findText+'' == 'undefined' || findText == null || findText == '')
    return originalString;

  if (replaceText+'' == 'undefined' || replaceText == null)
    return originalString;

  var len = findText.length;
  var limit = originalString.length;
  
  pos = originalString.indexOf(findText);

  while (pos != -1 && i < limit) { 
    // Get the first and last parts of the string:  preString + findText + postString
    // then change to preString + replaceText + postString to replace findText
    preString = originalString.substring(0, pos);
    postString = originalString.substring(pos+len, originalString.length);
    originalString = preString + replaceText + postString;
    pos = originalString.indexOf(findText); 
    i++;
  };
  
  return originalString;  
}; // end StringReplace

function StripNonNumeric( str ) {
  var   resultStr = '';

  // Return immediately if an invalid value was passed in
  if (str+'' == 'undefined' || str == null) 
    return null;

  // Make sure the argument is a string
  str += '';

  // Loop through entire string, adding each character from the original
  // string if it is a number
  for (var i=0; i < str.length; i++)
  {
    if ( ((str.charAt(i) >= '0') && (str.charAt(i) <= '9')) || (str.charAt(i) == '.') )
      resultStr = resultStr + str.charAt(i);
 
   }; // end for loop      

   return resultStr;
};  // end StripNonNumeric

function StripNonPrintable( str ) {
  var resultStr = '';
  var ch = '';

  // Return immediately if an invalid value was passed in
  if (str+'' == 'undefined' || str == null) 
    return null;

  // Make sure the argument is a string
  str += '';

  // Loop through string and keep only printable chars  
  for (var i=0; i < str.length; i++)
  {
    ch = str.charAt(i);
    if ((ch >= ' ') && (ch <= '~'))
      resultStr += ch;
  };
  
  return resultStr;
}; // end StripNonPrintable

// Make initCaps a method of all String objects 
String.prototype.initCaps = changeCase;
function changeCase(strVar) {
  var index;
  var tmpStr;
  var tmpChar;
  var preString;
  var postString;
  var strlen;
  var strSave='';
  
  strVar=Trim(strVar);
  if (strVar.indexOf('UPS ')==0){
    strSave='UPS ';
    strVar=strVar.substring(4,strVar.length)
  }
  
  tmpStr = strVar.toLowerCase();
  strLen = tmpStr.length;
  
  if (strLen > 0)  {
    for (index = 0; index < strLen; index++)  {
      if (index == 0)  {
        tmpChar = tmpStr.substring(0,1).toUpperCase();
        postString = tmpStr.substring(1,strLen);
        tmpStr = tmpChar + postString;
      }
      else {
        tmpChar = tmpStr.substring(index, index+1);
        if (tmpChar == " " && index < (strLen-1))  {
          tmpChar = tmpStr.substring(index+1, index+2).toUpperCase();
          preString = tmpStr.substring(0, index+1);
          postString = tmpStr.substring(index+2,strLen);
          tmpStr = preString + tmpChar + postString;
        }
      }
    };
  }
  
  return strSave+tmpStr;
};

// Make Trim a method of all String objects 
String.prototype.trim = Trim;
function Trim( str ) {
  var resultStr = '';
  
  try {
  resultStr = TrimLeft(str);
  resultStr = TrimRight(resultStr);
  }
  catch (e) { resultStr = str; }
  
  return resultStr;
}; // end Trim

// Make Trim a method of all String objects 
String.prototype.trimLeft = TrimLeft;
function TrimLeft( str ) {
  var resultStr = '';
  var i = len = 0;

  // Return immediately if an invalid value was passed in
  if (str+'' == 'undefined' || str == null) 
    return null;

  // Make sure the argument is a string
  str += '';

  if (str.length == 0) 
    resultStr = '';
  else {  
      // Loop through string starting at the beginning as long as there
      // are spaces.
//      len = str.length - 1;
    len = str.length;
    
      while ((i <= len) && (str.charAt(i) == ' '))
      i++;

    // When the loop is done, we're sitting at the first non-space char,
    // so return that char plus the remaining chars of the string.
      resultStr = str.substring(i, len);
    }

    return resultStr;
}; // end TrimLeft

// Make Trim a method of all String objects 
String.prototype.trimRight = TrimRight;
function TrimRight( str ) {
  var resultStr = '';
  var i = 0;

  // Return immediately if an invalid value was passed in
  if (str+'' == 'undefined' || str == null) 
    return null;

  // Make sure the argument is a string
  str += '';
  
  if (str.length == 0) 
    resultStr = '';
  else {
      // Loop through string starting at the end as long as there
      // are spaces.
      i = str.length - 1;
      while ((i >= 0) && (str.charAt(i) == ' '))
      i--;
      
    // When the loop is done, we're sitting at the last non-space char,
    // so return that char plus all previous chars of the string.
      resultStr = str.substring(0, i + 1);
    }
    
    return resultStr;   
}; // end TrimRight


function URLDecode ( str ) {
  var resultStr = '';

  // Return immediately if an invalid value was passed in
  if (str+'' == 'undefined' || str == null) 
    return null;

  // Make sure the argument is a string
  str += '';
  
  // Loop through each char in string and replace '+' with ' '
  for (var i = 0; i < str.length; i++) {
    if (str.charAt(i) == '+')
      resultStr += ' ';
    else
    ;  resultStr += str.charAt(i);
  }
  
  return unescape(resultStr);
};  // END URLDecode


function scrollit(){ 
  for (I=1; I<=500; I++){   
    parent.scroll(1,I) 
  };
};

function ShowSource() {
  msgWindow=window.open('','','scrollbars=yes, resizable, width=500, height=400');
  msgWindow.document.write('<TABLE style=font-size:10pt;color:#003399;><TR><TD id=TD nowrap>');
  msgWindow.document.write(FixCR(FixHTML(document.documentElement.innerHTML)));
  msgWindow.document.write('</TD></TR></TABLE>');
};


function FixCR(strText) {
  return String(strText).replace(/\n/gi,'<BR>\n');
};


function FixHTML(strText) {
  return String(strText).replace(/&/gi,'&#38;').replace(/</gi,'&#60;');
};

function loadImage(pic,imgname,maxwidth,scalefactor)
{
  var h;
  var w;
  var scalefactor;
  var maxwidth;
  var scalefactor;
  var theimg;
   var strImg;
  
//  alert(maxwidth + ' ' + scalefactor);
  theimg = new Image();
  theimg.src = pic;
  h = theimg.height;
  w = theimg.width;

    if (w > maxwidth)
      {
      w = (theimg.width * scalefactor) / theimg.width;
      h = (theimg.height * scalefactor) / theimg.width;
    }
  document.writeln('<img src="' + theimg.src +'" name="' + imgname + '" width="' +w+'" height="' +h+'">');
};

// Removes all characters which appear in string bag from string s.

function stripCharsInBag (s, bag)

{   var i;
    var returnString = "";

    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.

    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }

    return returnString;
};



// Removes all characters which do NOT appear in string bag 
// from string s.

function stripCharsNotInBag (s, bag)

{   var i;
    var returnString = "";
    
    // Search through string's characters one by one.
    // If character is in bag, append to returnString.

    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) != -1) returnString += c;
    }

    return returnString;
}

// Removes all NON-Alpha Characters 
// from string s.

function stripNonAlpha (s)
{   
  var i;
  var returnString = "";
 var bag = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';

  // Search through string's characters one by one.
  // If character is in bag, append to returnString.

  for (i = 0; i < s.length; i++)
  {   
      // Check that current character isn't whitespace.
      var c = s.charAt(i);
      if (bag.indexOf(c) != -1) returnString += c;
  };

  return returnString;
};

function getbrowserwidth()
{
  if (navigator.userAgent.indexOf("MSIE") > 0)
    return screen.availWidth;
  else
    return window.outerWidth;
};
function getbrowserheight()
{
  if (navigator.userAgent.indexOf("MSIE") > 0)
    return screen.availHeight;
  else
    return window.outerHeight;
};

function NewWin(URL)
{
  var X = getbrowserwidth();
  var Y = getbrowserheight();

  if ( browserVersion  == 1 )
  {
    var demowin = window.open(URL, 'DemoWin', 
      'scrollbars=yes ' +
      ',resizable=yes, toolbar=yes, menubar=yes, titlebar=yes ' +
      'width=' + X + ' ' +
      'height=' + Y + ' ' +
      'top=0 ' +
      'left=0' 
      );
        demowin.focus();
  }
  else
  {
    var demowin = window.open(URL, "DemoWin", "scrollbars=yes, titlebar=yes,toolbar=yes, menubar=yes, resizable=yes, width=" + X + ", height=" + Y + 
    ",screeny=0, screenx=0" );
    demowin.focus();
  }
};

function CenterPopup(URL, width, height)
{
  // get center of browser window
  var X = getbrowserwidth() / 2;
  var Y = getbrowserheight() / 2;
  //var popup = new Object()

  if ( browserVersion  == 1 ) {
    var popup = window.open(URL, 'PopUp', 
      'scrollbars=yes ' +
      'menubar=no ' +
      'width=' + width + ' ' +
      'height=' + height + ' ' +
      'top=' + ((Y - (height/2))) + ' ' +
      'left=' + ((X - (width/2))) 
      );
    popup.focus();
  }
  else
  {
    var popup = window.open(URL, "PopUp", "scrollbars=yes, width=" + width + ", height=" + height + 
    "screeny=" + ((Y - (height/2))) + ", screenx=" + ((X - (width/2))) + '"' );
    popup.focus();
  }
  
  return popup;
};

function OpenStdWin( sourceFile, width, height ) {

  // get center of browser window
  var X = getbrowserwidth() / 2;
  var Y = getbrowserheight() / 2;

var obj_winStdWin = window.open(sourceFile,'NavWin','toolbar=yes,width=' + width + 
        ',height=' + height + ',directories=no,status=yes,scrollbars=yes' + 
        ',resizable=yes,menubar=yes' +
        ',top=' + (window.screenTop + (Y - (height/2))) + ' ' +
        ',left=' + (window.screenLeft + (X - (width/2))) );

  obj_winStdWin.focus();
}; // end OpenNavWin


function OpenTrackWin(URL, width, height) {

  // get center of browser window
  var X = getbrowserwidth() / 2;
  var Y = getbrowserheight() / 2;
  //var popup = new Object()
  
  if ( browserVersion  == 1 )
  {
    var winTrackWin = window.open(URL, 'PopUp', 
      'scrollbars=yes ' +
      'width=' + width + ' ' +
      'height=' + height + ' ' +
      'top=' + ((Y - (height/2))) + ' ' +
      'left=' + ((X - (width/2))) 
      );
        winTrackWin.focus();
  }
  else
  {
    var winTrackWin = window.open(URL, "PopUp", "scrollbars=yes, width=" + width + ", height=" + height + 
    "screeny=" + ((Y - (height/2))) + ", screenx=" + ((X - (width/2))) + '"' );
        winTrackWin.focus();
  }

}; // end OpenTrackWin

function submitonce(theform)
{

   //if IE 4+ or NS 6+
  if (document.all||document.getElementById)
  {
    //screen thru every element in the form, and hunt down "submit" and "reset"
    for (i=0;i<theform.length;i++)
    {
      var tempobj=theform.elements[i];
      //alert(tempobj.type.toLowerCase());
      if(tempobj.type.toLowerCase()=="submit"||tempobj.type.toLowerCase()=="reset")
        //disable em
        tempobj.disabled=true;
    };
  }
};

function formatDollar (Val, DollarSign)
{ 
  var Dollars = 0;
  var Cents = 0;
  var len = 0;
  var OutString = "";
  
  Val = "" + Val;
  if (!validateNumberOnly(Val,1)) {
    return '';
  }

  if (Val.indexOf (".", 0) != -1) 
  {
    Dollars = Val.substring(0, Val.indexOf (".", 0));
    Cents = Val.substring(Val.indexOf (".", 0)+1, Val.indexOf (".", 0) + 3);

    if (Cents.length==0)
      Cents="00";   

    if (Cents.length==1)      
      Cents=Cents + "0";
    } 
    else 
    {   
      Dollars = Val;    
      Cents = "00"; 
    } 
    
    OutString=""; 
    
    len = Dollars.length;
    if ( len == 0 )
      Dollars = "0";
    
   if (len >= 3) 
   {    
    while (len > 0) 
    {     
      TempString = Dollars.substring(len-3, len);
        
        if (TempString.length == 3) 
        {       
          OutString = "," + TempString+OutString;
          len = len - 3;      
        } 
        else 
      {       
        OutString = TempString + OutString;   
        len = 0;
      }   
    }
        
      if (OutString.substring(0, 1) == ",") 
        Dollars = OutString.substring (1, OutString.length);
      else      
        Dollars = OutString;
    }
        
    
    if ( DollarSign )   
      return ("$" + Dollars + "." + Cents); 
    else
      return ( Dollars + "." + Cents);
  };
  
  
  function bye(strDomain) { return true; };
  

  function catNavigate(cat) {
    siteNavigate("browse&category=" + cat,"",1,0);
  };

  function itemNavigate(item) {
    siteNavigate('itemdetail&item=' + item + '&edit=1',"",1,0);  
  };

  function siteNavigate(strURL, strOption, intOption, blnTest)  {
    try {
      blnExit = false;
      var urlStr = Trim(strURL.toString().toLowerCase());

      if (urlStr.indexOf('mailto:')!=-1) {
        parent.location=urlStr;
        return true;
      }

      if (urlStr.indexOf('myaccount') != -1 )
        setTimeout('showPopWin("", loadMyAccount, 250, 110, null)',100);
        
      if (urlStr.indexOf('.')==-1)
        strURL = "../CustomerScripts/page.aspx?page=" + strURL;

      //from main browse page
      switch (intOption) {
        case '1':
        case '2':
          window.location = strURL;
          break;
        case '3': 
          NewWin(strURL);
          break;
        default:
          window.location = strURL;
          break;
      }
    }
    catch (e) { }
  };
  
function validateTopSearch() {

    var strKeywords = document.getElementById('txtTopSearchKeywords').value;
    
    if ( !IsBlank(strKeywords) )
      window.location = '../customerscripts/search.aspx?KEYWORDS=' + strKeywords;
    return false;

};

function displayflash(swffile,link,window,width,height)
{
  if(swffile)
  {
    if(link)
    {
      if(link.substr(0,7)!='http://')
      {
        link='http://'+link;
      }
      link=link.replace('?','%3F');
      link=link.replace('=','%3D');
      link=link.replace('&','%26');
      swffile=swffile+'?clicktag='+link;
    }

    if(window)
      swffile=swffile+'&target='+window;

    if(!width)
      width=468;

    if(!height)
      height=60;

    document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="'+width+'" height="'+height+'" align="top"><param name=movie value="'+swffile+'"><param name=quality value=high><param name=menu value=false><param name=wmode value=transparent><embed src="'+swffile+'" quality=high pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="'+width+'" height="'+height+'" menu="false" wmode="transparent" align="top"></embed></object>');
  }
};

function display(swffile,width,height)
{
  if(!width)
    width=468;

  if(!height)
    height=60;
  
  document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="'+width+'" height="'+height+'" align="top"><param name=movie value="'+swffile+'"><param name=quality value=high><param name=menu value=false><param name=wmode value=transparent><embed src="'+swffile+'" quality=high pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="'+width+'" height="'+height+'" menu="false" wmode="transparent" align="top"></embed></object>');
};

// Setup s-box and key.
var sbox = new Array(256);
var key = new Array(256);

function InicializarRC4(strLlave) {

  var a, b, tempSwap;

  for (a = 0; a < 256; a++) {
    key[a] = (strLlave.charCodeAt(a % strLlave.length)) % 256;
    sbox[a] = a;
  }

  b = 0;
  for (a = 0; a < 256; a++) {
    b = (b + sbox[a] + key[a]) % 256;
    tempSwap = sbox[a];
    sbox[a] = sbox[b];
    sbox[b] = tempSwap;
  }
};

function RC4(strTexto, strClave) {

  var i, j, k, temp, cipherby, cipher;

  i = 0;
  j = 0;
  cipher = "";
  temp = 0;

  InicializarRC4(strClave);

  for (a = 0; a < strTexto.length; a++) {
    i = (i + 1) % 256;
    j = (j + sbox[i]) % 256;
    temp = sbox[i];
    sbox[i] = sbox[j];
    sbox[j] = temp;

    k = sbox[(sbox[i] + sbox[j]) % 256];

    cipherby = strTexto.charCodeAt(a) ^ k;
    cipher = cipher + String.fromCharCode(cipherby);
  }

  return(cipher);

};

function browseNavigate(strCat) {

  var page = '';
  var regEx = /https/g;
  var loc = document.URL.toString().toLowerCase();
  
  try {
    if (catTree != null)
      catTree.saveOpenStates('eltree')  
  }
  catch (e) { }
  
  loc = loc.substring(0,loc.indexOf('customerscripts'));
  if (loc.indexOf('https') != -1 )
    loc = loc.replace(regEx,'http');
  else
    loc = '../';
    
  if (browseNavigate.arguments.length > 1 )
    page = loc + 'customerscripts/page.aspx?page=browse&category=' + strCat;
  else
    page = loc + 'customerscripts/page.aspx?page=browse&category=' + strCat;

  blnExit = false;
  if (strCat.toString().toLowerCase() == browseHome.toString().toLowerCase() )
    window.location = browseHome;
  else
    window.location=page;

};

/**
 * X-browser event handler attachment and detachment
 * TH: Switched first true to false per http://www.onlinetools.org/articles/unobtrusivejavascript/chapter4.html
 *
 * @argument obj - the object to attach event to
 * @argument evType - name of the event - DONT ADD "on", pass only "mouseover", etc
 * @argument fn - function to call
 */
function addEvent(obj, evType, fn){
 if (obj.addEventListener){
    obj.addEventListener(evType, fn, false);
    return true;
 } else if (obj.attachEvent){
    var r = obj.attachEvent("on"+evType, fn);
    return r;
 } else {
    return false;
 }
};
function removeEvent(obj, evType, fn, useCapture){
  if (obj.removeEventListener){
    obj.removeEventListener(evType, fn, useCapture);
    return true;
  } else if (obj.detachEvent){
    var r = obj.detachEvent("on"+evType, fn);
    return r;
  } else {
    alert("Handler could not be removed");
  }
};

/**
 * Code below taken from - http://www.evolt.org/article/document_body_doctype_switching_and_more/17/30655/
 *
 * Modified 4/22/04 to work with Opera/Moz (by webmaster at subimage dot com)
 *
 * Gets the full width/height because it's different for most browsers.
 */
function getViewportHeight() {
  if (window.innerHeight!=window.undefined) return window.innerHeight;
  if (document.compatMode=='CSS1Compat') return document.documentElement.clientHeight;
  if (document.body) return document.body.clientHeight; 

  return window.undefined; 
};
function getViewportWidth() {
  var offset = 17;
  var width = null;
  if (window.innerWidth!=window.undefined) return window.innerWidth; 
  if (document.compatMode=='CSS1Compat') return document.documentElement.clientWidth; 
  if (document.body) return document.body.clientWidth; 
};

/**
 * Gets the real scroll top
 */
function getScrollTop() {
  if (self.pageYOffset) // all except Explorer
  {
    return self.pageYOffset;
  }
  else if (document.documentElement && document.documentElement.scrollTop) // Explorer 6 Strict
  {
    return document.documentElement.scrollTop;
  }
  else if (document.body) // all other Explorers
  {
    return document.body.scrollTop;
  }
};
function getScrollLeft() {
  if (self.pageXOffset) // all except Explorer
  {
    return self.pageXOffset;
  }
  else if (document.documentElement && document.documentElement.scrollLeft)     // Explorer 6 Strict
  {
    return document.documentElement.scrollLeft;
  }
  else if (document.body) // all other Explorers
  {
    return document.body.scrollLeft;
  }
};

// Form Validation
function validateNumberOnly(objField)
{
  if ( document.getElementById(objField) != null && document.getElementById(objField)+'' != 'undefined' ) {
    var qty = document.getElementById(objField).value;

    qty = stripCharsInBag(qty,'%$,');
    
    if (!IsNum(qty) && !IsBlank(qty) ) {
      if (validateNumberOnly.arguments.length == 1) {
        alert("Only Valid Numbers are Allowed !   ");
        document.getElementById(objField).focus();
      }
      return false;
    }
  else 
    return false;
  }
  
  return true;
  
};

function validatePhone(objField)
{
  var strPhone = StripNonNumeric(document.getElementById(objField).value);

  if ( !isUSPhoneNumber(strPhone) && !IsBlank(strPhone) )
  {
    alert ('Please Enter a Valid Phone Number!  ');
    document.getElementById(objField).focus();
    return false;
  }
  else
  {
    if ( !IsBlank(strPhone) )
    document.getElementById(objField).value = reformatUSPhone(strPhone);
  }
  return true;
};

function validateURL(objField) {

  var strURL = StripNonNumeric(document.getElementById(objField).value);

  if ( isEmpty(strURL) ) {
    alert ('Please Enter Your Web Site Address!  ');
    document.getElementById(objField).focus();
  }
  else {
    strURL = strURL.toLowerCase();
    var i = strURL.indexOf('www');
    var j = strURL.indexOf('.');
    var k = strURL.substr(j+1);
    var l = k.indexOf('.');

    if ( i != -1 && j != -1 && l != -1 ) {
      if (strURL.indexOf('http://') == -1 ) {
        strURL = 'http://' + strURL.substr(i+1);
        document.getElementById(objField).value = strURL;
      }
    }
    else
      alert ('Please Enter a Valid Web Site Address!  ');
  } 
};


function validateEMail(objField)
{
  var strEmail = document.getElementById(objField).value;

  if ( !isEmail(strEmail) && !IsBlank(strEmail) )
  {
    alert ('Please Enter a Valid EMail Address!  ');
    document.getElementById(objField).focus();
    return false;
  }
  return true;
};

function validateDate(objField)
{
  var strDate = document.getElementById(objField).value;

  if ( !isDate(strDate) && !IsBlank(strDate) )
  {
    alert ('Please Enter a Valid Date ( mm/dd/yy or mm/dd/yyyy )!  ');
    document.getElementById(objField).focus();
    return false;
  }
  return true;
}
;
function validateCreditCard(objField, objSelect) {

  var ind = 0;
  var strCreditCardType = '';
  var blnCCType = false;

  var strCreditCard = document.getElementById(objField).value;
  
  if ( objSelect != '' && document.getElementById(objSelect)){
    blnCCType = true;
  }

  if ( !IsBlank( strCreditCard ) ) {
    if ( blnCCType ) {
      if ( isVisa(strCreditCard) )
        document.getElementById(objSelect).selectedIndex = 1;
      else if (isMasterCard(strCreditCard) )
        document.getElementById(objSelect).selectedIndex = 2;
      else if (isAmericanExpress(strCreditCard) )
        document.getElementById(objSelect).selectedIndex = 3;
      else if (isDiscover(strCreditCard) )
        document.getElementById(objSelect).selectedIndex = 4;
      else
      {
        alert ('Invalid Credit Card Type. Please use only Visa, MasterCard, Amex or Discover.  ');
        document.getElementById(objField).focus();
        return false;
      }
    }
    else {
      return isAnyCard(strCreditCard);
    }
  }
  
  return true;

};

function validateCVV2(objField, objField1)
{

  var strCreditCard = document.getElementById(objField1).value;
  var strCVV2 = document.getElementById(objField).value;

  if ( !IsBlank(strCreditCard) && IsBlank(strCVV2) )
  {
    alert("Look on the Back of your Credit Card and enter the Security Number! ");
    document.getElementById(objField).focus();
    return false;
  }

  return true;
}
;
function validateFloatOnly (objField)
{

  //stripCharsInBag (s, bag)
  var price = document.getElementById(objField).value;
  price = stripCharsInBag(price,'$,');

  if ( (!IsNum(price) && price != '$0.00' && !IsBlank(price) ) || ( IsNum(price) && price.indexOf('-') != -1 ) )
  {
    alert ('Please Enter a Valid Dollar Amount!  ');
    document.getElementById(objField).focus();
    return false;
  }
  else {
    //price = formatDollar(price, true);
    document.getElementById(objField).value = formatDollar(price, true);
  }
  return true;
};

function validateZip(objField) {
  var strZip = document.getElementById(objField).value;
  if ( !isZIPCode(strZip) && !IsBlank(strZip) ) {
    alert ('Please Enter a Valid Postal Code!  ');
    document.getElementById(objField).focus();
    return false;
  }
  return true;
};

function validatePassword(objPass) {
  strVar = Trim(document.getElementById(objPass).value);
  if ( !isEmpty(strVar) && strVar.length < 8 ) {
    alert ('Minimum password length is 8 chars!  ');
    document.getElementById(objPass).focus();
    return false;
  }
  if (validatePassword.arguments.length>1) {
    if (document.getElementById(validatePassword.arguments[0]).value!=document.getElementById(validatePassword.arguments[1]).value) {
      showPopWin('','<DIV id="modalContent" style="margin-top:25px;"><TABLE align="center" border="0" cellpadding="0" cellspacing="0" width="200px"><TR><TD id="loadingMsg"align="center"><span style="font-size:10pt;font-weight:bold;">Your passwords don\'t. Please re-enter your password.</span></TD></TR></TABLE></DIV>',250,100,null);
      document.getElementById(validatePassword.arguments[1]).focus();
      return false;
    }
  }
  return true;
};

function redirectHome(returnVal){

  var loc = 'http://' + GetDomain();

  try {
    if (browseHome+''=='undefined' || browseHome== '' )
      location.replace(loc+'/CustomerScripts/page.aspx');
    else
      location.replace(browseHome);
  }
  catch (e) {
    location.replace(loc+'/CustomerScripts/page.aspx');
  }
};

function refreshCurrentPage(returnVal) { window.location.reload(); };

/* eLinkCart Page specific functions */

function checkCart(total,page) {

  try {

    var totalTest = stripCharsInBag(total,'%$,');
    var cartElement = document.getElementById('cartTotal');
    totalTest = totalTest * 1;

    if ( page == 'checkout' ){
      doCheckoutSetup();
    }

    if ( cartElement == null )
      cartElement = document.getElementById('cartSubTotal');

    if ( page.toLowerCase() != 'reviewcart' && totalTest != 0 && cartElement != null ){
      document.getElementById('viewCartDiv').style.display = '';

      if ( userLevel <= 2 ) {
        document.getElementById('saveCartDiv').style.display = '';
      }
    }
    else if ( totalTest != 0 && cartElement != null && userLevel <= 2 ) {
      document.getElementById('saveCartDiv').style.display = '';
    }
    else {
      document.getElementById('viewCartDiv').style.display = 'none';
      document.getElementById('saveCartDiv').style.display = 'none';
    }

  }
  catch (e) {
    //No Error
  }

};


function Validate(){ return true; }

//URL Functions
var Url = {

    // public method for url encoding
    encode : function (string) {
        if ( string==null || string+''=='undefined' || (string+'' == '') )
          return '';
        else
          return escape(this._utf8_encode(string));
    },

    // public method for url decoding
    decode : function (string) {
        return this._utf8_decode(unescape(string));
    },

    // private method for UTF-8 encoding
    _utf8_encode : function (string) {
        string = string.replace(/\r\n/g,"\n");
        var utftext = "";

        for (var n = 0; n < string.length; n++) {

            var c = string.charCodeAt(n);

            if (c < 128) {
                utftext += String.fromCharCode(c);
            }
            else if((c > 127) && (c < 2048)) {
                utftext += String.fromCharCode((c >> 6) | 192);
                utftext += String.fromCharCode((c & 63) | 128);
            }
            else {
                utftext += String.fromCharCode((c >> 12) | 224);
                utftext += String.fromCharCode(((c >> 6) & 63) | 128);
                utftext += String.fromCharCode((c & 63) | 128);
            }

        }

        return utftext;
    },

    // private method for UTF-8 decoding
    _utf8_decode : function (utftext) {
        var string = "";
        var i = 0;
        var c = c1 = c2 = 0;

        while ( i < utftext.length ) {

            c = utftext.charCodeAt(i);

            if (c < 128) {
                string += String.fromCharCode(c);
                i++;
            }
            else if((c > 191) && (c < 224)) {
                c2 = utftext.charCodeAt(i+1);
                string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
                i += 2;
            }
            else {
                c2 = utftext.charCodeAt(i+1);
                c3 = utftext.charCodeAt(i+2);
                string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
                i += 3;
            }

        }

        return string;
    }

};

function correctPNG() { // correctly handle PNG transparency in Win IE 5.5 & 6.

  var arVersion = navigator.appVersion.split("MSIE");
  var version = parseFloat(arVersion[1]);
  var imgs = getElementsByName('img');
  var img,imgName,imgID,imgClass,imgTitle,imgStyle;
  var strNewHTML;
  
  if ((version >= 5.5) && (document.body.filters) && imgs.length>0) {

    for (var i=0;i<imgs.length;i++){
      imgName = imgs[i].src.toUpperCase();
      if (imgName.substring(imgName.length-3, imgName.length) == "PNG") {
        imgID = (imgs[i].id) ? "id='" + imgs[i].id + "' " : "";
        imgClass = (imgs[i].className) ? "class='" + imgs[i].className + "' " : "";
        imgTitle = (imgs[i].title) ? "title='" + imgs[i].title + "' " : "title='" + imgs[i].alt + "' ";
        imgStyle = "display:inline-block;" + imgs[i].style.cssText;
        if (imgs[i].align == "left") imgStyle = "float:left;" + imgStyle;
        if (imgs[i].align == "right") imgStyle = "float:right;" + imgStyle;
        if (imgs[i].parentElement.href) imgStyle = "cursor:hand;" + imgStyle;
        strNewHTML = "<span " + imgID + imgClass + imgTitle;
        + " style=\"" + "width:" + imgs[i].width + "px; height:" + imgs[i].height + "px;" + imgStyle + ";";
        + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader";
        + "(src=\'" + imgs[i].src + "\', sizingMethod='scale');\"></span>";
        imgs[i].outerHTML = strNewHTML;
      }
    };
  }    
};

function showNewWin(url, src, width, height, returnFunc) {
  var showCloseBox=true;
  if (showNewWin.arguments.length>5)
    showCloseBox=showNewWin.arguments[5];
  // show or hide the window close widget
  if (showCloseBox == null || showCloseBox == true) {
    document.getElementById("popCloseBox").style.display = "block";
  } else {
    document.getElementById("popCloseBox").style.display = "none";
  }

  gPopupIsShown = true;
  disableTabIndexes();
  gPopupMask.style.display = "block";
  gPopupContainer.style.display = "block";

  // calculate where to place the window on screen
  centerPopWin(width, height);
  
  var titleBarHeight = parseInt(document.getElementById("popupTitleBar").offsetHeight, 10);

  gPopupContainer.style.width = width + "px";
  gPopupContainer.style.height = (height+titleBarHeight) + "px";
  
  setMaskSize();

  // need to set the width of the iframe to the title bar width because of the dropshadow
  // some oddness was occuring and causing the frame to poke outside the border in IE6
  gPopFrame.style.width = parseInt(document.getElementById("popupTitleBar").offsetWidth, 10) + "px";
  gPopFrame.style.height = (height) + "px";

  // set the url or InnerHTML is src passed
  if (src != '' ) {
    window.frames['popupFrame'].document.body.innerHTML = src;
  }
  else
    gPopFrame.src = url;
  
  gReturnFunc = returnFunc;
  // for IE
  if (gHideSelects == true) {
    hideSelectBoxes();
  }
  
  window.setTimeout("setPopTitle();", 600);
};

// ===================================================================
// formatDate.js
//
// NOTICE: You may use this code for any purpose, commercial or
// private, without any further permission from the author. You may
// remove this notice from your final code if you wish.
//
// ===================================================================

// HISTORY
// ------------------------------------------------------------------
// May 17, 2003: Fixed bug in parseDate() for dates <1970
// March 11, 2003: Added parseDate() function
// March 11, 2003: Added "NNN" formatting option. Doesn't match up
//                 perfectly with SimpleDateFormat formats, but 
//                 backwards-compatability was required.

// ------------------------------------------------------------------
// These functions use the same 'format' strings as the 
// java.text.SimpleDateFormat class, with minor exceptions.
// The format string consists of the following abbreviations:
// 
// Field        | Full Form          | Short Form
// -------------+--------------------+-----------------------
// Year         | yyyy (4 digits)    | yy (2 digits), y (2 or 4 digits)
// Month        | MMM (name or abbr.)| MM (2 digits), M (1 or 2 digits)
//              | NNN (abbr.)        |
// Day of Month | dd (2 digits)      | d (1 or 2 digits)
// Day of Week  | EE (name)          | E (abbr)
// Hour (1-12)  | hh (2 digits)      | h (1 or 2 digits)
// Hour (0-23)  | HH (2 digits)      | H (1 or 2 digits)
// Hour (0-11)  | KK (2 digits)      | K (1 or 2 digits)
// Hour (1-24)  | kk (2 digits)      | k (1 or 2 digits)
// Minute       | mm (2 digits)      | m (1 or 2 digits)
// Second       | ss (2 digits)      | s (1 or 2 digits)
// AM/PM        | a                  |
//
// NOTE THE DIFFERENCE BETWEEN MM and mm! Month=MM, not mm!
// Examples:
//  "MMM d, y" matches: January 01, 2000
//                      Dec 1, 1900
//                      Nov 20, 00
//  "M/d/yy"   matches: 01/20/00
//                      9/2/00
//  "MMM dd, yyyy hh:mm:ssa" matches: "January 01, 2000 12:30:45AM"
// ------------------------------------------------------------------

function LZ(x) {return(x<0||x>9?"":"0")+x;};

// ------------------------------------------------------------------
// isDate ( date_string, format_string )
// Returns true if date string matches format of format string and
// is a valid date. Else returns false.
// It is recommended that you trim whitespace around the value before
// passing it to this function, as whitespace is NOT ignored!
// ------------------------------------------------------------------
function isDate(val,format) {
  var date=getDateFromFormat(val,format);
  if (date==0) { return false; }
  return true;
  };

// -------------------------------------------------------------------
// compareDates(date1,date1format,date2,date2format)
//   Compare two date strings to see which is greater.
//   Returns:
//   1 if date1 is greater than date2
//   0 if date2 is greater than date1 of if they are the same
//  -1 if either of the dates is in an invalid format
// -------------------------------------------------------------------
function compareDates(date1,dateformat1,date2,dateformat2) {
  var d1=getDateFromFormat(date1,dateformat1);
  var d2=getDateFromFormat(date2,dateformat2);
  if (d1==0 || d2==0) {
    return -1;
    }
  else if (d1 > d2) {
    return 1;
    }
  return 0;
  };

// ------------------------------------------------------------------
// formatDate (date_object, format)
// Returns a date in the output format specified.
// The format string uses the same abbreviations as in getDateFromFormat()
// ------------------------------------------------------------------
function formatDate(date,format) {
  format=format+"";
  var result="";
  var i_format=0;
  var c="";
  var token="";
  var y=date.getYear()+"";
  var M=date.getMonth()+1;
  var d=date.getDate();
  var E=date.getDay();
  var H=date.getHours();
  var m=date.getMinutes();
  var s=date.getSeconds();
  var yyyy,yy,MMM,MM,dd,hh,h,mm,ss,ampm,HH,H,KK,K,kk,k;

  // Convert real date parts into formatted versions
  var value=new Object();

  if (y.length < 4) {y=""+(y-0+1900);}

  value["y"]=""+y;
  value["yyyy"]=y;
  value["yy"]=y.substring(2,4);
  value["M"]=M;
  value["MM"]=LZ(M);
  value["MMM"]=MONTH_NAMES[M-1];
  value["NNN"]=MONTH_NAMES[M+11];
  value["d"]=d;
  value["dd"]=LZ(d);
  value["E"]=DAY_NAMES[E+7];
  value["EE"]=DAY_NAMES[E];
  value["H"]=H;
  value["HH"]=LZ(H);

  if (H==0){value["h"]=12;}
  else if (H>12){value["h"]=H-12;}
  else {value["h"]=H;}
  value["hh"]=LZ(value["h"]);
  if (H>11){value["K"]=H-12;} else {value["K"]=H;}
  value["k"]=H+1;
  value["KK"]=LZ(value["K"]);
  value["kk"]=LZ(value["k"]);
  if (H > 11) { value["a"]="PM"; }
  else { value["a"]="AM"; }
  value["m"]=m;
  value["mm"]=LZ(m);
  value["s"]=s;
  value["ss"]=LZ(s);
  while (i_format < format.length) {
    c=format.charAt(i_format);
    token="";
    while ((format.charAt(i_format)==c) && (i_format < format.length)) {
      token += format.charAt(i_format++);
      }
    if (value[token] != null) { result=result + value[token]; }
    else { result=result + token; }
    }
  return result;
  };
  
// ------------------------------------------------------------------
// Utility functions for parsing in getDateFromFormat()
// ------------------------------------------------------------------
function _isInteger(val) {
  var digits="1234567890";
  for (var i=0; i < val.length; i++) {
    if (digits.indexOf(val.charAt(i))==-1) { return false; }
    }
  return true;
  };
function _getInt(str,i,minlength,maxlength) {
  for (var x=maxlength; x>=minlength; x--) {
    var token=str.substring(i,i+x);
    if (token.length < minlength) { return null; }
    if (_isInteger(token)) { return token; }
    }
  return null;
  };
  
// ------------------------------------------------------------------
// getDateFromFormat( date_string , format_string )
//
// This function takes a date string and a format string. It matches
// If the date string matches the format string, it returns the 
// getTime() of the date. If it does not match, it returns 0.
// ------------------------------------------------------------------
function getDateFromFormat(val,format) {
  val=val+"";
  format=format+"";
  var i_val=0;
  var i_format=0;
  var c="";
  var token="";
  var token2="";
  var x,y;
  var now=new Date();
  var year=now.getYear();
  var month=now.getMonth()+1;
  var date=1;
  var hh=now.getHours();
  var mm=now.getMinutes();
  var ss=now.getSeconds();
  var ampm="";
  
  while (i_format < format.length) {
    // Get next token from format string
    c=format.charAt(i_format);
    token="";
    while ((format.charAt(i_format)==c) && (i_format < format.length)) {
      token += format.charAt(i_format++);
      }
    // Extract contents of value based on format token
    if (token=="yyyy" || token=="yy" || token=="y") {
      if (token=="yyyy") { x=4;y=4; }
      if (token=="yy")   { x=2;y=2; }
      if (token=="y")    { x=2;y=4; }
      year=_getInt(val,i_val,x,y);
      if (year==null) { return 0; }
      i_val += year.length;
      if (year.length==2) {
        if (year > 70) { year=1900+(year-0); }
        else { year=2000+(year-0); }
        }
      }
    else if (token=="MMM"||token=="NNN"){
      month=0;
      for (var i=0; i<MONTH_NAMES.length; i++) {
        var month_name=MONTH_NAMES[i];
        if (val.substring(i_val,i_val+month_name.length).toLowerCase()==month_name.toLowerCase()) {
          if (token=="MMM"||(token=="NNN"&&i>11)) {
            month=i+1;
            if (month>12) { month -= 12; }
            i_val += month_name.length;
            break;
            }
          }
        }
      if ((month < 1)||(month>12)){return 0;}
      }
    else if (token=="EE"||token=="E"){
      for (var i=0; i<DAY_NAMES.length; i++) {
        var day_name=DAY_NAMES[i];
        if (val.substring(i_val,i_val+day_name.length).toLowerCase()==day_name.toLowerCase()) {
          i_val += day_name.length;
          break;
          }
        }
      }
    else if (token=="MM"||token=="M") {
      month=_getInt(val,i_val,token.length,2);
      if(month==null||(month<1)||(month>12)){return 0;}
      i_val+=month.length;}
    else if (token=="dd"||token=="d") {
      date=_getInt(val,i_val,token.length,2);
      if(date==null||(date<1)||(date>31)){return 0;}
      i_val+=date.length;}
    else if (token=="hh"||token=="h") {
      hh=_getInt(val,i_val,token.length,2);
      if(hh==null||(hh<1)||(hh>12)){return 0;}
      i_val+=hh.length;}
    else if (token=="HH"||token=="H") {
      hh=_getInt(val,i_val,token.length,2);
      if(hh==null||(hh<0)||(hh>23)){return 0;}
      i_val+=hh.length;}
    else if (token=="KK"||token=="K") {
      hh=_getInt(val,i_val,token.length,2);
      if(hh==null||(hh<0)||(hh>11)){return 0;}
      i_val+=hh.length;}
    else if (token=="kk"||token=="k") {
      hh=_getInt(val,i_val,token.length,2);
      if(hh==null||(hh<1)||(hh>24)){return 0;}
      i_val+=hh.length;hh--;}
    else if (token=="mm"||token=="m") {
      mm=_getInt(val,i_val,token.length,2);
      if(mm==null||(mm<0)||(mm>59)){return 0;}
      i_val+=mm.length;}
    else if (token=="ss"||token=="s") {
      ss=_getInt(val,i_val,token.length,2);
      if(ss==null||(ss<0)||(ss>59)){return 0;}
      i_val+=ss.length;}
    else if (token=="a") {
      if (val.substring(i_val,i_val+2).toLowerCase()=="am") {ampm="AM";}
      else if (val.substring(i_val,i_val+2).toLowerCase()=="pm") {ampm="PM";}
      else {return 0;}
      i_val+=2;}
    else {
      if (val.substring(i_val,i_val+token.length)!=token) {return 0;}
      else {i_val+=token.length;}
      }
    }
  // If there are any trailing characters left in the value, it doesn't match
  if (i_val != val.length) { return 0; }
  // Is date valid for month?
  if (month==2) {
    // Check for leap year
    if ( ( (year%4==0)&&(year%100 != 0) ) || (year%400==0) ) { // leap year
      if (date > 29){ return 0; }
      }
    else { if (date > 28) { return 0; } }
    }
  if ((month==4)||(month==6)||(month==9)||(month==11)) {
    if (date > 30) { return 0; }
    }
  // Correct hours value
  if (hh<12 && ampm=="PM") { hh=hh-0+12; }
  else if (hh>11 && ampm=="AM") { hh-=12; }
  var newdate=new Date(year,month-1,date,hh,mm,ss);
  return newdate.getTime();
  };

// ------------------------------------------------------------------
// parseDate( date_string [, prefer_euro_format] )
//
// This function takes a date string and tries to match it to a
// number of possible date formats to get the value. It will try to
// match against the following international formats, in this order:
// y-M-d   MMM d, y   MMM d,y   y-MMM-d   d-MMM-y  MMM d
// M/d/y   M-d-y      M.d.y     MMM-d     M/d      M-d
// d/M/y   d-M-y      d.M.y     d-MMM     d/M      d-M
// A second argument may be passed to instruct the method to search
// for formats like d/M/y (european format) before M/d/y (American).
// Returns a Date object or null if no patterns match.
// ------------------------------------------------------------------
function parseDate(val) {
  var preferEuro=(arguments.length==2)?arguments[1]:false;
  generalFormats=new Array('y-M-d','MMM d, y','MMM d,y','y-MMM-d','d-MMM-y','MMM d');
  monthFirst=new Array('M/d/y','M-d-y','M.d.y','MMM-d','M/d','M-d');
  dateFirst =new Array('d/M/y','d-M-y','d.M.y','d-MMM','d/M','d-M');
  var checkList=new Array('generalFormats',preferEuro?'dateFirst':'monthFirst',preferEuro?'monthFirst':'dateFirst');
  var d=null;
  for (var i=0; i<checkList.length; i++) {
    var l=window[checkList[i]];
    for (var j=0; j<l.length; j++) {
      d=getDateFromFormat(val,l[j]);
      if (d!=0) { return new Date(d); }
      }
    }
  return null;
  };

function GetDomain() {
   return document.URL.match(/:\/\/(.[^/]+)/)[1];
};
