//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 quantity = ecom.quantity.value
var place= ecom.STATETOSHIP.value


c = 50
switch(quantity){
		 
				 case "1":
				 c = c;
				 break;	 
				 
				 case "2":
				 c = c*2;
				 break;	 
				 
				 case "3":
				 c = c*3;
				 break;	 
				 
				 case "4":
				 c = c*4;
				 break;	 
				 
				 case "5":
				 c = c*5;
				 break;
				 
				 case "6":
				 c = c*6;
				 break;	 
				 
				 case "7":
				 c = c*7;
				 break;	 
				 
				 case "8":
				 c = c*8;
				 break;	 
				 
				 case "9":
				 c = c*9;
				 break;	 
				 
				 case "10":
				 c = c*10;
				 break;	 
}


switch(place){
		 
				 case "International":
				 international();
				 break;	 
				 
				 case "AB":
				 canada ();
				 break;	 
				 
				 case "BC":
				 canada ();
				 break;
				 
				 case "MB":
				 canada ();
				 break;
				 
				 case "NB":
				 canada ();
				 break;
				 
				 case "NL":
				 canada ();
				 break;
				 
				 case "NT":
				 canada ();
				 break;
				 
				 case "NS":
				 canada ();
				 break;
				 
				 case "NU":
				 canada ();
				 break;
				 
				 case "ON":
				 canada ();
				 break;
				 
				 case "PE":
				 canada ();
				 break;
				 
				 case "QC":
				 canada ();
				 break;
				 
				 case "SK":
				 canada ();
				 break;
				 
				 case "YT":
				 canada ();
				 break;
				 
				 case "CO":
				 c = c+c*.064;
				 shipping();
				 break;	 
				 
				 case "CA":
				 c = c+c*.0725;
				 shipping();
				 break;	 
				 
				 default:
				 shipping();
				 }
			
				
ecom.AMOUNT.value = c

if (place != "blank"){
payment ();
}
else
alert("You must choose a State/Province. If you are located in another international location, please choose 'Other - International'.");
}

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




function international (){
var ecom = document.ditabook
var quantity = ecom.quantity.value
var place= ecom.STATETOSHIP.value

switch(quantity){
		 
				 case "1":
				 c = c + 14;
				 break;	 
				 
				 case "2":
				 c = c + 20.50;
				 break;	 
				 
				 case "3":
				 c = c + 27;
				 break;	 
				 
				 case "4":
				 c = c + 33.5;
				 break;	 
				 
				 case "5":
				 c = c + 40;
				 break;
				 
				 case "6":
				 c = c + 46.5;
				 break;	 
				 
				 case "7":
				 c = c + 53;
				 break;	 
				 
				 case "8":
				 c = c + 59.5;
				 break;	 
				 
				 case "9":
				 c = c + 66;
				 break;	 
				 
				 case "10":
				 c = c + 72.5;
				 break;	 	 

}
}


function canada (){
var ecom = document.ditabook
var m = ecom.quantity.value
var place= ecom.STATETOSHIP.value

switch(m){
		 
				 case "1":
				 c = c + 6.50;
				 break;	 
				 
				 case "2":
				 c = c + 13;
				 break;	 
				 
				 case "3":
				 c = c + 19.5;
				 break;	 
				 
				 case "4":
				 c = c + 24.5;
				 break;	 
				 
				 case "5":
				 c = c + 29.5;
				 break;
				 
				 case "6":
				 c = c + 34.5;
				 break;	 
				 
				 case "7":
				 c = c + 39.5;
				 break;	 
				 
				 case "8":
				 c = c + 44.5;
				 break;	 
				 
				 case "9":
				 c = c + 49.5;
				 break;	 
				 
				 case "10":
				 c = c + 54.5;
				 break;	 	 

}

}


function shipping (){
var ecom = document.ditabook
var shipping = ecom.quantity.value
var place= ecom.STATETOSHIP.value

switch(shipping){
		 
				 case "1":
				 c = c+4;
				 break;	 
				 
				 case "2":
				 c = c+4.5;
				 break;	 
				 
				 case "3":
				 c = c+5;
				 break;	 
				 
				 case "4":
				 c = c+5.5;
				 break;	 
				 
				 case "5":
				 c = c+6;
				 break;
				 
				 case "6":
				 c = c+6.5;
				 break;	 
				 
				 case "7":
				 c = c+7;
				 break;	 
				 
				 case "8":
				 c = c+7.5;
				 break;	 
				 
				 case "9":
				 c = c+8;
				 break;	 
				 
				 case "10":
				 c = c+8.5;
				 break;	 	 

}

}
//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.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 = ""
}
}
