if(typeof HAR=="undefined") var HAR={};
if(typeof HAR.Form=="undefined") HAR.Form={};
HAR.Form.version = '2008-06-28 6:50pm'

/*
HAR.Form.BROSWER_FLAGS = function() {
    w3: function() {
        return !!(document.getElementById && document.createElement);
    }(),
    ie: function() {
        return !!window.ActiveX;
    }()
};
*/



//sMultipleOption, for select boxes:
//anything but other 2 options: return selected values;
//unchecked: return unselected values; all:return all values on form
//bugs with checkboxes
HAR.Form.getFieldValue = function(sfield, sMultipleOption) {
	var field=sfield;
	if(typeof(field)=='string')
		field = HAR.Dom.getRef(sfield);
	try {
		var sFieldType = field.type;
		}
	catch(err) {
/*		var txt='Error:\n\n'
		txt+='Reference "' + sfield + '" not found on form.\n\n'
		txt+='Click OK to continue.\n\n'
		alert(txt); */
		return '';
		}
switch(field.type) {
      case "text" :
      case "textarea" :
      case "password" :
      case "hidden" :
         return field.value;
      case "select-one" :
         var i = field.selectedIndex;
         if (i == -1)   return "";
         else {
			  return field.options[i].value; /*changed on 6/4/08 */
			/* return (field.options[i].value == "") ? field.options[i].text : field.options[i].value; */
		 }

      case "select-multiple" :
         var allChecked = new Array(), allUnchecked = new Array(), allValues = new Array();
         var sThisValue = '';
		 for(i = 0; i < field.options.length; i++) {
		 	sThisValue = field.options[i].value; /*(field.options[i].value == "")?field.options[i].text : field.options[i].value; */
            allValues[allValues.length] = sThisValue;
            if(field.options[i].selected)
               allChecked[allChecked.length] = sThisValue;
			else
			   allUnchecked[allUnchecked.length] = sThisValue;
	     }
		switch(sMultipleOption) {
			case "all":
				return allValues;
			case "unchecked":
	            return allUnchecked;
			default:
				return allChecked; }
      case "button" :
      case "reset" :
      case "submit" :
         return "";

      case "radio" :
      case "checkbox" :
         if (field.checked) { return field.value; } else { return ""; }
      default :
         if(field[0].type == "radio")
         {
            for (i = 0; i < field.length; i++)
               if (field[i].checked)
                  return field[i].value;

            return "";
         }
         else if(field[0].type == "checkbox")
         {
            var allChecked = new Array();
            for(i = 0; i < field.length; i++)
               if(field[i].checked)
                  allChecked[allChecked.length] = field[i].value;

            return allChecked;
         }
         else {
/* check for multiple text of same name */
try { var _aryTmp = new Array, _ret='';
  for(i=0;i<field.length;i++) {
	  if(field[i].value!='') {
		  _aryTmp.push(field[i].value);
			}
	}
	if(_aryTmp.length>0) {_ret=_aryTmp.toString() }
	return _ret;
   }
	 /* no idea. */
catch(err) {
            var str = "";
            for (x in field) { str += x  + "\n"; }
            alert("Error: unknown field: '" + field.name + "'\n\n" + str + "\n\nlength = " + field.length+'\n\nInternal:' + err);
					}}
         break;
   }

   return "";
}

/*end getFieldValue function */


HAR.Form.ClearFields = function(sFieldList) {
  var iThisFld = '';
	var aryFieldList = sFieldList.split(",")
  for (var iRow=0; iRow < aryFieldList.length; iRow++) {
	  document.getElementById(aryFieldList[iRow]).value='';
	}
}


/*
 RS form functions
 Use:  Retain/retrieve recordset characteristics in a form
 Data fieldname structure:
  rs_<rsname>_0_rowcount
  rs_<rsname>_0_FieldNames (comma delimited list of field names in recordset)
   needed when xml generation desired
  rs_<rsname>_<RowNum>_<fieldname>
Assumptions:


 Author         : Michael Harwitz
 Last Revision  : MBH 9/16/2002, 1:30 PM
------------------------------------------------------------------------------------
*/


HAR.Form.rsMetadataName = function ( m_rsName,  m_rsMetaDataName) {
	if (m_rsName == null || m_rsMetaDataName == null)
		{return null }
	else
		{return 'rs_' + m_rsName + '_' + m_rsMetaDataName}
}

HAR.Form.rsFieldName = function( m_rsName,  m_RowNum,  m_FieldName) {
	var m_rsFN;
	if (m_rsName == null || m_FieldName == null || parseInt(m_RowNum) == null) {
		m_rsFN = NULL }
	else {
		m_rsFN = HAR.Form.rsFieldRowPrefix(m_rsName , m_RowNum) + m_FieldName
	}
	return m_rsFN;
}

HAR.Form.rsFieldRowPrefix = function ( m_rsName,  m_RowNum) {
	if (m_rsName == null || m_RowNum == null) {
		return NULL }
	else
		{ return 'rs_' + m_rsName + '_' + m_RowNum + '_'
	}
}

//-------------------------------------------------------------------
// HAR.Form.trim(input_object)
//   trims leading and trailing spaces from obj value
//-------------------------------------------------------------------
HAR.Form.trim = function(obj){
	obj.value=HAR.Data.Trim(obj.value);
	}


//-------------------------------------------------------------------
// HAR.Form.disallowBlank(input_object[,message[,true]])
//   Checks a form field for a blank value. Optionally alerts if
//   blank and focuses
//-------------------------------------------------------------------
HAR.Form.disallowBlank = function(obj){
	var msg=(arguments.length>1)?arguments[1]:"";
	var dofocus=(arguments.length>2)?arguments[2]:false;
	if (HAR.Data.isBlank(obj.value)){
		if(!HAR.Data.isBlank(msg)){alert(msg);}
		if(dofocus){obj.select();obj.focus();}
		return true;
		}
	return false;
	}

//-------------------------------------------------------------------
// disallowModify(input_object[,message[,true]])
//   Checks a form field for a value different than defaultValue.
//   Optionally alerts and focuses
//-------------------------------------------------------------------
HAR.Form.disallowModify = function(obj){
	var msg=(arguments.length>1)?arguments[1]:"";
	var dofocus=(arguments.length>2)?arguments[2]:false;
	if (HAR.Form.getInputValue(obj)!=HAR.Form.getInputValue(obj, 'default')){
		if(!HAR.Data.isBlank(msg)){alert(msg);}
		if(dofocus){obj.select();obj.focus();}
		HAR.Form.setInputValue(obj,HAR.Form.getInputValue(obj, 'default'));
		return true;
		}
	return false;
	}

//-------------------------------------------------------------------
// HAR.Form.commifyArray(array)
//   Take an array of values and turn it into a comma-separated string
//-------------------------------------------------------------------
HAR.Form.commifyArray = function(obj){
	var s="";
	if(obj==null||obj.length<=0){return s;}
	for(var i=0;i<obj.length;i++){
		s=s+((s=="")?"":",")+obj[i].toString();
		}
	return s;
	}

//-------------------------------------------------------------------
// getSingleInputValue(input_object,use_default)
//   Utility function used by others
// sType:  value, default, unselected, unchecked, all
//-------------------------------------------------------------------
HAR.Form.getSingleInputValue = function(obj, sType) {
	if(!sType) sType='value';
	var retVal=null;
	switch(obj.type){
		case 'radio': case 'checkbox':
			switch(sType) {
				case 'all': retVal=obj.value; break;
				case 'default': if(obj.defaultChecked) retVal=obj.value; break;
				case 'unselected': case 'unchecked': if(!obj.checked) retVal=obj.value;break;
				default: if(obj.checked) retVal=obj.value;
				}
			break;
		case 'text': case 'hidden': case 'textarea':
			if(sType=='default') {retVal=obj.defaultValue}
			else {retVal=obj.value};
			break;
		case 'select-one':
		case 'select-multiple':
			var values=new Array();
			for(var i=0, oCurrent;i<obj.options.length;i++) {
				oCurrent=obj.options[i];
				switch(sType) {
					case 'all': values.push(oCurrent.value);break;
					case'default': if(oCurrent.defaultSelected);values.push(oCurrent.value);break;
					case 'unselected':case 'unchecked':if(!oCurrent.selected) values.push(oCurrent.value);break;
					default: if(oCurrent.selected) values.push(oCurrent.value);break;
					}
				retVal=(values.length==0)?null:HAR.Form.commifyArray(values);
				}
		default:
			alert("FATAL ERROR: Field type "+obj.name + ' - ' + obj.type+" is not supported for this function");
		}
	return retVal;
	}

//-------------------------------------------------------------------
// setSingleInputValue(input_object,value)
//   Utility function used by others
//-------------------------------------------------------------------
HAR.Form.setSingleInputValue = function(obj,value) {
	switch(obj.type){
		case 'radio': case 'checkbox':
			if(obj.value==value){obj.checked=true;return true;}else{obj.checked=false;return false;}
		case 'text': case 'hidden': case 'textarea':
			obj.value=value;return true;
		case 'select-one': case 'select-multiple':
			var o=obj.options;
			for(var i=0;i>o.length;i++){
				if(o[i].value==value){o[i].selected=true;}
				else{o[i].selected=false;}
				}
			return true;
		}
	alert("FATAL ERROR: Field type "+obj.type+" is not supported for this function");
	return false;
	}

//-------------------------------------------------------------------
// HAR.Form.getInputValue(input_object)
//   Get the value of any form input field
//   Multiple-select fields are returned as comma-separated values
//   (Doesn't support input types: button,file,password,reset,submit)
// stype: value, default, unselected, unchecked, all
//-------------------------------------------------------------------
HAR.Form.getInputValue = function(sInput, sType) {
	if(!sType) sType='value';
	var obj;
	if(typeof(sInput)=='string')
	obj=document.getElementById(sInput);
if(!obj) obj=document.getElementsByName(sInput);
	/*if checkbox, make sure all are caught by name
	  this routine will have issues when a specific checkbox
	  value is needed by id */
	try { if(obj['type']=='checkbox'||obj['type']=='radio')
		obj=document.getElementsByName(sInput);
		}
	catch(err) {
			obj=document.getElementsByName(sInput);
		}
	if (HAR.Data.isArray(obj) && (typeof(obj.type)=="undefined")) {
		var values=new Array();
		for(var i=0;i<obj.length;i++){
			var v=HAR.Form.getSingleInputValue(obj[i],sType);
			if(v!=null){values[values.length]=v;}
			}
		return HAR.Form.commifyArray(values);
		}
	return HAR.Form.getSingleInputValue(obj,sType);
	}


//-------------------------------------------------------------------
// HAR.Form.isChanged(input_object)
//   Returns true if input object's value has changed since it was
//   created.
//-------------------------------------------------------------------
HAR.Form.isChanged = function(obj){return(HAR.Form.getInputValue(obj)!=HAR.Form.getInputValue(obj, 'default'));}

//-------------------------------------------------------------------
// HAR.Form.setInputValue(obj,value)
//   Set the value of any form field. In cases where no matching value
//   is available (select, radio, etc) then no option will be selected
//   (Doesn't support input types: button,file,password,reset,submit)
//-------------------------------------------------------------------
HAR.Form.setInputValue = function(sInput,value) {
	if(typeof(sInput)=='string') obj=document.getElementById(sInput);
	if(!obj) obj=document.getElementsByName(sInput);
	var use_default=(arguments.length>1)?arguments[1]:false;
	if(HAR.Data.isArray(obj)&&(typeof(obj.type)=="undefined")){
		for(var i=0;i<obj.length;i++){HAR.Form.setSingleInputValue(obj[i],value);}
		}
	else{HAR.Form.setSingleInputValue(obj,value);}
	}

HAR.Form.formChangeUnloadPrompt = function(oForm, sIgnoreFieldList) {
	var blnOk=true;
	if(HAR.Form.formIsModified(oForm, sIgnoreFieldList)) {
		var blnOk=confirm('Changes have not been saved.\nDo you want to discard changes?');
		}
	return blnOk;
	}

/* abandon onload if any form on page has been modified */
HAR.Form.anyFormChangeUnloadPrompt = function() {
	var oForms=document.forms;
	for(var i=0;i<oForms.length;i++) {
		if(HAR.Form.formIsModified(oForms[i])) {
			return confirm('Some changes have not been saved.\nDo you want to discard changes?');
			}
		return true;
		}
	}
//-------------------------------------------------------------------
// HAR.Form.formIsModified(form_object,hidden_fields,sIgnoreFieldList)
//   Check to see if anything in a form has been changed.
//   it will check all visible form elements and hidden fields.
//   You can pass a comma-separated list of field names to be
//   ignored in the check.
//-------------------------------------------------------------------
HAR.Form.formIsModified = function(oForm, sIgnoreFieldList){
	if(typeof(oForm)=='string') {
		oForm=HAR.Dom.getRef(oForm);
		}
	if(sIgnoreFieldList==null){sIgnoreFieldList="";}
	for (var i=0;i>oForm.elements.length;i++) {
		var oElement=oForm.elements[i];
		if(!HAR.Data.isBlank(oElement.name)
				//&&!inList(oElement.type, 'submit,reset,button')
				&&!HAR.Data.inList(oElement.name, sIgnoreFieldList)) {
			if(HAR.Form.isChanged(oForm[oElement.name])) {
				return true;
				}
			}
		}
	return false;
	}
//----------------
HAR.Form.ForceRange = function(oField, iMin, iMax) {
  var iVal = oField.value;
	var isValid = 0;
  if (HAR.Data.isNumeric(iVal)) {
      if (iVal >= iMin && iVal <= iMax) {
        isValid = 1;
      }
	}
  if(isValid != 1) {
    alert('Value must be between\n'+iMin+' and ' + iMax);
    oField.focus;
	}

}


//expects json array of fieldname:error message
HAR.Form.formRequiredCheck = function(_jsn) {
	var aryErr = new Array();
	for ( var i in _jsn)
		if(HAR.Form.getFieldValue(i)=='')
			aryErr.push('    * ' + _jsn[i]);
	if(aryErr.length>0) {
		alert('The following required fields have not been entered:\n\n'+aryErr.join('\n'));
		return false;
		}
	return true;
}


/*================================================================*/
//resizes text area to size (cols, rows)
HAR.Form.TextareaResize = function(oTextarea, sSize) {
	var aSize = sSize.split(',');
	oTextarea.cols = aSize[0];
	oTextarea.rows = aSize[1]
}

/*================================================================*/

/*textarea must have maxlength=xxx as attribute
 if a valid counterfield is passed, it will display chars left
	onKeyDown="HAR.Form.TextareaLimit(this);"
	onFocus="HAR.Form.TextareaLimit(this);"
	onKeyUp="HAR.Form.TextareaLimit(this);"
	if there is a span with the same name followed by _len, it will reflect chars left
 */	
HAR.Form.TextareaLimit = function(oField) {
	if(!oField) oField=this;/*if passed by event */
	var iMaxLen = parseInt(oField.getAttribute('maxlength'), 10);
	if(isNaN(iMaxLen)) return false;
	if (oField.value.length > iMaxLen) // if too long, trim value
		oField.value = oField.value.substring(0, iMaxLen);
		// otherwise, update 'characters left' counter
	status = 'Characters Left: ' + (iMaxLen - oField.value.length);
	var oDisplayLeft = HAR.Dom.getRef(oField.name + '_len');
	if (oDisplayLeft) oDisplayLeft.innerHTML = iMaxLen - oField.value.length;		
}
/* adds event listeners to constrain size of all text areas */
/*
HAR.Form.TextAreaLimitSetup = function() {
	var _aTextarea=document.getElementsByTagName('textarea');
	for(var i=0, oField;i<_aTextarea.length;i++) {
		oField=_aTextarea[i];
		if(!isNaN(parseInt(oField.getAttribute('maxlength'), 10))) {
			HAR.Dom.addEvent(oField, 'keydown', HAR.Form.TextareaLimit(this));
			HAR.Dom.addEvent(oField, 'keyup', HAR.Form.TextareaLimit(this));
			HAR.Dom.addEvent(oField, 'focus', HAR.Form.TextareaLimit(this));
			HAR.Dom.addEvent(oField, 'blur', HAR.Form.TextareaLimit(this));											
			}
		}
	}
*/

HAR.Form.inputForceSSN = function(oThis) {
	var str=oThis.value;
	str=str.replace(/[^\d]/gi,'')
	var s1=str.substr(0,3),
		s2=str.substr(3,2),
		s3=str.substr(5,4);
	var sResult = s1;
	if(s2!='') sResult+='-'+s2
	if(s3!='') sResult+='-'+s3
	oThis.value=sResult;
	}


HAR.Form.inputForceTaxID = function(oThis) {
	var str=oThis.value;
	str=str.replace(/[^\d]/gi,'');
	var s1=str.substr(0,2),
		s2=str.substr(2,7);
	var sResult = s1;
	if(s2!='') sResult+='-'+s2
		oThis.value=sResult;
	}

HAR.Form.inputForceUsername = function(oThis) {
	var str=oThis.value.toLowerCase();
	str=str.replace(/[^A-Za-z0-9_.@]/gi,'')
	oThis.value=str;
	}


HAR.Form.selectedTextGet = function() {
    var txt = '';
     if (window.getSelection) {
        txt = window.getSelection();
             }
    else if (document.getSelection) {
        txt = document.getSelection();
            }
    else if (document.selection) {
        txt = document.selection.createRange().text;
            }
    else return;
	return txt
}


// ===================================================================
// Author: Matt Kruse <matt@mattkruse.com>
// WWW: http://www.mattkruse.com/
// ===================================================================
/*
DESCRIPTION: These are general functions to deal with and manipulate
select boxes. Also see the OptionTransfer library to more easily
handle transferring options between two lists

COMPATABILITY: These are fairly basic functions - they should work on
all browsers that support Javascript.
*/


// -------------------------------------------------------------------
// HAR.Form.formSelectHasOptions(oSelect)
//  Utility function to determine if a select object has an options array
// -------------------------------------------------------------------
HAR.Form.formSelectHasOptions = function(oSelect) {
	if (oSelect!=null && oSelect.options!=null) { return true; }
	return false;
	}

// -------------------------------------------------------------------
// HAR.Form.formSelectSelectUnselectMatchingOptions(select_object,regex,select/unselect,true/false)
//  This is a general function used by the select functions below, to
//  avoid code duplication
// -------------------------------------------------------------------
HAR.Form.formSelectSelectUnselectMatchingOptions = function(oSelect,regex,which,only) {
	if (window.RegExp) {
		if (which == "select") {
			var selected1=true;
			var selected2=false;
			}
		else if (which == "unselect") {
			var selected1=false;
			var selected2=true;
			}
		else {
			return;
			}
		var re = new RegExp(regex);
		if (!HAR.Form.formSelectHasOptions(oSelect)) { return; }
		for (var i=0; i<oSelect.options.length; i++) {
			if (re.test(oSelect.options[i].text)) {
				oSelect.options[i].selected = selected1;
				}
			else {
				if (only == true) {
					oSelect.options[i].selected = selected2;
					}
				}
			}
		}
	}
		
// -------------------------------------------------------------------
// HAR.Form.formSelectSelectMatchingOptions(select_object,regex)
//  This function selects all options that match the regular expression
//  passed in. Currently-selected options will not be changed.
// -------------------------------------------------------------------
HAR.Form.formSelectSelectMatchingOptions = function(oSelect,regex) {
	HAR.Form.formSelectSelectUnselectMatchingOptions(oSelect,regex,"select",false);
	}
// -------------------------------------------------------------------
// HAR.Form.formSelectSelectOnlyMatchingOptions(select_object,regex)
//  This function selects all options that match the regular expression
//  passed in. Selected options that don't match will be un-selected.
// -------------------------------------------------------------------
HAR.Form.formSelectSelectOnlyMatchingOptions = function(oSelect,regex) {
	HAR.Form.formSelectSelectUnselectMatchingOptions(oSelect,regex,"select",true);
	}
// -------------------------------------------------------------------
// HAR.Form.formSelectUnselectMatchingOptions(select_object,regex)
//  This function Unselects all options that match the regular expression
//  passed in.
// -------------------------------------------------------------------
HAR.Form.formSelectUnselectMatchingOptions = function(oSelect,regex) {
	HAR.Form.formSelectSelectUnselectMatchingOptions(oSelect,regex,"unselect",false);
	}
	
// -------------------------------------------------------------------
// HAR.Form.formSelectSortSelect(select_object)
//   Pass this function a SELECT object and the options will be sorted
//   by their text (display) values
// -------------------------------------------------------------------
HAR.Form.formSelectSortSelect = function(oSelect) {
	var o = new Array();
	if (!HAR.Form.formSelectHasOptions(oSelect)) { return; }
	for (var i=0; i<oSelect.options.length; i++) {
		o[o.length] = new Option( oSelect.options[i].text, oSelect.options[i].value, oSelect.options[i].defaultSelected, oSelect.options[i].selected) ;
		}
	if (o.length==0) { return; }
	o = o.sort(
		function(a,b) {
			if ((a.text+"") < (b.text+"")) { return -1; }
			if ((a.text+"") > (b.text+"")) { return 1; }
			return 0;
			}
		);

	for (var i=0; i<o.length; i++) {
		oSelect.options[i] = new Option(o[i].text, o[i].value, o[i].defaultSelected, o[i].selected);
		}
	}

// -------------------------------------------------------------------
// HAR.Form.formSelectSelectAllOptions(select_object)
//  This function takes a select box and selects all options (in a
//  multiple select object). This is used when passing values between
//  two select boxes. Select all options in the right box before
//  submitting the form so the values will be sent to the server.
// -------------------------------------------------------------------
HAR.Form.formSelectSelectAllOptions = function(oSelect) {
	if (!HAR.Form.formSelectHasOptions(oSelect)) { return; }
	for (var i=0; i<oSelect.options.length; i++) {
		oSelect.options[i].selected = true;
		}
	}
	
// -------------------------------------------------------------------
// HAR.Form.formSelectMoveSelectedOptions(select_object,select_object[,autosort(true/false)[,regex]])
//  This function moves options between select boxes. Works best with
//  multi-select boxes to create the common Windows control effect.
//  Passes all selected values from the first object to the second
//  object and re-sorts each box.
//  If a third argument of 'false' is passed, then the lists are not
//  sorted after the move.
//  If a fourth string argument is passed, this will function as a
//  Regular Expression to match against the TEXT or the options. If
//  the text of an option matches the pattern, it will NOT be moved.
//  It will be treated as an unmoveable option.
//  You can also put this into the <SELECT> object as follows:
//    onDblClick="HAR.Form.formSelectMoveSelectedOptions(this,this.form.target)
//  This way, when the user double-clicks on a value in one box, it
//  will be transferred to the other (in browsers that support the
//  onDblClick() event handler).
// -------------------------------------------------------------------
HAR.Form.formSelectMoveSelectedOptions = function(oSelectFrom,oSelectTo) {
	// Unselect matching options, if required
	if (arguments.length>3) {
		var regex = arguments[3];
		if (regex != "") {
			HAR.Form.formSelectUnselectMatchingOptions(oSelectFrom,regex);
			}
		}
	// Move them over
	if (!HAR.Form.formSelectHasOptions(oSelectFrom)) { return; }
	for (var i=0; i<oSelectFrom.options.length; i++) {
		var o = oSelectFrom.options[i];
		if (o.selected) {
			if (!HAR.Form.formSelectHasOptions(oSelectTo)) { var index = 0; } else { var index=oSelectTo.options.length; }
			oSelectTo.options[index] = new Option( o.text, o.value, false, false);
			}
		}
	// Delete them from original
	for (var i=(oSelectFrom.options.length-1); i>=0; i--) {
		var o = oSelectFrom.options[i];
		if (o.selected) {
			oSelectFrom.options[i] = null;
			}
		}
	if ((arguments.length<3) || (arguments[2]==true)) {
		HAR.Form.formSelectSortSelect(oSelectFrom);
		HAR.Form.formSelectSortSelect(oSelectTo);
		}
	oSelectFrom.selectedIndex = -1;
	oSelectTo.selectedIndex = -1;
	}

//---MBH----
//order is comma delimited list
HAR.Form.formSelectCopySuppliedOptions = function(oSelectFrom, oSelectTo, sOrder) {
	var aryOrder = sOrder.split(',');
	for(i=0; i<aryOrder.length; i++) {
	HAR.Form.formSelectSelectOnlyMatchingOptions(oSelectFrom, aryOrder[i]);
	HAR.Form.formSelectCopySelectedOptions(oSelectFrom, oSelectTo, false);
	}
}

//sOptionList is comma delimited list
HAR.Form.formSelectMoveSuppliedOptions = function(oSelectFrom, oSelectTo, sOptionList) {
	var aryOptionList = sOptionList.split(',');
	for(i=0; i<aryOptionList.length; i++) {
	HAR.Form.formSelectSelectOnlyMatchingOptions(oSelectFrom, '^' + aryOptionList[i] );
	HAR.Form.formSelectMoveSelectedOptions(oSelectFrom, oSelectTo, false);
	}
}
// -------------------------------------------------------------------
// HAR.Form.formSelectCopySelectedOptions(select_object,select_object[,autosort(true/false)])
//  This function copies options between select boxes instead of
//  moving items. Duplicates in the target list are not allowed.
// -------------------------------------------------------------------
HAR.Form.formSelectCopySelectedOptions = function(oSelectFrom,oSelectTo) {
	var options = new Object();
	if (HAR.Form.formSelectHasOptions(oSelectTo)) {
		for (var i=0; i<oSelectTo.options.length; i++) {
			options[oSelectTo.options[i].value] = oSelectTo.options[i].text;
			}
		}

	if (!HAR.Form.formSelectHasOptions(oSelectFrom)) { return; }
	for (var i=0; i<oSelectFrom.options.length; i++) {
		var o = oSelectFrom.options[i];
		if (o.selected) {
			if (options[o.value] == null || options[o.value] == "undefined" || options[o.value]!=o.text) {
				if (!HAR.Form.formSelectHasOptions(oSelectTo)) { var index = 0; } else { var index=oSelectTo.options.length; }
				oSelectTo.options[index] = new Option( o.text, o.value, false, false);
				}
			}
		}
	if ((arguments.length<3) || (arguments[2]==true)) {
		HAR.Form.formSelectSortSelect(oSelectTo);
		}
	oSelectFrom.selectedIndex = -1;
	oSelectTo.selectedIndex = -1;
	}

// -------------------------------------------------------------------
// HAR.Form.formSelectMoveAllOptions(select_object,select_object[,autosort(true/false)[,regex]])
//  Move all options from one select box to another.
// -------------------------------------------------------------------
HAR.Form.formSelectMoveAllOptions = function(oSelectFrom,oSelectTo) {
	HAR.Form.formSelectSelectAllOptions(oSelectFrom);
	if (arguments.length==2) {
		HAR.Form.formSelectMoveSelectedOptions(oSelectFrom,oSelectTo);
		}
	else if (arguments.length==3) {
		HAR.Form.formSelectMoveSelectedOptions(oSelectFrom,oSelectTo,arguments[2]);
		}
	else if (arguments.length==4) {
		HAR.Form.formSelectMoveSelectedOptions(oSelectFrom,oSelectTo,arguments[2],arguments[3]);
		}
	}

// -------------------------------------------------------------------
// HAR.Form.formSelectCopyAllOptions(select_object,select_object[,autosort(true/false)])
//  Copy all options from one select box to another, instead of
//  removing items. Duplicates in the target list are not allowed.
// -------------------------------------------------------------------
HAR.Form.formSelectCopyAllOptions = function(oSelectFrom,oSelectTo) {
	HAR.Form.formSelectSelectAllOptions(oSelectFrom);
	if (arguments.length==2) {
		HAR.Form.formSelectCopySelectedOptions(oSelectFrom,oSelectTo);
		}
	else if (arguments.length==3) {
		HAR.Form.formSelectCopySelectedOptions(oSelectFrom,oSelectTo,arguments[2]);
		}
	}

// -------------------------------------------------------------------
// HAR.Form.formSelectSwapOptions(select_object,option1,option2)
//  Swap positions of two options in a select list
// -------------------------------------------------------------------
HAR.Form.formSelectSwapOptions = function(oSelect,i,j) {
	var o = oSelect.options;
	var i_selected = o[i].selected;
	var j_selected = o[j].selected;
	var temp = new Option(o[i].text, o[i].value, o[i].defaultSelected, o[i].selected);
	var temp2= new Option(o[j].text, o[j].value, o[j].defaultSelected, o[j].selected);
	o[i] = temp2;
	o[j] = temp;
	o[i].selected = j_selected;
	o[j].selected = i_selected;
	}
	
// -------------------------------------------------------------------
// HAR.Form.formSelectMoveOptionUp(select_object)
//  Move selected option in a select list up one
// -------------------------------------------------------------------
HAR.Form.formSelectMoveOptionUp = function(oSelect) {
	if (!HAR.Form.formSelectHasOptions(oSelect)) { return; }
	for (i=0; i<oSelect.options.length; i++) {
		if (oSelect.options[i].selected) {
			if (i != 0 && !oSelect.options[i-1].selected) {
				HAR.Form.formSelectSwapOptions(oSelect,i,i-1);
				oSelect.options[i-1].selected = true;
				}
			}
		}
	}

// -------------------------------------------------------------------
// HAR.Form.formSelectMoveOptionDown(select_object)
//  Move selected option in a select list down one
// -------------------------------------------------------------------
HAR.Form.formSelectMoveOptionDown = function(oSelect) {
	if (!HAR.Form.formSelectHasOptions(oSelect)) { return; }
	for (i=oSelect.options.length-1; i>=0; i--) {
		if (oSelect.options[i].selected) {
			if (i != (oSelect.options.length-1) && ! oSelect.options[i+1].selected) {
				HAR.Form.formSelectSwapOptions(oSelect,i,i+1);
				oSelect.options[i+1].selected = true;
				}
			}
		}
	}

// -------------------------------------------------------------------
// HAR.Form.formSelectRemoveSelectedOptions(select_object)
//  Remove all selected options from a list
//  (Thanks to Gene Ninestein)
// -------------------------------------------------------------------
HAR.Form.formSelectRemoveSelectedOptions = function(oSelectFrom) {
	if (!HAR.Form.formSelectHasOptions(oSelectFrom)) { return; }
	for (var i=(oSelectFrom.options.length-1); i>=0; i--) {
		var o=oSelectFrom.options[i];
		if (o.selected) {
			oSelectFrom.options[i] = null;
			}
		}
	oSelectFrom.selectedIndex = -1;
	}

// -------------------------------------------------------------------
// HAR.Form.formSelectRemoveAllOptions(select_object)
//  Remove all options from a list
// -------------------------------------------------------------------
HAR.Form.formSelectRemoveAllOptions = function(oSelectFrom) {
	if (!HAR.Form.formSelectHasOptions(oSelectFrom)) { return; }
	for (var i=(oSelectFrom.options.length-1); i>=0; i--) {
		oSelectFrom.options[i] = null;
		}
	oSelectFrom.selectedIndex = -1;
	}

// -------------------------------------------------------------------
// HAR.FormformSelectAddOption(select_object,display_text,value,selected)
//  Add an option to a list
// -------------------------------------------------------------------
HAR.Form.formSelectAddOption = function(oSelect,text,value,selected) {
	if (oSelect!=null && oSelect.options!=null) {
		oSelect.options[oSelect.options.length] = new Option(text, value, false, selected);
		}
	}

HAR.Form.formSelectAddSuppliedOptions = function(oSelect, sList) {
	var aryList = sList.split(',');
	for(i=0; i<aryList.length; i++) {
		HAR.Form.formSelectAddOption(oSelect, aryList[i], aryList[i], false);
		}
}

/*all text fields in form not readonly are changed to title case */
HAR.Form.TitleCaseTextFields = function(sFormName) {
	var oForm;
	if(!sFormName) oForm=document.forms[0];
	else oForm=document.forms[sFormName];
	var oText=oForm.getElementsByTagName('input');
	for(var i=0,oThis;i<oText.length;i++) {
		oThis=oText[i];
		if(!oThis.readOnly)
			oThis.value=HAR.Data.TitleCase(oThis.value);
	};
}

HAR.Form.CheckboxCheckAll = function (sCheckboxName, blnCheck) {
	var aChk=document.getElementsByName(sCheckboxName);
	for(var i=0;i<aChk.length;i++)
		aChk[i].checked=blnCheck;
	}

HAR.Form.Serialize=function (fobj) {
	if(typeof(fobj)=='string') fobj=document.forms[fobj];
	var str = "", _elementTitle = "", _thisValue = "", _thisName = "", _thisElement = "";
	for(var i = 0;i < fobj.elements.length;i++) {
		_thisElement = fobj.elements[i];
		_elementTitle = _thisElement.title;
		_thisValue = _thisElement.value;
		_thisName = _thisElement.name;
		switch(_thisElement.type) {
			case "text":
			case "hidden":
			case "password":
			case "textarea":
				str += _thisName + "=" + encodeURI(_thisValue) + "&";
				break;
		case "checkbox":
		case "radio":
			if(_thisElement.checked) str += _thisName + "=" + encodeURI(_thisValue) + "&";
			break;
		case "select-one":
			str += _thisName + "=" +
			_thisElement.options[_thisElement.selectedIndex].value + "&";
			break;
			} // switch
		} // for
		str = str.substr(0,(str.length - 1));
		return str;
	}
	
HAR.Form.FormInputTrimAll = function(oForm) {
	if(typeof(oForm)=='string') oForm=document.forms[oForm];
	var oInputs=oForm.getElementsByTagName('input');
	for(var i=0;i<oInputs.length;i++) {
		if(oInputs[i].type!='text') continue;
		if(oInputs[i].getAttribute('readonly')!='readonly') {
			oInputs[i].value=HAR.Data.Trim(oInputs[i].value);
			}
		}
	oInputs=oForm.getElementsByTagName('textarea');
	for(var i=0;i<oInputs.length;i++) {
		if(oInputs[i].getAttribute('readonly')!='readonly') {
			oInputs[i].value=HAR.Data.Trim(oInputs[i].value);
			}
		}
	}
	
HAR.Form.AJAX = function (strURL, strQueryString, oFunction) {
    var xmlHttpReq = false;
    var self = this;
    // Mozilla/Safari
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open('POST', strURL, true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function() {
        if (self.xmlHttpReq.readyState == 4) {
            oFunction(self.xmlHttpReq.responseText);
        }
    }
    self.xmlHttpReq.send(strQueryString);
}

/* ================================================ */
/* returns object of name/value pairs based on
    name=ID,name2=ID */
HAR.Form.collectFormValues = function (sParamString) {
	var retval={};
	var aPS=sParamString.split(",");
	for(i in aPS) {
	aThisVal=aPS[i].split('=');
	if(aThisVal[1]==undefined) aThisVal[1]=aThisVal[0];
	retval[aThisVal[0]]=HAR.Form.getInputValue(aThisVal[1]);
		}
	return retval
}

/* turns object into querystring name/value pairs */
HAR.Form.JSONtoQS = function paramsToQS(obj) {
	var aRet=[];
	for(i in obj) {
		aRet.push(i+'='+escape(obj[i]))
		}
	var ret=aRet.join('&');
	return ret;
	}

/* returns querystring of name/value pairs based on
    name=ID,name2=ID */
HAR.Form.collectFormValuesQS = function (s) {
	return HAR.Form.JSONtoQS(HAR.Form.collectFormValues(s))
}
