<!--//
function onChangeAssetClass(frm,cboSelect,txtClassID, cboAssetClass, cboAssetSubClassH,cboAssetSubClassFilter) {
    var intCurrent = cboSelect.selectedIndex;
	var strItem = cboSelect.options[intCurrent].text;
	var intItemValue = cboSelect.options[intCurrent].value
	var strClass;
	var strSubClass;
	var intPipe;
	
	// Starting item value	
	//alert('intCurrent = ' + intCurrent + ' intItemValue = ' + intItemValue + ' strItem = ' + strItem);

	// Locate the first pipe
	intPipe = strItem.indexOf('|');
	//alert('First Pipe = ' + intPipe);
	
	// Assign the First Name value
	strClass = strItem.substring(0,intPipe -1);
	//alert('strClass = ' + strClass );

	// Reduce the string
	strItem = strItem.substring(intPipe + 1,strItem.length);
	//alert('strItem = ' + strItem);

	// Locate the next pipe
	intPipe = strItem.indexOf('|');

	// Assign the Last Name value
	strSubClass = strItem = strItem.substring(1,strItem.length);
	//alert('strSubClass = ' + strSubClass );

		
	// Asssign the values to the fields
	txtClassID.value = intItemValue;
	findDDEntryByText(cboAssetClass,strClass);
	FilterSubList(cboAssetClass,cboAssetSubClassH,cboAssetSubClassFilter, true)
	findDDEntryByText (cboAssetSubClassFilter,strSubClass);	
	
	// Deselect the item
	cboSelect.selectedIndex = -1;
}

function addAssetClassOption(cboAssetClassList, txtClassID, cboAssetClass, cboAssetSubClassFilter, blnClear) {


    var defaultSelected = true;
    var selected = false;
	var intCurrentClass = cboAssetClass.selectedIndex;
	var intCurrentSubClass = cboAssetSubClassFilter.selectedIndex;

	// Exit is missing values
	if(intCurrentClass < 0 || intCurrentSubClass  < 0) return true;
	
	var strValue = cboAssetClass.options[intCurrentClass].text + ' | ' + cboAssetSubClassFilter.options[intCurrentSubClass].text;
	var length = cboAssetClassList.length;
	
	var strOption0;
	if(cboAssetClassList.length > 0) 
		strOption0 = cboAssetClassList.options[0].value;
	else
		strOption0 = 1000;
	
	//alert ('strValue = ' + strValue);

	//alert('Option 0 =' + cboSelect.options[0].text);
	//alert('s = ' + strOption0 );

	// Enable the ability to replace the first entry
	if(strOption0  == 1000) length = 0;

	// Create a new option if there are not any or
	// if we entered new information
	// Update an existing option if we had an ID	
	//alert('txtID = ' + txtID.value);
	if(txtClassID.value == '') txtClassID.value = 0;	
	if (txtClassID.value == 0) {
		var optionName = new Option(strValue, length, defaultSelected, selected);	
    	cboAssetClassList.options[length] = optionName;
		cboAssetClassList.options[length].value = 'C' +cboAssetClass.options[intCurrentClass].value + 'S' +  cboAssetSubClassFilter.options[intCurrentSubClass].value; 
		// Add entries to global variables
		addUpdGlobalEntryAssetClass(strValue,cboAssetClass.options[intCurrentClass].value,cboAssetSubClassFilter.options[intCurrentSubClass].value);
		

	}else{
		var intIndex = findDDEntryByValue(cboAssetClassList,txtClassID.value);
		cboAssetClassList.options[intIndex].text = strValue;
		// Update entries to global variables
		addUpdGlobalEntryAssetClass(strValue,cboAssetClass.options[intCurrentClass].value,cboAssetSubClassFilter.options[intCurrentSubClass].value);
	}
	
	// Since we will reuse this same function in different areas, we don't 
	// always want the source fields cleared; however, we should always clear
	// the ID
	txtClassID.value = '';
	if(blnClear){
		
		cboAssetClass.options[0].selected = true; 
		removeAll(cboAssetSubClassFilter);
		
	}

	// Unselect any highlighted items
	cboAssetClassList.selectedIndex = -1;
	
	return true;
	
}

function removeAssetClassOption(cboAssetClassList, txtClassID, cboAssetClass, cboAssetSubClassFilter,  blnClear) {

	if(txtClassID.value == '') txtClassID.value = 0;
    	
	if (txtClassID.value != 0) {
		//alert('removing txtID.value = ' + txtID.value);
		var intIndex = findDDEntryByValue(cboAssetClassList,txtClassID.value);
		cboAssetClassList.options[intIndex] = null;
		
		
		removeGlobalEntryInvProps(txtClassID.value);
		
		// Clear values
		txtClassID.value = 0;
		if(blnClear){
			cboAssetClass.options[0].selected = true; 
			removeAll(cboAssetSubClassFilter);
		}
		
	}

}

function addUpdGlobalEntryAssetClass(strText, intClassID, intSubClassID){
	// add / update entries to global variables
	var blnFound = false;
	
	//alert('Text = ' + strText + ' ID = ' + intID + ' Qty = ' + intQty);
	if(intClassID > 0){
		// Lookup the matching entry
		for (var x = 0; x < m_intAssetClassIndex; x++){
			if(m_intAssetClassID[x] == 'C'+intClassID+'S'+intSubClassID)  {
				blnFound = true;
				// Assign new values
				m_strAssetClassText[x] = strText;
				m_intAssetSubClassID[x] = intSubClassID;
				break;
			}
		}
	}
	// Add a new entry if either the ID = 0 or we did not find the entry
	if(!(blnFound)){
		// Assign a new entry
		m_strAssetClassText[m_intAssetClassIndex] = strText;
		m_intAssetClassID[m_intAssetClassIndex] = 'C'+intClassID+'S'+intSubClassID;
		m_intAssetSubClassID[m_intAssetClassIndex] = intSubClassID;
	}
	
	
	// Increment Index
	m_intAssetClassIndex += 1;
}
function removeGlobalEntryAssetClass(intClassSubClassComboID){
	// remove entries to global variables
	// and shift all values
	var blnFound = false;
	for (var x = 0; x < m_intAssetClassIndex; x++){
		//alert('test: m_intInvPropsID[x] = ' + m_intInvPropsID[x]  + ' ID = ' + intID); 
		if(m_intAssetClassID[x] == intClassSubClassComboID) blnFound = true;
		if(blnFound) {
			// Do shifting
			// If we have reached the max of the array then just clear all values
			if(x == 300) {
				m_strAssetClassText[x] = '';
				m_intAssetClassID[x] = 0;
				m_intAssetSubClassID[x] = 0;

			}else{
				m_strAssetClassText[x] = m_strAssetClassText[x+1];
				m_intAssetClassID[x] = m_intAssetClassID[x+1];
				m_intAssetSubClassID[x] = m_intAssetSubClassID[x+1];
			}
		}
	}		
	// decrement counter
	m_intAssetClassIndex -= 1;
}

//-->