// * Dependencies * 

// this function requires the following snippets:

// JavaScript/readable_MM_functions/findObj

//

// Accepts a variable number of arguments, in triplets as follows:

// arg 1: simple name of a layer object, such as "Layer1"

// arg 2: ignored (for backward compatibility)

// arg 3: 'hide' or 'show'

// repeat...

//

// Example: showHideLayers(formpopup,'','show');

document.write('<script src="/cgi-bin/FormValidatorScript.js" type="text/javascript" language="JavaScript"></script>');

function showHideLayers()
{ 

  var i, visStr, obj, args = showHideLayers.arguments;

  for (i=0; i<(args.length-2); i+=3)
  {
    if ((obj = findObj(args[i])) != null)
    {
      visStr = args[i+2];
      if (obj.style)
      {
        obj = obj.style;
        if(visStr == 'show') {
	    visStr = 'visible';
	}
        else if(visStr == 'hide') {
	    visStr = 'hidden';
	}
      }
      obj.visibility = visStr;
    }
  }
  if(visStr == 'visible') {
      document.theform.realname.focus();
  }
}

// Example: obj = findObj("image1");

function findObj(theObj, theDoc)

{

  var p, i, foundObj;

  

  if(!theDoc) theDoc = document;

  if( (p = theObj.indexOf("?")) > 0 && parent.frames.length)

  {

    theDoc = parent.frames[theObj.substring(p+1)].document;

    theObj = theObj.substring(0,p);

  }

  if(!(foundObj = theDoc[theObj]) && theDoc.all) foundObj = theDoc.all[theObj];

  for (i=0; !foundObj && i < theDoc.forms.length; i++) 

    foundObj = theDoc.forms[i][theObj];

  for(i=0; !foundObj && theDoc.layers && i < theDoc.layers.length; i++) 

    foundObj = findObj(theObj,theDoc.layers[i].document);

  if(!foundObj && document.getElementById) foundObj = document.getElementById(theObj);

  

  return foundObj;

}

function IntroForm(theForm) {

    errorFree = true;
    theError = "You have entered in the following information improperly:\n";

    req_text(theForm.realname, "Name");
    req_text(theForm.real_addr, "Street Address");
    req_number_length(theForm.zip, 5, "Zip Code");

    return finish_Validation(theForm);
}

function correctAddress(theForm) {

    errorFree = true;
    theError = "You have entered in the following information improperly:\n";

    req_text(theForm.first_name, "First Name");
    req_text(theForm.last_name, "Last Name");
    req_text(theForm.real_addr, "Street Address");
    req_text(theForm.city, "City");
    req_text(theForm.state, "State");
    req_number_length(theForm.zip, 5, "Zip Code");

    return finish_Validation(theForm);
}

function quoteForm1(theForm) {

    errorFree = true;
    theError = "You have entered in the following information improperly:\n";

    req_phone_3_fields(theForm.day_phone_ac, theForm.day_phone_pre, theForm.day_phone_num, "Day Phone");
    req_phone_3_fields(theForm.eve_phone_ac, theForm.eve_phone_pre, theForm.eve_phone_num, "Contact Phone");
    req_regexp(theForm.email, ".+@.+\..+", "Email Address");
    req_number_length(theForm.year, 2, "Birth Year");
    req_number(theForm.TotalStoriesNumber, "Total Stories");
    req_number_length(theForm.YearBuilt, 4, "Year Built");
    req_number(theForm.Bedrooms, "Bedrooms");
    req_number(theForm.TotalLivingAreaSquareFeetNumber, "SquareFeet");
    req_number(theForm.Fireplaces, "Fireplaces");
    req_number(theForm.Bathrooms, "Bathrooms");
    req_text(theForm.City, "Property City");
    req_text(theForm.State, "Property State");

    return finish_Validation(theForm);
}

function quoteForm2(theForm) {
    errorFree = true;
    theError = "You have entered in the following information improperly:\n";

    return finish_Validation(theForm);
}
