//mchk makes sure when a workshop is selected that a paymentNews 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 eCommercePrice(){
//m is a placeholder for the registration value
//c is the Standard Cost of the workshops
var ecom = document.newsletter
var m

if (ecom.STATETOSHIP.value==''){
ecom.STATE.value = ""
c = 109
}
else {
c = 99
}

ecom.AMOUNT.value = c

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

//This function handles the paymentNews method, whether they are going to use e-commerce or register via e-mail
function paymentNews(ecom){
//var ecom = document.newsletter
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 Newsletter online."
			ecom.action = "https://payments.verisign.com/payflowlink"
	}
		else{
			ecom.DESCRIPTION.value = "This person did not purchase the Newsletter online.  Please contact them for an alternative payment choice"
			ecom.action="/cgi-bin/merge.pl/emerge/newsletter/text.txt&display=/emerge/newsletter/display.htm"
		}
	}
	else{
		alert("You must enter your name")
	}

ecom.submit()
}

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