<script language="javascript" type="text/javascript">
<!-- Begin hiding from old browsers
/*Break frames*/
     if (top.frames.length!=0)
     top.location=self.document.location;

/*Pop-up page, variable width, height; closes when focus is lost*/
var openwin = null;
function KeepTop ()
{
   if (openwin != null && openwin.open) openwin.close();
}
function WinSize(loc,winwidth,winheight)
{
wintype =
'width='+winwidth+',height='+winheight+',toolbar=no,menubar=no,location=no,status=no,copy history=no,scrollbars=yes,resizable=yes,top=0,left=0,screenX=0,screenY=0';
openwin = window.open(loc,'CtrlWindow',wintype);
}
window.onfocus=KeepTop;

/*Simple market value calculator*/
function propvalCalc(form) {
var ok = 0;
var asst = Math.round(form.asst.value);
var rar = form.rar.value;
var worth = Math.round(form.worth.value);

var complete = "Please enter your Assessment or your Market Value (price), but NOT both.\nClick Reset and try again.";
var incomplete = "Please enter EITHER your Assessment or your Market Value, then press Solve.";
var reassess = "This town is conducting a reassessment.\n Market Values and Assessments can't be calculated.";

if (rar == "0.0") alert(reassess);
if (asst != "" && rar != "")   { form.worth.value = Math.round (asst / rar); ok++; } 
// solve for worth
if (asst != "" && worth != "") { form.rar.value = ( asst / worth); ok++; } 
// solve for rar
if (rar != "" && worth != "")  { form.asst.value = ( rar * worth); ok++; } 
// solve for asst

if (!ok) alert(incomplete);  
// they did not enter at least 2 fields
if (asst != "" && rar != "" && worth != "") alert(complete); 
// they filled in all the fields!
}

/*Prevent Duplicate Form Submission*/
var submitcount=0;
function DupeStop()
{
   if (submitcount == 0)
      {
      submitcount++;
      return true;
      }
   else
      {
      alert("This form has already been submitted.  Thanks!");
      return false;
      }
}

/*Forms Handler: Recommend page; Email This*/
function reset() {
document.emailform.visitorname.value="";
document.emailform.visitormail.value="";
document.emailform.friendname.value="";
document.emailform.friendmail.value="";
document.emailform.name.value="";
document.emailform.fromemail.value="";
document.emailform.toemail.value="";
}
function checkFields() {
if ( (document.emailform.visitorname.value=="")  ||
     (document.emailform.visitormail.value=="") ||
     (document.emailform.friendname.value=="") ||
     (document.emailform.friendmail.value=="") )
   {
   alert("Please enter your Name and Email Address, and your friend's Name and Email Address. \n\nThen re-submit this form.");
   return false;
   }}
function fieldsCheck() {
if ( (document.emailform.name.value=="")  ||
     (document.emailform.fromemail.value=="") ||
     (document.emailform.toemail.value=="") )
   {
   alert("Please enter your Name and Email Address, and the Recipient\'s Email Address. \n\nThen re-submit this form.");
   return false;
   }}

/*Disable Submit While Sending*/
function disableForm(theform) {
if (document.all || document.getElementById) {
for (i = 0; i < theform.length; i++) {
var tempobj = theform.elements[i];
if (tempobj.type.toLowerCase() == "submit" || tempobj.type.toLowerCase() == "reset")
tempobj.disabled = true;
}}}

// End hiding from old browsers-->
</script>

