//mchk makes sure when a workshop is selected that a payment method is also selected
var mchk = 0

/*This function sets the price of the workshop and sets the description for the reciept.
  If an additional workshop is added (like maybe one for csfss2), make sure to add two lines like the ones between
  the dashes, under the switch(m) statement.
  ---------------------------------------------------------------------------------------------------------------
  case "BUTTON VALUE":
  desc = workshop[490000]
  ---------------------------------------------------------------------------------------------------------------
  The number inside the brackets will be determined by where you added it to the workshop descriptions at the top of the
  script.
*/
function resetForm()
{
	document.books.reset()
	textValue();
	ChangeTitle();
}
function calculatePrice()
{
var totalPrice = 0;

var DynamicWebDelivery = document.books.DynamicWebDelivery.selectedIndex;
totalPrice = DynamicWebDelivery * 52;

var InfoDev = document.books.InfoDev.selectedIndex;
totalPrice = totalPrice + InfoDev * 44;

var dita_2nd = document.books.dita_2nd.selectedIndex;
totalPrice = totalPrice + dita_2nd * 50;

var DITA_arbor = document.books.DITA_arbor.selectedIndex;
totalPrice = totalPrice + DITA_arbor * 50;

var ManagingDocumentation = document.books.ManagingDocumentation.selectedIndex;
totalPrice = totalPrice + ManagingDocumentation * 44;

var Standards = document.books.Standards.selectedIndex;
totalPrice = totalPrice + Standards * 30;

var UserandTask = document.books.UserandTask.selectedIndex;
totalPrice = totalPrice + UserandTask * 72;

//alert(totalPrice);
	
return totalPrice;	
}

function calculateTax(totalPrice)
{
	var totalTax = 0;
	var stateInteger, stateString     
	if(document.books.STATETOSHIP.disabled == true)
	{
		totalTax =0;
	}
	else
	{
		stateInteger=document.books.STATETOSHIP.selectedIndex
		stateString=document.books.STATETOSHIP.options[stateInteger].text 
	
		if (stateString == "California")
		{
			totalTax = 0.085 * totalPrice;	
		}
		else if (stateString == "Colorado")
		{
			totalTax = 0.064 * totalPrice;	
		}
		else
		{
			totalTax = 0;	
		}
	}
	return totalTax;
}

function calculateShipping()
{
	var numberOfBooks = 0;
	var countryInteger, countryString       
	countryInteger=document.books.COUNTRYTOSHIP.selectedIndex
	countryString=document.books.COUNTRYTOSHIP.options[countryInteger].text 
	
	var DynamicWebDelivery = document.books.DynamicWebDelivery.selectedIndex;
	numberOfBooks = DynamicWebDelivery;
	
	var InfoDev = document.books.InfoDev.selectedIndex;
	numberOfBooks = numberOfBooks + InfoDev;
	
	var dita_2nd = document.books.dita_2nd.selectedIndex;
	numberOfBooks = numberOfBooks + dita_2nd;
	
	var DITA_arbor = document.books.DITA_arbor.selectedIndex;
	numberOfBooks = numberOfBooks + DITA_arbor;
	
	var ManagingDocumentation = document.books.ManagingDocumentation.selectedIndex;
	numberOfBooks = numberOfBooks + ManagingDocumentation;
	
	var Standards = document.books.Standards.selectedIndex;
	numberOfBooks = numberOfBooks + Standards;
	
	var UserandTask = document.books.UserandTask.selectedIndex;
	numberOfBooks = numberOfBooks + UserandTask;
	
	if (countryString == "United States")
	{
		if (numberOfBooks >= 1)
		{
			totalShipping = 4.00 + ((numberOfBooks - 1) * 1.00);
		}
		else
		{
			totalShipping = 0;
		}
	}
	else if (countryString == "Canada")
	{
		if (numberOfBooks >= 1)
		{
			totalShipping = 10.00 + ((numberOfBooks - 1) * 6.00);
		}
		else
		{
			totalShipping = 0;
		}	
	}
	else
	{
		if (numberOfBooks >= 1)
		{
			totalShipping = 19.00 + ((numberOfBooks - 1) * 10.00);
		}
		else
		{
			totalShipping = 0;
		}	
	}
	return totalShipping;
}

function price(){
	
//m is a placeholder for the registration value
//c is the Standard Cost of the workshops
//var ecom = document.books
var totalBooks;
/*var quantity = ecom.quantity.value
var place= ecom.STATETOSHIP.value*/
var totalBooks = 0;
var DynamicWebDelivery = document.books.DynamicWebDelivery.selectedIndex;
if (DynamicWebDelivery >= 1)
{
totalBooks = DynamicWebDelivery + " DynamicWebDelivery\t";	
}

var InfoDev = document.books.InfoDev.selectedIndex;
if (InfoDev >= 1)
{
totalBooks = totalBooks + InfoDev + " InfoDev\t";	
}

var dita_2nd = document.books.dita_2nd.selectedIndex;
if(dita_2nd >= 1)
{
totalBooks = totalBooks + dita_2nd + " DITA_2nd\t";
}

var DITA_arbor = document.books.DITA_arbor.selectedIndex;
if(DITA_arbor >= 1)
{
totalBooks = totalBooks + DITA_arbor + " DITA Arbortext\t";
}

var ManagingDocumentation = document.books.ManagingDocumentation.selectedIndex;
if(ManagingDocumentation >= 1)
{
totalBooks = totalBooks + ManagingDocumentation + " ManagingDocumentation\t";
}

var Standards = document.books.Standards.selectedIndex;
if(Standards >= 1)
{
totalBooks = totalBooks + Standards + " Standards\t";
}

var UserandTask = document.books.UserandTask.selectedIndex;
if (UserandTask >= 1)
{
totalBooks = totalBooks + UserandTask + " UserandTask\t";
}
//get total price
var c = ChangeTitle();
//alert(c);
//alert(totalBooks);
document.books.DESCRIPTION.value = totalBooks;
document.books.AMOUNT.value = c;


payment();
//form validation here

//payment validation here


}
function payment()
{
	countryShip=document.books.COUNTRYTOSHIP.value;
	if (document.books.STATETOSHIPtext.disabled == true)
	{
		stateInteger=document.books.STATETOSHIP.selectedIndex
		stateString=document.books.STATETOSHIP.options[stateInteger].text
		
		countryState="null";
	}
	else
	{
		countryState=document.books.STATETOSHIPtext.value;	
		stateInteger=1;
	}
	var ecom = document.books
	if(ecom.METHOD[0].checked == true && (stateInteger != 0 && countryState !=""))
	{
			//ecom.DESCRIPTION.value = "DITA Europe Conference Registration."
			ecom.action = "https://payments.verisign.com/payflowlink"
	}
	else if(ecom.METHOD[1].checked == true && (stateInteger != 0 && countryState !=""))
	{
			ecom.DESCRIPTION.value = "This person did not pay for the Books using a Credit Card.  Please contact them for an alternative payment choice"
			ecom.action="http://www.infomanagementcenter.com/cgi/merge.pl/emerge/ditabook/text.html"
	}
	else if(countryShip != "United States")
	{
		ecom.action = "https://payments.verisign.com/payflowlink"
	}
	else
	{
		alert("You must select payment type and Country/State Information to proceed to checkout");
		return false;
	}
	ecom.NAME.disabled = false;
	ecom.ADDRESS.disabled = false;
	ecom.CITY.disabled = false;
	ecom.STATEBill.disabled = false;
	ecom.STATEBilltext.disabled = false;
	ecom.ZIP.disabled = false;
	ecom.COUNTRY.disabled = false;
	ecom.EMAIL.disabled = false;
	ecom.PHONE.disabled = false;
	ecom.submit()

}
//This function handles the payment method, whether they are going to use e-commerce or register via e-mail
/*function payment(){
var ecom = document.ditabook
var mail = document.sendmail
var bookselection= ecom.CUSTID.value

for(i=0;i<ecom.METHOD.length;i++){

	if(ecom.METHOD[i].checked==true){
		break;
	}
}

if(ecom.NAME.value != null){
	if(ecom.METHOD[i].value=='CC'){
		switch (bookselection){
		
		case "ditabook":
		ecom.DESCRIPTION.value = "This person purchased the DITA Book online."
		ecom.action = "https://payments.verisign.com/payflowlink";
		break;  
		
		case "arditabook":
		ecom.DESCRIPTION.value = "This person purchased the Abortext Edition DITA Book online."
		ecom.action = "https://payments.verisign.com/payflowlink";
		break;
		}
			
	}
		else{
			switch (bookselection){
		
		case "ditabook":
		ecom.DESCRIPTION.value = "This person did not purchase the DITA Book online.  Please contact them for an alternative payment choice"
		ecom.action="http://www.infomanagementcenter.com/cgi-bin/merge.pl/emerge/ditabook/text.txt&display=/emerge/ditabook/display.htm";
		break;  
		
		case "arditabook":
		ecom.DESCRIPTION.value = "This person did not purchase the Arbortext Edition DITA Book online.  Please contact them for an alternative payment choice"
		ecom.action="http://www.infomanagementcenter.com/cgi-bin/merge.pl/emerge/ditabook/text.txt&display=/emerge/ditabook/display.htm"
		break;
		}
			
		}
	}
	else{
		alert("You must enter your name")
	}

ecom.submit()
}*/

function billing(){
var ecom = document.books
if(ecom.samebill.checked == true){
	ecom.NAME.value = ecom.NAMETOSHIP.value
	ecom.ADDRESS.value = ecom.ADDRESSTOSHIP.value
	ecom.CITY.value = ecom.CITYTOSHIP.value
	
	ecom.ZIP.value = ecom.ZIPTOSHIP.value
	
	ecom.EMAIL.value = ecom.EMAILTOSHIP.value
	ecom.PHONE.value = ecom.PHONETOSHIP.value
	
	if(document.books.STATETOSHIP.disabled == false)
	{
	var countryInteger, countryString       
	countryInteger=document.books.COUNTRYTOSHIP.selectedIndex
	stateInteger=document.books.STATETOSHIP.selectedIndex 
	
	ecom.COUNTRY.selectedIndex = countryInteger
	ecom.STATEBill.selectedIndex = stateInteger;
	
	//
	countryString=document.books.COUNTRYTOSHIP.options[countryInteger].text
	if(countryString == "Canada")
	{		
		var STATETOSHIPList = new Array("Alberta","British Columbia","Manitoba","New Brunswick","Newfoundland","Northwest Territories","Nova Scotia","Nunavut","Ontario","Prince Edward Island","Quebec","Saskatchewan","Yukon Territory");
		document.books.STATEBill.options.length=0;
		for (i=0;i<=STATETOSHIPList.length -1;i++)
		{
		document.forms['books'].STATEBill.options[i] = new Option(STATETOSHIPList[i],STATETOSHIPList[i]);
		}
		ecom.STATEBill.selectedIndex = stateInteger;
	}
	//
	}
	else
	{
		var countryInteger, countryString       
		countryInteger=document.books.COUNTRYTOSHIP.selectedIndex
		ecom.COUNTRY.selectedIndex = countryInteger		
		document.books.STATEBill.options.length=0;
		document.books.STATEBill.disabled = true;
		document.books.STATEBill.style.visibility='hidden';
		
		
		document.books.STATEBilltext.style.visibility='visible';
		document.books.STATEBilltext.style.width='170px';
		ecom.STATEBilltext.value = ecom.STATETOSHIPtext.value;
	}
	
	ecom.NAME.disabled = true;
	ecom.ADDRESS.disabled = true;
	ecom.CITY.disabled = true;
	ecom.STATEBill.disabled = true;
	ecom.ZIP.disabled = true;
	ecom.COUNTRY.disabled = true;
	ecom.EMAIL.disabled = true;
	ecom.PHONE.disabled = true;
	
}
else{
	ecom.NAME.value = ""
	ecom.ADDRESS.value = ""
	ecom.CITY.value = ""
	ecom.STATEBill.value = ""
	ecom.ZIP.value = ""
	ecom.COUNTRY.value = ""
	ecom.EMAIL.value = ""
	ecom.PHONE.value = ""
	
	ecom.NAME.disabled = false;
	ecom.ADDRESS.disabled = false;
	ecom.CITY.disabled = false;
	ecom.STATEBill.disabled = false;
	ecom.STATEBilltext.disabled = false;
	ecom.ZIP.disabled = false;
	ecom.COUNTRY.disabled = false;
	ecom.EMAIL.disabled = false;
	ecom.PHONE.disabled = false;
	
	ecom.COUNTRY.selectedIndex = 0
	ecom.STATEBill.selectedIndex = 0
		document.books.STATEBill.style.visibility='visible';
	document.books.STATEBill.disabled = false;
	
	
	document.books.STATEBilltext.disabled = true;
	document.books.STATEBilltext.style.visibility='hidden';
	document.books.STATEBilltext.style.width='0px';
	
	var STATEBillList =  new Array("Alabama","Alaska","American Samoa","Arizona","Arkansas","Armed Forces America","Armed Forces Other Areas","Armed Forces Pacific","California","Colorado","Connecticut","Delaware","District of Columbia","Federated States of Micronesia","Florida","Georgia","Guam","Hawaii","Idaho","Illinois","Indiana","Iowa","Kansas","Kentucky","Louisiana","Maine","Marshall Islands","Maryland","Massachusetts","Michigan","Minnesota","Mississippi","Missouri","Montana","Nebraska","Nevada","New Hampshire","New Jersey","New Mexico","New York","North Carolina","North Dakota","Northern Mariana Islands","Ohio","Oklahoma","Oregon","Palau","Pennsylvania","Puerto Rico","Rhode Island","South Carolina","South Dakota","Tennessee","Texas","U.S. Virgin Islands","Utah","Vermont","Virginia","Washington","West Virginia","Wisconsin","Wyoming");
	document.books.STATEBill.options.length=0;
	for (i=0;i<=STATEBillList.length -1;i++)
	{
	document.forms['books'].STATEBill.options[i] = new Option(STATEBillList[i],STATEBillList[i]);
	}
}
}


function textValue() 
{   
var countryInteger, countryString       
countryInteger=document.books.COUNTRYTOSHIP.selectedIndex
countryString=document.books.COUNTRYTOSHIP.options[countryInteger].text  

if(countryString == "Canada")
{
	document.books.STATETOSHIP.style.visibility='visible';
	document.books.STATETOSHIP.disabled = false;
	
	
	document.books.STATETOSHIPtext.disabled = true;
	document.books.STATETOSHIPtext.style.visibility='hidden';
	document.books.STATETOSHIPtext.style.width='0px';
	
	var STATETOSHIPList = new Array("Alberta","British Columbia","Manitoba","New Brunswick","Newfoundland","Northwest Territories","Nova Scotia","Nunavut","Ontario","Prince Edward Island","Quebec","Saskatchewan","Yukon Territory");
	document.books.STATETOSHIP.options.length=0;
	for (i=0;i<=STATETOSHIPList.length -1;i++)
	{
	document.forms['books'].STATETOSHIP.options[i] = new Option(STATETOSHIPList[i],STATETOSHIPList[i]);
	}
}
else if (countryString == "United States")
{
	document.books.STATETOSHIP.style.visibility='visible';
	document.books.STATETOSHIP.disabled = false;
	
	
	document.books.STATETOSHIPtext.disabled = true;
	document.books.STATETOSHIPtext.style.visibility='hidden';
	document.books.STATETOSHIPtext.style.width='0px';
	
	var STATETOSHIPList =  new Array("Alabama","Alaska","American Samoa","Arizona","Arkansas","Armed Forces America","Armed Forces Other Areas","Armed Forces Pacific","California","Colorado","Connecticut","Delaware","District of Columbia","Federated States of Micronesia","Florida","Georgia","Guam","Hawaii","Idaho","Illinois","Indiana","Iowa","Kansas","Kentucky","Louisiana","Maine","Marshall Islands","Maryland","Massachusetts","Michigan","Minnesota","Mississippi","Missouri","Montana","Nebraska","Nevada","New Hampshire","New Jersey","New Mexico","New York","North Carolina","North Dakota","Northern Mariana Islands","Ohio","Oklahoma","Oregon","Palau","Pennsylvania","Puerto Rico","Rhode Island","South Carolina","South Dakota","Tennessee","Texas","U.S. Virgin Islands","Utah","Vermont","Virginia","Washington","West Virginia","Wisconsin","Wyoming");
	document.books.STATETOSHIP.options.length=0;
	for (i=0;i<=STATETOSHIPList.length -1;i++)
	{
	document.forms['books'].STATETOSHIP.options[i] = new Option(STATETOSHIPList[i],STATETOSHIPList[i]);
	}
}
else
{
	document.books.STATETOSHIP.options.length=0;
	document.books.STATETOSHIP.disabled = true;
	document.books.STATETOSHIP.style.visibility='hidden';
	
	document.books.STATETOSHIPtext.disabled = false;
	document.books.STATETOSHIPtext.style.visibility='visible';
	document.books.STATETOSHIPtext.style.width='170px';
}

/*var STATETOSHIPList = new Array("Australian Capital Territory","New South Wales","Northern Territory","Queensland","South Australia","Tasmania","Victoria","Western Australia","Acre","Alagoas","Amapa","Amazonas","Bahia","Ceara","Distrito Federal","Espirito Santo","Goias","Maranhao","Mato Grosso","Mato Grosso do Sul","Minas Gerais","Para","Paraiba","Parana","Pernambuco","Piaui","Rio de Janeiro","Rio Grande do Norte","Rio Grande do Sul","Rondonia","Roraima","Santa Catarina","Sao Paulo","Sergipe","Tocantins","Alberta","British Columbia","Manitoba","New Brunswick","Newfoundland","Northwest Territories","Nova Scotia","Nunavut","Ontario","Prince Edward Island","Quebec","Saskatchewan","Yukon Territory","Aichi","Akita","Aomori","Chiba","Ehime","Fukui","Fukuoka","Fukushima","Gifu","Gumma","Hiroshima","Hokkaido","Hyogo","Ibaraki","Ishikawa","Iwate","Kagawa","Kagoshima","Kanagawa","Kouchi","Kumamoto","Kyoto","Mie","Miyagi","Miyazaki","Nagano","Nagasaki","Nara","Niigata","Oita","Okayama","Okinawa","Osaka","Saga","Saitama","Shiga","Shimane","Shizuoka","Tochigi","Tokushima","Tokyo","Tottori","Toyama","Wakayama","Yamagata","Yamaguchi","Yamanashi","Aguascalientes","Baja California","Baja California Sur","Campeche","Chiapas","Chihuahua","Coahuila","Colima","Distrito Federal","Durango","Guanajuato","Guerrero","Hidalgo","Jalisco","Mexico","Michoacan","Morelos","Nayarit","Nuevo Leon","Oaxaca","Puebla","Queretaro","Quintana Roo","San Luis Potosi","Sinaloa","Sonora","Tabasco","Tamaulipas","Tlaxcala","Veracruz","Yucatan","Zacatecas","Alabama","Alaska","American Samoa","Arizona","Arkansas","Armed Forces America","Armed Forces Other Areas","Armed Forces Pacific","California","Colorado","Connecticut","Delaware","District of Columbia","Federated STATETOSHIPs of Micronesia","Florida","Georgia","Guam","Hawaii","Idaho","Illinois","Indiana","Iowa","Kansas","Kentucky","Louisiana","Maine","Marshall Islands","Maryland","Massachusetts","Michigan","Minnesota","Mississippi","Missouri","Montana","Nebraska","Nevada","New Hampshire","New Jersey","New Mexico","New York","North Carolina","North Dakota","Northern Mariana Islands","Ohio","Oklahoma","Oregon","Palau","Pennsylvania","Puerto Rico","Rhode Island","South Carolina","South Dakota","Tennessee","Texas","U.S. Virgin Islands","Utah","Vermont","Virginia","Washington","West Virginia","Wisconsin","Wyoming");*/


/*stationString=document.stationform.stationselect.options[stationInteger].text   
document.stationform.stationtext.value = "A " + stationString +" A"
document.stationform.stationtext2.value = "B " + stationString +" B"
document.stationform.stationtext3.value = "C " + stationString +" C"*/



}
function textValueBill() 
{   

var countryInteger, countryString       
countryInteger=document.books.COUNTRY.selectedIndex
countryString=document.books.COUNTRY.options[countryInteger].text  

if(countryString == "Canada")
{
	document.books.STATEBill.style.visibility='visible';
	document.books.STATEBill.disabled = false;
	
	
	document.books.STATEBilltext.disabled = true;
	document.books.STATEBilltext.style.visibility='hidden';
	document.books.STATEBilltext.style.width='0px';
	
	var STATEBillList = new Array("Alberta","British Columbia","Manitoba","New Brunswick","Newfoundland","Northwest Territories","Nova Scotia","Nunavut","Ontario","Prince Edward Island","Quebec","Saskatchewan","Yukon Territory");
	document.books.STATE.options.length=0;
	for (i=0;i<=STATEBillList.length -1;i++)
	{
	document.forms['books'].STATEBill.options[i] = new Option(STATEBillList[i],STATEBillList[i]);
	}
}
else if (countryString == "United States")
{
	document.books.STATEBill.style.visibility='visible';
	document.books.STATEBill.disabled = false;
	
	
	document.books.STATEBilltext.disabled = true;
	document.books.STATEBilltext.style.visibility='hidden';
	document.books.STATEBilltext.style.width='0px';
	
	var STATEBillList =  new Array("Alabama","Alaska","American Samoa","Arizona","Arkansas","Armed Forces America","Armed Forces Other Areas","Armed Forces Pacific","California","Colorado","Connecticut","Delaware","District of Columbia","Federated States of Micronesia","Florida","Georgia","Guam","Hawaii","Idaho","Illinois","Indiana","Iowa","Kansas","Kentucky","Louisiana","Maine","Marshall Islands","Maryland","Massachusetts","Michigan","Minnesota","Mississippi","Missouri","Montana","Nebraska","Nevada","New Hampshire","New Jersey","New Mexico","New York","North Carolina","North Dakota","Northern Mariana Islands","Ohio","Oklahoma","Oregon","Palau","Pennsylvania","Puerto Rico","Rhode Island","South Carolina","South Dakota","Tennessee","Texas","U.S. Virgin Islands","Utah","Vermont","Virginia","Washington","West Virginia","Wisconsin","Wyoming");
	document.books.STATEBill.options.length=0;
	for (i=0;i<=STATEBillList.length -1;i++)
	{
	document.forms['books'].STATEBill.options[i] = new Option(STATEBillList[i],STATEBillList[i]);
	}
}
else
{
	document.books.STATEBill.options.length=0;
	document.books.STATEBill.disabled = true;
	document.books.STATEBill.style.visibility='hidden';
	
	document.books.STATEBilltext.disabled = false;
	document.books.STATEBilltext.style.visibility='visible';
	document.books.STATEBilltext.style.width='170px';
}

/*var STATETOSHIPList = new Array("Australian Capital Territory","New South Wales","Northern Territory","Queensland","South Australia","Tasmania","Victoria","Western Australia","Acre","Alagoas","Amapa","Amazonas","Bahia","Ceara","Distrito Federal","Espirito Santo","Goias","Maranhao","Mato Grosso","Mato Grosso do Sul","Minas Gerais","Para","Paraiba","Parana","Pernambuco","Piaui","Rio de Janeiro","Rio Grande do Norte","Rio Grande do Sul","Rondonia","Roraima","Santa Catarina","Sao Paulo","Sergipe","Tocantins","Alberta","British Columbia","Manitoba","New Brunswick","Newfoundland","Northwest Territories","Nova Scotia","Nunavut","Ontario","Prince Edward Island","Quebec","Saskatchewan","Yukon Territory","Aichi","Akita","Aomori","Chiba","Ehime","Fukui","Fukuoka","Fukushima","Gifu","Gumma","Hiroshima","Hokkaido","Hyogo","Ibaraki","Ishikawa","Iwate","Kagawa","Kagoshima","Kanagawa","Kouchi","Kumamoto","Kyoto","Mie","Miyagi","Miyazaki","Nagano","Nagasaki","Nara","Niigata","Oita","Okayama","Okinawa","Osaka","Saga","Saitama","Shiga","Shimane","Shizuoka","Tochigi","Tokushima","Tokyo","Tottori","Toyama","Wakayama","Yamagata","Yamaguchi","Yamanashi","Aguascalientes","Baja California","Baja California Sur","Campeche","Chiapas","Chihuahua","Coahuila","Colima","Distrito Federal","Durango","Guanajuato","Guerrero","Hidalgo","Jalisco","Mexico","Michoacan","Morelos","Nayarit","Nuevo Leon","Oaxaca","Puebla","Queretaro","Quintana Roo","San Luis Potosi","Sinaloa","Sonora","Tabasco","Tamaulipas","Tlaxcala","Veracruz","Yucatan","Zacatecas","Alabama","Alaska","American Samoa","Arizona","Arkansas","Armed Forces America","Armed Forces Other Areas","Armed Forces Pacific","California","Colorado","Connecticut","Delaware","District of Columbia","Federated STATETOSHIPs of Micronesia","Florida","Georgia","Guam","Hawaii","Idaho","Illinois","Indiana","Iowa","Kansas","Kentucky","Louisiana","Maine","Marshall Islands","Maryland","Massachusetts","Michigan","Minnesota","Mississippi","Missouri","Montana","Nebraska","Nevada","New Hampshire","New Jersey","New Mexico","New York","North Carolina","North Dakota","Northern Mariana Islands","Ohio","Oklahoma","Oregon","Palau","Pennsylvania","Puerto Rico","Rhode Island","South Carolina","South Dakota","Tennessee","Texas","U.S. Virgin Islands","Utah","Vermont","Virginia","Washington","West Virginia","Wisconsin","Wyoming");*/


/*stationString=document.stationform.stationselect.options[stationInteger].text   
document.stationform.stationtext.value = "A " + stationString +" A"
document.stationform.stationtext2.value = "B " + stationString +" B"
document.stationform.stationtext3.value = "C " + stationString +" C"*/



}
function ChangeTitle() {
	var totalPrice = calculatePrice();
	totalPrice2 = properRound(totalPrice, 2)
	var head1 = document.getElementById("head1");
    head1.firstChild.nodeValue="$"+totalPrice2 ;
	
	var totalTax = calculateTax(totalPrice);
	totalTax2 = properRound(totalTax, 2)
	var head2 = document.getElementById("head2");
    head2.firstChild.nodeValue="$"+totalTax2;
	
	var totalShipping = calculateShipping();
	totalShipping2 = properRound(totalShipping, 2)
	var head3 = document.getElementById("head3");
    head3.firstChild.nodeValue="$"+totalShipping2;
	
	var totalCost = totalPrice + totalTax + totalShipping;
	totalCost2 = properRound(totalCost, 2)
	var head4 = document.getElementById("head4");
    head4.firstChild.nodeValue="$"+totalCost2;
	//create Price variable
	return totalCost;

}
function properRound(num, digits) {
        //if no decimal places needed, we're done
        if (digits <= 0) {
                return Math.round(num); 
        } 
        //round the number to specified decimal places
        //e.g. 12.3456 to 3 digits (12.346) -> mult. by 1000, round, div. by 1000
        var tenToPower = Math.pow(10, digits);
        var cropped = String(Math.round(num * tenToPower) / tenToPower);

        //add decimal point if missing
        if (cropped.indexOf(".") == -1) {
                cropped += ".0";  //e.g. 5 -> 5.0 (at least one zero is needed)
        }

        //finally, force correct number of zeroes; add some if necessary
        var halves = cropped.split("."); //grab numbers to the right of the decimal
        //compare digits in right half of string to digits wanted
        var zerosNeeded = digits - halves[1].length; //number of zeros to add
        for (var i=1; i <= zerosNeeded; i++) {
                cropped += "0";
        }
        return(cropped);
} 

