/*
function selectRadio(e){
	document.forms[0][e].checked =  true;//(document.forms[0][e].checked ? false : true);	
}
*/

function clearDesc(n){
	var value = document.form1[n].value;
	if(value == 'Project description MUST be 100 characters or longer') 
		document.form1[n].value = '';
	document.form1[n].focus();
	document.form1[n].select();	
}


function phoneFill() {
	var phone1 = document.form1.phone1.value;
	
	if(phone2.length < 14) {
		document.form1.phone2.value = phone1;
	}
}



function openWin(URL, wName, wWidth, wHeight, wTop, wLeft, wResize) {
	features = 'scrollbars=1,status=1,resizable=' + ((wResize) ? 1 : 0) + ((wWidth) ? ',width=' + wWidth : '') + ((wHeight) ? ',height=' + wHeight : '') + ((wTop) ? ',top=' + wTop : '') + ((wLeft) ? ',left=' + wLeft : '');;
	popWin = window.open(URL, wName, features);
	if(popWin.focus) { popWin.focus(); }
//	return true;
}

function ShowHide(e) {
	ImageObject = document.getElementById(e + "Image");
	TextObject = document.getElementById(e + "Text");
	if (TextObject.style.display == "none")	{
//		ImageObject.src = "images/arrow_smdkred.gif";
		TextObject.style.display = "";
	} 	else 	{
//		ImageObject.src = "images/arrow_smred.gif";
		TextObject.style.display = "none";
	}
}





//DOM SCRIPTS FOR SHOW/HIDE

// 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 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) {
	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]); }
		};}
	}
}


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);
   if (i == -1) {
      return "";
   } else {
      if (buttonGroup[i]) { // Make sure the button group is an array (not just one button)
         return buttonGroup[i].value;
      } else { // The button group is just the one button, and it is checked
         return buttonGroup.value;
      }
   }
} // Ends the "getSelectedRadioValue" function
/*******************************************/
/* END DOM FUNCTIONS                       */
/*******************************************/
