<!--//

////////////////////////////////////////////////////////////////////
// Management Team
////////////////////////////////////////////////////////////////////
function onChangeMgmtTeam(frm,cboSelect,txtID, txtFirstName, txtLastName, txtTitle) {
	if(cboSelect == null) return true;
    var intCurrent = cboSelect.selectedIndex;
	var strItem = cboSelect.options[intCurrent].text;
	var strFirst;
	var strLast;
	var strTitle;
	var intPipe;
	
	// Starting item value
	//alert('strItem = ' + strItem);

	// Locate the first pipe
	intPipe = strItem.indexOf('|');
	//alert('First Pipe = ' + intPipe);
	
	// Assign the First Name value
	strFirst = strItem.substring(0,intPipe -1);
	//alert('First Name = ' + strFirst );

	// 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
	strLast = strItem.substring(0,intPipe -1);
	//alert('Last Name = ' + strLast );

	// Reduce the string
	strItem = strItem.substring(intPipe + 1,strItem.length);	
	//alert('strItem = ' + strItem);

	// Assign the Title value
	strTitle = strItem = strItem.substring(0,strItem.length);
	//alert('Title = ' + strTitle );
	
	// Asssign the values to the fields
	txtID.value = intCurrent;
	txtFirstName.value = strFirst.trim();
   	txtLastName.value = strLast.trim();
	txtTitle.value = strTitle.trim();	
	// Deselect the item
	cboSelect.selectedIndex = -1;
	
	return true;
}

function addMgmtOption(cboSelect,txtID, txtFirstName, txtLastName, txtTitle, blnClear) {
    var defaultSelected = true;
    var selected = false;
	
	// Exit if missing entries
	if(txtFirstName.value == '' || txtLastName.value == '' ||  txtTitle.value == '') return false;
	
	var strValue = txtFirstName.value + ' | ' + txtLastName.value  + ' | ' + txtTitle.value;
	var length = cboSelect.length;
	
	//alert('cboSelect.length =' + cboSelect.length);
	
	var intOption0;
	var strOption0 = '';
	if(length > 0)
		strOption0 = cboSelect.options[0].text;
	
	strOption0 = trim3(strOption0);
	strOption0.replace('nbsp;','');
	strOption0.replace(/\s/g,"");
	
	//alert('strOption0 = ' + strOption0);
	
	if(length > 0 && strOption0 != '') 
		intOption0 = cboSelect.options[0].value;
	else
		intOption0 = 1000;
	
	//alert ('strValue = ' + strValue);

	//alert('Option 0 =' + cboSelect.options[0].text);
	//alert('Index = ' + intOption0 );

	// Enable the ability to replace the first entry
	if(intOption0  == 1000) {
		length = 0;	
		txtID.value = '';
	}
	// 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 (txtID.value == '') {
		var optionName = new Option(strValue, length, defaultSelected, selected)	
    		cboSelect.options[length] = optionName;
	}else{
		var intIndex = txtID.value;
		cboSelect.options[intIndex].text = strValue;

	}
	// 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
	txtID.value = '';
	if(blnClear){
		
		txtFirstName.value = ''; 
		txtLastName.value = ''; 
		txtTitle.value = '';
	}
	cboSelect.selectedIndex = -1;
	
	return true;
}

function removeMgmtOption(cboSelect,txtID, txtFirstName, txtLastName, txtTitle, blnClear) {


    	
	if (txtID.value != '') {
		
		var intIndex = txtID.value;
		cboSelect.options[intIndex] = null;
		
		txtID.value = '';
		if(blnClear){
			
			txtFirstName.value = ''; 
			txtLastName.value = ''; 
			txtTitle.value = '';
		}
	}

}
function storeMgmt(cboSelect){
	var strMgmt = '';
	for(var x = 0; x < cboSelect.options.length; x++){
		if(strMgmt != '' ) strMgmt = strMgmt + '^';
		// Don't store the default entry
		if(cboSelect.options[x].value != 1000) strMgmt = strMgmt + cboSelect.options[x].text;
	}
	$('MgmtList').value = strMgmt;
}

function setIsMgmt(chkIsMgmt,frm,txtID, txtFirst, txtLast, txtTitle, cboSelect) {
    	//alert('chkIsMgmt = ' + chkIsMgmt.checked);
	if (chkIsMgmt.checked) {
		// Copy the values into the management team list
		
		//alert('First  = ' + txtFirst.value);
		//alert('Last  = ' + txtLast.value);
		//alert('Title  = ' + txtTitle.value);

		txtID.value = '';
		addOption (cboSelect, txtID, txtFirst, txtLast, txtTitle,false);		
	}else{
		// Search for the matching index
		txtID.value = findEntry(cboSelect, txtFirst, txtLast, txtTitle);
		// Remove the entry
		if(txtID.value != -1)
			removeOption(cboSelect,txtID, txtFirst, txtLast, txtTitle,false);
	}
}

function clearMgmtOption(txtID,txtFirst, txtLast, txtTitle ){
	txtID.value = '';
	txtFirst.value = '';
	txtLast.value = '';
	txtTitle.value = ''; 
}


//-->
