
// -------------------------------------------------------------------------
// formaker.js -- Global Javascript functions for the Formaker
// Created 6-6-2000      Last modified 6-6-2000
// bill@nytebyte.com   Nytebyte Visual Development
// -------------------------------------------------------------------------

// NYTEBYTE ONLY: ----------------------------------------------------------
// This entire section is only for the image mouseovers in the nytebyte
// headings and can be deleted for the generic 1.4 version release:
// -------------------------------------------------------------------------

//global variables
 // var layerRef="null", layerStyleRef="null", styleSwitch="null";
 var origMsg = "Watch this space for helpful navigation tips!";
 var msg = origMsg;

 function init(){
       // if (navigator.appName == "Netscape") {
       //         layerStyleRef="layer.";
       //         layerRef="document.layers";
       //         styleSwitch="";
       // }
       // else {
       //         layerStyleRef="layer.style.";
       //         layerRef="document.all";
       //         styleSwitch=".style";
       // }
	   return false;
 }

function newWindow(url, windowName){
     open(url, windowName, 'scrollbars=1,resizable=1,width=600,height=400');
}

 function showLayer(layerName){
      //  eval(layerRef+'["'+layerName+'"]'+styleSwitch+'.visibility="visible";');
       if (document.getElementById) {
		 var h = document.getElementById(layerName);
         h.style.visibility='visible';
       }
 }

 function hideLayer(layerName){
       // eval(layerRef+'["'+layerName+'"]'+styleSwitch+'.visibility="hidden";');
       if (document.getElementById) {
		 var h = document.getElementById(layerName);
         h.style.visibility='hidden';
       }
 }
//------------------------------------------------------------------------------
// END OF NYTEBYTE SECTION: The following is REQUIRED to run the Formaker:
//------------------------------------------------------------------------------

//  MULTI-VERSION CAPABLE: Screened for version 4.0 or higher of Netscape and MSIE
    var bName = navigator.appName;
    var bVer  = parseInt(navigator.appVersion);
    var ok;
    var url;

     if (  (bVer >= 4) && ( (bName == "Netscape") || (bName == "Microsoft Internet Explorer")  ) )
     {   ok = 1;   }
     else { ok = 0; }

    function Example(FocusOnThis) {
       if (FocusOnThis == 'Newname') {
             fieldMsg = "The form filename is required to process your request.\n" +
                   "Please enter a name for your finished form.";
       }
       else {
             fieldMsg = "Entering data in this part of the form will have no effect." + "\n" +
             "This is just an example of the output. Use the form below" + "\n" +
             "to create your form elements." + "\n";
       }
       eval ('document.trueform.' + FocusOnThis + '.focus();');
       alert (fieldMsg);
    }

    function NewWindow (url, windowName){
         NewWindow = open(url,windowName, 'status,resizable,scrollbars,toolbar,menubar,width=550,height=350');
    }

// CHECK FORM FOR REQUIRED FIELDS, Formaker only -----------------------------------------

    function checkForm(form) {
      if (  ok == 1 ) {
        var formMsg    = "Please enter your";
        var it         = " It";
        var noName     = 1;
        var noEmail    = 1;
        var partTwoMsg = "";
        var passChecks = true;

        for (i=0; i<2; i++) {
            if (form.elements[0].value == "") { noName = 0;  }
            if (form.elements[1].value == "") { noEmail = 0; }
        }
        if ((noName == 0) || (noEmail == 0)) {
            if (noName == 0)                     { partTwoMsg = " first name";          }
            if ((noName == 0) && (noEmail == 0)) { partTwoMsg += " and";  it = " They"; }
            if (noEmail == 0)                    { partTwoMsg += " email address";      }
            formMsg += partTwoMsg;
            formMsg += "\nto use the Formaker." + it + " will only be\n" +
                       "used to create temporary files and send\n" +
                       "you a short thank-you note. You will\n" +
                       "not be put on any mailing lists!";
            passChecks = false;
        }

        if ((passChecks == true) && (form.elements[1].value != "")) {
            var found = false;
            var emailString = form.elements[1].value;
            for (j=0; j < emailString.length; j++) {
                if (emailString.charAt(j) == "@") { found = true; }
            }
            if (found == false) {
                formMsg = 'Is that your true email address?\n' +
                          'Please enter your correct email address.\n' +
                          'We will not place you on any mailing lists!\n';
                passChecks = false;
            }
        }

        if (passChecks == true) { form.submit(); }
        else if (passChecks == false) {  alert(formMsg);  }

       } // End if ok == 1
       else {
           alert('Incompatible browser version detected.\n Please use Netscape or MSIE versions 4 or higher.');
           return 0;
       }

    }

    function CheckMultiple() {

        if (document.trueform.multi[1].checked == true) {
            if (document.trueform.multisize.value == "") {

                document.trueform.multisize.focus();
                alert("If you don't set a value for the multiple" + "\n" +
                    "select size, it will be as tall as a list of your" + "\n" +
                    "items and take up a lot of space on your form." + "\n" +
                     "The example at the top of this page has a size of 4." + "\n" );
           }
        }
    }   

    function CheckAlign() {

        var left = document.choose.Align[0];
        var center = document.choose.Align[1];
        var right = document.choose.Align[2];
        var indent = document.choose.Align[3];

        if (document.choose.NewObject[11].checked==true) {
            if ((left.checked != true) && (center.checked != true) &&
               (right.checked != true) && (indent.checked != true)) {

               document.choose.NewObject[11].focus();
               alert("If you are changing alignment of your" + "\n" +
                     "form, you must choose a new alignment: left," + "\n" +
                     "centered right, or indented." + "\n");
           }
        }
    }

// END OF LIBRARY

