
//============================================================================================================================
	function formReset(thisForm){
		for(var i=0; i<thisForm.elements.length; i++){
			var j = thisForm.elements[i];
			switch(j.tagName){
				case 'INPUT' :
					if(j.type=='text') j.value='';
					break;
				case 'SELECT' :
					j.selectedIndex=0;
					break;
			}
		}
	}



//============================================================================================================================
// Category Entry Form Scripts
//============================================================================================================================

	var catFromSubCatIndex, subCatFromCatIndex;
	//var catOptionTextArray, catOptionValueArray;
	//var subCatOptionTextArray, subCatOptionValueArray;
	
//============================================================================================================================
// Address Entry Form Scripts
//============================================================================================================================
	var cntryFromStateIndex, stateFromCntryIndex;		
	//var cntryOptionTextArray, cntryOptionValueArray;
	//var stateOptionTextArray, stateOptionValueArray;	

//============================================================================================================================
	function addOptions(thisObj, optionsValue, optionsText, isOptional){
	
		var idSelected, tmpOption;
//alert(typeof(thisObj.selectedIndex));
//alert(thisObj.selectedIndex);
		if(typeof(thisObj.options)!='undefined') {
			//if(thisObj.selectedIndex<0)
			idSelected = thisObj.options[thisObj.selectedIndex].value;
			thisObj.options.length = 0;
		} else {
			idSelected = '';
		}

		if(isOptional){
			tmpOption = document.createElement("OPTION");
			tmpOption.text = 'N/A';
			tmpOption.value = '';
			thisObj.options.add(tmpOption);
		}
		for(var i=0; i<optionsValue.length; i++){
			tmpOption = document.createElement("OPTION");
			tmpOption.text = optionsText[i];
			tmpOption.value = optionsValue[i];
			thisObj.options.add(tmpOption);
			if(optionsValue[i].toString()==idSelected.toString()) {
				tmpOption.selected = true;
			}
		};
		
	
	}
	
	
//============================================================================================================================
	function addSubOptions(thisObj, optionsValue, optionsText, isOptional){
	
		var idSelected, tmpOption;
		if(typeof(thisObj.options)!='undefined') {
			idSelected = thisObj.options[thisObj.selectedIndex].value;
			thisObj.options.length = 0;
		} else {
			idSelected = '';
		}
		
		if(isOptional){
			tmpOption = document.createElement("OPTION");
			tmpOption.text = 'N/A';
			tmpOption.value = '';
			thisObj.options.add(tmpOption);
		}
		for(var i=0; i<optionsValue.length; i++){
			tmpOption = document.createElement("OPTION");
			if(optionsValue[i].toString()!='') {
				tmpOption.text = '  ';
			} else {
				tmpOption.text = '';
				tmpOption.style.color='#808080';
			}
			tmpOption.text = tmpOption.text + optionsText[i];
			tmpOption.value = optionsValue[i];
			thisObj.options.add(tmpOption);
			if(optionsValue[i].toString()==idSelected.toString()) {
				tmpOption.selected = true;
			}
		}
	
	}
	
	
//============================================================================================================================


//============================================================================================================================
// Category Entry Form Scripts
//============================================================================================================================

//============================================================================================================================
	function SubCategory_OnFocus(thisObj){
		if(thisObj.selectedIndex==0) {
			getSubCategoryFromCategory(thisObj.form.Cat_ID);
		}
	}

//============================================================================================================================
	function category_SubCategory_OnChange(thisObj){
		if(typeof(thisObj.form.Cat_Name)!='undefined')thisObj.form.Cat_Name.value=thisObj.form.Cat_ID.options[thisObj.selectedIndex].text;
		if(typeof(thisObj.form.SubCat_Name)!='undefined')thisObj.form.SubCat_Name.value=thisObj.form.SubCat_ID.options[thisObj.selectedIndex].text;
	}
	
//============================================================================================================================
	function getSubCategoryFromCategory(thisSubCatObj, thisCatObj){
		thisSubCatObj.selectedIndex=subCatFromCatIndex[thisCatObj.selectedIndex];
		//category_SubCategory_OnChange(thisObj);
	}
	
//============================================================================================================================
	function getCategoryFromSubCategory(thisCatObj, thisSubCatObj){
		if(thisSubCatObj.selectedIndex>0)	thisCatObj.selectedIndex=catFromSubCatIndex[thisSubCatObj.selectedIndex];
		//category_SubCategory_OnChange(thisObj);
	}

//============================================================================================================================
	function addCatOptions(thisObj){
//alert('thisObj.name=' + thisObj.name + '\ncatOptionValueArray.length=' + catOptionValueArray.length + '\ncatOptionTextArray.length=' + catOptionTextArray.length);
		addOptions(thisObj, catOptionValueArray, catOptionTextArray, false);
	}
		
//============================================================================================================================
	function addSubCatOptions(thisObj){
		addSubOptions(thisObj, subCatOptionValueArray, subCatOptionTextArray, true);
	}

//============================================================================================================================


//============================================================================================================================
// Address Entry Form Scripts
//============================================================================================================================

//============================================================================================================================
	function country_State_OnChange(thisObj){
		if(typeof(thisObj.form.Cntry_Name)!='undefined')thisObj.form.Cntry_Name.value=thisObj.form.Cntry_ID.options[thisObj.selectedIndex].text;
		if(typeof(thisObj.form.State_Name)!='undefined')thisObj.form.State_Name.value=thisObj.form.State_ID.options[thisObj.selectedIndex].text;
	}
	
//============================================================================================================================
	function getStateFromCountry(thisStateObj, thisCountryObj){
		thisStateObj.selectedIndex=stateFromCntryIndex[thisCountryObj.selectedIndex];
		//country_State_OnChange(thisObj);
	}
	
//============================================================================================================================
	function getCountryFromState(thisCountryObj, thisStateObj){
		if(thisStateObj.selectedIndex>0)	thisCountryObj.selectedIndex=cntryFromStateIndex[thisStateObj.selectedIndex];
		//country_State_OnChange(thisObj);
	}

//============================================================================================================================
	function State_OnFocus(thisObj){
		if(thisObj.selectedIndex==0) {
			getStateFromCountry(thisObj.form.Cntry_ID);
		}
	}

//============================================================================================================================
	function addCntryOptions(thisObj){
		addOptions(thisObj, cntryOptionValueArray, cntryOptionTextArray, false)
	}
	
//============================================================================================================================
	function addStateOptions(thisObj){
		addSubOptions(thisObj, stateOptionValueArray, stateOptionTextArray, true)
	}
	


