function showAllCMFGroups(){
	showOne('Guarantor1Div');
	showOne('Guarantor1FinancialsDiv');
	showOne('BusinessProfileDiv');
	showOne('BusinessFinancialsDiv');	
	showOne('Guarantor2Div');
	showOne('Guarantor2FinancialsDiv');
	showOne('AlternatePrimaryContactDiv');
	showOne('InterviewDiv');
	showOne('DocWarehouseDiv');
	showOne('GenerateBankCMFDiv');	
	showOne('DebtSchedule');
	return null;
}

function hideAllCMFGroups(){
	hideOne('Guarantor1Div');
	hideOne('Guarantor1FinancialsDiv');
	hideOne('BusinessProfileDiv');
	hideOne('BusinessFinancialsDiv');		
	hideOne('Guarantor2Div');
	hideOne('Guarantor2FinancialsDiv');
	hideOne('AlternatePrimaryContactDiv');
	hideOne('InterviewDiv');
	hideOne('DocWarehouseDiv');
	hideOne('GenerateBankCMFDiv');
	hideOne('DebtSchedule');
	return null;
}

function showOneCMF(e)	{
	var dom = findDOM(e,1);
	dom.display = "";
	document.forms[0].div.value = e;
	return null;
}


function showHide(e) {
	panel = document.getElementById(e);
	if (panel.style.display == "none") {
		panel.style.display = "";
	} else {
		panel.style.display = "none";
	}
}



// return the value of the radio button that is checked
// return an empty string if none are checked, or
// there are no radio buttons
function getCheckedValue(radioObj) {
	var msg = 'getting checked value\n' + radioObj;
//	alert (msg);
	if(!radioObj){
		alert('not a radio object');
		return "";
	}
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}

function extraQuestions(formname) {
	var len = document.forms[formname].elements.length;
	for(i = 0; i < len; i++){
		if(document.forms[formname].elements[i].type == 'radio'){
			val = getSelectedRadioValue(document.forms[formname].elements[i]);
			if(val == 1){
				Show(document.forms[formname].elements[i].name+"_row");
			}
		}
	}
}

function showDesc(){
//	alert('begin showing desc:');
	var bankruptcy = document.forms[0].elements['bankruptcy'];
	bankruptcy = bankruptcy.length;
//	alert(bankruptcy);
//	var bankruptcy = getCheckedValue(document.forms[0].bankruptcy);
//	alert(bankruptcy);


	/*var ids = new Array();
	ids[0] = 'bankruptcy';
	ids[1] = 'judgements';
	ids[2] = 'liens';	
	ids[3] = 'foreclosures';*/
	
//	for(x = 0; x < ids.length; x++) 
//		alert(ids[x].value);
//		var foo = getSelectedRadioValue(ids[x]);
//		alert(x + ' ' + foo);
//		alert(ids[x]);
		// problem seems to be with this function
//		var foo = getSelectedRadioValue(ids[x]);
//		alert(foo);
//		document.write(ids[x] + "<br>");

//	if(foo)
//		alert('bankrupt');
//	else 
//		alert('not bankrupt');
}

function getDropDownValueFullForm (formName, elementName){
	alert('foo');
	alert(formName);
	var index = document.formName[name].options.selectedIndex;
	var selected_value = document.formName[name].options[index].value;
	return selected_value;
}

function showTokenExpiration(){
	var index = document.forms[2]['token_type'].options.selectedIndex;
	var ttype = document.forms[2]['token_type'].options[index].value;
	//alert(ttype);
	if(ttype == 'FA'){
		showOne('durdis1');
		showOne('durdis2');				
	} else {
		hideOne('durdis1');
		hideOne('durdis2');		
	}	
}

function showLeadSource(){
	var button_val;
	button_val = getSelectedRadioValue(document.forms[0]['lead_source']);	
	hideOne('internal');
	hideOne('rep');
	hideOne('vendor');
	showOne(button_val);	
}

function showCommissionStructure(){
	var button_val;
	button_val = getSelectedRadioValue(document.forms[0]['fee_type']);	
	
	if(button_val == 'tiered')
		showOne('CommStatus');
	else
		hideOne('CommStatus');

	return null;

}



function showHideSource(){
	var	source = getDropDownValue('lp_id');
	if(source == "101"){
		showOne('channelRow');
	} else {
		hideOne('channelRow');
	}
}



function showHideChannel(){
	var	source = getDropDownValue('source');
	if(source == "111"){
		hideOne('channel');		
		showOne('channelRBSL');		
		shiftFocus('channelRBSL');
	} else {
		hideOne('channelRBSL');
		showOne('channel');
		shiftFocus('channel');		
	}
}


/******************************************************/
/*  GENERAL DOM FUNCTIONS FOR HIDING/SHOWING ELEMETS  */
/******************************************************/
var isDHTML = 0;
var isID = 0;
var isAll = 0;
var isLayers = 0;

if (document.getElementById) {
	isID = 1; 
	isDHTML = 1;
} else {
		if (document.all) {
			isAll = 1; isDHTML = 1;
		} else {
			browserVersion = parseInt(navigator.appVersion);
			if ((navigator.appName.indexOf('Netscape') != -1) && (browserVersion == 4)) {
				isLayers = 1; isDHTML = 1;
		}
	}
}

function findDOM(objectID,withStyle){
	//try{
		if (withStyle == 1){
			if (isID) { return (document.getElementById(objectID).style) ; }
			else {
				if (isAll) { return (document.all[objectID].style); }
			else {
				if (isLayers) { return (document.layers[objectID]); }
			};}
		}
		else {
			if (isID) { return (document.getElementById(objectID)) ; }
			else {
				if (isAll) { return (document.all[objectID]); }
			else {
				if (isLayers) { return (document.layers[objectID]); }
			};}
		}
	//}catch(error){
		//alert(objectID);
		//alert(error);
	//}
}


function hideOne (e) {
	var dom = findDOM(e,1);
	dom.display = "none";
}

function showOne(e)	{
	var dom = findDOM(e,1);
	dom.display = "";
}


function getDropDownValue (name){
	var index = document.forms[0][name].options.selectedIndex;
	var selected_value = document.forms[0][name].options[index].value;
	return selected_value;
}


function getSelectedRadio(buttonGroup) {
	// returns the array number of the selected radio button or -1 if no button is selected
	var foo = buttonGroup.length;
	if (buttonGroup[0]) { // if the button group is an array (one button is not an array)
		for (var i=0; i<buttonGroup.length; i++) {
			if (buttonGroup[i].checked) {
				return i;
			}
		}
	} else {
		if (buttonGroup.checked) {
			return 0;  // if the one button is checked, return zero
		}
	}// if we get to this point, no radio button is selected
	return -1;
} // Ends the "getSelectedRadio" function

function getSelectedRadioValue(buttonGroup) {
   // returns the value of the selected radio button or "" if no button is selected
   var i = getSelectedRadio(buttonGroup);
   var bval;
   if (i == -1) {
	  return "";
   } else {
	  if (buttonGroup[i]) { // Make sure the button group is an array (not just one button)
		 bval = buttonGroup[i].value;
	  } else { // The button group is just the one button, and it is checked
		 bval = buttonGroup.value;
	  }
	  return bval;
   }
} // Ends the "getSelectedRadioValue" function


/*
function getSelectedRadio_OLD(buttonGroup) {
	// returns the array number of the selected radio button or -1 if no button is selected
	var length = document.forms[0][buttonGroup].length;
	if (buttonGroup[0]) { // if the button group is an array (one button is not an array)
		for (var i=0; i<length; i++) {
			if (document.forms[0][buttonGroup][i].checked) { 
				return i;
			}
		}
	} else {
		if (buttonGroup.checked) {
			return 0;  // if the one button is checked, return zero
		}
	}// if we get to this point, no radio button is selected
	return -1;
} // Ends the "getSelectedRadio" function

function getSelectedRadioValue_OLD(buttonGroup) {
   // returns the value of the selected radio button or "" if no button is selected
   var i = getSelectedRadio_OLD(buttonGroup);
   if (i == -1) {
      return "";
   } else {
      if (buttonGroup[i]) { // Make sure the button group is an array (not just one button)
         return document.forms[0][buttonGroup][i].value;
      } else { // The button group is just the one button, and it is checked
         return document.forms[0][buttonGroup].value;
      }
   }
} // Ends the "getSelectedRadioValue" function
*/
/*******************************************/
/* END DOM FUNCTIONS                       */
/*******************************************/