
function click(e)
{
/*
  if (document.all)
  {
    if(event.button==2) alert("This information is copyrighted. Please contact administrator for permission to reuse.");
    else return false;
  }
  else if (document.layers || document.getElementById)
  {
    if(e.which==3) alert("This information is copyrighted. Please contact administrator for permission to reuse.");
    else return false;
  }
*/
}
if (document.layers) document.captureEvents(Event.MOUSEDOWN);

document.onmousedown = click;

function showContent(divID,pageName)
{
  if(pageName=="people")
  {
    hideContent('busy_professionals');
    hideContent('building_owners_and_landlords');
    hideContent('single_adults_or_parents_with_children');
    hideContent('children_responsible_for_aging_parents');
    hideContent('adults_who_recently_lost_a_spouse');
    hideContent('senior_citizens');
    hideContent('home_sellers');
    hideContent('home_buyers');
    hideContent('real_estate_agents');
    hideContent('the_do_it_yourselfer');
    hideContent('great_gift_or_housewarming_present');
  }
  if(pageName=="jobs")
  {
    hideContent('interior');
    hideContent('exterior');
    hideContent('bathrooms');
    hideContent('kitchens');
    hideContent('seasonal');
    hideContent('commercial');
    hideContent('realestate');
  }
  document.getElementById(divID).style.visibility="visible";
  document.getElementById(divID).style.position="relative";
}

function hideContent(divID)
{
  document.getElementById(divID).style.visibility="hidden";
  document.getElementById(divID).style.position="absolute";
}

function defineTerm(term)
{
  if(term=="pmsk") alert('Preventive Maintenance Supply Kit\nThis customized kit consists of items typically used or consumed during any of our visits. It includes things like filters, light bulbs, cleaning supplies, and seasonal items such as lawn clean-up bags and salt for walkway ice. It is stored in an area you designate, and can be used by you when needed. Otherwise, it becomes available to the service technician during any pre-planned visit. During our visits, we also inventory the kit so that we can replenish it on subsequent visits. This kit is purchased by you, through us, and we will invoice you when we restock any items from it.');
}

function goCommand(command)
{
  document.userdata.command.value = command;
  document.userdata.submit();
}

function addressBoxChange()
{
  var isChecked = document.getElementById("sameasmailingaddress").checked;
  document.getElementById("street1b").disabled = isChecked;
  document.getElementById("street2b").disabled = isChecked;
  document.getElementById("citystatezipb").disabled = isChecked;

  var backColor = "#FFFFFF"; if(isChecked) backColor = "transparent";
  document.getElementById("street1b").style.background = backColor;
  document.getElementById("street2b").style.background = backColor;
  document.getElementById("citystatezipb").style.background = backColor;
}

function hideContactInfo()
{
  var isChecked = document.getElementById("returningclient").checked;
  if(isChecked)
  {
    hideContent("contactInfo1");
    hideContent("contactInfo2");
    hideContent("contactInfo3");
    hideContent("contactInfo4");
    showContent("contactInfo0","contact");
  }
  else
  {
    hideContent("contactInfo0");
    showContent("contactInfo1","contact");
    showContent("contactInfo2","contact");
    showContent("contactInfo3","contact");
    showContent("contactInfo4","contact");
  }
}

function confirmField(nameAndID,message)
{
  var returnValue = false;
  if(document.getElementById(nameAndID).value=="")
  {
    returnValue = true;
    alert(message);
    document.getElementById(nameAndID).focus();
  }
  return returnValue;
}

function confirmSubmit()
{
  var returnValue = true;

  if(document.getElementById("returningclient").checked)
  {
    if(confirmField("contactUserID","Please specify a user ID.")) returnValue = false;
    else if(confirmField("contactPassword","Please specify a password.")) returnValue = false;
  }
  else
  {
    if(confirmField("first","Please specify a first name.")) returnValue = false;
    else if(confirmField("last","Please specify a last name.")) returnValue = false;
    else if(confirmField("email","Please specify an e-mail address.")) returnValue = false;
    else if(document.getElementById("phone1").value=="" && document.getElementById("phone2").value=="" && document.getElementById("phone3").value=="")
    {
      returnValue = false;
      alert("Please specify a phone number.");
      document.getElementById("phone1").focus();
    }
    else if(confirmField("street1a","Please specify a mailing address.")) returnValue = false;
    else if(confirmField("citystatezipa","Please specify a mailing address.")) returnValue = false;
    else if(!document.getElementById("sameasmailingaddress").checked && confirmField("street1b","Please specify the address where work will be done.")) returnValue = false;
    else if(!document.getElementById("sameasmailingaddress").checked && confirmField("citystatezipb","Please specify the address where work will be done.")) returnValue = false;
    else if(confirmField("referral","Please specify how you heard about us.")) returnValue = false;
  }
  if(returnValue==true)
  {
    if(confirmField("jobsrequested","Please describe the job(s) requested.")) returnValue = false;
  }

  return returnValue;
}

function getCharsRemain(getFrom,displayWhere,allowedLength)
{
  var fieldLength = document.getElementById(getFrom).value.length;
  if(fieldLength>allowedLength) document.getElementById(getFrom).value = document.getElementById(getFrom).value.substring(0,allowedLength);
  var displayNumber = (allowedLength-fieldLength);
  if(displayNumber<0) displayNumber = 0;
  document.getElementById(displayWhere).innerHTML = "This field is limited to <b>" + displayNumber + "</b> additional characters.";
}
