var NeedToShowRequired;
NeedToShowRequired=1;
function crlf() { return '\r\n'; }
function newline() { return '\n'; }
String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g, ''); }
function dw(dws) { document.write(dws); }
function FormIt(Msg,Cnsl,Body,Foot) {
  var fTxt;
  fTxt='';
  fTxt+='<table border="2" cellpadding="4" bgcolor="#C0C0C0"'
  fTxt+=' bordercolor="#808080" bordercolorlight="#C0C0C0">'
  fTxt+=' <tr><td bgcolor="#000082" bordercolordark="#808080" bordercolorlight="#C0C0C0">'
  fTxt+=' <font color="#FFFFFF" size="2" face="Arial">'
  fTxt+='<table border=0 cellpadding=0 cellspacing=0 width="100%"><tr><td>'
  fTxt+='<font color="#FFFFFF"><b>'
  fTxt+=Msg
  fTxt+='</b></font>'
  fTxt+='</td><td>'
  fTxt+=Cnsl
  fTxt+='</td></tr></table>'
  fTxt+='</font>'
  fTxt+=' </td></tr><tr><td align="left" bordercolordark="#000000" bordercolorlight="#FFFFFF">'
  fTxt+=Body
  fTxt+='</td></tr><tr>'
  fTxt+=' <td align="left" bordercolor="#C0C0C0" bordercolordark="#C0C0C0">'
  fTxt+=Foot
  fTxt+='</td></tr></table>'
  return fTxt
}
function DeleteCurrencyChars(S) {
  if(!S) return ''
  // Clean out currency characters
  S=S.replace( /\$/g,'');  // Regex to replace '$' with value ''
  S=S.replace( /\,/g,'');  // Regex to replace ',' with value ''
  return S
}
function ValidateSalary(S,DelChars,CheckMin) {
  if(!S) return ''
  if(DelChars==1) S=DeleteCurrencyChars(S)
  if(isNaN(S)){alert('Error.  Please enter numbers into the salary fields.'); return ''; }
  if(CheckMin==1) {
    if(S<10000) {alert('Make sure you enter salaries in annual amounts.  You entered: '+S); return S}
    if(S>400000) {alert('Wow.  That\'s a high salary.  You entered: '+S);return S}
  }
  return S
}
function Round(preValue,decPlaces) {
  preFactor=Math.pow(10,decPlaces)
  preValue=Math.round(preValue*preFactor)/preFactor;
  preValue=preValue+'';
  if(preValue.indexOf(".")<0){ preValue=preValue+"."; }
  numZeros=decPlaces-(preValue.length-(preValue.indexOf('.')+1));
  for(;numZeros>0;numZeros--) { preValue=preValue+'0'; }
  return preValue
}
function SetCheckBoxValues() {
  return;
   var j,k,l;
   j=document.dataform.length/10;
   k=j;l=0;
   for(var i=0; i<document.dataform.length; i++){
      if(i>k && j>30){k+=j;l+=10;
        Status("Processing your form.<br>",l,"percent completed.","Please wait.");
      }
      var t=document.dataform.elements[i].type;
      if(t.indexOf('check')>=0) {
        if(document.dataform.elements[i].checked) {
          document.dataform.elements[i].value=1;
        } else {
          document.dataform.elements[i].checked=true;
          document.dataform.elements[i].value=0;
        }
      }
   }
   if(j>30) Status("<H3>",100,"percent completed.</H3>","You may close this window.");
}
function Status(msg0,pct,msg1,msg2) {
   var Body;
   Body=msg0+pct+' '+msg1+'<P>'
   Body+='<table border=1 width="80%" cellpadding=0 cellspacing=0><tr><td align=left>'
   Body+='<table border=1 width="'+pct+'%" cellpadding=0 cellspacing=0 bgcolor="#000000"><tr><td align=left>'
   Body+='</td></tr></table></td></tr></table><P>'+msg2
   win2=window.open('','status_window','width=300,height=200,status=no,menubar=no,scrollbars=yes')
   win2.document.writeln(FormIt('Status','',Body,''))
   win2.document.close()
}

//////////////////////////////////////////////////////////
// Create a Hash array class
//
// alert(myHash.setItem('foobar', 'hey'));  Set foobar=hey
// Scan through name/value pairs:
//   for (var i in myHash.items) { 
//     alert('key is: ' + i + ', value is: ' + myHash.items[i]); 
//   }
//   for (var i = 0; i < myHash.length; i++) { 
//     alert('key is: ' + i + ', value is: ' + myHash.items[i]); 
//   }
//   for (var i = 0; i < myHash.length; i++) { 
//     alert('key is: ' + i + ', value is: ' + myHash.getItem(i)); 
//   }
//
// Sorts based on keys / values
//   myHash.sortItems(By_Hash_Values);
//   for(i=0;i<myHash.length;i++) {
//     document.write(myHash.sortedItems[i].key+': '+myHash.sortedItems[i].value+'<br>')
//   }
//
var By_Hash_Keys=1;
var By_Hash_Values=2;
var By_Hash_NumericValues=3;
var By_Hash_NumericValuesDesc=4;
function Element(n,v) { this.key=n; this.value=v; }
function Hash() {
    this.length = 0;
    this.items = new Array();
    for (var i = 0; i < arguments.length; i += 2) {
        if (typeof(arguments[i + 1]) != 'undefined') {
            this.items[arguments[i]] = arguments[i + 1];
            this.length++;
        }
    }

    this.removeItem = function(in_key) { 
        var tmp_value; 
        if (typeof(this.items[in_key]) != 'undefined') { 
            this.length--; 
            var tmp_value = this.items[in_key]; 
            delete this.items[in_key]; 
        } 
        return tmp_value; 
    } 

    this.getItem = function(in_key) { return this.items[in_key]; } 

    this.setItem = function(in_key, in_value) { 
        if (typeof(in_value) != 'undefined') { 
            if (typeof(this.items[in_key]) == 'undefined') { 
                this.length++; 
            } 

            this.items[in_key] = in_value; 
        } 
        
        return in_value; 
    } 

    this.hasItem = function(in_key) { 
        return typeof(this.items[in_key]) != 'undefined'; 
    } 

    ////////////////////////////////////////////////////////////////////////
    //  Sorting Functions for Hashed Array
    this.sortedItems = new Array();
    this.elementIndex=0;
    this.sortItems = function(by_key) {
      if(by_key && by_key != By_Hash_Keys && by_key != By_Hash_Values && by_key != By_Hash_NumericValues && by_key != By_Hash_NumericValuesDesc) { alert('Incorrect sort by value in utils.js!'); }
      this.sortedItems = new Array(); this.elementIndex=0;
      for (var i in this.items) { this.sortedItems[this.elementIndex++]=new Element(i, this.items[i]); }
      if(!by_key || by_key==By_Hash_Keys) { this.sortedItems.sort(this.sort_by_key); }
      if(by_key==By_Hash_Values) { this.sortedItems.sort(this.sort_by_value); }
      if(by_key==By_Hash_NumericValues) { this.sortedItems.sort(this.sort_by_numericvalue); }
      if(by_key==By_Hash_NumericValuesDesc) { this.sortedItems.sort(this.sort_by_numericvaluedesc); }
    }
    this.sort_by_key=function(a, b) { if ( a.key < b.key ) return -1; if ( a.key > b.key ) return 1; return 0; }
    this.sort_by_value=function(a, b) {if ( a.value < b.value)return -1; if ( a.value >b.value) return 1; return 0; }
    this.sort_by_numericvalue=function(a, b) { if ( a.value*1 < b.value*1 ) return -1; if ( a.value*1 > b.value*1 ) return 1; return 0; }
    this.sort_by_numericvaluedesc=function(a, b) { if ( a.value*1 > b.value*1 ) return -1; if ( a.value*1 < b.value*1 ) return 1; return 0; }
}



///////////////////////////////////////////////////////////////////////////
//  BEGIN MODAL DIALOG CODE
//
// Global for brower version branching.
var Nav4 = ((navigator.appName == "Netscape") && (parseInt(navigator.appVersion) == 4))
// One object tracks the current modal dialog opened from this window.
var dialogWin = new Object()
// Generate a modal dialog.
// Parameters:
//    url -- URL of the page/frameset to be loaded into dialog
//    width -- pixel width of the dialog window
//    height -- pixel height of the dialog window
//    returnFunc -- reference to the function (on this page)
//                  that is to act on the data returned from the dialog
//    args -- [optional] any data you need to pass to the dialog
function openDialog(url, width, height, returnFunc, args) {
	if (!dialogWin.win || (dialogWin.win && dialogWin.win.closed)) {
		// Initialize properties of the modal dialog object.
		dialogWin.returnFunc = returnFunc
		dialogWin.returnedValue = ""
		dialogWin.args = args
		dialogWin.url = url
		dialogWin.width = width
		dialogWin.height = height
		// Keep name unique so Navigator doesn't overwrite an existing dialog.
		dialogWin.name = (new Date()).getSeconds().toString()
		// Assemble window attributes and try to center the dialog.
		if (Nav4) {
			// Center on the main window.
			dialogWin.left = window.screenX + 
			   ((window.outerWidth - dialogWin.width) / 2)
			dialogWin.top = window.screenY + 
			   ((window.outerHeight - dialogWin.height) / 2)
			var attr = "screenX=" + dialogWin.left + 
			   ",screenY=" + dialogWin.top + ",resizable=yes,scrollbars=yes,width=" + 
			   dialogWin.width + ",height=" + dialogWin.height
		} else {
			// The best we can do is center in screen.
			dialogWin.left = (screen.width - dialogWin.width) / 2
			dialogWin.top = (screen.height - dialogWin.height) / 2
			var attr = "left=" + dialogWin.left + ",top=" + 
			   dialogWin.top + ",resizable=yes,scrollbars=yes,width=" + dialogWin.width + 
			   ",height=" + dialogWin.height
		}
		
		// Generate the dialog and make sure it has focus.
		dialogWin.win=window.open(dialogWin.url, dialogWin.name, attr)
		dialogWin.win.focus()
	} else {
		dialogWin.win.focus()
	}
}


