// JavaScript Document for certificate-of-authority-online.html
var s = -1; 
var i = 0;
var _dis="";
var selValue = "WA";  //selected state
var entity = "";
var price = 0;			//state fees 
var expFee = 0;			//expedite fee				
var dis="";            //discount or add on
var NewSubTotal = 0;
var FinalTotal = 0;//total fees
var ExpProcStep1 = 0;
var selStateCorp = "";   
var selValueLLC = "";   //state fees if llc
var selValueCorp =""; //state fees if corp
var assetName = "";
var NewIncTotal = 100;  //total incorporation fees
var NewRATotal = 65;  //total registered agent fees
var NewStateFeeTotal = 0;
var tblStates = new Array();
var expFeesArray = new Array();  //stores amount of expedite fees added, index is the same as tblStates
var numStates=0;  //number of states=array length
var sts="WA";
var totalDOR = 0;
var totalLic = 0;
var cog = 0;  
var cc = 0;   
var cogFee = cog; //home state cog fee
var ccFee = cc;  //home state cc fee
var ccreq="";  //stores type of certified copy required: original or copy or "" if none
var cogreq="";  //stores type of  certificate of good standing required: original or copy or "" if none
var numCOG = 1; //total number of states requiring original COG
var numCC = 0;  //total number of states requring original certified copies 
var numCOGcopy = 1;  ///total number of states requiring copy of COG
var numCCcopy = 0;  ///total number of states requiring copy of CC
var homeState = "";
var numYears = 1;
var d = new Date();
var expMo = d.getMonth() + 1;
var y = new Date();
var expYr = y.getFullYear();

//Array.clear(tblStates);  //clear contents
function verif(myArray,myValue) {
	var yesno = eval(myArray).join().indexOf(myValue)>=0;
	return yesno;
}
function checkEmail(){
   var emailAddress = document.getElementById("emailAddress").value;
   var emCheck = document.getElementById("emCheck").value;
   if (emailAddress != emCheck){
     alert("Reenter the same email");
     return false;
   }else{
     return true;
   }
}
function usePrincipal(){
	if(document.forms[0].usePrincipalAddrs.checked == true){ 
		document.forms[0].ContactMailingAddress.value = document.forms[0].principalAddress.value;
		document.forms[0].ContactMailingAddressCity.value = document.forms[0].principalAddressCity.value;
		document.forms[0].ContactMailingAddressState.selectedIndex = document.forms[0].principalAddressState.selectedIndex;
		document.forms[0].ContactMailingAddressZip.value = document.forms[0].principalAddressZip.value;
		document.forms[0].ContactMailingAddressCountry.selectedIndex = document.forms[0].principalAddressCountry.selectedIndex; 
	}
	else{
        document.forms[0].ContactMailingAddress.value = "";
		document.forms[0].ContactMailingAddressCity.value = "";
		document.forms[0].ContactMailingAddressState.selectedIndex = "";
		document.forms[0].ContactMailingAddressZip.value = "";
		//document.forms[0].ContactMailingAddressCountry.selectedIndex = "United States";
	}
}

function checkPassword(){
   var password = document.getElementById("password").value;
   var pwCheck = document.getElementById("pwCheck").value;
   if (password != pwCheck){
     alert("Reenter the same password");
     document.form[0].pwCheck.focus();
     return false;
   }else{
     return true;
   }
}
function checkPhone(phone){	//phone numbers are accepted in the forms: (xxx)xxx-xxxx | xxx-xxx-xxxx | xxx xxx xxxx
	re = /^(\(\d{3})\)\d{3}-\d{4}$|^\d{3}-\d{3}-\d{4}$|^\d{3}\s\d{3}\s\d{4}$/;
	return re.test(phone);
}
function IsNumeric(sText)
{
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;
   for (i = 0; i < sText.length && IsNumber == true; i++)  { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1)    {
         IsNumber = false;
      }
   }
   return IsNumber;
}
//format currency
function formatCurrency(num) {
  	num = isNaN(num) || num === '' || num === null ? 0.00 : num;
	return parseFloat(num).toFixed(2);
}
function resetState(){   //clear display of state information  Not using but save.
	document.getElementById('expCorpChoice1').style.display = ""; //hide multiple expedite choices
	document.getElementById('expCorpChoice2').style.display = "";//hide multiple expedite choices
	document.getElementById('expCorpChoice3').style.display = "none";//hide multiple expedite choices
	document.getElementById('expLLCChoice1').style.display = ""; //hide multiple expedite choices
	document.getElementById('expLLCChoice2').style.display = "";//hide multiple expedite choices
	document.getElementById('expLLCChoice3').style.display = "none";//hide multiple expedite choices
	document.getElementById('expSingleL').style.display = "none";//display single expedite choice
	document.getElementById('expSingleC').style.display = "none";//display single expedite choice
	document.getElementById('optItemsDORReg').disabled=false;
	//document.forms[0].DORReg.value = "";
	document.getElementById('statePriceNV').style.display = "none";
	document.getElementById('raPriceNV').style.display = "none";
	document.getElementById('raPrice').style.display = "";
	document.getElementById('raPrice2').style.display = "";
    ExpProcStep1 = "";
}
function getHomeStateFees(){
		var selHomeState = document.getElementById("homeState");
		homeState = document.getElementById("homeState").options[selHomeState.selectedIndex].value;
		getFees(homeState);
		cogFee = cog;
		ccFee = cc;
		document.getElementById('cogsAmt').value = formatCurrency(cogFee);
		document.getElementById('ccAmt').value = formatCurrency(ccFee);
		document.getElementById('homeStateNameCOG').innerHTML =  document.getElementById("homeState").options[selHomeState.selectedIndex].text;
		document.getElementById('homeStateNameCC').innerHTML = document.getElementById("homeState").options[selHomeState.selectedIndex].text;
		//alert(homeState + " fees are cog=" + cogFee + ", copy articles= " + ccFee);
		compute(); //display fees
		
}
function getFees(selValue){  //sets variables only, no calculation
		 if(selValue != "NV"){
		 	document.getElementById('raPriceNV').style.display = "none";
            document.getElementById('raPrice').style.display = "";
		}
		if(selValue == "NV"){
		 	document.getElementById('raPriceNV').style.display = "";
            document.getElementById('raPrice').style.display = "none";
		}
		switch(selValue){
			case "AK":
			    if(entity == "LLC"){
					cog = 10;
					cc = 15;
					ccreq="";  //none required
					cogreq="";	//none required
				}else{
					cog = 10;
					cc = 15;
					ccreq="";  //none required
					cogreq="";	//none required
				}
				break;
			case "AL":
			    if(entity == "LLC"){
					cc = 6;
					cog = 5;
					ccreq="original";  //original required
					cogreq="";			//none required
				}else{
					cc = 6;
					cog = 5;
					ccreq="original";  //original required
					cogreq="";			//none required
				}
				break;
			case "AZ":
				if(entity == "LLC"){
					cc = 15;
					cog = 45;
					ccreq="copy";  //copy required
					cogreq="copy";			//copy required
				}else{
					cc = 5;
					cog = 45;
					ccreq="copy";  //copy required
					cogreq="copy";	//copy required
				}
				break;
			case "AR":
				if(entity == "LLC"){
					cc = 5;
					cog = 28;
					ccreq="";  
					cogreq="original";	//original required
				}else{
					cc = 5;
					cog = 28;
					ccreq="";  
					cogreq="original";	//original required
				}
				break;
			case "CA":
				if(entity == "LLC"){
					cc = 5;
					cog = 5;
					ccreq="";  
					cogreq="copy";	//copy required
				}else{
					cc = 5;
					cog = 5;
					ccreq="";  
					cogreq="copy";	//copy required
				}
				break;
			case "CO":
				if(entity == "LLC"){
					cc = 2;
					cog = 0;
					ccreq="";  
					cogreq="";	
				}else{
					cc = 2;
					cog = 0;
					ccreq="";  
					cogreq="";	
				}
				break;
			case "CT":
				if(entity == "LLC"){
					cc = 55;
					cog = 50;
					ccreq="";  
					cogreq="copy";	//copy requried
				}else{
					cc = 55;
					cog = 50;
					ccreq="";  
					cogreq="original";	//original required
				}
				break;
			case "DE":
				if(entity == "LLC"){
					cc = 52;
					cog = 50;
					ccreq="";  
					cogreq="copy";	//copy required
				}else{
					cc = 52;
					cog = 50;
					ccreq="";  
					cogreq="copy";	//copy required
				}
				break;
			case "DC":
				if(entity == "LLC"){
					cc = 35;
					cog = 15;
					ccreq="";  
					cogreq="copy";	//copy required
				}else{
					cc = 35;
					cog = 15;
					ccreq="";  
					cogreq="original";	//original required
				}
				break;
			case "FL":
				if(entity == "LLC"){
					cc = 30.00;
					cog = 5;
					ccreq="";  
					cogreq="original";	//original required
				}else{
					cc = 8.75;
					cog = 8.75;
					ccreq="";  
					cogreq="original";	//original required
				}
				break;
			case "GA":
				if(entity == "LLC"){
					cc = 10;
					cog = 10;
					ccreq="";  
					cogreq="copy";	//copy required
				}else{
					cc = 10;
					cog = 10;
					ccreq="";  
					cogreq="copy";	//copy required
				}
				break;
			case "HI":
				if(entity == "LLC"){
					cc = 5;
					cog = 5;
					ccreq="";  
					cogreq="copy";	//copy required
				}else{
					cc = 5;
					cog = 5;
					ccreq="";  
					cogreq="copy";	//copy required
				}
				break;
			case "ID":
				if(entity == "LLC"){
					cc = 10;
					cog = 11.50;
					ccreq="";  
					cogreq="copy";	//copy required
				}else{
					cc = 10;
					cog = 11.50;
					ccreq="";  
					cogreq="copy";	//copy required
				}
				break;
			case "IL":
				if(entity == "LLC"){
					cc = 25;
					cog = 47;
					ccreq="original";  //original required
					cogreq="original";	//original required
				}else{
					cc = 25;
					cog = 47;
					ccreq="original";  //original required
					cogreq="original";	//original required
				}
				break;
			case "IN":
				if(entity == "LLC"){
					cc = 15;
					cog = 20;
					ccreq="";  
					cogreq="original";	//original required
				}else{
					cc = 15;
					cog = 20;
					ccreq="";  
					cogreq="original";	//original required
				}
				break;
			case "IA":
				if(entity == "LLC"){
					cc = 5;
					cog = 5;
					ccreq="";  
					cogreq="copy";	//copy required
				}else{
					cc = 5;
					cog = 5;
					ccreq="";  
					cogreq="copy";	//copy required
				}
				break;
			case "KS":
				if(entity == "LLC"){
					cc = 17;
					cog = 15;
					ccreq="";  
					cogreq="original";	//original required
				}else{
					cc = 17;
					cog = 15;
					ccreq="";  
					cogreq="original";	//original required
				}
				break;
			case "KY":
				if(entity == "LLC"){
					cc = 10;
					cog = 10;
					ccreq="";  
					cogreq="copy";	//copy required
				}else{
					cc = 10;
					cog = 10;
					ccreq="";  
					cogreq="copy";	//copy required
				}
				break;
			case "LA":
				if(entity == "LLC"){
					cc = 15;
					cog = 20;
					ccreq="";  
					cogreq="copy";	//copy required
				}else{
					cc = 15;
					cog = 20;
					ccreq="";  
					cogreq="copy";	//copy required
				}
				if ((document.forms[0].expediteL.checked==true) || (document.forms[0].expediteC.checked==true)){
					expFee = 30;
				}
				break;
			case "ME":
				if(entity == "LLC"){
					cc = 8;
					cog = 30;
					ccreq="";  
					cogreq="copy";	//copy required
				}else{
					cc = 8;
					cog = 30;
					ccreq="";  
					cogreq="copy";	//copy required
				}
				if ((document.forms[0].expediteL.checked==true) || (document.forms[0].expediteC.checked==true)){
					expFee = 50;
				}
				break;
			case "MD":
				if(entity == "LLC"){
					cc = 25;  //assume 5 pages
					cog = 40;
					ccreq="";  
					cogreq="copy";	//copy required
				}else{
					cc = 25;  //assume 5 pages
					cog = 40;
					ccreq="";  
					cogreq="copy";	//copy required
				}
				break;
			case "MA":
				if(entity == "LLC"){
					cc = 15;  
					cog = 15;
					ccreq="";  
					cogreq="original";	//original required
				}else{
					cc = 15;  
					cog = 15;
					ccreq="";  
					cogreq="original";	//original required
				}
				break;
			case "MI":
				if(entity == "LLC"){
					cc = 16;  
					cog = 12.50;
					ccreq="";  
					cogreq="copy";	//copy required
				}else{
					cc = 16;  
					cog = 12.50;
					ccreq="";  
					cogreq="copy";	//copy required
				}
				break;
			case "MN":
				if(entity == "LLC"){
					cc = 21;  
					cog = 15;
					ccreq="";  
					cogreq="copy";	//copy required
				}else{
					cc = 21;  
					cog = 15;
					ccreq="";  
					cogreq="copy";	//copy required
				}
				break;
			case "MS":
				if(entity == "LLC"){
					cc = 15;  
					cog = 27;
					ccreq="";  
					cogreq="copy";	//copy required
				}else{
					cc = 15;  
					cog = 27;
					ccreq="";  
					cogreq="copy";	//copy required
				}
				break;
			case "MO":
				if(entity == "LLC"){
					cc = 10;  
					cog = 10;
					ccreq="";  
					cogreq="copy";	//copy required
				}else{
					cc = 10;  
					cog = 10;
					ccreq="";  
					cogreq="copy";	//copy required
				}
				break;
			case "MT":
				if(entity == "LLC"){
					cc = 10;  
					cog = 5;
					ccreq="";  
					cogreq="copy";	//copy required
				}else{
					cc = 10;  
					cog = 5;
					ccreq="";  
					cogreq="copy";	//copy required
				}
	
				break;
			case "NE":
				if(entity == "LLC"){
					cc = 15;  
					cog = 10;
					ccreq="";  
					cogreq="copy";	//copy required
				}else{
					cc = 15;  
					cog = 10;
					ccreq="";  
					cogreq="copy";	//copy required
				}
				break;
			case "NV":
				if(entity == "LLC"){
					cc = 40;  
					cog = 50;
					ccreq="";  
					cogreq="";	
				}else{
					cc = 40;  
					cog = 50;
					ccreq="original";  //original required
					cogreq="original";	//original required
				}
				break;
			case "NH":
				if(entity == "LLC"){
					cc = 10;  
					cog = 5;
					ccreq="";  
					cogreq="original";	//original required
				}else{
					cc = 10;  
					cog = 5;
					ccreq="";  
					cogreq="original";	//original required
				}
				break;
			case "NJ":
				if(entity == "LLC"){
					cc = 43;  
					cog = 50;
					ccreq="";  
					cogreq="copy";	//copy required
				}else{
					cc = 30;  
					cog = 25;
					ccreq="";  
					cogreq="copy";	//copy required
				 }
				break;
			case "NM":
				if(entity == "LLC"){
					cc = 35;  
					cog = 25;
					ccreq="";  
					cogreq="original";	//original required
				}else{
					cc = 35;  
					cog = 50;
					ccreq="";  
					cogreq="original";	//original required
				}
				break;
			case "NY":
				if(entity == "LLC"){
					cc = 10;  
					cog = 25;
					ccreq="";  
					cogreq="copy";	//copy required
				}else{
					cc = 10;  
					cog = 25;
					ccreq="";  
					cogreq="copy";	//copy required
				}
				break;
			case "NC":
				if(entity == "LLC"){
					cc = 12;  
					cog = 12;
					ccreq="";  
					cogreq="original";	//original required
				}else{
					cc = 12;  
					cog = 12;
					ccreq="";  
					cogreq="original";	//original required
				}
				break;
			case "ND":
				if(entity == "LLC"){
					cc = 22.50;  
					cog = 20;
					ccreq="";  
					cogreq="copy";	//copy required
				}else{
					cc = 22.50;  
					cog = 20;
					ccreq="";  
					cogreq="copy";	//copy required
				}
				break;
			case "OH":
				if(entity == "LLC"){
					cc = 5;  
					cog = 5;
					ccreq="";  
					cogreq="copy";	//copy required
				}else{
					cc = 5;  
					cog = 5;
					ccreq="";  
					cogreq="copy";	//copy required
				}
				break;
			case "OK":
				if(entity == "LLC"){
					cc = 15.60;  
					cog = 20.80;
					ccreq="";  
					cogreq="copy";	//copy required
				}else{
					cc = 15.60;  
					cog = 20.80;
					ccreq="";  
					cogreq="copy";	//copy required
				}
				break;
			case "OR":
				if(entity == "LLC"){
					cc = 15;  
					cog = 10;
					ccreq="";  
					cogreq="copy";	//copy required
				}else{
					cc = 15;  
					cog = 10;
					ccreq="";  
					cogreq="copy";	//copy required
				}
				break;
			case "PA":
				if(entity == "LLC"){
					cc = 55;  
					cog = 40;
					ccreq="";  
					cogreq="";	
				}else{
					cc = 55;  
					cog = 40;
					ccreq="";  
					cogreq="";	
				}
				break;
			case "RI":
				if(entity == "LLC"){
					cc = 10.75;  
					cog = 22;
					ccreq="";  
					cogreq="copy";	//copy required
				}else{
					cc = 10.75;  
					cog = 22;
					ccreq="";  
					cogreq="copy";	//copy required
				}
				break;
			case "SC":
				if(entity == "LLC"){
					cc = 5;  
					cog = 10;
					ccreq="";  
					cogreq="copy";	//copy required
				}else{
					cc = 5;  
					cog = 10;
					ccreq="";  
					cogreq="copy";	//copy required
				}
				break;
			case "SD":
				if(entity == "LLC"){
					cc = 20;  
					cog = 25;
					ccreq="";  
					cogreq="copy";	//copy required
				}else{
					cc = 20;  
					cog = 25;
					ccreq="";  
					cogreq="copy";	//copy required
				}
				break;
			case "TN":
				if(entity == "LLC"){
					cc = 20;  
					cog = 20;
					ccreq="";  
					cogreq="copy";	//copy required
				}else{
					cc = 20;  
					cog = 20;
					ccreq="";  
					cogreq="copy";	//copy required
				}
				break;
			case "TX":
				if(entity == "LLC"){
					cc = 20;  
					cog = 15;
					ccreq="";  
					cogreq="copy";	//copy required
				}else{
					cc = 20;  
					cog = 15;
					ccreq="";  
					cogreq="copy";	//copy required
				}
				break;
			case "UT":
				if(entity == "LLC"){
					cc = 12;  
					cog = 12;
					ccreq="";  
					cogreq="copy";	//copy required
				}else{
					cc = 12;  
					cog = 12;
					ccreq="";  
					cogreq="copy";	//copy required
				}
				break;
			case "VT":
				if(entity == "LLC"){
					cc = 25;  
					cog = 20;
					ccreq="";  
					cogreq="original";	//original required
				}else{
					cc = 25;  
					cog = 20;
					ccreq="";  
					cogreq="original";	//original required
				}
				break;
			case "VA":
				if(entity == "LLC"){
					cc = 5.50;  
					cog = 6;
					ccreq="original";  //original required
					cogreq="";	
				}else{
					cc = 5.50;  
					cog = 6;
					ccreq="original";   //original required
					cogreq="";	
				}
				break;
			case "WA":
				if(entity == "LLC"){
					price = 180;
					cc = 20;  
					cog = 70;
					ccreq="";  
					cogreq="copy";	//copy required
					document.getElementById('expSingleL').style.display = "none";
					document.getElementById('expLLCChoice1').style.display = ""; //display multiple choices
					document.getElementById('expLLCChoice2').style.display = "";
					document.getElementById('expLLCChoice3').style.display = "none";
				}else{
					price = 180;
					cc = 20;  
					cog = 70;
					ccreq="";  
					cogreq="copy";	//copy required
					document.getElementById('expSingleC').style.display = "none";
					document.getElementById('expCorpChoice1').style.display = ""; //display multiple choices
					document.getElementById('expCorpChoice2').style.display = "";
					document.getElementById('expCorpChoice3').style.display = "none";
				}
                document.getElementById('normalTimeLLC').innerHTML  = "2 months";
				document.getElementById('normalTimeCorp').innerHTML = "2 months";
				document.getElementById('ExpProcStep1LLC').innerHTML = "1 -10 days $20 <br /> walk in - same day filing $125";
				document.getElementById('ExpProcStep1Corp').innerHTML = "1 -10 days $20 <br /> walk in - same day filing $125";
				document.getElementById('exp1Corp').innerHTML  = "1 - 10 days"; //checkboxes for expedite
				document.getElementById('exp2Corp').innerHTML  = "same day"; //checkboxes for expedite
				document.getElementById('exp1LLC').innerHTML  = "1 - 10 days"; //checkboxes for expedite
				document.getElementById('exp2LLC').innerHTML  = "same day"; //checkboxes for expedite
	
				if ((document.forms[0].expediteL4.checked!=true) || (document.forms[0].expediteC4.checked!=true)){
					if ((document.forms[0].expediteL1.checked==true) || (document.forms[0].expediteC1.checked==true)){
						expFee = 20;
					}
					if ((document.forms[0].expediteL2.checked==true) || (document.forms[0].expediteC2.checked==true)){
						expFee = 125;
					}
				} else {
					document.forms[0].expediteL4.checked=true;
					expFee = 0;
				}				
				break;
			case "WV":
				if(entity == "LLC"){
					cc = 13.50;  
					cog = 10;
					ccreq="";  
					cogreq="copy";	//copy required
				}else{
					cc = 13.50;  
					cog = 10;
					ccreq="";  
					cogreq="copy";	//copy required
				}
				break;
			case "WI":
				if(entity == "LLC"){
					cc = 10;  
					cog = 10;
					ccreq="";  
					cogreq="copy";	//copy required
				}else{
					cc = 10;  
					cog = 10;
					ccreq="";  
					cogreq="copy";	//copy required
				}
				break;
			case "WY":
				if(entity == "LLC"){
					cc = 5.50;  
					cog = 0;
					ccreq="";  
					cogreq="original";	//original required
				}else{
					cc = 5.50;  
					cog = 0;
					ccreq="";  
					cogreq="original";	//original required
				}
				break;
			default:
				if(entity == "LLC"){
					price = 180;
					document.getElementById('expSingleL').style.display = "none";
					document.getElementById('expLLCChoice1').style.display = ""; //display multiple choices
					document.getElementById('expLLCChoice2').style.display = "";
					document.getElementById('expLLCChoice3').style.display = "none";
					//document.forms[0].expediteL4.checked=true;
				}else{
					price = 180;
					document.getElementById('expSingleC').style.display = "none";
					document.getElementById('expCorpChoice1').style.display = ""; //display multiple choices
					document.getElementById('expCorpChoice2').style.display = "";
					document.getElementById('expCorpChoice3').style.display = "none";
					//document.forms[0].expediteC4.checked==true;
				}
				document.getElementById('normalTimeLLC').innerHTML  = "2 months";
				document.getElementById('normalTimeCorp').innerHTML = "2 months";
				document.getElementById('ExpProcStep1LLC').innerHTML = "1 -10 days $20 <br /> walk in - same day filing $125";
				document.getElementById('ExpProcStep1Corp').innerHTML = "1 -10 days $20 <br /> walk in - same day filing $125";
				document.getElementById('exp1Corp').innerHTML  = "1 - 10 days"; //checkboxes for expedite
				document.getElementById('exp2Corp').innerHTML  = "same day"; //checkboxes for expedite
				document.getElementById('exp1LLC').innerHTML  = "1 - 10 days"; //checkboxes for expedite
				document.getElementById('exp2LLC').innerHTML  = "same day"; //checkboxes for expedite
	
				if ((document.forms[0].expediteL4.checked!=true) || (document.forms[0].expediteC4.checked!=true)){
					if ((document.forms[0].expediteL1.checked==true) || (document.forms[0].expediteC1.checked==true)){
						expFee = 20;
					}
					if ((document.forms[0].expediteL2.checked==true) || (document.forms[0].expediteC2.checked==true)){
						expFee = 95;
					}
				} else {
					document.forms[0].expediteL4.checked=true;
					expFee = 0;
				}
		}
}
function checkCC(s) {
  var i, n, c, r, t;
  // First, reverse the string and remove any non-numeric characters.
  r = "";
  for (i = 0; i < s.length; i++) {
    c = parseInt(s.charAt(i), 10);
    if (c >= 0 && c <= 9)
      r = c + r;
  }

  // Check for a bad string.
  if (r.length <= 1)
    return false;

  // Now run through each single digit to create a new string. Even digits
  // are multiplied by two, odd digits are left alone.
  t = "";
  for (i = 0; i < r.length; i++) {
    c = parseInt(r.charAt(i), 10);
    if (i % 2 != 0)
      c *= 2;
    t = t + c;
  }

  // Finally, add up all the single digits in this string.
  n = 0;
  for (i = 0; i < t.length; i++) {
    c = parseInt(t.charAt(i), 10);
    n = n + c;
  }

  // If the resulting sum is an even multiple of ten (but not zero), the
  // card number is good.
  if (n != 0 && n % 10 == 0)
    return true;
  else
    return false;
}

function compute(n){
		if(homeState == ""){ 
			alert("Select a home state");
		}
		expFee=0;
		selStateCorp = "";
		selValueLLC = "";
		selValueCorp ="";
		var selStateLLC = document.getElementById("stateLLC");
		//var selOptionLLC = document.getElementById("stateLLC").options[selStateLLC.selectedIndex].text;//don't need this
		selValueLLC = document.getElementById("stateLLC").options[selStateLLC.selectedIndex].value;
		selStateCorp = document.getElementById("stateCorp");
		//var selOptionCorp = document.getElementById("stateCorp").options[selStateCorp.selectedIndex].text;//don't need this
		selValueCorp = document.getElementById("stateCorp").options[selStateCorp.selectedIndex].value;
		
		document.getElementById('Price').value = "0.00";
		document.getElementById('ExpProcStep1').value = "0.00";
		for( i = 0; i < document.forms[0].entityType.length; i++ )
		{
		if( document.forms[0].entityType[i].checked == true )
			entity = document.forms[0].entityType[i].value;
		}
		if (document.forms[0].stateLLC.selectedIndex != ""){
			selValue = selValueLLC;
			s=1; //tracks if state was chosen
		}
		if (document.forms[0].stateCorp.selectedIndex != ""){
			selValue = selValueCorp;
			s=1;  
		}
		getFees('WA');
		if ((document.forms[0].expediteL.checked==true) || (document.forms[0].expediteC.checked==true)){
			document.getElementById('ExpProcStep1').value = formatCurrency(expFee);
		}else{
			document.getElementById('ExpProcStep1').value = "0.00";
		}

		addState();
		computeTotal(n);  //calls getFees 
		document.getElementById('ExpProcStep1').value = formatCurrency(expFee) ;
		document.getElementById('Price').value = formatCurrency(price) ;
	}
	//store states in array. if don't find state in the array, add and display string of states and add to list
	function addState(){
			NewSubTotal = 0;
			FinalTotal = 0;  //total fees
			if (homeState != selValue){
				NewStateFeeTotal = price + expFee;
				//tally number of original COGS and CC's needed
				if(ccreq=="original"){
					numCC = numCC + 1;
					//alert("# of original certified copies articles needed: " + numCC);
				}
				if(cogreq=="original"){
					numCOG = numCOG + 1;
					//alert("# of original COGS needed: " + numCOG);
				}
				//tally number of original COGS and CC's needed
				if(ccreq=="copy" ){
					numCCcopy = numCCcopy+1;
					//alert("# of copies articles needed: " + numCCcopy);
				}
				if(cogreq=="copy" ){
					numCOGcopy = numCOGcopy+1;
					//alert("# of copies of COGS needed: " + numCOGcopy);
				}
			}
			else{
				alert(selValue + " is your home state");
			}
				
	}
	 // calculates total package cost
	function computeTotal(n){
		//getFees('WA');
		FinalTotal = 0;//total fees
	    NewSubTotal=0;
		cog = 0;  //home state cog fee
		cc = 0;   //home state cc fee
		ccreq="";  //indicates if certified copy required: original or copy or "" if none
		cogreq="";  //indicates if certificate of good standing required: original or copy or "" if none
		var TotalCOGfees = 1;  //set this for WA 
		var TotalCCfees = 0; //set this for WA 
	  //Display fees
		numStates = 1
        /*for(i=0; i<numStates; i++) {  //Note needed. iterate through array and calculate cumulative ra, inc and state fees
		   selValue=tblStates[i];
		   getFees(selValue);  //determine state fee prices
		   if(selValue == "NV"){
			NVBusLic = 50;  //add NV business license
		   } 
		}*/ 
		//add COG and CC fees  **WA only needs COGS
		if(numCOG == 0){
			if(numCOGcopy == 0){
				TotalCOGfees = 0;
			}
			if(numCOGcopy != 0){
				TotalCOGfees = cogFee*1;   //need at least one ordered if copy needed
			}
		}
		if(numCOG != 0){
				TotalCOGfees = cogFee*numCOG;
		}
		if(numCC == 0){
			if(numCCcopy == 0){
				TotalCCfees = 0;
			}
			if(numCCcopy != 0){
				TotalCCfees = ccFee*1;   //need at least one ordered if copy needed
			}
		}
		if(numCC != 0){
				TotalCCfees = ccFee*numCC;
		}
		NewSubTotal = NewStateFeeTotal + TotalCCfees + TotalCOGfees + NewIncTotal + NewRATotal;  //NewStateFeeTotal from addState()
		addOptions(); //add options
		//NewSubTotal = NewStateFeeTotal + NewRATotal + NewIncTotal + TotalCCfees + TotalCOGfees + totalLic + totalDOR;
		//alert("subtotal with options" +NewSubTotal);
		var _dis="";
		//check for dis
			if(document.getElementById("dis").value.length >= 6){
				var str=document.getElementById("dis").value;
				var _dis = (str.substring(5));  
				//alert(_dis);
				if (( str.indexOf("-") == 4 ) || ( str.indexOf("+") == 4 )){
				    var dis = parseInt(_dis);
					if(str.indexOf("-") == 4 ){
					  if(NewSubTotal >= dis + 10){
					    NewSubTotal = NewSubTotal - dis;
					  } else {
					    alert("Total must be at least 10");
					  }
					} 
					
					if ( str.indexOf("+") == 4 ){
					    NewSubTotal = NewSubTotal + dis;
						//alert("subtract line1589" + NewSubTotal);
					}
					if(!IsNumeric(_dis)){
					  alert("input valid numbers");
					}
				} else {
					alert("input is invalid");
				}
			}
			//alert("subtotal with dis" + NewSubTotal);
			FinalTotal = NewSubTotal;
			document.getElementById('Total').value = FinalTotal;  //final total. leave id=Total. form field name=ItemCost
			//NewSubTotal = NewSubTotal + NewStateFeeTotal + NewRATotal + NewIncTotal + TotalCCfees + TotalCOGfees + totalLic + totalDOR;
		///////////////////////////////////reset for next state///////////////////////////
		document.getElementById('Price').value = price;  //update  state fees
		document.getElementById('ExpProcStep1').value = expFee;  //update State Expedite Fees
		document.forms[0].stateCorp.selectedIndex = "";
		document.forms[0].stateLLC.selectedIndex = "";
		////////////////////////////////display new totals
		document.getElementById('TotalOfStateFeesStep1').value = formatCurrency(expFee + price);
		document.getElementById('TotalIncFeesStep1').value = "100.00";  
		document.getElementById('StateCertFees').value = formatCurrency(TotalCCfees + TotalCOGfees);  //doesn't apply to WA
		document.getElementById('TotalRAFeesStep1').value = "65.00";  // Registered agent fees
		document.getElementById('StateFeesStep1').value = formatCurrency(NewStateFeeTotal + TotalCCfees + TotalCOGfees + NewIncTotal + NewRATotal);   //Total Package Cost
		document.getElementById('StateFeesTotal').value = formatCurrency(NewStateFeeTotal + TotalCCfees + TotalCOGfees);  //shopping cart state filing fees + total cert fees
		document.getElementById('IncAndRAFees').value="165.00";  //shopping cart inc+ra fees
		document.getElementById('SubTotal').value = formatCurrency(NewStateFeeTotal + TotalCCfees + TotalCOGfees + NewIncTotal + NewRATotal);    //shopping card Sub Total
		document.getElementById('Total').value = formatCurrency(FinalTotal);   //final total

	}
	function addOptions(){
			//add options
			numStates = 1;
					//DOR Reg
					if(document.forms[0].optItemsDORReg.checked){        
						 totalDOR = numStates*125;
						 //alert(totalDOR);
						 document.getElementById('DORReg').value = formatCurrency(totalDOR);
						 NewSubTotal = NewSubTotal + totalDOR;
						 //except NV
					}
					else{
						document.getElementById('DORReg').value = "";
						totalDOR = 0;
						NewSubTotal = NewSubTotal - totalDOR;
						   //reset if unchecked
					}
					//Lic State & local Reg
					if(document.forms[0].optItemsLicReg.checked){ 
						 totalLic = numStates*125;
						 document.getElementById('LicReg').value = formatCurrency(totalLic);
						 NewSubTotal = NewSubTotal + totalLic;
					}else{
						document.getElementById('LicReg').value = "";
						totalLic = 0;
						NewSubTotal = NewSubTotal - totalLic;   //reset if unchecked
					}
		   
    }
//add&delete state information
       function addRow(tableID) {
           var table = document.getElementById(tableID);
           var rowCount = table.rows.length;
            var row = table.insertRow(rowCount);
 
            var cell1 = row.insertCell(0);
           var element1 = document.createElement("input");
            element1.type = "checkbox";
            cell1.appendChild(element1);
 
             //var cell2 = row.insertCell(1);
            //cell2.innerHTML = rowCount + 1;
			var cell2 = row.insertCell(1);
            var element2 = document.createElement("input");
            element2.type = "text";
            cell2.appendChild(element2);
			cell2.innerHTML=selValue;
 
            var cell3 = row.insertCell(2);
            var element3 = document.createElement("input");
            element3.type = "text";
			cell3.innerHTML = "$";
            cell3.appendChild(element3);
			cell3.innerHTML=price;
			
			var cell4 = row.insertCell(3);
            var element4 = document.createElement("input");
            element4.type = "text";
			cell4.innerHTML = "$";
            cell4.appendChild(element4);
			cell4.innerHTML=expFee;
			
			var cell5 = row.insertCell(4);
            var element5 = document.createElement("input");
            element5.type = "text";
			cell5.innerHTML = "$";
            cell5.appendChild(element5);
			cell5.innerHTML=expFee+price;

			var num = rowCount-1;  //setting equal to array index
			assetName = selValue;
			var assetId = num;
			expFeesArray[assetId]=expFee;  //store expFee in array at same index
			element3.setAttribute('name', assetName);
			element3.setAttribute('id', assetId);
       }
//////end state information

function hideOpts() {
	document.getElementById('opt4').style.display = "none";
}

function showOpts() {
	document.getElementById('opt4').style.display = "block";	
}
///////////////////////LLC members/////////////////
//remove single listing for memeber, manager, officer or director
function removeListingLLC(section){
    var i=1;
	for( i = 1; i < 5; i++ ){
		var radBtnAdd="mAddress" + i;
		document.getElementById(radBtnAdd).checked=false;
	}
	var val="LLC_M_Name" + section;
	document.getElementById(val).value="";
	var maLLC="M" + section + "AnotherAddress";
	document.getElementById(maLLC).value="";
	var trVal="LLC_member" + section;
	var cbxVal="removeLLCMember" + section;
	document.getElementById(cbxVal).checked=false;
	document.getElementById(trVal).style.display="none";
}

/////////////// add LLC members or managers
var n=2
function addMemberManager(){
	n=n+1;
	
	for( i = 2; i < n; i++ )
	{
		section="LLC_member" + i;
		if(document.getElementById(section).style.display="none"){
			document.getElementById(section).style.display="";
		}
	}
		document.getElementById('spanRemoveListing').style.display="";
}
/////////////// clear all and remove all LLC members or managers except the first
var i=2;
function remMemberManager(){
	for( i = 2; i < 9; i++ )
	{
		section="LLC_member" + i;
		document.getElementById(section).style.display="none";
		document.getElementById('spanRemoveListing').style.display="none";
	}
	for( i = 1; i < 9; i++ ){
		rem="LLC_M_Name" + i;
		document.getElementById(rem).value="";
	}
	n=2;
}
///////////////////////Corp Officers/////////////////////////////
//remove single listing for corp officer
function removeListingCO(section){
    var i=1;
	for( i = 1; i < 3; i++ ){
		var radBtnAdd="CO" + i + "Address";
		document.getElementById(radBtnAdd).checked=false;
	}
	var val="CorpOfficer_Name" + section;
	document.getElementById(val).value="";
	var maCO="otherCO" + section + "Address";
	document.getElementById(maCO).value="";
	var trVal="CorpOfficer" + section;
	var cbxVal="removeOfficer" + section;
	document.getElementById(cbxVal).checked=false;
	document.getElementById(trVal).style.display="none";
}
/////////////// add Corp officer
var off=1;
function addOfficers(){
	off=off+1;
	for( i = 1; i < off; i++ )
	{
		section="CorpOfficer" + i;
		if(document.getElementById(section).style.display="none"){
			document.getElementById(section).style.display="";
		}
	}
}
/////////////// clear all and remove all corp officers  -not being used
var i=1;
function remAllCO(){
	for( i = 1; i < 9; i++ )
	{
		section="CorpOfficer" + i;
		document.getElementById(section).style.display="none";
		document.getElementById('spanRemoveListingCo').style.display="none";
	}
	for( i = 1; i < 9; i++ ){
		rem="CorpOfficer_Name" + i;
		document.getElementById(rem).value="";
	}
	off=1;
}
///////////////////////////Corp Directors///////////////////////
function removeListingCD(section){
    var i=1;
	for( i = 1; i < 3; i++ ){
		var radBtnAdd="D" + i + "Address";
		document.getElementById(radBtnAdd).checked=false;
	}
	var val="Director_Name" + section;
	document.getElementById(val).value="";
	var maCD="otherD" + section + "Address";
	document.getElementById(maCD).value="";

	var trVal="Director" + section;
	var cbxVal="removeDir" + section;
	document.getElementById(cbxVal).checked=false;
	document.getElementById(trVal).style.display="none";
}
/////////////// add Corp Director
var dir=1
function addDirector(){
	//document.getElementById(addDirHeading).style.display="";
	dir=dir+1;
	for( i = 1; i < dir; i++ )
	{
		section="Director" + i;
		if(document.getElementById(section).style.display="none"){
			document.getElementById(section).style.display="";
		}
	}

}
function displayDirector(){
	if(document.forms[0].all_Officers_are_Directors[0].checked){
	document.getElementById('yesDir').style.display="inline";
	document.getElementById('noDir').style.display="none";
	document.getElementById('AddDirector').style.display="inline";
	}
	if(document.forms[0].all_Officers_are_Directors[1].checked){
	document.getElementById('noDir').style.display="inline";
	document.getElementById('yesDir').style.display="none";
	document.getElementById('AddDirector').style.display="inline";
	}
}
/////////////////////////////////////////////////////////////////H I D E - S H O W //////////////////////////////////
//disable common shares box
function disableServices8(){
	var val = '';
	if( document.forms[0].commonShares[0].checked == true ){
		document.getElementById("spanCommonShares").style.display="none";
		document.getElementById("typeCommonShares").style.display="none";
		document.forms[0].typeCommonShares.value="";
		document.forms[0].typeCommonShares.disabled=true;
	}else{
		document.getElementById("typeCommonShares").style.display="inline";
		document.getElementById("spanCommonShares").style.display="inline";
		document.forms[0].typeCommonShares.disabled=false;
	}
}
//hide show Principal address for state  ---3 radio buttons and 1 textarea ---
function disableServices7(radiobtnName, option1, option2, option3, Ntextarea, spanId){
var val = '';
	if(radiobtnName[0].checked){
		val = radiobtnName[0].value;
	}
	if(radiobtnName[1].checked){
		val = radiobtnName[1].value;
	}
	if(radiobtnName[2].checked){
		val = radiobtnName[2].value;
	}
	if(radiobtnName[3].checked){
		val = radiobtnName[3].value;
	}
	if(val==radiobtnName[0].value || val==radiobtnName[1].value || val==radiobtnName[2].value){
		radiobtnName[0].display="none";
		document.getElementById(spanId).style.display="none";
		document.getElementById(Ntextarea).value="";
		document.getElementById(Ntextarea).disabled=true;
	}
	if(val==radiobtnName[3].value){
		document.getElementById(spanId).style.display="inline";
		document.getElementById(Ntextarea).disabled=false;
	}
}
//hide-show member or manager info 
function disableServices6(){
	var val = '';
	for( i = 0; i < document.forms[0].howManaged.length; i++ )
	{
		if( document.forms[0].howManaged[i].checked == true )
		val = document.forms[0].howManaged[i].value;
	}
	
	if(val=='Manager_Managed'){
		document.getElementById("span6").style.display="none";
		document.getElementById("span61").style.display="inline";
		document.getElementById("span62").style.display="none";
		document.getElementById("span612").style.display="inline";
		document.getElementById("span600").style.display="none";
		document.getElementById("span611").style.display="inline";
	
	}else{
		document.getElementById("span6").style.display="inline";
		document.getElementById("span61").style.display="none";
		document.getElementById("span62").style.display="inline";
		document.getElementById("span612").style.display="none";
		document.getElementById("span600").style.display="inline";
		document.getElementById("span611").style.display="none";
	
	}
}
//hide/show entityType  
function disableServices4(){
	//document.getElementById('CorpBook').value = "";   //reset fee fields if entity changes
	entity = "";
	price = 0;			//state fees			
	expFee = 0;			//expedite fee				
	dis="";            //discount or add on
	selValue = "WA";    //selected state
	NewSubTotal = 0;   //total fees
	FinalTotal = 0;//total fees
	ExpProcStep1 = 0;
	selStateCorp = "";
	selValueLLC = "";
	selValueCorp ="";
	assetName = "";
	NewIncTotal = 100;  //total incorporation fees
	NewRATotal = 65;  //total registered agent fees
	NewStateFeeTotal = 0;
	tblStates = new Array();
	expFeesArray = new Array();  //stores amount of expedite fees added, index is the same as tblStates
	numStates=0;  //number of states=array length
    cog = 0;  //home state cog fee
    cc = 0;   //home state cc fee
	ccreq="";  //stores type of  certified copy required: original or copy or "" if none
	cogreq="";  //stores type of  certificate of good standing required: original or copy or "" if none
	numCOG = 0; //total number of states requiring original COG
	numCC = 0;  //total number of states requring original certified copies 
	numCOGcopy = 0;  ///total number of states requiring copy of COG
	numCCcopy = 0;  ///total number of states requiring copy of CC	document.forms[0].AllStates.checked=false;
	document.getElementById('StateFeesTotal').value="";  //shopping cart state filing fees
	document.getElementById('IncAndRAFees').value="165.00";  //shopping cart inc+ra fees
	document.getElementById('TotalIncFeesStep1').value = "100.00";  //Total Incorporation Fees 100 or 50 x number of states
	document.getElementById('TotalRAFeesStep1').value = "65.00";  // Registered agent fees
	document.getElementById('TotalOfStateFeesStep1').value = "180.00";  //WA state Fees
	document.getElementById('StateCertFees').value = "";  //certificate fees
	document.getElementById('DORReg').value = "";   
	document.getElementById('LicReg').value = "";   
	document.getElementById('StateFeesStep1').value = "";  //Total Package cost step 1
	document.getElementById('ExpProcStep1').value = "0.00";  //clear expedite fees
    document.getElementById('SubTotal').value = "";
    document.getElementById('Total').value = ""; 
	document.forms[0].homeState.selectedIndex = "";
	document.getElementById('homeStateNameCOG').innerHTML = "";
	document.getElementById('homeStateNameCC').innerHTML = "";
	document.getElementById('cogsAmt').value = "";
	document.getElementById('ccAmt').value = "";
	//reset Nevada exceptions
	document.getElementById('statePriceNV').style.display = "none";
	document.getElementById('raPriceNV').style.display = "none";
	document.getElementById('raPrice').style.display = "";
	document.getElementById('raPrice2').style.display = "";
	document.getElementById('optItemsDORReg').disabled=false;  //enable DOR option
	document.getElementById('optItemsDORReg').checked=false;  //uncheck options
	document.forms[0].DORReg.value = "";
	document.forms[0].optItemsLicReg.checked = false;
	var val = '';
	for( i = 0; i < document.forms[0].entityType.length; i++ )
	{
		if( document.forms[0].entityType[i].checked == true )
		val = document.forms[0].entityType[i].value;
	}
	for (i=0; i < 3; i++){
	   if(document.forms[0].radExpC[i].checked == true){
			document.forms[0].radExpC[i].checked = false;
		} 
	   if(document.forms[0].radExpL[i].checked == true){
			document.forms[0].radExpL[i].checked = false;
		} 
	 }	
	if(val=='Corp'){
		document.getElementById("span2").style.display="none";
		document.getElementById("span21").style.display="";
		document.getElementById("Corp_prices").style.display="";
		document.getElementById("LLC_prices").style.display="none";
		 document.forms[0].expediteC4.checked=true;		
		for( i=0; i< document.forms[0].sectyAddress.length; i++){
			document.forms[0].sectyAddress[i].checked = false;
			document.forms[0].treasAddress[i].checked = false;
		}
		for( i=0; i< document.forms[0].PresAddress.length; i++){
			document.forms[0].PresAddress[i].checked = false;
		}
	}
	if(val=='LLC'){
		document.getElementById("span2").style.display="";
		document.getElementById("span21").style.display="none";
		document.getElementById("Corp_prices").style.display="none";
		document.getElementById("LLC_prices").style.display="";
        document.forms[0].expediteL4.checked=true;
	}
	getFees('WA');   //reload page??
}
//Notify lawsuit hide show   
function disableServices3(){
var val = '';
for( i = 0; i < document.forms[0].notifyLawSuit.length; i++ )
{
if( document.forms[0].notifyLawSuit[i].checked == true )
val = document.forms[0].notifyLawSuit[i].value;
}
if(val=='No'){
    document.getElementById("span3").style.display="none";
    document.forms[0].notifyLawSuitAddress.value="";
    document.forms[0].notifyLawSuitAddress.disabled=true;
}else{
    document.getElementById("span3").style.display="inline";
    document.forms[0].notifyLawSuitAddress.disabled=false;
}
}
//Mailing address for State - hide show  ---hide show 1 radio button and 1 textarea---   
function disableServices2(radiobtnName, option1, Ntextarea, spanId){
var val = '';
	if(radiobtnName[0].checked){
		val = radiobtnName[0].value;
	}
	if(radiobtnName[1].checked){
		val = radiobtnName[1].value;
	}

	if(val==radiobtnName[0].value){
		radiobtnName[0].display="none";
		document.getElementById(spanId).style.display="none";
		document.getElementById(Ntextarea).value="";
		document.getElementById(Ntextarea).disabled=true;
	}
	if(val==radiobtnName[1].value){
		document.getElementById(spanId).style.display="inline";
		document.getElementById(Ntextarea).disabled=false;
	}
}
//hide show Principal address for state  ---2 radio buttons and 1 textarea ---
function disableServices(radiobtnName, option1, option2, Ntextarea, spanId){
var val = '';
	if(radiobtnName[0].checked){
		val = radiobtnName[0].value;
	}
	if(radiobtnName[1].checked){
		val = radiobtnName[1].value;
	}
	if(radiobtnName[2].checked){
		val = radiobtnName[2].value;
	}
	if(val==radiobtnName[0].value || val==radiobtnName[1].value){
		radiobtnName[0].display="none";
		document.getElementById(spanId).style.display="none";
		document.getElementById(Ntextarea).value="";
		document.getElementById(Ntextarea).disabled=true;
	}
	if(val==radiobtnName[2].value){
		document.getElementById(spanId).style.display="inline";
		document.getElementById(Ntextarea).disabled=false;
	}
}
/////////////////////////////////////////////////////////////////E N D   H I D E - S H O W //////////////////////////////////
// help information pop up
var t=0;
function ShowTip(item) {
  if (!document.getElementById) return;
  thelink=document.getElementById(item);
  thetip=document.getElementById("tip-" + item);
  t=window.setTimeout("ShowIt(\""+item+"\");",500);
  thetip.style.backgroundColor="#FFD9B3";
}
function ShowIt(item) {
  t=0;
  thetip=document.getElementById("tip-" + item);
  thetip.style.visibility="visible";
}
function HideTip(item) {
  if (!document.getElementById) return;
  if (t) window.clearTimeout(t);
  thetip=document.getElementById("tip-" + item);
  thetip.style.visibility="hidden";
}
function ReLoadPage(){
	if(document.forms[0].entityType[0].checked == true || document.forms[0].entityType[1].checked == true){
		//window.location.reload();
		//document.forms[0].reset();
		document.forms[0].stateCorp.selectedIndex = "";
		document.forms[0].stateLLC.selectedIndex = "";
		document.forms[0].expediteL.checked = false;
		document.forms[0].expediteC.checked = false;
		//delete list of selected states (all rows except heading)
        var table = document.getElementById('dataTable');
        var rowCount = table.rows.length;
	   for(var i=1; i<rowCount; i++) {
		    var row = table.rows[i];
			var chkbox = row.cells[0].childNodes[0];
		    row.cells[0].childNodes[0].checked;
			table.deleteRow(i);
			rowCount--;
			i--;
		}
		tblStates.length = 0;   //clear array
		//window.location.href=window.location.href;
		//history.go(0);
	}
}
////////////////////////////////////////////////////////////////////////////SUBMIT////////////////////////////////////////////////////
function submitForm(myAction) {
	var msg="";	
	var b = -1;
	var c = -1;
    phone = document.getElementById("phoneNumber").value;
    if (homeState == "")					msg += "  * #3 Choose home State\n";
	if(selValue == "")  msg += "  * #4 Choose state to register in\n";
	if (document.forms[0].contactName.value == "")					msg += "  * #5 Contact Name and Title\n";
	if (checkPhone(phone) != true)				msg += "  * #7 Phone Number\n";			
	if ((document.forms[0].emailAddress.value.indexOf('@') == -1) || (document.forms[0].emailAddress.value.indexOf('.') == -1) || (document.forms[0].emailAddress.value.length < 7)) 
		msg += "  * #9 Email\n";
    if ((document.forms[0].emCheck.value == "") || (checkEmail() == false)){
	    msg += "  * #9 Confirm Email\n";
	    document.forms[0].emCheck.focus();
    }	
	for (var i=document.forms[0].notifyLawSuit.length-1; i > -1; i--) {
        if (document.forms[0].notifyLawSuit[i].checked) {b = i; i = -1;}
    }	
	if  (b == -1){msg += "  * #11 Attorney notification\n";}
	var val = '';
	for( i = 0; i < document.forms[0].notifyLawSuit.length; i++ )
	{
		if( document.forms[0].notifyLawSuit[i].checked == true ) val = document.forms[0].notifyLawSuit[i].value;
	}	
	if(val=='Yes'){
		if (document.forms[0].notifyLawSuitAddress.value == ""){
		    msg += "  * #11 Attorneys email address\n";
		} else {
		   	if ((document.forms[0].notifyLawSuitAddress.value.indexOf('@') == -1) || (document.forms[0].notifyLawSuitAddress.value.indexOf('.') == -1) || (document.forms[0].notifyLawSuitAddress.value.length < 7)) 
				msg += "  * #11 Attorneys email address\n";
		}

	}

     //check contact's principal address
    if (document.forms[0].principalAddressCountry.value =="United States"){
		if ((document.forms[0].principalAddress.value == "") || (document.forms[0].principalAddressCity.value == "") || (document.forms[0].principalAddressState.selectedIndex == "") || (document.forms[0].principalAddressZip.value == "") )				    msg += "* #12 Principal business address\n";
	}
	if (document.forms[0].principalAddressCountry.value !="United States"){
		if ((document.forms[0].principalAddress.value == "") || (document.forms[0].principalAddressCity.value == "") )				    msg += "* #12 Principal business address\n";
	 }
	 if(document.forms[0].usePrincipalAddrs.checked == false){ 
//check contact's mailing address
				if (document.forms[0].ContactMailingAddressCountry.value =="United States"){
				   if ((document.forms[0].ContactMailingAddress.value == "") || (document.forms[0].ContactMailingAddressCity.value == "") || (document.forms[0].ContactMailingAddressState.selectedIndex == "") || (document.forms[0].ContactMailingAddressZip.value == "") )				    msg += "* #13 Mailing address\n";
			    }
			    if (document.forms[0].ContactMailingAddressCountry.value !="United States"){
				   if ((document.forms[0].ContactMailingAddress.value == "") || (document.forms[0].ContactMailingAddressCity.value == "") )				    msg += "* #13 Mailing address\n";
			    }
    }

	if (document.forms[0].entityName.value == "")					    msg += "  * #16 Entity Name\n";
	
	//validate principal address for State
	for( i=0; i< document.forms[0].principalAddressState1.length; i++){
		if(document.forms[0].principalAddressState1[i].checked == true){
		 	val = document.forms[0].principalAddressState1[i].value;
			c=i;
		}
	}
	if(c == -1)   msg += "  * #18 Principal address for State\n";
	if(val=='DifferentAddress'){
		if (document.forms[0].AddressForState.value == ""){
		    msg += "  * #18 Specify Principal address for State\n";
		}
	}
	//validate mailing address for State
	c=-1;
	for( i=0; i< document.forms[0].mailingAddressState.length; i++){
		if(document.forms[0].mailingAddressState[i].checked == true){
		 	val = document.forms[0].mailingAddressState[i].value;
			c=i;
		}
	}
	if(c == -1)   msg += "  * #19 Mailing address for State\n";
	if(val=='DifferentAddress'){
		if (document.forms[0].mailAddressForState.value == ""){
		    msg += "  * #19 Specify mailing address for State\n";
		}
	}
	var entity = "";
	for( i = 0; i < document.forms[0].entityType.length; i++ )
	{
		if( document.forms[0].entityType[i].checked == true )
		entity = document.forms[0].entityType[i].value;
	}
	/////////LLC validate
	var mType="";
	if(entity == "LLC"){
		if((document.forms[0].howManaged[0].checked == true ) || (document.forms[0].howManaged[1].checked == true )){
		  
			if(document.forms[0].howManaged[0].checked == true ){
				mType ="member";
				if(document.forms[0].LLC_M_Name1.value == ""){   
				 msg += "  * #20b Enter at least 1 member \n"; 
				} 
			}
			if(document.forms[0].howManaged[1].checked == true ){
				mType = "manager";
				if(document.forms[0].LLC_M_Name1.value == ""){  
				  msg += "  * #20b Enter at least 1 manager \n"; 
				
				}
			}
			c=-1;
			for( i=0; i< document.forms[0].mAddress1.length; i++){
				if(document.forms[0].mAddress1[i].checked == true){
					val = document.forms[0].mAddress1[i].value;
					c=i;
				}
			}
			if(c == -1)   msg += "  * #20b Mailing address for " + mType + "\n";
			if(val=='DifferentAddress'){
				if (document.forms[0].M1AnotherAddress.value == ""){
					msg += "  * #20b Specify mailing address for " + mType + "\n";
				}
			}
		} else {
		   msg += "  * #20a Member or manager managed?\n";
		}
	}
	////////Corp validate
	if(entity == "Corp"){
		if(document.forms[0].Pres_Name.value == "")            msg += "  * #20a President's name \n";
		for( i=0; i< document.forms[0].PresAddress.length; i++){
			if(document.forms[0].PresAddress[i].checked == true){
				val = document.forms[0].PresAddress[i].value;
				c=i;
			}
		}
		if(c == -1)   msg += "  * #20a Mailing address for President \n";
		if(val=='DifferentAddress'){
			if (document.forms[0].PresAnotherAddress.value == ""){
				msg += "  * #20a Specify mailing address for President \n";
			}
		}
		c=-1;
		if(document.forms[0].Secty_Name.value == "")            msg += "  * #20b Secretary's name \n";
	    for( i=0; i< document.forms[0].sectyAddress.length; i++){
			if(document.forms[0].sectyAddress[i].checked == true){
				val = document.forms[0].sectyAddress[i].value;
				c=i;
			}
		}
		if(c == -1)   msg += "  * #20b Mailing address for Secretary \n";
		if(val=='DifferentAddress'){
			if (document.forms[0].othersectyAddress.value == ""){
				msg += "  * #20b Specify mailing address for Secretary \n";
			}
		}
		c=-1;
		if(document.forms[0].Treas_Name.value == "")            msg += "  * #20c Treasurer's name \n";
	    for( i=0; i< document.forms[0].treasAddress.length; i++){
			if(document.forms[0].treasAddress[i].checked == true){
				val = document.forms[0].treasAddress[i].value;
				c=i;
			}
		}
		if(c == -1)   msg += "  * #20c Mailing address for Treasurer \n";
		if(val=='DifferentAddress'){
			if (document.forms[0].otherTreasAddress.value == ""){
				msg += "  * #20c Specify mailing address for Treasurer \n";
			}
		}
		//require at least 1 director unless all officers are directors
		if((document.forms[0].all_Officers_are_Directors[0].checked == false) && (document.forms[0].all_Officers_are_Directors[1].checked == false)){
			msg += "  * #20e Are all officers directors? \n";
		}
		c=-1;
		if(document.forms[0].all_Officers_are_Directors[1].checked == true){
		    if(document.forms[0].Director_Name1.value == "")    msg += "  * #20e Enter at least 1 Director \n"; 
			for( i=0; i< document.forms[0].D1Address.length; i++){
				if(document.forms[0].D1Address[i].checked == true){
					val = document.forms[0].D1Address[i].value;
					c=i;
				}
			}
			if(c == -1)   msg += "  * #20e Mailing address for Director \n";
			if(val=='DifferentAddress'){
				if (document.forms[0].otherD1Address.value == ""){
					msg += "  * #20e Specify mailing address for Director \n";
				}
			}
		}
		if(document.forms[0].numShares.value == "")    msg += "  * #20f Enter number of shares \n"; 
		if(document.forms[0].parValue.value == "")    msg += "  * #20g Enter par value \n";
		if(document.forms[0].numSharesIssued.value == "")    msg += "  * #20h Enter shares issued \n";
		if((document.forms[0].commonShares[0].checked == false) && (document.forms[0].commonShares[1].checked == false)){
		  msg += "  * #20i Common shares? \n";
		} 
		if(document.forms[0].commonShares[1].checked == true){
		 if(document.forms[0].typeCommonShares.value == ""){
		    msg += "  * #20i Enter common share information. \n";
		 }
		}
	}
	if (document.forms[0].busPurpose.value == ""){
	    msg += "  * #21  Business Purpose\n";
	}	
	if (document.forms[0].password.value == ""){
	    msg += "  * Password\n";
		document.forms[0].password.focus();
	}	
	if ((document.forms[0].pwCheck.value == "") || (checkPassword() == false)){
	    msg += "  * Confirm Password\n";
		document.forms[0].pwCheck.focus();
	}	
	if (document.forms[0].serviceagreement.checked==false)    msg += "  * Please read and accept the Service Agreement \n";
	if (document.forms[0].ccLastName.value == "")					msg += "* Credit Card Last Name\n";
	if (document.forms[0].ccCardType.value == "")					msg += "* Credit Card Type (Visa, Mastercard, AmEx or Discover ) \n";
	 if (document.forms[0].ccNumber.value == ""){
	 		msg += "* Credit Card number \n";
	 } else {
		if (checkCC(document.forms[0].ccNumber.value) == false){
		   alert("INVALID");
		    msg += "* Credit Card number is invalid \n";
		 }
	 }
	//Check for expired card. January is 0, February is 1, and so on
	var mo= document.forms[0].ccExpMo.value; 
	var yr= document.forms[0].ccExpYr.value;
	var d = new Date();
	var expMo = d.getMonth() + 1;  //current month
	var y = new Date();
	var expYr = y.getFullYear();   //current year
	if((mo == "") || (yr == "")){
		msg += "* Credit Card expiration date\n";
	}else{
	if( (mo < expMo) && (expYr == yr)) msg += "* Credit Card expired\n";
	}

	
	if (document.forms[0].ccCountry.value =="United States"){
		if ((document.forms[0].ccStreet.value == "") || (document.forms[0].ccCity.value == "") || (document.forms[0].ccState.selectedIndex == "") || (document.forms[0].ccZip.value == "")    )			msg += "* Credit Card Billing Address\n";
	}
	if (document.forms[0].ccCountry.value !="United States"){
		if ((document.forms[0].ccStreet.value == "") || (document.forms[0].ccCity.value == "") )				    msg += "* Credit Card Billing Address\n";
	}
	if (msg == "") {
        sts=tblStates.join();
        document.forms[0].action = "continueIncForeign2.php?sts=WA" + "&numYears=" + 1;
	    document.forms[0].submit();
		return true;
	} else {
		alert("The following required fields are not filled out:\n" + msg);
		return false;
	}	
}
