﻿function clickButton(e, buttonid){
    var evt = e ? e : window.event;
    var bt = document.getElementById(buttonid);
    if (bt){ 
          if (evt.keyCode == 13){ 
                bt.click(); 
                return false; 
          } 
    }
}
function stripHtml(){
  var numberForms = document.forms.length;
  var formIndex =0;
  var myvalue="";
  for (formIndex=0; formIndex<numberForms; formIndex++){
    for(x=0;x<document.forms[formIndex].length;x++){
      if(document.forms[formIndex].elements[x].type=='textarea'||document.forms[formIndex].elements[x].type=='text'){
        myvalue = document.forms[formIndex].elements[x].value;
        document.forms[formIndex].elements[x].value=myvalue.replace(/(<([^>]+)>)/ig,""); 
      }
    }
  }
}
function stripNonNumeric(thisboxid){
  thisboxid.value=thisboxid.value.replace(/[^0-9]/,"");
}
function testThenStripNonNumeric(thisboxid){
  if(/[^0-9]/.test(thisboxid.value)){
    stripNonNumeric(thisboxid);
  }
}

function stripNumeric(thisboxid){
  thisboxid.value=thisboxid.value.replace(/[^a-zA-Z]+\s/,"");
}
function testThenStripNumeric(thisboxid){
  if(/[^a-zA-Z]+\s/.test(thisboxid.value)){
    stripNumeric(thisboxid);
  }
}

function stripNonMoney(thisboxid){
  thisboxid.value=thisboxid.value.replace(/[^0-9.]+$/,"");
}
function testThenStripNonMoney(thisboxid){
  if(/[^0-9.]+$/.test(thisboxid.value)){
    stripNonMoney(thisboxid);
  }
}
function validateCheckboxList(checkboxlistid){
      var formIndex =0;
      var hasChecked = false;
        for(x=0;x<document.forms[formIndex].length;x++){
          if(document.forms[formIndex].elements[x].type=='checkbox'){
            if (document.forms[formIndex].elements[x].id.indexOf(checkboxlistid)>=0){
                if(document.forms[formIndex].elements[x].checked){
                    hasChecked = true;
                    return true;
                }
            }
          }
        }
    if (!hasChecked) alert('Select one or more property types.');
    return hasChecked;
}
function email(){
    var body = "\nCheck out this page >> " + document.location.href + ".\n\nI found it on www.55plusresales.com.\n\n"
    window.location = "mailto:?subject=55+Resales.Com :: Helping people over 55 find the active adult retirement community that is right for them.&body=" + escape(body);
}
function emailListing(){
    var body = "\nI found a 55+ community that I think you would be interested in on www.55plusresales.com.\n\nClick here to view it: " + document.location.href
    window.location = "mailto:?subject=55+Resales Community Listing&body=" + escape(body);
}