function doesExist(inputValue, inputExpected)
{
	var aCharExists=0;
	if (inputValue) {
		for (var i=0; i<inputValue.length; i++) {
		 if (inputValue.charAt(i) != "") {
			aCharExists=1
			}
		}
	}
	if (!aCharExists) {
	 alert("Please enter a " + inputExpected)
	}
	}


function clearform3 (form)
{
form.firm_name.value="";
form.m_address1.value="";
form.m_address2.value="";
form.m_address3.value="";
form.m_city.value="";
form.m_state.value="";
form.m_zip.value="";
form.m_country.value="";
}
function clearform4 (form)
{
form.d_address1.value="";
form.d_address2.value="";
form.d_address3.value="";
form.d_city.value="";
form.d_state.value="";
form.d_zip.value="";
form.d_country.value="";
}
function clearform5 (form)
{
form.cardtype.value="";
form.cardnumber.value="";
form.cardexpire.value="";
form.ACCTNO.value="";
form.ABACODE.value="";
form.BANKNAME.value="";
form.comments.value="";
}

function clearform2 (form)
{
form.prefix.value="";
form.first_name.value="";
form.middle_initial.value="";
form.last_name.value="";
form.title.value="";
form.phone.value="";
form.fax.value="";
form.email.value="";
}

function clearform1 (form)
{
form.nr1.value=0;
form.nr2.value=0;
form.nr3.value=0;
form.nr4.value=0;
form.nr5.value=0;
form.nr6.value=0;
form.nr6a.value=0;
form.nr7.value=0;
form.taxtotal.value=0.00;
form.total.value=0.00;
}

function compute (form) 
{
//flresident = form.flresident[1].checked;
//if (flresident) {fltax1 = 65;} else {fltax1 = 0;}
fltax1 = 0;
postage1=3.50;
postage2=3.50;
postage3=3.50;
postage4=3.50;
postage5=3.50;
postage6=1.75;
postage6a=1.25;
postage7=1.25;
taxtotal=0.00;
temp1=0.00;
temp2=0.00;

nr1=form.nr1.value;
nr2=form.nr2.value;
nr3=form.nr3.value;
nr4=form.nr4.value;
nr5=form.nr5.value;
nr6=form.nr6.value;
nr6a=form.nr6a.value;
nr7=form.nr7.value;
var amount1 = (form.nr1.value*postage1)+(form.nr1.value*25.00);
var amount2 = (form.nr2.value*postage2)+(form.nr2.value*13.00);
var amount3 = (form.nr3.value*postage3)+(form.nr3.value*12.00);
var amount4 = (form.nr4.value*postage4)+(form.nr4.value*25.00);
var amount5 = (form.nr5.value*postage5)+(form.nr5.value*25.95);
var amount6 = (form.nr6.value*postage6)+(form.nr6.value*14.95);
var amount6a = (form.nr6a.value*postage6a)+(form.nr6a.value*6.50);
var amount7 = (form.nr7.value*postage7)+(form.nr7.value*6.50);
tpc1 = postage1*1+25.00;
tpc2 = postage2*1+13.00;
tpc3 = postage3*1+12.00;
tpc4 = postage4*1+25.00;
tpc5 = postage5*1+25.95;
tpc6 = postage6*1+14.95;
tpc6a = postage6a*1+6.50;
tpc7 = postage7*1+6.50;
total = (amount1*1) + (amount2*1) + (amount3*1) + (amount4*1) + (amount5*1) + (amount6*1) + (amount6a*1) + (amount7*1);
form.amount1.value = amount1;
form.amount1.value = asMoney(form.amount1.value);
form.amount2.value = amount2;
form.amount2.value = asMoney(form.amount2.value);
form.amount3.value = amount3;
form.amount3.value = asMoney(form.amount3.value);
form.amount4.value = amount4;
form.amount4.value = asMoney(form.amount4.value);
form.amount5.value = amount5;
form.amount5.value = asMoney(form.amount5.value);
form.amount6.value = amount6;
form.amount6.value = asMoney(form.amount6.value);
form.amount6a.value = amount6a;
form.amount6a.value = asMoney(form.amount6a.value);
form.amount7.value = amount7;
form.amount7.value = asMoney(form.amount7.value);
form.tpc1.value=tpc1;
form.tpc2.value=tpc2;
form.tpc3.value=tpc3;
form.tpc4.value=tpc4;
form.tpc5.value=tpc5;
form.tpc6.value=tpc6;
form.tpc6a.value=tpc6a;
form.tpc7.value=tpc7;
with (Math) {temp1=((round((fltax1*(total)/10)))/100)};
form.taxtotal.value=temp1;
form.taxtotal.value=asMoney(form.taxtotal.value);
form.total.value=(temp1)+(total);
form.total.value = asMoney (form.total.value);
}

/* ******clean money********* */

function scrubData (inputValue) {
// this function deletes digits that aren't numbers
// or periods. if a non-money-based digit is 
// encountered (something other that a "$", a "."
// or a space) an error is displayed.

var returnValue = ""
for (var i = 0; i<inputValue.length; i++) {
var digit = inputValue.charAt(i)
if (parseFloat(digit) || digit == "."
				 || digit == "0") {
// digit is a number or period, so keep it
returnValue += digit
}
else {
if (digit != " " && digit != "$" && digit !=
","){
// something weird encountered
alert("Please enter a non-zero numeric value.")
        break
	} break
   }
 }
return returnValue
}
/* *********** return input value as money *******  */
function asMoney (inputValue) {
// first, make sure that input value is clean
var scrubValue = scrubData(inputValue)

// declare some temporary variables
var returnString = ""
var tempNumber = 0
var tempString = ""
tempNumber = Math.round(scrubValue * 100)
// manipulate the number so we know what we are dealing with
if (tempNumber < 10) {
tempString = "00" + tempNumber
}
else if (tempNumber < 100) {
tempString = "0" + tempNumber
}
else {
	tempString = "" + tempNumber
	}
	
if (tempString.length > 9) {
alert("Sorry, can't process numbers > one million.")
return scrubValue
}

/* ***************  Build a return String  ***********  */
// This next section builds the return string by
// starting with a dollar sign, then breaking up the 
// number ito sections, then placing commas and 
// periods between the sections as appropriate.

returnString = "$"

if (tempString.length > 5) {
// Need to add at least one comma
if (tempString.length == 6) {
returnString += tempString.substring(0,1) +
"," +
tempString.substring(1,tempString.length-2)
}
else if (tempString.length == 7) {
returnString += tempString.substring(0,2) +
"," +
tempString.substring(2,tempString.length-2) 
}
else if (tempString.length == 8) {
returnString += tempString.substring(0,3) +
"," +
tempString.substring(3,tempString.length-2)
}
else if (tempString.length == 9) {
// Need to add two commas
returnString += tempString.substring(0,1) +
"," +
tempString.substring(1,4) + "," +
tempString.substring(4,tempString.length-2)
	}
}
else { // No commas necessary
returnString = "$" +
tempString.substring(0,(tempString.length-2))
}
// Add in the cents
returnString += "." +
tempString.substring((tempString.length -
2),tempString.length)

//Return the newly formatted string back to the //
//caller

return returnString
}

function openWindow(myLink,windowName)

{

if(! window.focus)return;

var myWin=window.open("",windowName,"height=315,width=315,scrollbars=no,toolbar=no");

myWin.focus();

myLink.target=windowName;

}

/* ...
Enter a number and click anywhere else on the page.
You can also use the following sybols if you want. $ , .
<input type="text" name="desiredSalary" size=15 onblur="document.myForm.desiredSalary.value=asMoney(this.value)">
*/	
/*   <SCRIPT language="JavaScript" type="text/javascript"><!-- Begin */
function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=650,height=650,left = 326,top = 157');");
}
/* // End -->
</SCRIPT> */