function onClick()	{
//Initialize core service variables at 0
fire = 0;
hhs = 0;
library = 0;
trail = 0;
infrastructure = 0;
rec = 0;
bus = 0;
CourtTax = 0;
LawTax = 0;

	for (i=0;i<document.tenyear.fire.length;i++) {
		if (document.tenyear.fire[i].checked) {
			fire = document.tenyear.fire[i].value;
		}
	}
	for (i=0;i<document.tenyear.hhs.length;i++) {
		if (document.tenyear.hhs[i].checked) {
			hhs = document.tenyear.hhs[i].value;
		}
	}
	for (i=0;i<document.tenyear.library.length;i++) {
		if (document.tenyear.library[i].checked) {
			library = document.tenyear.library[i].value;
		}
	}
	for (i=0;i<document.tenyear.trail.length;i++) {
		if (document.tenyear.trail[i].checked) {
			trail = document.tenyear.trail[i].value;
		}
	}
	for (i=0;i<document.tenyear.infrastructure.length;i++) {
		if (document.tenyear.infrastructure[i].checked) {
			infrastructure = document.tenyear.infrastructure[i].value;
		}
	}
	for (i=0;i<document.tenyear.rec.length;i++) {
		if (document.tenyear.rec[i].checked) {
			rec = document.tenyear.rec[i].value;
		}
	}
	for (i=0;i<document.tenyear.bus.length;i++) {
		if (document.tenyear.bus[i].checked) {
			bus = document.tenyear.bus[i].value;
		}
	}

//Revenue using STatus quo:
//C14:
AllRevenue = 119696001;

//Revenue using choices:
//H4-H10:
LOSvc = AllRevenue;
if (fire != 0) LOSvc = LOSvc - (64163923 - fire);
if (hhs != 0) LOSvc = LOSvc - (3439162 - hhs);
if (library != 0) LOSvc = LOSvc - (11456829 - library);
if (trail != 0) LOSvc = LOSvc - (3342746 - trail);
if (infrastructure != 0) LOSvc = LOSvc - (6801678 - infrastructure);
if (rec != 0) LOSvc = LOSvc - (12710986 - rec);
if (bus != 0) LOSvc = LOSvc - (17780677 - bus);

//SETUP FOR CALCULATIONS:
//H18:
AllCtyTaxable = 53155120531;
//H17:
AllEMSTaxable = 45106548683;


AssumedDecrease = 1-0.13;
//H27:
NewCtyTaxable = 46244954862;
//H26:
NewEMSTaxable = 39242697354;

homevalue = document.tenyear.homevalue.value;
newhomevalue = homevalue * AssumedDecrease;

//I4-I10:
fireMillage = ((fire / 0.95) * 1000 / NewEMSTaxable);
hhsMillage = ((hhs/0.95) * 1000 / NewCtyTaxable);
libraryMillage = ((library/0.95) * 1000 / NewCtyTaxable); 
trailMillage = ((trail/0.95) * 1000 / NewCtyTaxable);
infrastructureMillage = ((infrastructure/0.95) * 1000 / NewCtyTaxable);
recMillage = ((rec/0.95) * 1000 / NewCtyTaxable);
busMillage = ((bus/0.95) * 1000 / NewCtyTaxable);

ChangeInTax = 0;
firetax = 0; hhstax = 0; librarytax = 0; trailtax = 0; infrastructuretax = 0; rectax = 0; bustax = 0;

if (fireMillage != 0) firetax = (fireMillage - 1.4974) / 1000 * newhomevalue;
if (hhsMillage != 0) hhstax = (hhsMillage - 0.0681) / 1000 * newhomevalue;
if (libraryMillage != 0) librarytax= (libraryMillage - 0.2269) / 1000 * newhomevalue;
if (trailMillage != 0) trailtax = (trailMillage - 0.0662) / 1000 * newhomevalue;
if (infrastructureMillage != 0) infrastructuretax = (infrastructureMillage - 0.1347) / 1000 * newhomevalue;
if (recMillage != 0) rectax = (recMillage - 0.2517) / 1000 * newhomevalue;
if (busMillage != 0) bustax = (busMillage - 0.3521) / 1000 * newhomevalue;

ChangeInTax = firetax + hhstax + librarytax + trailtax + infrastructuretax + rectax + bustax;

//Round to 2 decimal places:
if (ChangeInTax != 0) ChangeInTax = Math.round(ChangeInTax * 100) / 100;

user_input = 0;
if (LOSvc > 0) user_input = LOSvc - AllRevenue;



user_input = Math.round(Math.abs(user_input / 1000000) * 1000) / 1000;

CurrCtyMillage = 3.1342;
CourtTax = (homevalue / 1000) * CurrCtyMillage * 0.1248;
CourtTax = Math.round(CourtTax * 100) / 100;
LawTax = (homevalue / 1000) * CurrCtyMillage * 0.2186;
LawTax = Math.round(LawTax * 100) / 100;

document.getElementById('LawEffect').firstChild.nodeValue = "$" + LawTax;
document.getElementById('LawEffect').style.color = '#961414';

document.getElementById('CourtEffect').firstChild.nodeValue = "$" + CourtTax;
document.getElementById('CourtEffect').style.color = '#961414';

//Set color of Effect area based on whether there is a net loss or savings
if (user_input < 0) {
	//Put calculation results into Effect area
	document.getElementById('cityEffect').firstChild.nodeValue = "Increases the budget $" + user_input + " million";
	document.getElementById('cityEffect').style.color = '#961414';
	}
else if (user_input > 0) {
	document.getElementById('cityEffect').firstChild.nodeValue = "Reduces the budget $" + user_input + " million";
	document.getElementById('cityEffect').style.color = '#1A9714';
	}
else {
	//Put calculation results into Effect area
	document.getElementById('cityEffect').firstChild.nodeValue = "$0";
	document.getElementById('cityEffect').style.color = '#333333';
	}
if (ChangeInTax < 0) {
    document.getElementById('yourEffect').firstChild.nodeValue = "Save $" + Math.abs(ChangeInTax);
    document.getElementById('yourEffectDB').value = "Save $" + Math.abs(ChangeInTax);
	document.getElementById('yourEffect').style.color = '#1A9714';
	} 
else if (ChangeInTax > 0) {
    document.getElementById('yourEffect').firstChild.nodeValue = "Cost $" + Math.abs(ChangeInTax);
    document.getElementById('yourEffectDB').value = "Cost $" + Math.abs(ChangeInTax);
	document.getElementById('yourEffect').style.color = '#961414';
	}
else {
	//Put calculation results into Effect area
    document.getElementById('yourEffect').firstChild.nodeValue = "$0";
    document.getElementById('yourEffectDB').value = "$0";
	document.getElementById('yourEffect').style.color = '#333333';
	}

} // END ONCLICK FUNCTION

function removeCommas( strValue ) {
/************************************************
DESCRIPTION: Removes commas from source string.

PARAMETERS: 
  strValue - Source string from which commas will 
    be removed;

RETURNS: Source string with commas removed.
*************************************************/
  var objRegExp = /,/g; //search for commas globally
 
  //replace all matches with empty strings
  return strValue.replace(objRegExp,'');
}
function formatCurrency(num) {
num = num.toString().replace(/\$|\,/g,'');
if(isNaN(num))
num = "0";
sign = (num == (num = Math.abs(num)));
num = Math.floor(num*100+0.50000000001);
cents = num%100;
num = Math.floor(num/100).toString();
if(cents<10)
cents = "0" + cents;
for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
num = num.substring(0,num.length-(4*i+3))+','+
num.substring(num.length-(4*i+3));
return (((sign)?'':'-') + '$' + num + '.' + cents);
}
function removeDollar( strValue ) {
/************************************************
DESCRIPTION: Removes $ from source string.

PARAMETERS: 
  strValue - Source string from which $ will 
    be removed;

RETURNS: Source string with $ removed.
*************************************************/
  var objRegExp = /\$/g; //search for $ globally
 
  //replace all matches with empty strings
  return strValue.replace(objRegExp,'');
}

function  validateNumeric( strValue ) {
/******************************************************************************
DESCRIPTION: Validates that a string contains only valid numbers.

PARAMETERS:
   strValue - String to be tested for validity
   
RETURNS:
   True if valid, otherwise false.
******************************************************************************/
  var objRegExp  =  /(^-?\d\d*\.\d*$)|(^-?\d\d*$)|(^-?\.\d\d*$)/; 
 
  //check for numeric characters 
  return objRegExp.test(strValue);
}

function validateEmail( strValue) {
/************************************************
DESCRIPTION: Validates that a string contains a 
  valid email pattern. 
  
 PARAMETERS:
   strValue - String to be tested for validity
   
RETURNS:
   True if valid, otherwise false.
   
REMARKS: Accounts for email with country appended
  does not validate that email contains valid URL
  type (.com, .gov, etc.) and optionally,
  a valid country suffix.  Since email has many
  forms this expression only tests for near valid
  address.  Some additional validation may be
  required.
*************************************************/
var objRegExp  = /^[a-z0-9]([a-z0-9_\-\.]*)@([a-z0-9_\-\.]*)(\.[a-z]{2,3}(\.[a-z]{2}){0,2})$/i;
  //check for valid email
  return objRegExp.test(strValue);
}

function nameCheck()	{
name = document.tenyear.name.value;

	if (name == '')	{
		document.getElementById('nameValid').firstChild.nodeValue = "(invalid)";
		document.getElementById('nameValid').style.color = '#961414';
		//alert('No name entered');
		document.tenyear.name.value = '';
	} else {
		document.getElementById('nameValid').firstChild.nodeValue = "(valid)";
		document.getElementById('nameValid').style.color = '#1A9714';
	}
}

function addressCheck()	{
name = document.tenyear.address.value;

	if (name == '')	{
		document.getElementById('addressValid').firstChild.nodeValue = "(invalid)";
		document.getElementById('addressValid').style.color = '#961414';
		//alert('No address entered');
		document.tenyear.address.value = '';
	} else {
		document.getElementById('addressValid').firstChild.nodeValue = "(valid)";
		document.getElementById('addressValid').style.color = '#1A9714';
	}
}

function emailCheck()	{
	if(!validateEmail(document.tenyear.email.value))	{
		document.getElementById('emailValid').firstChild.nodeValue = "(invalid)";
		document.getElementById('emailValid').style.color = '#961414';
		document.tenyear.email.value = '';
	} else {
		document.getElementById('emailValid').firstChild.nodeValue = "(valid)";
		document.getElementById('emailValid').style.color = '#1A9714';
	}
}

function zipCheck()	{
zip = document.tenyear.zip.value;

	if ((zip != 78664) && (zip != 78681))	{
		document.getElementById('zipValid').firstChild.nodeValue = "(valid)";
		document.getElementById('zipValid').style.color = '#d1d900';
		//alert('Not a valid zipcode');
		//document.tenyear.zip.value = '';
	} else {
		document.getElementById('zipValid').firstChild.nodeValue = "(valid)";
		document.getElementById('zipValid').style.color = '#1A9714';
	}
}

function homeCheck()	{
	if(!validateNumeric(document.tenyear.homevalue.value))	{
		document.getElementById('homeValid').firstChild.nodeValue = "(invalid)";
		document.getElementById('homeValid').style.color = '#961414';
		//alert('Please don\'t use a dollar sign');
		document.tenyear.homevalue.value = 0;
	} else {
		document.getElementById('homeValid').firstChild.nodeValue = "(valid)";
		document.getElementById('homeValid').style.color = '#1A9714';
	}
}
function resetdoc()	{
fire = 0;
hhs = 0;
library = 0;
trail = 0;
infrastructure = 0;
rec = 0;
bus = 0;
CourtTax = 0;
LawTax = 0;
payServices='';
document.getElementById('findOutByMtgs').value='N';
LOSvc = Math.abs(0);
ChangeInTax = 0;
firetax = 0; hhstax = 0; librarytax = 0; trailtax = 0; infrastructuretax = 0; rectax = 0; bustax = 0;
user_input = 0;
document.getElementById('cityEffect').firstChild.nodeValue = "$0";
document.getElementById('yourEffect').firstChild.nodeValue = "$0";
document.getElementById('cityEffect').style.color = '#333333';
document.getElementById('yourEffect').style.color = '#333333';
for (i=0;i<document.tenyear.fire.length;i++) { document.tenyear.fire[i].checked = false; }
for (i=0;i<document.tenyear.hhs.length;i++) { document.tenyear.hhs[i].checked = false; }
for (i=0;i<document.tenyear.library.length;i++) { document.tenyear.library[i].checked = false; }
for (i=0;i<document.tenyear.trail.length;i++) { document.tenyear.trail[i].checked = false; }
for (i=0;i<document.tenyear.infrastructure.length;i++) { document.tenyear.infrastructure[i].checked = false; }
for (i=0;i<document.tenyear.rec.length;i++) { document.tenyear.rec[i].checked = false; }
for (i=0;i<document.tenyear.bus.length;i++) { document.tenyear.bus[i].checked = false; }
}
function checkit()	{
	//codeCheck = document.tenyear.voteCheck.value;
	name = document.tenyear.name.value;
	email = document.tenyear.email.value;
	address = document.tenyear.address.value;
	zip = document.tenyear.zip.value;
	homevalue = document.tenyear.homevalue.value;
	codeAlert = ""; //Empty code alert so multiple alerts don't stack up
	finalAlert = ""; //Empty final alert so entry can go in once all are fixed
  
/*	if(codeCheck=='')	{
	codeAlert = 'You forgot to enter a voting code\n';
	finalAlert = 1;
}*/

	if(name=='')	{
	codeAlert += 'You forgot to enter your name\n';
	finalAlert = 1;
}

	if(email=='')	{
	codeAlert += 'Please Enter A Valid E-Mail Address\n';
	finalAlert = 1;
}	

	if(address=='')	{
	codeAlert += 'Please Enter A Sarasota County Address\n';
	finalAlert = 1;
}

	if(zip=='')	{
	codeAlert += 'Please Enter Your Zip Code\n';
	finalAlert = 1;
}

	if(homevalue==0)	{
	codeAlert += 'Please Enter a Home Value Greater Than Zero. If You Rent, Enter 100,000\n';
	finalAlert = 1;
}

	if (finalAlert == 1)	{
	alert(codeAlert);
	return false;
}

	alert('Thank you for your input! Please allow the next in line to use the system.');
	window.open('survey.html','MoneyMatters','width=1000,height=1000,left=0,top=0,toolbar=1,menubar=1,status=1,location=1,resizable=1,scrollbars=1');
	self.close();
return true;
}
function errorhandler( msg, url, ln )
{
	alert(" "+msg+"\nAt Line:"+ln);
	return true;
}