<!-- 

//-------------------------------------------------------------------------------------
//
// Author:	Dan Carlson
// Modified by: Marc Fogel
// Description:	Contained JavaScript functions modified 
// for C_QuoteRequest2.asp on external website
//------------------------------------------------------------------------------------- 

//-------------------------------------------------------------------------------------
// Perform input validations, set the appropriate submit action, and then submit
// input data to server.
//-------------------------------------------------------------------------------------

function IndexDoSubmit() {

	if (!IndexValidUserInput()) return;
	//alert("Validate reached");
    
    IndexGetQuote.submit();
	//alert("Passed Submit function");
}


//-------------------------------------------------------------------------------------
// Validate user input.
//-------------------------------------------------------------------------------------
function IndexValidUserInput() {


 	//Customer Name.
    if ($("IndexQuoteName").value.length == 0) {
        alert("Please enter your name.");
        $("IndexQuoteName").focus();
        return false;
    }	

	//Email Address.
 
// 	alert("Checking email...");

    var apos=$("IndexQuoteEmail").value.indexOf("@");
    var dotpos=$("IndexQuoteEmail").value.lastIndexOf(".");

    if ((apos<1) || ((dotpos-apos)<2)) {
	    alert("Please enter valid email address.");
//        $("IndexQuoteEmail").focus();
        return false;
    }

    //Area code.
	
    if ($("IndexQuoteTelephone").value.length == 0) {
        alert("Please enter your area code and phone number.");
        $("IndexQuoteTelephone").focus();
        return false;
    }	

	if ($("IndexQuoteTelephone").value.length != 3) {
		alert("Please Enter 3 Digits");
		$("IndexQuoteTelephone").focus();
		return false;
   }
   
	//Phone prefix.
    if ($("IndexQuoteTelephone2").value.length == 0) {
        alert("Please enter your phone number.");
        $("IndexQuoteTelephone2").focus();
        return false;
    }	

	if($("IndexQuoteTelephone2").value.length != 3) {
		alert("Please Enter 3 Digits");
		$("IndexQuoteTelephone2").focus();
		return false;
   }
    //Phone suffix.
    if ($("IndexQuoteTelephone3").value.length == 0) {
        alert("Please enter your phone number.");
        $("IndexQuoteTelephone3").focus();
        return false;
    }	

	if($("IndexQuoteTelephone3").value.length != 4) {
		alert("Please Enter 4 Digits");
		$("IndexQuoteTelephone3").focus();
		return false;
   }
	
    //Service Type.
    if ($("IndexQuoteService").value == "a") {
        alert("Please select your Service.");
        $("IndexQuoteService").focus();
        return false;
    }
    
    //Primary Role.
    if ($("IndexQuoteRole").value == "a") {
        alert("Please select your Primary Role.");
        $("IndexQuoteRole").focus();
        return false;
    }
    
    //Comment field. Prevent html characters (like links).
    var strFilter = /^[A-Za-zƒŠŒŽšœžŸÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ \t\r\n\f0-9-.,:'?!()_@#$&%;=+]*$/;
    var chkVal = $("IndexQuoteComments").value;
    if (!strFilter.test(chkVal)) {
        alert("Please do not enter any html characters in the \"Comments\" field.");
        $("IndexQuoteComments").focus();
        return false;
    }
    
    //Success.
    return true;

}

function KeyPhoneNumberOnly(evt) {

	var charCode = (evt.which) ? evt.which : event.keyCode;
//	alert("charcode " + charCode + ", evt.which = " + evt.which);
    if ((charCode >= 48 && charCode <= 57)) {
        //Allow 0-9    
    }
//    else if (charCode == 45) {
//        // allow hyphen
//    }
    else {
        //Not valid.
        return false;
    }
    
    return true;    
}

function $(sName) {

	return document.getElementById(sName);
}


// ******* allows only letters in text box - no numbers or special characters
function KeyTextOnly(evt) {

	var charCode = (evt.which) ? evt.which : event.keyCode;
//	alert("charcode " + charCode + ", evt.which = " + evt.which);
    if ((charCode >= 97 && charCode <= 122)) {
        //Allow a-z    
    }
    else if ((charCode >= 65 && charCode <= 90)) {
        //Allow A-Z    
    }    
    else if (charCode == 46) {
        // allow period
    }
    else if (charCode == 32) {
        // allow space
    }
    else if (charCode == 8) {
        // allow backspace
    } 
    else {
        //Not valid.
        return false;
    }
    
    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 FocusName() {
	$("IndexQuoteName").focus();
}

-->