<!--//

////////////////////////////////////////////////////////////////////
// Affiliates
////////////////////////////////////////////////////////////////////
function onChangeAffiliate(frm,cboSelect,txtID, txtAffiliate) {
	if(cboSelect == null) return true;
    var intCurrent = cboSelect.selectedIndex;
	var strAffiliate = cboSelect.options[intCurrent].text;
	
	// Asssign the values to the fields
	txtID.value = intCurrent;
	txtAffiliate.value = strAffiliate.trim();
	// Deselect the item
	cboSelect.selectedIndex = -1;
	
	return true;
}

function addAffiliateOption(cboSelect,txtID, txtAffiliate, blnClear) {
    var defaultSelected = true;
    var selected = false;
	
	// Exit if missing entries
	if(txtAffiliate.value == '' ) return false;
	
	var strValue = txtAffiliate.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){
		
		txtAffiliate.value = ''; 
	}
	cboSelect.selectedIndex = -1;
	
	return true;
}

function removeAffiliateOption(cboSelect,txtID, txtAffiliate, blnClear) {


    	
	if (txtID.value != '') {
		
		var intIndex = txtID.value;
		cboSelect.options[intIndex] = null;
		
		txtID.value = '';
		if(blnClear){
			
			txtAffiliate.value = ''; 
			
		}
	}

}
function storeAffiliates(cboSelect){
	var strAffiliate = '';
	//alert('Storing affiliates...');
	for(var x = 0; x < cboSelect.options.length; x++){
		if(strAffiliate != '' ) strAffiliate += '^';
		// Don't store the default entry
		var strValue = cboSelect.options[x].text;
		strValue.replace(/\s/g,"");
		if(cboSelect.options[x].value != 1000) strAffiliate +=  strValue;
	}
	$('AffiliateList').value = strAffiliate;
}


//-->