
window.onload = function()
{

	highlightGlobalNav('header');
	highlightLocalNav('right-column');

}


function highlightGlobalNav(navdiv)
{
	var thissection = window.location.toString().split('/')[3];
	var navul = document.getElementById(navdiv);
	if (navul) {
		var navanchors = navul.getElementsByTagName('a');
		if (navanchors) {
			for(var i = 0; i <= navanchors.length-1; i++) {
				if (navanchors[i].href.toString().split('/')[3] == thissection) {
					navanchors[i].className = 'here';
					break;
				} else {
					navanchors[i].className = 'nothere';
				}
			}
		}
	}
}


function highlightLocalNav(navdiv)
{
	var thispath = window.location.toString().split('#')[0].split('?')[0];
	var navwrap = document.getElementById(navdiv);
	if (navwrap) {
		var navanchors = navwrap.getElementsByTagName('a');
		if (navanchors) {
			for(var i = 0; i <= navanchors.length-1; i++) {
				if (navanchors[i].href == thispath) {
					navanchors[i].className = 'here';
					break;
				} else {
					navanchors[i].className = 'nothere';
				}
			}
		}
	}
}


function clearfield(element) 
{
	if (element.defaultValue == element.value) element.value = "";
}

function startCalc(){
	interval = setInterval("calc()",1);
}
	
function calc(){
	one = document.Form990Payment.Subtotal.value;
	two = document.Form990Payment.Tax.value; 
	document.Form990Payment.AMOUNT.value = (one * 1) + (two * 1);
}

function startCalc2(){
	interval = setInterval("calc2()",1);
}
	
function calc2(){
	one = document.Form990Payment.BQUnits.value;
	two = document.Form990Payment.OrgUnits.value;
	three = document.Form990Payment.RBQUnits.value;
	
	if (one < 51) {
		subtotal1 = (one * 200);	
	}
	
	else if (one >= 51 && one <= 100) {
		subtotal1 = (one * 150);
	}
	
	else if (one >= 101) {
		subtotal1 = (one * 100);
	}
	
	if (three < 51) {
		subtotal2 = (three * 250);	
	}
	
	else if (three >= 51 && one <= 100) {
		subtotal2 = (three * 200);
	}
	
	else if (three >= 101) {
		subtotal2 = (three * 150);
	}	
	
	document.Form990Payment.Subtotal.value = subtotal1 + subtotal2 + (two * 100);	
	
}

function startCalc3(){
	interval = setInterval("calc3()",1);
}
	
function calc3(){
	one = document.Form990Payment.BQUnits.value;
	two = document.Form990Payment.OrgUnits.value;
	three = document.Form990Payment.RBQUnits.value;

	if (one < 51) {
		subtotal1 = (one * 200);	
	}
	
	else if (one >= 51 && one <= 100) {
		subtotal1 = (one * 150);
	}
	
	else if (one >= 101) {
		subtotal1 = (one * 100);
	}
	
	if (three < 51) {
		subtotal2 = (three * 250);	
	}
	
	else if (three >= 51 && one <= 100) {
		subtotal2 = (three * 200);
	}
	
	else if (three >= 101) {
		subtotal2 = (three * 150);
	}	
	
	document.Form990Payment.AMOUNT.value = subtotal1 + subtotal2 + (two * 100);
}
	
function stopCalc(){
	clearInterval(interval);
}

function Form_Validator(theForm) {

	// check to see if the name field is blank
	if (theForm.Name.value == "") {
	  alert("You must enter a name.");
	  theForm.Name.focus();
	  return (false);
	}

	if (theForm.Firm.value == "") {
	  alert("You must enter a Firm/Organization name.");
	  theForm.Firm.focus();
	  return (false);
	}

	if (theForm.Address.value == "") {
	  alert("You must enter an address.");
	  theForm.Address.focus();
	  return (false);
	}

	if (theForm.City.value == "") {
	  alert("You must enter a city.");
	  theForm.City.focus();
	  return (false);
	}

	if (theForm.State.value == "Default") {
	  alert("You must enter a state.");
	  theForm.State.focus();
	  return (false);
	}

	if (theForm.Zip.value == ""  || theForm.Zip.value.length < 5) {
	  alert("You must enter a valid zip code.");
	  theForm.Zip.focus();
	  return (false);
	}

	if (theForm.Email.value == "") {
	  alert("You must enter an email address.");
	  theForm.Email.focus();
	  return (false);
	}

	if (theForm.Phone.value != "" && theForm.Phone.value.length < 12) {
	  alert("You have entered an invalid phone number.");
	  theForm.Email.focus();
	  return (false);
	}

	if (theForm.Fax.value != "" && theForm.Fax.value.length < 12) {
	  alert("You have entered an invalid fax number.");
	  theForm.Email.focus();
	  return (false);
	}

	if ((theForm.BQUnits.value == "" &&  theForm.RBQUnits.value == "" && theForm.OrgUnits.value == "")  || (theForm.BQUnits.value == "0" &&  theForm.RBQUnits.value == "0" && theForm.OrgUnits.value == "0") || (theForm.BQUnits.value == "0" && theForm.RBQUnits.value == "0" && theForm.OrgUnits.value == "") || 
	(theForm.BQUnits.value == "" && theForm.RBQUnits.value == "" && theForm.OrgUnits.value == "0") ||
	(theForm.BQUnits.value == "" && theForm.RBQUnits.value == "0" && theForm.OrgUnits.value == "") ||
	(theForm.BQUnits.value == "" && theForm.RBQUnits.value == "0" && theForm.OrgUnits.value == "0") ||
	(theForm.BQUnits.value == "0" && theForm.RBQUnits.value == "" && theForm.OrgUnits.value == "0") ||
	(theForm.BQUnits.value == "0" && theForm.RBQUnits.value == "" && theForm.OrgUnits.value == "")) {
	  alert("Please enter the amount of basic Board Questionnaire Templates, related Board Questionnaire Templates and/or 990 Organizers you would like to purchase.");
	  theForm.BQUnits.focus();
	  return (false);
	}

	if (theForm.BQUnits.value != "") {
		var v1=arguments[0].BQUnits.value
		var v2=v1.replace(/[^0-9]/g,"")
		if(v1!=v2) {
			alert("Please enter only numbers for the number of basic Board Questionnaire Templates you would like to purchase");arguments[0].BQUnits.focus();
			return (false);
		}
	}
	
	if (theForm.RBQUnits.value != "") {
		var v1=arguments[0].BQUnits.value
		var v2=v1.replace(/[^0-9]/g,"")
		if(v1!=v2) {
			alert("Please enter only numbers for the number of related Board Questionnaire Templates you would like to purchase");arguments[0].BQUnits.focus();
			return (false);
		}
	}	
	
	if (theForm.OrgUnits.value != "") {
		var v1=arguments[0].OrgUnits.value
		var v2=v1.replace(/[^0-9]/g,"")
		if(v1!=v2) {
			alert("Please enter only numbers for the number of 990 Organizaers you would like to purchase");arguments[0].OrgUnits.focus();
			return (false);
		}
	}	

	if (theForm.Agree.checked == false) {
	  alert("You must accept the Terms and Conditions before proceeding.");
	  theForm.Agree.focus();
	  return (false);
	}

}

function Form1_Validator(theForm) {

	if (theForm.Tax.value == ""  || theForm.Tax.value == 0) {
		alert("Washington State residents must add sales tax.");
	  	theForm.Tax.focus();
	  	return (false);
	}

}



