var totalprice = 0;
var reset_to = 0;
var packageprice = 0;
var optionValue = "Temp";

var C13price=new Array(); 
	C13price["aln"]= 150;
	C13price["alm"]= 150;
	C13price["als"]= 150;
	C13price["az"]= 250;
	C13price["ar"]= 200;
	C13price["cac"]= 300;
	C13price["cae"]= 300;
	C13price["can"]= 200;
	C13price["cas"]= 200;
	C13price["co"]= 150;
	C13price["ct"]= 150;
	C13price["dc"]= 200;
	C13price["de"]= 250;
	C13price["flm"]= 250;
	C13price["fln"]= 100;
	C13price["fls"]= 150;
	C13price["gan"]= 150;
	C13price["gas"]= 150;
	C13price["gam"]= 150;
	C13price["hi"]= 200;
	C13price["id"]= 200;
	C13price["iln"]= 250;
	C13price["ils"]= 250;
	C13price["ins"]= 200;
	C13price["kye"]= 250;
	C13price["lae"]= 100;
	C13price["lam"]= 300;
	C13price["law"]= 200;
	C13price["md"]= 150;
	C13price["ma"]= 200;
	C13price["me"]= 200;
	C13price["mie"]= 300;
	C13price["miw"]= 300;
	C13price["mn"]= 150;
	C13price["msa"]= 150;
	C13price["moe"]= 150;
	C13price["mow"]= 200;
	C13price["mt"]= 200;
	C13price["ne"]= 150;
	C13price["nv"]= 300;
	C13price["nh"]= 250;
	C13price["nj"]= 200;
	C13price["nm"]= 200;
	C13price["nye"]= 150;
	C13price["nyn"]= 250;
	C13price["nys"]= 250;
	C13price["nyw"]= 200;
	C13price["nce"]= 200;
	C13price["ncw"]= 150;
	C13price["ncm"]= 150;
	C13price["ohn"]= 200;
	C13price["ohs"]= 300;
	C13price["or"]= 150;
	C13price["pam"]= 150;
	C13price["paw"]= 150;
	C13price["pr"]= 150;
	C13price["ri"]= 200;
	C13price["sc"]= 150;
	C13price["tne"]= 100;
	C13price["tnw"]= 150;
	C13price["tnm"]= 150;
	C13price["txe"]= 150;
	C13price["txn"]= 300;
	C13price["txs"]= 200;
	C13price["txw"]= 250;
	C13price["ut"]= 100;
	C13price["vt"]= 150;
	C13price["vi"]= 150;
	C13price["va"]= 200;
	C13price["wae"]= 200;
	C13price["waw"]= 200;
	C13price["wvn"]= 250;
	C13price["wvs"]= 150;
	C13price["wie"]= 150;
	C13price["wy"]= 200;

function changeText2(chapters){
	document.getElementById('resultsChapters').innerHTML = chapters;
}

function changeText(pkginfo){
	document.getElementById('results').innerHTML = pkginfo;
}

function hidec13addon(selop) {
if(selop == null) {
	document.getElementById('resultsAddOnc13').innerHTML = " ";
		if(!document.getElementById('C7caclf')) {
			resettoPkg();
		}
	} else { 
	document.getElementById("C13" + selop).innerHTML = " ";	
	resetTotal(totalprice - C13price[selop]);	
	}	
}

function hidec7addon(selop) {
	document.getElementById('C7' + selop).innerHTML = " ";
		resetTotal(totalprice - 125);	

}

function addtoTotal(district_name, lfurl){
	if(!document.getElementById("C13" + lfurl)) {
	addto = C13price[lfurl];
	totalprice += addto;
	document.getElementById('total_price').innerHTML = "<hr>Your current total is: $"+totalprice+"<p style='font-weight:normal'><em>Please note: prices do NOT include applicable sales tax or shipping</em></p>";
	document.getElementById('resultsAddOnc13').innerHTML += "<div id='C13" + lfurl + "'>" + district_name + " Custom Chapter 13 Plan.<strong>$" + addto + "</strong> <a class='two block' target=_blank href='http://www.bestcase.com/localforms.htm#" + lfurl + "'>View Details</a><input type='button'  class='remove' onclick='removeaddOn(\""+ lfurl +"\");' value='[X] Remove' /></div>";
	
	optionValue = lfurl;
	}
}
function addtoTotalcac(addto, district_name, lfurl){
	if(!document.getElementById('hideC7caclf')) {
	totalprice = addto+totalprice;
	document.getElementById('total_price').innerHTML ="<hr>Your current total is: $"+totalprice+"<p style='font-weight:normal'><em>Please note: prices do NOT include applicable sales tax or shipping</em></p>";

	document.getElementById('resultsAddOnc7').style.display = 'block';
	document.getElementById('resultsAddOnc7').innerHTML += "<div id='C7caclf'>" + district_name + " Local Forms Package.<strong>$" + addto + "</strong> <a class='two block' target=_blank href='http://www.bestcase.com/localforms.htm#" + lfurl + "'>View Details</a><input type='button'  class='remove' onclick='removeaddOn(\"caclf\");' value='[X] Remove' /></div>";
	optionValue = lfurl;
	}
}
function resetTotal(reset_to){
	totalprice = reset_to;
	packageprice = reset_to;
	document.getElementById('total_price').innerHTML = "<hr>Your current total is: $"+totalprice+"<p style='font-weight:normal'><em>Please note: prices do NOT include applicable sales tax or shipping</em></p>";
	}
function resettoPkg() {
	document.getElementById('total_price').innerHTML = "<hr>Your current total is: $"+packageprice+"<p style='font-weight:normal'><em>Please note: prices do NOT include applicable sales tax or shipping</em></p>";
}
function removeaddOn(opval) {

	if(opval != 'cac' && opval != 'caclf') {	
		document.getElementById('removec13').innerHTML += "<input type='hidden' name='hideC13" + opval + "' id='hideC13" + opval + "' value='000'' />";
		hidec13addon(opval);
		
	} else {
	if(opval != "caclf") {
			hidec13addon(opval);
			document.getElementById('total_price').innerHTML = "<hr>Your current total is: $"+totalprice+"<p style='font-weight:normal'><em>Please note: prices do NOT include applicable sales tax or shipping</em></p>";
			document.getElementById('removec13').innerHTML += "<input type='hidden' name='hideC13" + opval + "' id='hideC13" + opval + "' value='000'' />";

		} else {
		document.getElementById('removec13').innerHTML += "<input type='hidden' name='hideC7" + opval + "' id='hideC7" + opval + "' value='000'' />";
			hidec7addon('caclf');
		}
	}
}
function iefix(optionValue)
{ 
if(!document.getElementById('C13' + optionValue)) {	
	if (document.getElementById('chapter7').checked==true)
  {
            	if(!document.getElementById('C7caclf')) 
            	{
								 switch( optionValue )
									{
										
										case "Temp" :
		
										break;
										
										case "cac" :
										
										addtoTotalcac(125.00, 'Central District of California', optionValue);
										
										break;
										
										default :
										document.getElementById('resultsAddOnc7').style.display = "block";
										if(!document.getElementById("otherForms")) {
										document.getElementById('resultsAddOnc7').innerHTML = "<a class='two block' target=_blank href='http://www.bestcase.com/localforms.htm'>View Details on local forms for your jurisdiction offered by Best Case!</a>";
									}
										resettoPkg();
									}
								            	
            	}
        
  } else {
		if(!document.getElementById('hideC13' + optionValue))
		{
			switch( optionValue )
			{
				case "Temp" :
				
				
				break;
				
				case "aln" :
				
				addtoTotal('Northern District of Alabama', optionValue);
				
				break;
				
				case "alm" :
				
				addtoTotal('Middle District of Alabama', optionValue);
				
				break;
				
				case "als" :
				
				addtoTotal('Southern District of Alabama', optionValue);
				
				break;
				
				case "az" :
				
				addtoTotal('District of Arizona', optionValue);
				
				break;
				
				case "are" :
				
				optionValue = "ar";
				addtoTotal('Eastern and Western Districts of Arkansas', optionValue);
				
				break;
				
				case "arw" :
				optionValue = "ar";
				addtoTotal('Eastern and Western Districts of Arkansas', optionValue);
				
				break;
				
				case "cac" :
				
				addtoTotal('Central District of California', optionValue);
				addtoTotalcac(125.00, 'Central District of California', optionValue);
				break;
				
				case "cae" :
				
				addtoTotal('Eastern District of California', optionValue);
				
				break;
				
				case "can" :
				
				addtoTotal('Northern District of California', optionValue);
				
				break;
				
				case "cas" :
				
				addtoTotal('Southern District of California', optionValue);
				
				break;
				
				case "co" :
				
				addtoTotal('District of Colorado', optionValue);
				
				break;
				
				case "ct" :
				
				addtoTotal('District of Connecticut', optionValue);
				
				break;
		
				
				case "dc" :
				
				addtoTotal('District of Columbia', optionValue);
				
				break;
				
				case "de" :
				
				addtoTotal('District of Delaware', optionValue);
				
				break;
				
				case "flm" :
				
				addtoTotal('Middle District of Florida', optionValue);
				
				break;
				
				case "fln" :
				
				addtoTotal('Northern District of Florida', optionValue);
				
				break;
				
				case "fls" :
				
				addtoTotal('Southern District of Florida', optionValue);
				
				break;
				
				case "gan" :
				
				addtoTotal('Northern District of Georgia', optionValue);
				
				break;
				
				case "gas" :
				
				addtoTotal('Southern District of Georgia', optionValue);
				
				break;
				
				case "gam" :
				
				addtoTotal('Middle District of Georgia', optionValue);
				
				break;
				
				case "hi" :
				
				addtoTotal('District of Hawaii', optionValue);
				
				break;
				
				case "ida" :
				
				addtoTotal('District of Idaho', optionValue);
				
				break;
				
				case "iln" :
				
				addtoTotal('Northern District of Illinois', optionValue);
				
				break;
				
				case "ils" :
				
				addtoTotal('Southern District of Illinois', optionValue);
				
				break;
				
				case "ins" :
				
				addtoTotal('Southern District of Indiana', optionValue);
				
				break;
				
				case "kye" :
				
				addtoTotal('Eastern District of Kentucky', optionValue);
				
				break;
				
				case "lae" :
				
				addtoTotal('Eastern District of Louisiana', optionValue);
				
				break;
				
				case "lam" :
				
				addtoTotal('Middle District of Louisiana', optionValue);
				
				break;
				
				case "law" :
				
				addtoTotal('Western District of Louisiana', optionValue);
				
				break;
				
				case "md" :
				
				addtoTotal('District of Maryland', optionValue);
				
				break;
				
				case "ma" :
				
				addtoTotal('District of Massachusetts', optionValue);
				
				break;
				
				case "me" :
				
				addtoTotal('District of Maine', optionValue);
				
				break;
				
				case "mie" :
				
				addtoTotal('Eastern District of Michigan', optionValue);
				
				break;
				
				case "miw" :
				
				addtoTotal('Western District of Michigan', optionValue);
				
				break;
				
				case "mn" :
				
				addtoTotal('District of Minnesota', optionValue);
				
				break;
				
				case "msa" :
				
				addtoTotal('Northern District of Mississippi', optionValue);
				
				break;
				
				case "msa" :
				
				addtoTotal('Southern District of Mississippi', optionValue);
				
				break;
				
				case "moe" :
				
				addtoTotal('Eastern District of Missouri', optionValue);
				
				break;
				
				case "mow" :
				
				addtoTotal('Western District of Missouri', optionValue);
				
				break;
				
				case "mt" :
				
				addtoTotal('District of Montana', optionValue);
				
				break;
				
				case "ne" :
				
				addtoTotal('District of Nebraska', optionValue);
				
				break;
				
				case "nv" :
				
				addtoTotal('District of Nevada', optionValue);
				
				break;
				
				case "nh" :
				
				addtoTotal('District of New Hampshire', optionValue);
				
				break;
				
				case "nj" :
				
				addtoTotal('District of New Jersey', optionValue);
				
				break;
				
				case "nm" :
				
				addtoTotal('District of New Mexico', optionValue);
				
				break;
				
				case "nye" :
				
				addtoTotal('Eastern District of New York', optionValue);
				
				break;
				
				case "nyn" :
				
				addtoTotal('Northern District of New York', optionValue);
				
				break;				
				case "nys" :
				
				addtoTotal('Southern District of New York', optionValue);
				
				break;
				
				case "nyw" :
				
				addtoTotal('Western District of New York', optionValue);
				
				break;
				
				case "nce" :
				
				addtoTotal('Eastern District of North Carolina', optionValue);
				
				break;
				
				case "ncw" :
				
				addtoTotal('Western District of North Carolina', optionValue);
				
				break;
				
				case "ncm" :
				
				addtoTotal('Middle District of North Carolina', optionValue);
				
				break;
				
				case "ohn" :
				
				addtoTotal('Northern District of Ohio', optionValue);
				
				break;
				
				case "ohs" :
				
				addtoTotal('Southern District of Ohio', optionValue);
				
				break;
				
				case "or" :
				
				addtoTotal('District of Oregon', optionValue);
				
				break;
				
				case "pam" :
				
				addtoTotal('Middle District of Pennsylvania', optionValue);
				
				break;
				
				case "paw" :
				
				addtoTotal('Western District of Pennsylvania', optionValue);
				
				break;
				
				case "pr" :
				
				addtoTotal('District of Puerto Rico', optionValue);
				
				break;
				
				case "ria" :
				
				addtoTotal('District of Rhode Island', optionValue);
				
				break;
				
				case "sc" :
				
				addtoTotal('District of South Carolina', optionValue);
				
				break;
						
				case "tne" :
				
				addtoTotal('Eastern District of Tennessee', optionValue);
				
				break;
				
				case "tnw" :
				
				addtoTotal('Western District of Tennessee', optionValue);
				
				break;
				
				case "tnm" :
				
				addtoTotal('Middle District of Tennessee', optionValue);
				
				break;
				
				case "txe" :
				
				addtoTotal('Eastern District of Texas', optionValue);
				
				break;
				
				case "txn" :
				
				addtoTotal('Northern District of Texas', optionValue);
				
				break;
				
				case "txs" :
				
				addtoTotal('Southern District of Texas', optionValue);
				
				break;
				
				case "txw" :
				
				addtoTotal('Western District of Texas', optionValue);
				
				break;
				
				case "uta" :
				
				addtoTotal('District of Utah', optionValue);
				
				break;
				
				case "vt" :
				
				addtoTotal('District of Vermont', optionValue);
				
				break;
				
				case "via" :
				
				addtoTotal('District of the Virgin Islands', optionValue);
				
				break;
				
				case "vae" :
				
				optionValue = "va";
				addtoTotal('Eastern and Western Districts of Virginia', optionValue);
				
				break;
				
				case "vaw" :
				
				optionValue = "va";
				addtoTotal('Eastern and Western Districts of Virginia', optionValue);
				
				break;
				
				case "wae" :
				
				addtoTotal('Eastern District of Washington', optionValue);
				
				break;
				
				case "waw" :
				
				addtoTotal('Western District of Washington', optionValue);
				
				break;
				
				case "wvn" :
				
				addtoTotal('Northern District of West Virginia', optionValue);
				
				break;
				
				case "wvs" :
				
				addtoTotal('Southern District of West Virginia', optionValue);
				
				break;
				
				case "wie" :
				
				addtoTotal('Eastern District of Wisconsin', optionValue);
				
				break;
				
				case "wy" :
				
				addtoTotal('District of Wyoming', optionValue);
				
				break;
				
				default :
					if(!document.getElementById('otherForms').innerHTML) {
					document.getElementById('otherForms').innerHTML += "<div id='otherForms'><a class='two block' target=_blank href='http://www.bestcase.com/localforms.htm#'>View details on all the local forms offered by Best Case!</a></div>";
				}
				break;
				
			} // endswitch

		}  //end else
	
	} // end 2nd if
} else { // else to last if 
		if(optionValue != 'caclf') {
			var d = document.getElementById('resultsAddOnc13');
		  var olddiv = document.getElementById('C13' + optionValue);
		  d.removeChild(olddiv);
			  if(!C13price[optionValue]) {
				} else {
			  resetTotal(totalprice - C13price[optionValue]);
				}
		} else {
		if(document.getElementById('C7caclf')) {
						var d = document.getElementById('resultsAddOnc7');
		 					 var olddiv = document.getElementById('C7caclf');
		  				d.removeChild(olddiv);
					}	
		}
			
			
}
} //end function call

function hideobjects() 
{
document.getElementById('suc7').style.display = 'none';
document.getElementById('suc13').style.display = 'none';
document.getElementById('suall').style.display = 'none';
document.getElementById('muc7').style.display = 'none';
document.getElementById('muc13').style.display = 'none';
document.getElementById('muall').style.display = 'none';
document.getElementById('tab3').style.display = 'none';
document.getElementById('total_price').style.display = 'none';


document.getElementById('results').innerHTML = ' ';
document.getElementById('resultsChapters').innerHTML = ' ';
document.getElementById('resultsAddOnc7').innerHTML = ' ';
document.getElementById('resultsAddOnc13').innerHTML = ' ';


document.getElementById('tab1').style.display = 'block'
}

function clearprice(version) 
{

document.getElementById('suc7').style.display = 'none';
document.getElementById('suc13').style.display = 'none';
document.getElementById('suall').style.display = 'none';
document.getElementById('muc7').style.display = 'none';
document.getElementById('muc13').style.display = 'none';
document.getElementById('muall').style.display = 'none';

pkgs();

}
function pkgs() {
if (document.getElementById('singleuserrb').checked==true)
 		{
		if (document.getElementById('chapter7').checked==true)
			{
			document.getElementById('suc7').style.display = 'block';
			document.getElementById('suc13').style.display = 'none';
			document.getElementById('suall').style.display = 'none';
			document.getElementById('tab3').style.display = 'block';
			changeText('<strong>Single User License</strong><ul class="inbody"><li>allows one attorney</li><li>one support worker</li><li>one office location</strong></li></ul>');
			changeText2('Chapter 7 Only - $995');
			resetTotal(995.00);
			checkAddOns();
			hidec13addon();
			}
			if(document.getElementById('chapter13').checked==true) {
			document.getElementById('suc13').style.display = 'block';
			document.getElementById('suc7').style.display = 'none';
			document.getElementById('suall').style.display = 'none';
			document.getElementById('tab3').style.display = 'block';
			changeText('<strong>Single User License</strong><ul class="inbody"><li>allows one attorney</li><li>one support worker</li><li>one office location</strong></li></ul>');
			changeText2('Chapters 7 &amp; 13 - $1195');
			resetTotal(1195.00);
			checkAddOns();
			
			} 
			if(document.getElementById('chapterALL').checked==true) {
			document.getElementById('suall').style.display = 'block';
			document.getElementById('suc13').style.display = 'none';
			document.getElementById('suc7').style.display = 'none';
			document.getElementById('tab3').style.display = 'block';
			changeText('<strong>Single User License</strong><ul class="inbody"><li>allows one attorney</li><li>one support worker</li><li>one office location</strong></li></ul>');
			changeText2('Chapters 7, 11, 12 &amp; 13 - $1395');
			resetTotal(1395.00);
			checkAddOns();
			
			}
		
}
if (document.getElementById('multiuserrb').checked==true)
 		{	
	if (document.getElementById('chapter7').checked==true)
			{
			document.getElementById('muc7').style.display = 'block';
			document.getElementById('muc13').style.display = 'none';
			document.getElementById('muall').style.display = 'none';
			document.getElementById('tab3').style.display = 'block';
			changeText('<strong>Multi-User License</strong><ul class="inbody"><li>Allows everone from one office location</li><li>three simultaneous users across a local area network</li></ul>');
			changeText2('Chapter 7 Only - $1495');
			resetTotal(1495.00);
			checkAddOns();
			hidec13addon();
		  }
		  if(document.getElementById('chapter13').checked==true)
		  {
		  document.getElementById('muc13').style.display = 'block';
		  document.getElementById('muc7').style.display = 'none';
		  document.getElementById('muall').style.display = 'none';
		  document.getElementById('tab3').style.display = 'block';
		  changeText('<strong>Multi-User License</strong><ul class="inbody"><li>Allows everone from one office location</li><li>three simultaneous users across a local area network</li></ul>');
		  changeText2('Chapters 7 &amp; 13 - $1695');
		  resetTotal(1695.00);
		 checkAddOns();
		  
		  } 
		  if(document.getElementById('chapterALL').checked==true)
		  {
		  document.getElementById('muall').style.display = 'block';
		  document.getElementById('muc13').style.display = 'none';
		  document.getElementById('muc7').style.display = 'none';
		  document.getElementById('tab3').style.display = 'block';
		  changeText('<strong>Multi-User License</strong><ul class="inbody"><li>Allows everone from one office location</li><li>three simultaneous users across a local area network</li></ul>');
		  changeText2('Chapters 7, 11, 12 &amp; 13 - $1895');
		  resetTotal(1895.00);
		  checkAddOns();
		  
		  }
}
}

function clearForms()
{
  var i;
  for (i = 0; (i < document.forms.length); i++) {
    document.forms[i].reset();
  }
  //document.getElementById('includeC7').value="1";
  //document.getElementById('includeC13').value="1";
}
function validate_required(field,alerttxt)
{
with (field)
  {
  if (value==null||value=="")
    { 
    alert(alerttxt);return false;
    }
  else
    {
    return true;
    }
  }
}

function validate_form(thisform)
{
with (thisform)
  {
  if (validate_required('selectJurs[]',"Please Select a Jurisdiction!")==false)
  {email.focus();return false;}
  }
}
function checkAddOns() {
	var selectJurs = new Array();
	selectJurs = getElementsByClassName('jur');
				for (i = 0; i < selectJurs.length; i++)
				{
					
					if(selectJurs[i].checked == true) { 
						if(document.getElementById('C13' + selectJurs[i].value)) {
							var d = document.getElementById('resultsAddOnc13');
		 					 var olddiv = document.getElementById('C13' + selectJurs[i].value);
		  				d.removeChild(olddiv);
						} 
						if(document.getElementById('C7caclf')) {
						var d = document.getElementById('resultsAddOnc7');
		 					 var olddiv = document.getElementById('C7caclf');
		  				d.removeChild(olddiv);
					}
						iefix(selectJurs[i].value);
						
					}
				}
			
	
}
