//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 BookPrice(){
//m is a placeholder for the registration value
//c is the Standard Cost of the workshops
var ecom = document.books
var c = 0

if (ecom.LeadershipChallenge.checked == true) 
{
c = c + 14
ecom.DESCRIPTION.value = ecom.DESCRIPTION.value+"Leadership Challenge, "
}

if (ecom.CoreCSS.checked == true) 
{
c = c + 31.5
ecom.DESCRIPTION.value = ecom.DESCRIPTION.value+"Core CSS, "
}

if (ecom.XMLWeekend.checked == true) 
{
c = c + 24
ecom.DESCRIPTION.value = ecom.DESCRIPTION.value+"XML Weekend, "
}

if (ecom.RapidDevelopment.checked == true) 
{
c = c + 21.5
ecom.DESCRIPTION.value = ecom.DESCRIPTION.value+"Rapid Development, "
}

if (ecom.DynamicWebDelivery.checked == true) 
{
c = c + 36
ecom.DESCRIPTION.value = ecom.DESCRIPTION.value+"Dynamic Web Delivery, "
}

if (ecom.InfoDev.checked == true) 
{
c = c + 54
ecom.DESCRIPTION.value = ecom.DESCRIPTION.value+"Information Development, "
}

if (ecom.DITA.checked == true)
{
c = c + 54
ecom.DESCRIPTION.value = ecom.DESCRIPTION.value+"Introduction to DITA, "
}
if (ecom.DITA_arbor.checked == true)
{
c = c + 54
ecom.DESCRIPTION.value = ecom.DESCRIPTION.value+"Introduction to DITA: Arbortext Edition, "
}

if (ecom.ManagingDocumentation.checked == true)
{
c = c + 48
ecom.DESCRIPTION.value = ecom.DESCRIPTION.value+"Managing Your Documentation, "
}

if (ecom.Standards.checked == true) 
{
c = c + 34
ecom.DESCRIPTION.value = ecom.DESCRIPTION.value+"Standards, "
}

if (ecom.UserandTask.checked == true) 
{
c = c + 68
ecom.DESCRIPTION.value = ecom.DESCRIPTION.value+"User and Task, "
}

ecom.AMOUNT.value = c

if(mchk != 0){
	payment()
}
	else{
		alert("You must choose a payment method")
	}
}

//This function handles the payment method, whether they are going to use e-commerce or register via e-mail
function payment(){
var ecom = document.books
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'){
			ecom.action = "https://payments.verisign.com/payflowlink"
	}
		else{
			ecom.action="/cgi-bin/merge.pl/emerge/books/text.txt&display=/emerge/books/display.htm"
		}
	}
	else{
		alert("You must enter your name")
	}

ecom.submit()
}

function billing(){
var ecom = document.books
var c = 0
var result = 0
if(ecom.samebill.checked == true){
	ecom.NAME.value = ecom.NAMETOSHIP.value
	ecom.ADDRESS.value = ecom.ADDRESSTOSHIP.value
	ecom.CITY.value = ecom.CITYTOSHIP.value
	ecom.STATE.value = ecom.STATETOSHIP.value
	ecom.ZIP.value = ecom.ZIPTOSHIP.value
	ecom.COUNTRY.value = ecom.COUNTRYTOSHIP.value
	ecom.EMAIL.value = ecom.EMAILTOSHIP.value
	ecom.PHONE.value = ecom.PHONETOSHIP.value
}
else{
	ecom.NAME.value = ""
	ecom.ADDRESS.value = ""
	ecom.CITY.value = ""
	ecom.STATE.value = ""
	ecom.ZIP.value = ""
	ecom.COUNTRY.value = ""
	ecom.EMAIL.value = ""
	ecom.PHONE.value = ""
}
}

function total(){
var ecom = document.books
var c = 0


if (ecom.LeadershipChallenge.checked == true) 
{
c = c + 14
}

if (ecom.CoreCSS.checked == true) 
{
c = c + 31.5
}

if (ecom.XMLWeekend.checked == true) 
{
c = c + 24
}

if (ecom.RapidDevelopment.checked == true) 
{
c = c + 21.5
}

if (ecom.DynamicWebDelivery.checked == true) 
{
c = c + 36
}

if (ecom.InfoDev.checked == true) 
{
c = c + 54
}

if (ecom.DITA.checked == true)
{
c = c + 54
}

if (ecom.ManagingDocumentation.checked == true)
{
c = c + 48
}

if (ecom.Standards.checked == true) 
{
c = c + 34
}

if (ecom.UserandTask.checked == true) 
{
c = c + 68
}

var result = c.toFixed(2);

alert("Your current total is: $" + result)
}