//SEND REQUEST FORM VALIDATION
function requestFormValidate(){
	var msg = ""

//        if (switchDom(this,"title").value == ""){
//                msg = msg + "Please enter a title.\n"
//        }
//
	if (switchDom(this,"company").value == ""){
		msg = msg + "Please enter a company name.\n"
	}
///	
	if (switchDom(this,"firstName").value == ""){
		msg = msg + "Please enter a first name.\n"
	}
///	
	if (switchDom(this,"lastName").value == ""){
		msg = msg + "Please enter a last name.\n"
	}
///	
	if (switchDom(this,"address").value == ""){
		msg = msg + "Please enter an address.\n"
	}
///
	if (switchDom(this,"city").value == ""){
		msg = msg + "Please enter a city.\n"
	}
//
	if (switchDom(this,"state").value == ""){
		msg = msg + "Please select a state.\n"
	}
//
        if (switchDom(this,"zip").value.length < 5)
          {
           msg = msg + "The zip code must be at least 5 digits.\n"
          }
//
//      if (switchDom(this,"country").value == "")
//      {
//              msg = msg + "Please enter a country.\n"
//      }
///	
        if (switchDom(this,"workPhone").value.length < 10)
        {
         msg = msg + "The phone number must be 10 digits.\n"
        }
///
	if (switchDom(this,"email").value != "")
        {
         if (validateEmail(switchDom(this,"email").value) != true)
          {
           msg = msg + validateEmail(switchDom(this,"email").value)
          }
	}
	else
        {
         msg = msg + "Please enter a company contact email address.\n"
	}
///
	if (msg != "")
        {
         alert(msg);
	}
	else
        {
         switchDom(this,"requestForm").submit();
	}
}
//EMAIL VALIDATION
function validateEmail(email) {
            // Script prepared by Answer Studios / ToUnite.com
            // Version 1.1 (Feb. 1, 2001)
            // Logic:
            // 8 steps: Preset elements, 6 error checks, write error (if appicable)
            // --- Presets
            var count = 0;
            var error = "";
            // #1 Check if email address field is blank
                        if (email == "") {
                                    error = "";
                        }
            // #1 Check for invalid characters
            // Create an arroay of invalid characters
            if (error == "") {
            var invChars = new Array(" ", "#", "$", "%", "!", "^", "~", "'", "*", "(", ")", ",", "<", ">", "/", "\\");
            // Loop through Array and see if there are any matches, if yes then throw and error.
            for (var i = 0; i < invChars.length; i++) {
                        if (email.indexOf(invChars[i]) >= 0) {
                                    error = error + "Email address: Invalid character found.\n";
                        }
            }
            }
            // #2 If passed previous error step  >>> Check the @ symbol (1 instance of the symbol)
            if (error == "") {
                        // Loop by character through the email string for the @ symbol, count the number of instances
                        for (var i = 0; i < email.length; i++) {
                                    if (email.charAt(i) == "@") {
                                                count = count+1;
                                    }
                        }
                        // If there is not 1 instance (0 or more than 1) then throw an error.
                        if (count != 1) {
                                    error = error + "Email address: Missing the @ symbol.\n";
                        }
            }
            // Split the email string by the @ sign, forming the name portion and the domain portion.
            if (error == "") {
                        var splitEmail = email.split("@");
                        var emailName = splitEmail[0];
                        var emailDom = splitEmail[1];
                        // #3 Verify minimum characters in name portion (minimum of 1), if not throw an error.
                        if (emailName.length<1) {
                                    error = error + "Email address: Problem with the email name.\n";
                        }
                        // #4 Verify there is a . (dot) in the domain portion
                        if (emailDom.indexOf(".")<0) {
                                    error = error + "Email address: Missing the dot for the domain name.\n";
                        } else {
                                    // #5 Verify a minimum of 2 characters before the dot, if not throw an error.
                                    // First split the domain portion by the . (dot)
                                    var splitDom = emailDom.split(".");
                                    if (splitDom[0].length<2) {
                                                error = error + "Email address: Problem with the domain name or domain name missing.\n";
                                    }
                                    // #6 Verify a minimum of 2 characters after the dot, if not throw an error.
                                    if (splitDom[1].length<2) {
                                                error = error + "Email address: Invalid domain name extension (.com).\n";
                                    }
                        }
            }
            // Associate the error number into the message array for displaying results on the screen.
            if (error != ""){
              emailerror = error
            }
            else{
              emailerror = true
            }
            return emailerror
}

//function to switch the dom object between NS and IE
function switchDom(loc,objName){
	if (navigator.userAgent.toUpperCase().indexOf("NETSCAPE") != -1){
		return eval(loc).document.getElementById(objName);
	}
	else if (navigator.userAgent.toUpperCase().indexOf("MSIE") != -1){
		return eval(loc).document.all(objName);
	}
	else{
		return eval(loc).document.all(objName);
	}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function clickReset(fName) {
	var thisForm = switchDom(this,fName)
	for (i=0;i<thisForm.length;i++){
		thisForm[i].value = ""
	}
}

//Function added for clearing the form when the "Clear Application" button is clicked. (ALAugust12,2005)
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

