function toggle(obj,show) {

	var el = document.getElementById(obj);

	if (show != 0){

	    el.style.display = 'block';

	} else {

	    el.style.display = 'none';

	}

}



function step1() {

	if(!document.legalHelp.agree.checked){

		alert("You need to check this to receive the Free video and other valuable offers.");

		return false;

	}



	if (

			CheckNull(document.legalHelp.firstname, "First Name") && 

			DoRegEx1("legalHelp.firstname","First Name") && 

			CheckNull(document.legalHelp.lastname, "Last Name") && 

			DoRegEx1("legalHelp.lastname","Last Name") &&  

			CheckNull(document.legalHelp.email, "E-mail") && 

			CheckEmail(document.legalHelp.email) && 

			DoRegEx2("legalHelp.email","E-mail") &&  

			CheckValidPhoneNumber()

	){ 

	    

    	toggle('form1',0);

    	toggle('submit1',0);

    	toggle('form2',1);

    	toggle('submit2',1);

    	toggle('form3',0);

    	toggle('submit3',0);

    	document.forms[0].address.focus();	

    }

}



function step2() {

	if(!document.legalHelp.agree.checked){

		alert("You need to check this to receive the Free video and other valuable offers.");

		return false;

	}



	if (

	        CheckNull(document.legalHelp.address, "Address") &&

			CheckNull(document.legalHelp.city, "City") &&

			CheckNull(document.legalHelp.zip, "Zip")

	){

		if (document.legalHelp.state.options[document.legalHelp.state.selectedIndex].value == "")

		{

			alert("Please select a state");

			document.legalHelp.state.focus();

			return false;

		} else {	    	

        	toggle('form1',0);

        	toggle('submit1',0);

        	toggle('form2',0);

        	toggle('submit2',0);

        	toggle('form3',1);

        	toggle('submit3',1);

        	document.forms[0].timetocall.focus();

        }

    }

}

	

function step3() {

	document.legalHelp.submit();

}		



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;

}