var info = new Array(
		"Select a Ticket Type...*Select Ticket Type First...",
	    "Season Tickets*Series A (Tuesdays 9:35 a.m.)|Series B (Tuesdays 11 a.m.)|Series C (Wednesdays 9:35 a.m.)|Series D (Wednesdays 11 a.m.)|Series E (Thursdays 9:35 a.m.)|Series F (Thursdays 11 a.m.)",
	    "Single Tickets*YPC1 A (10/19/04 @ 9:35 a.m.)|YPC1 B (10/19/04 @ 11 a.m.)|YPC1 C (10/20/04 @ 9:35 a.m.)|YPC1 D (10/20/04 @ 11 a.m.)|YPC1 E (10/21/04 @ 9:35 a.m.)|YPC1 F (10/21/04 @ 11 a.m.)|YPC2 A (11/09/04 @ 9:35 a.m.)|YPC2 B (11/09/04 @ 11 a.m.)|YPC2 C (11/10/04 @ 9:35 a.m.)|YPC2 D (11/10/04 @ 11 a.m.)|YPC2 E (11/11/04 @ 9:35 a.m.)|YPC2 F (11/11/04 @ 11 a.m.)|YPC3 A (02/01/05 @ 9:35 a.m.)|YPC3 B (02/01/05 @ 11 a.m.)|YPC3 C (02/02/05 @ 9:35 a.m.)|YPC3 D (02/02/05 @ 11 a.m.)|YPC3 E (02/03/03 @ 9:35 a.m.)|YPC3 F (02/03/05 @ 11 a.m.)|YPC4 A (04/12/05 @ 9:35 a.m.)|YPC4 B (04/12/05 @ 11 a.m.)|YPC4 C (04/13/05 @ 9:35 a.m.)|YPC4 D (04/13/05 @ 11 a.m.)|YPC4 E (04/14/05 @ 9:35 a.m.)|YPC4 F (04/14/05 @ 11 a.m.)"
	);

	function stringSplit ( string, delimiter ) { 
	    if ( string == null || string == "" ) { 
	        return null; 
	    } else if ( string.split != null ) { 
	        return string.split ( delimiter ); 
	    } else { 
	        var ar = new Array(); 
	        var i = 0; 
	        var start = 0; 
	        while( start >= 0 && start < string.length ) { 
	             var end = string.indexOf ( delimiter, start ) ; 
	             if( end >= 0 ) { 
	                 ar[i++] = string.substring ( start, end ); 
	                 start = end+1; 
	             } else { 
	                 ar[i++] = string.substring ( start, string.length ); 
	                 start = -1; 
	             } 
	        } 
	        return ar; 
	    } 
	}

	var menu1 = new Array();
	var menu2 = new Array();

	function createMenus () {
	    for ( var i=0; i < info.length; i++ ) {
	        menu1[i] = stringSplit ( info[i], '*' );
	        menu2[i] = stringSplit ( menu1[i][1], '|' );
	    }

	    var author = document.ypc.ticketType;
	    var book = document.ypc.tix;

	    author.length = menu1.length;
	    book.length = menu2[0].length; 
	    for ( var i=0; i < menu1.length; i++ ) {
 	        author.options[i].value  = menu1[i][0];
	         author.options[i].text   = menu1[i][0];
	    }
	    document.ypc.ticketType.selected = 0;
 	   for (var x=0; x < menu2[0].length; x++) {
	         book.options[x].text = menu2[0][x];
 	        book.options[x].value = menu2[0][x];
	    }         
	    document.ypc.tix.selected = 0;
    
    	updatePrice();
	}

	function updateMenus ( what ) {
	    var sel = what.selectedIndex;

	    if ( sel >= 0 && sel < menu1.length ) 
	        var temp = menu2[sel];
	    else
        var temp = new Array ();
	    
	    what.form.tix.length = temp.length;

	    for ( var i = 0; i < temp.length; i++ ) {
	        what.form.tix.options[i].text  = temp[i];
	        what.form.tix.options[i].value = temp[i];
	    }
	    what.form.tix.selected=0;
    
    	updatePrice();
    	cost_ypc();
	}	

	function updatePrice() {
		if (document.ypc.ticketType.value == "Please Select a Ticket Type...") {
			document.ypc.ticketPrice.value = 0;
		}
		else if(document.ypc.ticketType.value == "Season Tickets") {
			document.ypc.ticketPrice.value = 14;
		}
		else {
			document.ypc.ticketPrice.value = 6;
		}
	}

	function total_ypc() {
		total = 0;
		
  		non_special = Number(document.ypc.non_special.value);
  		total += non_special;
  		chaperones = Number(document.ypc.chaperones.value);
  		total += chaperones;
  		wheelchair = Number(document.ypc.wheelchair.value);
  		total += wheelchair;
  		hearing = Number(document.ypc.hearing.value);
  		total += hearing;
  		
  		document.ypc.total.value = total;
  		
  		cost_ypc();
	}
	
	function cost_ypc() {
		cost = 0;
		seriesCost = Number(document.ypc.ticketPrice.value);
		cost = seriesCost * document.ypc.total.value;
		
		document.ypc.cost.value = cost;
	}
	
	function validate() {
  		confirmBool = 1;
  		confirmForm = "The following values are missing or incorrect:\n";
    	
    	if (document.contactform.sname.value.length < 1) {
    		confirmBool = 0;
			confirmForm += "\nPatron's Name";
  		}
  		if (document.contactform.saddress.value.length < 1) {
    		confirmBool = 0;
			confirmForm += "\nMailing Address";
  		}
  		if (document.contactform.city2.value.length < 1) {
    		confirmBool = 0;
			confirmForm += "\nCity";
  		}
  		if (document.contactform.zip2.value.length < 1) {
    		confirmBool = 0;
			confirmForm += "\nZip Code";
  		}
  		if (document.contactform.semail.value.length < 1) {
    		confirmBool = 0;
			confirmForm += "\nEmail Address";
  		}
    	
    	if (confirmBool == 0) {
   			alert(confirmForm);
			return false;
  		}
 		else {
			submit();
			return true;
  		}
	function updateTotal()   {
	
	var st = document.ypc.students.value;
	var ch = document.ypc.chaperones.value;	
	var pr = document.ypc.ticketPrice.value;
	var ds = (st/10) ;
	var d2 = Math.floor(ds);
	
	var d4 = (ch-d2)
	var d5 = Math.max(d4, 0);	
	document.ypc.cost.value = (d5 * pr) + (st * pr) ;
	document.ypc.tixprice.value = pr * 1;

	var st2 = document.ypc.students2.value;
	var ch2 = document.ypc.chaperones2.value;	
	var pr2 = document.ypc.ticketPrice2.value;
	var ds2 = (st2/10) ;
	var d22 = Math.floor(ds2);
	var d42 = (ch2-d22);
	var d52 = Math.max(d42, 0);
	
	document.ypc.cost2.value = (d52 * pr2) + (st2 * pr2) ;
	document.ypc.tixprice2.value = pr2 * 1;

	document.ypc.cost4.value = document.ypc.cost2.value ;
	document.ypc.cost3.value = document.ypc.cost.value ;
	
	document.ypc.total.value = (document.ypc.cost2.value * 1) + (document.ypc.cost.value * 1 ) + (5 * 1);
	
}

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('email')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
}
	}
	
	