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

c = 50

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.ditabook
var mail = document.sendmail

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.DESCRIPTION.value = "This person purchased the DITA Book online."
			ecom.action = "https://payments.verisign.com/payflowlink"
	}
		else{
			ecom.DESCRIPTION.value = "This person did not purchase the DITA Book online.  Please contact them for an alternative payment choice"
			ecom.action="/cgi-bin/merge.pl/emerge/ditabook/text.txt&display=/emerge/ditabook/display.htm"
		}
	}
	else{
		alert("You must enter your name")
	}

ecom.submit()
}

function billing(){
var ecom = document.ditabook
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 = ""
}
}