<!--//

////////////////////////////////////////////////////////////////////
// Contact Communcations List
////////////////////////////////////////////////////////////////////
function onChangeContactComm(frm,cboSelect,txtID, cboContactType,txtContactEntry, txtExt, txtContactTypeID) {
	if(cboSelect == null) return;
    var intCurrent = cboSelect.selectedIndex;
	var strContactComm = cboSelect.options[intCurrent].text;
	var intCurrentCommID = cboSelect.options[intCurrent].value;
	var strPhone, strExt;
	
	strContactComm = strContactComm.split('x');
		strPhone = strContactComm[0];
	if(strContactComm.length > 0)
		strExt = strContactComm[1];
		
	// Asssign the values to the fields
	txtID.value = intCurrent;
	//txtContactEntry.value = strContactComm.trim();
	txtContactEntry.value = strPhone.trim();
	txtExt.value = strExt.trim();
	
	findDDEntryByValue(cboContactType,txtContactTypeID.value);

	// Deselect the item
	cboSelect.selectedIndex = -1;
}

function addContactCommOption(txtID, cboContactType, txtContactEntry, txtExt, blnClear) {
    var defaultSelected = true;
    var selected = false;
	
	
	// Exit if missing entries
	if(txtContactEntry.value == '' ) return  true;
	if(cboContactType.selectedIndex <= 0) return  true;
	
	var strValue = txtContactEntry.value ;
	var intType = cboContactType.options[cboContactType.selectedIndex].value;
	if(txtExt.value != '') strValue += 'x' + txtExt.value;
	
	var cboSelect = null;
	switch (intType){
		case "1": // Phone
			cboSelect = $('cboPhoneList');
			
			break;
		case "2": // Fax
			cboSelect = $('cboFaxList');
			break;
		case "3": // Email
			cboSelect = $('cboEmailList');
			break;
	}
	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){
		
		txtContactEntry.value = ''; 
		txtExt.value = '';
	}
	cboSelect.selectedIndex = -1;
	
	return true;
}

function removeContactCommOption(txtID, cboContactType, txtContactEntry, txtExt, blnClear) {

	var intType = cboContactType.options[cboContactType.selectedIndex].value;
	
	var cboSelect = null;
	switch  (intType){
		case "1": // Phone
			cboSelect = $('cboPhoneList');
			
			break;
		case "2": // Fax
			cboSelect = $('cboFaxList');
			break;
		case "3": // Email
			cboSelect = $('cboEmailList');
			break;
	}
    	
	if (txtID.value != '') {
		
		var intIndex = txtID.value;
		cboSelect.options[intIndex] = null;
		
		txtID.value = '';
		if(blnClear){
			
			txtContactEntry.value = ''; 
			txtExt.value='';
		}
	}

}
function storeContactComm(){
	var strContactComm = '';
	
	//alert('Storing affiliates...');
	for(var intType = 1; intType < 4; intType++){
		var cboSelect  =  null;
		switch  (intType){
			case 1: // Phone
				cboSelect = $('cboPhoneList');				
				break;
			case 2: // Fax
				cboSelect = $('cboFaxList');
				break;
			case 3: // Email
				cboSelect = $('cboEmailList');
				break;
		}
		// Ensure we found a valid match
		if(cboSelect  ==  null) break;
		
		for(var x = 0; x < cboSelect.options.length; x++){
			//alert('Type=' + intType + ' x=' + x);
			if(strContactComm != '' ) strContactComm +=  '!';
			// Don't store the default entry			
			if(cboSelect.options[x].value != 1000) strContactComm +=  intType + '!' + cboSelect.options[x].text;
				
		}
	}
	$('ContactCommList').value = strContactComm;
}


//-->