<!-- 

//-------------------------------------------------------------------------------------
//
// Author:	Dan Carlson
// Modified by: Marc Fogel
// Description:	Contained JavaScript functions specific to LeadQualAnalysis.asp page
//------------------------------------------------------------------------------------- 

//-------------------------------------------------------------------------------------
// Perform input validations, set the appropriate submit action, and then submit
// input data to server.
//-------------------------------------------------------------------------------------

function LQAnalysisDoSubmit() {

	if (!ValidUserInput()) return;
    
	LQAnalysis.submit();
}


//-------------------------------------------------------------------------------------
// Inserts a red asterisk for all required fields. Note: You must add the custom 
// attribute "InputReq='y'" to all TD elements used as labels for input fields in the
// user interface.  
//-------------------------------------------------------------------------------------
function SetRequiredInputFlags() {

	var aInputFields = document.getElementsByTagName("label");
//	alert("counts " + aInputFields.length);
	var sAsterisk = '<label style="color:red;font-weight:bold">*</label>'
    
	for (var i=0; i<aInputFields.length; i++) {
		var oField = aInputFields[i];
		if (oField.getAttribute("InputReq") != null) {
		var sText = oField.innerHTML;
		oField.innerHTML = "";
		oField.innerHTML = sText + " " + sAsterisk;
		}        
	}
}

//-------------------------------------------------------------------------------------
// Validate user input.
//-------------------------------------------------------------------------------------
function ValidUserInput() {

 //   var da = document.all;
 
 	//Name.
    if ($("LQAnalysisName").value.length == 0) {
        alert("Please enter your name.");
        $("LQAnalysisName").focus();
        return false;
    }	

 	//Company Name
    if ($("LQAnalysisCompany").value.length == 0) {
        alert("Please enter your Company name.");
        $("LQAnalysisCompany").focus();
        return false;
    }

    //Email.
	
    if ($("LQAnalysisEmail").value.length == 0) {
        alert("Please enter your Email Address.");
        $("LQAnalysisEmail").focus();
        return false;
    }
	
	var apos=$("LQAnalysisEmail").value.indexOf("@");
	var dotpos=$("LQAnalysisEmail").value.lastIndexOf(".");

	if ((apos<1) || ((dotpos-apos)<2)) {
		alert("Please enter a valid email address.");
  		$("LQAnalysisEmail").focus();
  		return false;
}

    //Area code.
	
    if ($("LQAnalysisPhone1").value.length == 0) {
        alert("Please enter your area code and phone number.");
        $("LQAnalysisPhone1").focus();
        return false;
    }	

	if ($("LQAnalysisPhone1").value.length != 3) {
		alert("Please Enter 3 Digit Area Code");
		$("LQAnalysisPhone1").focus();
		return false;
   }
   
	//Phone prefix.
    if ($("LQAnalysisPhone2").value.length == 0) {
        alert("Please enter your phone number.");
        $("LQAnalysisPhone2").focus();
        return false;
    }	

	if($("LQAnalysisPhone2").value.length != 3) {
		alert("Please Enter 3 Digits");
		$("LQAnalysisPhone2").focus();
		return false;
   }
    //Phone suffix.
    if ($("LQAnalysisPhone3").value.length == 0) {
        alert("Please enter your phone number.");
        $("LQAnalysisPhone3").focus();
        return false;
    }	

	if($("LQAnalysisPhone3").value.length != 4) {
		alert("Please Enter 4 Digits");
		$("LQAnalysisPhone3").focus();
		return false;
   }
    
    //Success.
    return true;

}



	
/* This script and many more are available free online at
The JavaScript Source!! http://javascript.internet.com
Created by: Cyanide_7 |  */
var isNN = (navigator.appName.indexOf("Netscape")!=-1);

function autoTab(input,len, e) {
  var keyCode = (isNN) ? e.which : e.keyCode; 
  var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
  if(input.value.length >= len && !containsElement(filter,keyCode)) {
    input.value = input.value.slice(0, len);
    input.form[(getIndex(input)+1) % input.form.length].focus();
  }

function containsElement(arr, ele) {
    var found = false, index = 0;
    while(!found && index < arr.length)
    if(arr[index] == ele)
    found = true;
    else
    index++;
    return found;
  }

function getIndex(input) {
    var index = -1, i = 0, found = false;
    while (i < input.form.length && index == -1)
    if (input.form[i] == input)index = i;
    else i++;
    return index;
  }
  return true;
}
// * end of tab next function


function $(sName) {

	return document.getElementById(sName);
}

function FocusName() {
	$("LQAnalysisName").focus();
}

-->