
function GetSelectedText(box){
  var boxText = '';
  for(var i=0; i<box.options.length; i++){
    if(box.options[i].selected && box.options[i].value != ''){
      boxText = box.options[i].value;
    }
  }
  return boxText;
}

/**
 * init_select_source
 * 
 * This function is called when a user selects a source. 
 * Depending on the source is selected initially, the "promotion code" box
 * and "other source" box will be displayed or hidden.
 */

function init_select_source() {
	
   boxText = GetSelectedText(document.reseller_form.source);

	if(boxText == "CRN" || boxText == "ARN" || boxText == "RCP" || boxText == "SMB Nation" || boxText == "SBS Usergroup") {

		// Display the "promotion code" box.

		document.getElementById("promotion_code").style.display = "block";						
	}
	else {
		
		// Hide the "promotion code" box.
		
		document.getElementById("promotion_code").style.display = "none";						
	}

	if(boxText == "Other") {

		// Display the "other source" box.
		
		document.getElementById("other_source").style.display = "block";						
	}
	else {
		
		// Hide the "other source" box.
		
		document.getElementById("other_source").style.display = "none";						
	}
}

/**
 * select_source
 * 
 * This function is called when a user selects a source. 
 * Depending on the source selected, the "promotion code" box
 * and "other source" box will be displayed or hidden.
 */

function select_source() {

   boxText = GetSelectedText(document.reseller_form.source);

	if(boxText == "CRN" || boxText == "ARN" || boxText == "RCP" || boxText == "SMB Nation" || boxText == "SBS Usergroup") {

		// Display the "promotion code" box.
	
		document.getElementById("promotion_code").style.display = "block";						
	}
	else {
	
		// Hide the "promotion code" box.
		
		document.getElementById("promotion_code").style.display = "none";						
	}

	if(boxText == "Other") {

		// Display the "other source" box.

		document.getElementById("other_source").style.display = "block";						
	}
	else {
		
		// Hide the "other source" box.
		
		document.getElementById("other_source").style.display = "none";						
	}
}