	
function ShowHide(id) {
    obj = document.getElementsByTagName("div");
    
    obj[id].style.visibility = 'visible';

    }
function Hide(id) {
    obj = document.getElementsByTagName("div");
    
    obj[id].style.visibility = 'hidden';

    }

	
function setShipping() {
	
	var shipString = document.frmFedX.FedX.value;
	var cost=shipString.split("|");
	var subTotal = document.frmTotals.subTotal.value;
	var tax;
	
	if (document.frmCheckout.sState.value=='AZ')
	{
		tax = (+subTotal * +.0795);
	}else{
		tax = 0
	}
	
	document.getElementById('tax').innerHTML = formatCurrency(tax);
	//document.frmCheckout.shipCost.value = cost[1];
	document.getElementById('ship').innerHTML=formatCurrency(cost[1]);
	document.getElementById('total').innerHTML= formatCurrency(+subTotal + +cost[1] + +tax);
	
	
	document.frmComplete.orderTaxAmount.value = tax.toFixed(2); 
	document.frmComplete.orderCost.value = subTotal;
	document.frmComplete.orderShippingCost.value = cost[1];
	document.frmComplete.orderShipType.value = cost[0];	
	document.frmComplete.orderTotalCost.value = (+subTotal + +cost[1] + +tax).toFixed(2);	
	
	
	if (document.frmFedX.FedX.value == 'Bill My Acct|0')
	{
		ShowHide('BillAcct');
		document.frmComplete.billMyAcct.value = 1 ;
	}
	else
	{
		Hide('BillAcct');
		document.frmComplete.billMyAcct.value = 0 ;
	}
	
		ShowHide('checkOutButtons');
		Hide('shipWarning');
}

function onShipAccountEnter()

{
document.frmComplete.billShipType.value = document.frmFedX.billShipType.value ; 
document.frmComplete.billShipAcct.value = document.frmFedX.billShipAcct.value ;
document.frmComplete.billShipService.value = document.frmFedX.billShipService.value ;

}

function setNoShipping() {

	document.frmComplete2.weightTotal.value = document.frmTotals.totalDimWeight.value;
	document.frmComplete2.dimWeightTotal.value = document.frmTotals.totalWeight.value;	
	document.frmComplete2.orderTaxAmount.value = (+document.frmTotals.subTotal.value * +.0795);
	document.frmComplete2.orderCost.value = document.frmTotals.subTotal.value;
	document.frmComplete2.orderShippingCost.value = 0;	
	document.frmComplete2.orderTotalCost.value = document.frmTotals.grandTotal.value;	
}


function formatCurrency(num) {
	num = num.toString().replace(/\$|\,/g,'');
	if(isNaN(num))
	num = "0";
	sign = (num == (num = Math.abs(num)));
	num = Math.floor(num*100+0.50000000001);
	cents = num%100;
	num = Math.floor(num/100).toString();
	if(cents<10)
	cents = "0" + cents;
	for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
	num = num.substring(0,num.length-(4*i+3))+','+
	num.substring(num.length-(4*i+3));
	return (((sign)?'':'-') + '$' + num + '.' + cents);
}
