

function clearField( field_name )
{
	document.getElementById( field_name ).value = '';
	document.getElementById( field_name ).style.backgroundColor = '';
}

function highlightFields( field_str )
{
	var fields = field_str.split(',');
	
	for( var i=0; i<fields.length; i++ )
	{
		highlightField( fields[i], '#F6F5CF' ); 
	}
	
}


function highlightField( field_name, field_color )
{
	document.getElementById( field_name ).style.backgroundColor = field_color;
}

function popUp(URL, intWidth, intHeight) 
{
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=" + intWidth + ",height=" + intHeight + "');");
}

//this function will move the page to an <a name>
function jumpto( type, number )
{
	jumptoaddress = '#' + type + number;

	window.location.hash = jumptoaddress;	
	
}	//end function

function validate_required_fields(frmName, strTextBoxes)
{
	var oForm = document.getElementById(frmName);
	
	//turn the comma separated list into an array
	var arrBoxes = strTextBoxes.split(",");
	
	error = 0;
	
	//loop thru each box and determine if the text value is empty
	for( var intCount = 0; intCount < arrBoxes.length; intCount++ )
	{
		arrBoxes[intCount] = arrBoxes[intCount].trim_spaces();
		
		//alert( "inCount: " + intCount + " - text box: -->" + arrBoxes[intCount] + "<--" );
		
		var strText = document.getElementById(arrBoxes[intCount]).value;
		
		if( strText.length == 0 )
		{
			error++;
			
		}	//end if
		
	}	//end for loop
	
	//if any errors, then user did not enter all the required fields
	if( error > 0 )
	{
		alert( "Please enter all the required fields." );
		
		valid = false;
		
	}	//end if
	
	else
	{
		valid = true;
		
	}	//end else
	
	return valid;
	
}	//end function

//removes all spaces in a string
function removespaces_private() 
{
	return this.replace(/.*\S/,'');
	
}	//end function

//trims leading and trailing spaces
function trim_spaces() 
{
	return this.replace(/^\s+/,'').replace(/\s+$/,'');
	
}	//end function

function pop_help( strPath, intTopicId )
{
	var strURL = strPath + 'popup_help.php?t=' + intTopicId ;

	window.open( strURL,'help_pop','width=350,height=300,scrollbars=yes,resizable=yes');	
}

//assigns a new function to string types
String.prototype.removespaces_private = removespaces_private;
String.prototype.trim_spaces = trim_spaces;

function printpage() 
{
	window.print();
	
}	//end function

function sizeRealityCheck(targetField) {
	var valEntered = targetField.value;
	valEntered = valEntered.replace(/[^0-9.]/gi, '');
	targetField.value = valEntered;

	var sizeData = parseFloat(valEntered);
	if(sizeData<500 || sizeData>1500)
		alert('Reality Check:\nDid you really mean to enter ' + sizeData + ' gallons?');
}

function limitTextArea(limitField, limitCount, limitNum) {
	if (limitField.value.length > limitNum) {
		limitField.value = limitField.value.substring(0, limitNum);
	} else {
		limitCount.value = limitField.value.length;
	}
}

// copyright 1999 Idocs, Inc. http://www.idocs.com
// Distribute this script freely but keep this notice in place
function numbersOnly(myfield, e, dec) {
var key;
var keychar;

if (window.event)
   key = window.event.keyCode;
else if (e)
   key = e.which;
else
   return true;
keychar = String.fromCharCode(key);

if ((key==null) || (key==0) || (key==8) || (key==9) || (key==13) || (key==27) ) // control keys
   return true;

else if ((("0123456789.").indexOf(keychar) > -1)) // numbers and decimal
   return true;

else
   return false;
}
