function calculate() {
	var salesPrice = 0;
	var ownersPolicy = 0;
	var total = 0;
	
	if(document.seller.salesPrice.value == 0) {  
		alert("Please enter a sales price!");
		document.seller.salesPrice.focus();
		return false; 
	}
	salesPrice =  parseFloat(stringFilter(document.seller.salesPrice.value));
	var taxable = new Array(5)
	var taxableamount = new Array(5)
	var rate = new Array(5)
	for(var i=0;i<=5;i++)
		taxable[i]=0
	
	rate[0] = .00575
	rate[1] = .005
	rate[2] = .0025
	rate[3] = .00225
	rate[4] = .002

	if(salesPrice>0) taxable[0]=1
	if(salesPrice>100000) taxable[1]=1
	if(salesPrice>1000000) taxable[2]=1
	if(salesPrice>5000000) taxable[3]=1
	if(salesPrice>10000000) taxable[4]=1
	
	if (taxable[1] > 0) {taxableamount[0] = 100000} else {taxableamount[0] = salesPrice}
	if (taxable[2] > 0) {taxableamount[1] = 1000000 - 100000} else {taxableamount[1] = salesPrice - taxableamount[0]}
	if (taxable[3] > 0) {taxableamount[2] = 5000000 - 1000000} else {taxableamount[2] = salesPrice - taxableamount[0] - taxableamount[1]}
	if (taxable[4] > 0) {taxableamount[3] = 10000000 - 5000000} else {taxableamount[3] = salesPrice - taxableamount[0] - taxableamount[1] - taxableamount[2]}
	if (taxable[4] > 0) {taxableamount[4] = salesPrice - 10000000} else {taxableamount[4] = salesPrice - taxableamount[0] - taxableamount[1] - taxableamount[2] - taxableamount[3]}
	
	for(var i=0;i<=5;i++) {
//		alert('taxable[' + i + '] = ' + taxable[i] + ', taxableamount = ' + taxableamount[i])
		if (!isNaN(taxableamount[i]))
			ownersPolicy = ownersPolicy + (taxableamount[i] * rate[i]) }
	
	var searchFee = parseFloat(stringFilter(document.seller.search.value));
	var examinationFee = parseFloat(stringFilter(document.seller.examination.value));
	var closingFee = parseFloat(stringFilter(document.seller.closingFee.value));
	var totalFees = searchFee + examinationFee + closingFee;
	
	if (ownersPolicy < totalFees)
		{ ownersPolicy = totalFees; }
		
	total = ownersPolicy + totalFees;
	total = roundOff(total);
	ownersPolicy = roundOff(ownersPolicy);
	
	document.seller.salesPrice.value = currency(stringFilter(document.seller.salesPrice.value));
	document.seller.search.value = currency(searchFee);
	document.seller.examination.value = currency(examinationFee);
	document.seller.closingFee.value = currency(closingFee);
	
	document.seller.ownersPolicy.value = currency(ownersPolicy);
	document.seller.total.value = currency(total);
}

function sendData() {
	if (document.seller.ownersPolicy.value == "") { 
		opener.document.data.insPremium.value = "0";
		self.close();
		return false; 
	} else {
		opener.document.data.insPremium.value = document.seller.ownersPolicy.value;
		self.close();
		return false;
	}
}

function sendData2() {
	var ownersPolicy = stringFilter(document.seller.ownersPolicy.value);
	if (ownersPolicy == "")
		ownersPolicy = 0;
	var salesPrice = stringFilter(document.seller.salesPrice.value);
	if (salesPrice == "")
		salesPrice = 0;
				
	document.location = "netProceeds.html?ownersPolicy=" + ownersPolicy + "&salesPrice=" + salesPrice 
}


function loadsalesprice() {
	if (!isNaN(stringFilter(url['salesprice'])))
		document.seller.salesPrice.value = stringFilter(url['salesprice']);
}


function printform() {
	var url = "sellersSale2_printable.asp?salesPrice=" + document.seller.salesPrice.value
	url = url + "&search=" + document.seller.search.value
	url = url + "&examination=" + document.seller.examination.value
	url = url + "&closingFee=" + document.seller.closingFee.value
	url = url + "&ownersPolicy=" + document.seller.ownersPolicy.value
	url = url + "&total=" + document.seller.total.value
	document.location = url
}// JavaScript Document