// JavaScript Document
/*
var Matinee_Price =
{
	'Satday':{'Orchestra':255,'7th Row':515,'Outer Ring':200,'Front Mezzanine':215,'Mid Mezzanine':200,'Rear Mezzanine':175,'Box Seats':425},
	'Sunday':{'Orchestra':280,'7th Row':515,'Outer Ring':225,'Front Mezzanine':245,'Mid Mezzanine':200,'Rear Mezzanine':175,'Box Seats':425}
};

var Evening_Price =
{
	'Satday':{'Orchestra':310,'7th Row':515,'Outer Ring':250,'Front Mezzanine':280,'Mid Mezzanine':200,'Rear Mezzanine':175,'Box Seats':425},
	'Sunday':{'Orchestra':255,'7th Row':515,'Outer Ring':200,'Front Mezzanine':215,'Mid Mezzanine':200,'Rear Mezzanine':175,'Box Seats':425},
	'Tuesday':{'Orchestra':255,'7th Row':515,'Outer Ring':200,'Front Mezzanine':215,'Mid Mezzanine':200,'Rear Mezzanine':175,'Box Seats':425},
	'Wednesday':{'Orchestra':255,'7th Row':515,'Outer Ring':200,'Front Mezzanine':215,'Mid Mezzanine':200,'Rear Mezzanine':175,'Box Seats':425},
	'Thursday':{'Orchestra':255,'7th Row':515,'Outer Ring':200,'Front Mezzanine':215,'Mid Mezzanine':200,'Rear Mezzanine':175,'Box Seats':425},
	'Friday':{'Orchestra':280,'7th Row':515,'Outer Ring':225,'Front Mezzanine':245,'Mid Mezzanine':200,'Rear Mezzanine':175,'Box Seats':425}
};

var Matinee_Preview_Price =
{
	'Satday':{'Orchestra':200,'7th Row':200,'Outer Ring':200,'Front Mezzanine':190,'Mid Mezzanine':190,'Rear Mezzanine':170,'Box Seats':200},
	'Sunday':{'Orchestra':210,'7th Row':210,'Outer Ring':210,'Front Mezzanine':205,'Mid Mezzanine':190,'Rear Mezzanine':170,'Box Seats':210}
};

var Evening_Preview_Price =
{
	'Satday':{'Orchestra':210,'7th Row':210,'Outer Ring':210,'Front Mezzanine':205,'Mid Mezzanine':190,'Rear Mezzanine':170,'Box Seats':210},
	'Sunday':{'Orchestra':200,'7th Row':200,'Outer Ring':200,'Front Mezzanine':190,'Mid Mezzanine':190,'Rear Mezzanine':170,'Box Seats':200},
	'Tuesday':{'Orchestra':200,'7th Row':200,'Outer Ring':200,'Front Mezzanine':190,'Mid Mezzanine':190,'Rear Mezzanine':170,'Box Seats':200},
	'Wednesday':{'Orchestra':200,'7th Row':200,'Outer Ring':200,'Front Mezzanine':190,'Mid Mezzanine':190,'Rear Mezzanine':170,'Box Seats':200},
	'Thursday':{'Orchestra':200,'7th Row':200,'Outer Ring':200,'Front Mezzanine':190,'Mid Mezzanine':190,'Rear Mezzanine':170,'Box Seats':200},
	'Friday':{'Orchestra':210,'7th Row':210,'Outer Ring':210,'Front Mezzanine':205,'Mid Mezzanine':190,'Rear Mezzanine':170,'Box Seats':210}
};
*/
var Matinee_Price =
{
	'Satday':{'Orchestra':0,'7th Row':0,'Outer Ring':0,'Front Mezzanine':0,'Mid Mezzanine':0,'Rear Mezzanine':0,'Box Seats':0},
	'Sunday':{'Orchestra':0,'7th Row':0,'Outer Ring':0,'Front Mezzanine':0,'Mid Mezzanine':0,'Rear Mezzanine':0,'Box Seats':0}
};

var Evening_Price =
{
	'Satday':{'Orchestra':186,'7th Row':309,'Outer Ring':150,'Front Mezzanine':168,'Mid Mezzanine':90,'Rear Mezzanine':105,'Box Seats':255},
	'Sunday':{'Orchestra':153,'7th Row':309,'Outer Ring':120,'Front Mezzanine':129,'Mid Mezzanine':90,'Rear Mezzanine':105,'Box Seats':255},
	'Tuesday':{'Orchestra':153,'7th Row':309,'Outer Ring':120,'Front Mezzanine':129,'Mid Mezzanine':90,'Rear Mezzanine':105,'Box Seats':255},
	'Wednesday':{'Orchestra':153,'7th Row':309,'Outer Ring':120,'Front Mezzanine':129,'Mid Mezzanine':90,'Rear Mezzanine':105,'Box Seats':255},
	'Thursday':{'Orchestra':153,'7th Row':309,'Outer Ring':120,'Front Mezzanine':129,'Mid Mezzanine':90,'Rear Mezzanine':105,'Box Seats':255},
	'Friday':{'Orchestra':168,'7th Row':309,'Outer Ring':135,'Front Mezzanine':147,'Mid Mezzanine':90,'Rear Mezzanine':105,'Box Seats':255}
};

var Matinee_Preview_Price =
{
	'Satday':{'Orchestra':0,'7th Row':0,'Outer Ring':0,'Front Mezzanine':0,'Mid Mezzanine':0,'Rear Mezzanine':0,'Box Seats':0},
	'Sunday':{'Orchestra':0,'7th Row':0,'Outer Ring':0,'Front Mezzanine':0,'Mid Mezzanine':0,'Rear Mezzanine':0,'Box Seats':0}
};

var Evening_Preview_Price =
{
	'Satday':{'Orchestra':0,'7th Row':0,'Outer Ring':0,'Front Mezzanine':123,'Mid Mezzanine':90,'Rear Mezzanine':102,'Box Seats':0},
	'Sunday':{'Orchestra':120,'7th Row':0,'Outer Ring':0,'Front Mezzanine':123,'Mid Mezzanine':90,'Rear Mezzanine':102,'Box Seats':0},
	'Tuesday':{'Orchestra':120,'7th Row':120,'Outer Ring':0,'Front Mezzanine':114,'Mid Mezzanine':90,'Rear Mezzanine':102,'Box Seats':120},
	'Wednesday':{'Orchestra':120,'7th Row':120,'Outer Ring':0,'Front Mezzanine':114,'Mid Mezzanine':90,'Rear Mezzanine':102,'Box Seats':120},
	'Thursday':{'Orchestra':120,'7th Row':120,'Outer Ring':0,'Front Mezzanine':114,'Mid Mezzanine':90,'Rear Mezzanine':102,'Box Seats':120},
	'Friday':{'Orchestra':0,'7th Row':0,'Outer Ring':0,'Front Mezzanine':123,'Mid Mezzanine':90,'Rear Mezzanine':102,'Box Seats':0}
};

function validate(myForm)
{
	var form_error=false
	var error_message = ""
	var found_Time = getCheckedButton('Time',myForm);
	var found_Day = getCheckedButton('Day',myForm);
	var found_Preference = getCheckedButton('Preference',myForm);
	var found_Seat = getCheckedButton('Seat',myForm);
	var NumberOfPatrons = myForm.NumberOfPatrons;
	var found_DONATE = getCheckedButton('DONATE',myForm);
	var f_Name = myForm.FirstName.value;
	var l_Name = myForm.LastName.value;
	var address1 = myForm.Address1.value;
	var Subtotal = myForm.Subtotal.value;
	var Grandtotal = myForm.Grandtotal.value;

	if (found_Time == null)
{		error_message += "Please Pick Your Show Time.\n"
		form_error = true
}
	if (found_Day == null)
{		error_message += "Please Pick Your Show Day.\n"
		form_error = true
}
	if (found_Seat == null)
{		error_message += "Please Pick Your Seat.\n"
		form_error = true
}
	if (found_Time != null && found_Time.value == "Matinee" && found_Day.value != "Satday" && found_Day.value != "Sunday")
{		error_message += "Please Pick Your Show Day either Saturday OR Sunday for Maitnee.\n"
		form_error = true
}
	if (isNaN(NumberOfPatrons.value))
{		error_message += "Please provide only number in how many People are in party.\n"
		form_error = true
}
	if (found_DONATE != null && found_DONATE.value == 'Other')
{		if (myForm.OtherDONATE.value == '' || myForm.OtherDONATE.value == null)
{			error_message += "Please provide DONATION amount.\n"
			form_error = true
}
		if (isNaN(myForm.OtherDONATE.value))
{			error_message += "Please provide only number in DONATION FIELD.\n"
			form_error = true
}}
	if (f_Name == null || f_Name == '' || f_Name == '0')
{		error_message += "Please Provide your first name.\n"
		form_error = true
}
	if (l_Name == null || l_Name == '' || l_Name == '0')
{		error_message += "Please Provide your last name.\n"
		form_error = true
}
	if (address1 == null || address1 == '' || address1 == '0')
{		error_message += "Please Provide your address.\n"
		form_error = true
}
	if (form_error)
{		alert(error_message)
		return false
}
	changePerPersonCost(myForm);
}

function getCheckedButton(group, form)
{
	if (typeof group == 'string')
		group = form.elements[group];

	if(!group) return null;

	for (var i = 0, n = group.length; i < n; ++i)
		if (group[i].checked)
			return group[i];

	return null;
}

function addPerPersonCost(myForm)
{
	myForm.PerPersonCost.value = '';
	myForm.Subtotal.value = '';

	var found_Time = getCheckedButton('Time',myForm);
	var found_Day = getCheckedButton('Day',myForm);
	var found_Seat = getCheckedButton('Seat',myForm);
	var found_Preference = getCheckedButton('Preference',myForm);

	if (found_Time == null)
{		alert('Please Pick Your Show Time');
		return false;
}
	if (found_Day == null)
{		alert('Please Pick Your Show Day');
		return false;
}
	if (found_Seat == null)
{		alert('Please Pick Your Show Seat');
		return false;
}
	if ((found_Time.value == "Matinee") && (found_Day.value != "Satday" && found_Day.value != "Sunday"))
{		alert("Please Pick Your Show Day either Saturday OR Sunday for Maitnee.");
		return false;
}
	//var NumberOfPatrons = 1;
	//var DonVal = 0;
	var PPCost = 0;	

	if (found_Time.value == "Matinee")
{		//PPCost = Matinee_Price[found_Day.value][found_Seat.value];

		if (found_Preference.value == "Regular")
			PPCost = Matinee_Price[found_Day.value][found_Seat.value];
		else
			PPCost = Matinee_Preview_Price[found_Day.value][found_Seat.value];
}	else
{		//PPCost = Evening_Price[found_Day.value][found_Seat.value];

		if (found_Preference.value == "Regular")
			PPCost = Evening_Price[found_Day.value][found_Seat.value];
		else
			PPCost = Evening_Preview_Price[found_Day.value][found_Seat.value];
}
	if(myForm.hiddenPPCost && myForm.hiddenPPCost.value*1==myForm.hiddenPPCost.value) PPCost=PPCost*myForm.hiddenPPCost.value;
	myForm.PerPersonCost.value = PPCost;
	calculation(myForm,PPCost);
}

function changePerPersonCost(myForm)
{
	myForm.PerPersonCost.value = '';
	myForm.Subtotal.value = '';

	var found_Time = getCheckedButton('Time',myForm);
	var found_Day = getCheckedButton('Day',myForm);
	var found_Seat = getCheckedButton('Seat',myForm);
	var found_Preference = getCheckedButton('Preference',myForm);

	if ((found_Time.value == "Matinee") && (found_Day.value != "Satday" && found_Day.value != "Sunday"))
{		alert("Please Pick Your Show Day either Saturday OR Sunday for Maitnee.");
		return false;
}
	//var NumberOfPatrons = 1;
	//var DonVal = 0;
	var PPCost = 0;
	
	//if (found_Time != null && found_Day != null && found_Seat != null)
	if (true)
{		if (found_Time.value == "Matinee")
{			//PPCost = Matinee_Price[found_Day.value][found_Seat.value];

			if (found_Preference.value == "Preview")
				PPCost = Matinee_Preview_Price[found_Day.value][found_Seat.value];
			else
				PPCost = Matinee_Price[found_Day.value][found_Seat.value];
}		else
{			//PPCost = Evening_Price[found_Day.value][found_Seat.value];

			if (found_Preference.value == "Preview")
				PPCost = Evening_Preview_Price[found_Day.value][found_Seat.value];
			else
				PPCost = Evening_Price[found_Day.value][found_Seat.value];
}
		if(myForm.hiddenPPCost && myForm.hiddenPPCost.value*1==myForm.hiddenPPCost.value) PPCost=PPCost*myForm.hiddenPPCost.value;
		myForm.PerPersonCost.value = PPCost;
		calculation(myForm,PPCost);
}
}

function calculation(myForm, PPCost)
{
	var found_DONATE = getCheckedButton('DONATE',myForm);
	var NumberOfPatrons = myForm.NumberOfPatrons.value;
	var DonVal = 0;

	if (NumberOfPatrons != "")
{		if (isNaN(NumberOfPatrons))
{			alert("Please Provide numbers only People are in my party field.");
			myForm.NumberOfPatrons.value = '';
			myForm.NumberOfPatrons.value.focus();
			return false;
}
		PPCost = PPCost * myForm.NumberOfPatrons.value;
}
	myForm.Subtotal.value = PPCost;
	myForm.Grandtotal.value = PPCost;

	if (found_DONATE != null && found_DONATE.value == 'Other')
{		if (myForm.OtherDONATE.value == '' || myForm.OtherDONATE.value == null)
{			alert("Please provide DONATION amount.");
			myForm.OtherDONATE.value = '';
			myForm.Donationtotal.value = '';
			myForm.OtherDONATE.value.focus();
			return false;
}
		if (isNaN(myForm.OtherDONATE.value))
{			alert("Please provide only number in DONATION FIELD.");
			myForm.OtherDONATE.value = '';
			myForm.Donationtotal.value = '';
			myForm.OtherDONATE.value.focus();
			return false;
}
		DonVal = myForm.OtherDONATE.value;
}	else
{		myForm.OtherDONATE.value = '';
		DonVal = found_DONATE.value
}
	myForm.Donationtotal.value = DonVal;
	myForm.Grandtotal.value = (parseInt(PPCost)+parseInt(DonVal)+16);
}


function shows(){
	
var len = document.subscribe.length ;
  for(i=3;i < len; i++){
  	
 	 if (document.subscribe.elements[i].type == "checkbox")
 		 { 
 	 if(document.subscribe.elements[i].checked == true)
		 {
  	 nFlag=true;
 	  optVal=document.subscribe.elements[i].value
 	  break;
 	}
  else
 	 nFlag=false;  
	 }
 	}
 	 if(nFlag == false)
  {
 	 alert("Please Select  Atleast  4 Shows ?")
 	 nFlag=false;
 	 return false;
  
  }
}
function tickets(){
	
alert("test tickets");
}
 