function isBlank(str){
	if (str.length == 0)             // yes - nothing entered
	return true
	for (i=0; i<=str.length-1; i++)  // yes - all spaces
	if (str.charAt(i) != " ")
		return false
	return true                      // nope
}

function isDigit (c){
	return ((c >= "0") && (c <= "9"))
}

function isIntegerPN (s){   
	var i, startPos;
	if (isBlank(s))
	return false;


	// Search through string's characters one by one
	// until we find a non-numeric character.
	// When we do, return false; if we don't, return true.

	if ( s.charAt(0) == "-" )
		startPos = 1;
	else
		startPos = 0;

	for (i = startPos; i < s.length; i++){
		// Check that current character is number.
		var c = s.charAt(i);
		if (!isDigit(c)) return false;
	}

	// All characters are numbers.
	return true;
}

function isNumber( number ){
	number = removeCommas( number );
	if ( isIntegerPN(number) )
		return true;
	else
		return false
}

function removeCommas( strValue ){
	var objRegExp = /,/g; //search for commas globally
	//replace all matches with empty strings
	return strValue.replace(objRegExp,'');
}


function format_number(num){
	var dol = Math.floor(num).toString();
   	var cents = Math.floor((num*100+.5)%100).toString();
	for (var i = 0; i < Math.floor((dol.length-1)/3)-i; i++)	
		dol = dol.slice(0,-(4*i+3))+','+dol.slice(-(4*i+3));
   	while (cents.length<2)
		cents += "0";
   return "$"+dol+"."+cents;
}

function nexttab(thisone, maxlength, nextfieldname){
	if ( thisone.value.length == maxlength ){
   		eval('document.' + thisone.form.name + '.' + nextfieldname + '.focus()');
  	}
}   		

function writeCombo(pName, index, pstart, pend, pincr){
	document.write('<select name="'+pName+'" size="1" tabindex="'+index+'" class="formFields">');
	document.write('<option value="" selected>- Select -</option>');
	for(i=pstart;i<=pend;i+=pincr){
		document.write('<option value="'+i+'">'+format_number(i)+'</option>');
	}
	document.write('</select>');
}			

function writeComboSF(pName, index, pstart, pend, pincr){
	document.write('<select name="'+pName+'" size="1" tabindex="'+index+'" class="formFields">');
	document.write('<option value="" selected>- Select -</option>');
	for(i=pstart;i<=pend;i+=pincr){	
		document.write('<option value="'+i+'">'+(Math.round(i*100)/100)+'</option>');
	}
	document.write('</select>');
}			


/*function format_number(n){
	if (!isNumber(n))
		return n;
	var isBlank = true;
	var isNegative = false;
		if (n.length == 0)             // yes - nothing entered
		return "";
		for (i=0; i<=n.length-1; i++)  // yes - all spaces
		if (n.charAt(i) != " ")
			isBlank = false;
		if(isBlank)
			return "";
	n = removeCommas(n);
	var arr=new Array('0'), i=0;
	if ( n < 0 ){
		isNegative = true;
		n = n * -1;
	}
	while (n>0){
		arr[i]=''+n%1000; n=Math.floor(n/1000); i++;
	}
	arr=arr.reverse();
	for (var i in arr) if (i>0) //padding zeros
		while (arr[i].length<3) arr[i]='0'+arr[i];
	if ( isNegative )
		return "-" + arr.join();
	else
		return arr.join();
}*/