function roundit(Num, Places) {
	if (Places > 0) {
		if ((Num.toString().length - Num.toString().lastIndexOf('.')) > (Places + 1)) {
		  var Rounder = Math.pow(10, Places);
		  return Math.round(Num * Rounder) / Rounder;
		}
	else return Num;
	}
   	else return Math.round(Num);
}
function xGetElementById(e) {
  if(typeof(e)!='string') return e;
  if(document.getElementById) e=document.getElementById(e);
  else if(document.all) e=document.all[e];
  else e=null;
  return e;
}
function calculate() {
	var doc = document.estimate;

	try{
		fedrate = parseFloat(doc.cmn_fedrate.value);
		if(isNaN(fedrate)) fedrate=0;
	}catch(e){
		fedrate = 0;
	}
	try{
		staterate = parseFloat(doc.cmn_staterate.value);
		if(isNaN(staterate)) staterate=0;
	}catch(e){
		staterate = 0;
	}
	try{
		selfrate = parseFloat(doc.cmn_selfrate.value);
		if(isNaN(selfrate)) selfrate=0;
	}catch(e){
		selfrate = 0;
	}
	try{
		ins = parseFloat(doc.cmn_insurance.value);
		if(isNaN(ins)) ins=0;
	}catch(e){
		ins = 0;
	}
	try{
		ltc = parseFloat(doc.cmn_ltc.value);
		if(isNaN(ltc)) ltc=0;
	}catch(e){
		ltc = 0;
	}
	try{
		other = parseFloat(doc.cmn_other.value);
		if(isNaN(other)) other=0;
	}catch(e){
		other = 0;
	}
	if(doc.cmn_subScorp[0].checked){
		scorp="Y";
	}else{
		scorp="N";
	}
	try{
		state = doc.cmn_state.value;
	}catch(e){
		state = "";
	}
	if(state=="") {
		alert("Please select your state.");
	}else{
		
		calcLink = "http://www.baseonline.com/calc105.asp?"+
			"fedrate="+fedrate+
			"&staterate="+staterate+
			"&selfrate="+selfrate+
			"&ins="+ins+
			"&ltc="+ltc+
			"&scorp="+scorp+
			"&other="+other+
			"&state="+state;
		

		GB_show("Tax Savings Calculator", calcLink, 670, 480);



	}
}
function showtab( tabnum ) {
	tabname = "tab" + tabnum
	handle="document.all";
	stylevar=".style";
	hideVar="hidden";
	showVar="visible";

     
	
}
function expTable( action ) {
	

	
	
	document.estimate.cmn_other.value = roundit(+document.estimate.exp_1.value + +document.estimate.exp_2.value + +document.estimate.exp_3.value + +document.estimate.exp_4.value + +document.estimate.exp_5.value + +document.estimate.exp_6.value + +document.estimate.exp_7.value + +document.estimate.exp_8.value + +document.estimate.exp_9.value + +document.estimate.exp_10.value + +document.estimate.exp_11.value + +document.estimate.exp_12.value + +document.estimate.exp_13.value + +document.estimate.exp_14.value + +document.estimate.exp_15.value + +document.estimate.exp_16.value + +document.estimate.exp_17.value + +document.estimate.exp_18.value + +document.estimate.exp_19.value + +document.estimate.exp_20.value + +document.estimate.exp_21.value + +document.estimate.exp_22.value + +document.estimate.exp_23.value + +document.estimate.exp_24.value + +document.estimate.exp_25.value + +document.estimate.exp_26.value + +document.estimate.exp_27.value + +document.estimate.exp_28.value + +document.estimate.exp_29.value + +document.estimate.exp_30.value + +document.estimate.exp_31.value, 2);
	
	
}


function pickFedRate( fedrate, serate ) {
	var doc = document.estimate;

	doc.cmn_fedrate.value = fedrate;
	doc.cmn_selfrate.value = serate;
	//fedTaxTable('hide');
}
