	var itemsArray = new Array();
	var discountTable = new Array();
	var colorArray = ['#cccccc', '#ff9999'];

	var cutoffDateTime = new Date();
	var rightNow = new Date();	
	
	var curServiceCharge = 0.0;
	
	//================================================================================
	function setupYahooMap (addr, csz, text) {
	//================================================================================
			 var newAddr = escape (addr);
			 var newCSZ = escape (csz);
			 
		 var newText = "<A HREF='http://maps.yahoo.com/py/maps.py?BFCat=&Pyt=Tmap&newFL=Use+Address+Below&addr=";
		 newText += newAddr;
		 newText += "&csz=";
		 newText += newCSZ;
		 newText += "&country=us&Get%A0Map=Get+Map' target='_top'>";
		 newText += text;
		 newText += "</A>";
		 return newText;
	}
	//================================================================================
	function checkExpiryAndPrintButton () {
	//================================================================================
if (arguments.length > 0)
	document.write ('Sorry, Tickets SOLD OUT!!!');
else
			 if (rightNow.getTime() > cutoffDateTime.getTime()) {
   	   		 	document.write('Sorry, online ticket sales are now closed.');
			 }
			 else {
document.write ("<b><A HREF='http://www.indogram.com/CookiesNPayPal.html'>How to Enable Cookies on Your Computer</A><b><br>");
   			 	document.write('<input type="Submit" NAME="button" value="I\'d like to buy my tickets now!">');
			 }
document.write ("<BR><BR><BR>Online Tickets By:<br><A HREF='http://www.indogram.com/index.php?basedir=newIndogram&centerpiece=__connectticket.html&title=Connect-Ticket%26%23153%3B%20Online%20Ticketing'>");
document.write ("<IMG SRC=http://www.indogram.com/newIndogram/1947_006b.gif border='0' alt='Connect-Ticket -- Online Tickets from Indogram'>");
document.write ("</A>");
	}
	function cutoffExpired() {
			 return (rightNow.getTime() > cutoffDateTime.getTime());
	}
	

	//================================================================================
	function LineItem (name, unitPrice, maxItems) {
	//================================================================================
		this.desc = name;
		this.unitPrice = unitPrice;
		this.maxItems = maxItems;
	}
	//================================================================================
	function currencyFormat(price) {
	//================================================================================
		var printValue = parseFloat(price).toString();
		if (printValue.indexOf(".") == -1)
			printValue += ".00";
		else
			if (printValue.indexOf(".") > (printValue.length-3))
				printValue += "0";
		return "$" + printValue;
	}
	//================================================================================
	function calculateServiceCharge(formIndex) {
	//================================================================================
		var thisForm = document.forms[formIndex];
		var serviceCharge = (getTotalTicketsPurchased(formIndex) * parseFloat(thisForm.ServiceCharge.value.substr(1)));
		return serviceCharge;	
	}
	//================================================================================
	function calculateSubTotal (formIndex) {
	//================================================================================
		var total = 0.00;
		var thisForm = document.forms[formIndex];
		for (var j = 0; j < itemsArray.length; ++j) {
			var currentItem = thisForm.elements[j*3 + 2];
			var amtStr = currentItem.value.substr(1);
			total += parseFloat(amtStr);
		}
		return total;
	}
	//================================================================================
	function calculateTotal(formIndex) {
	//================================================================================
		var total = calculateSubTotal(formIndex);
		//	Subtract any discounts
		//	Add Service Charge
		//if (curServiceCharge) // Changed...
		   total += calculateServiceCharge(formIndex);
		return currencyFormat(total);
			
	}
	//================================================================================
	function calculatePercentDiscount(formIndex, obj) {
	//================================================================================
		var thisForm = document.forms[formIndex];
		var itemNameElement=-1;
		for (var i = 0; i < thisForm.elements.length; ++i) {
			if (thisForm.elements[i].name == obj) {
				itemNameElement = i;
				break;
			}
		}
		if (itemNameElement == -1)
			alert(itemName + " not found.");
		var unitDiscountItem = thisForm.elements[itemNameElement-1];
		var thisElement = thisForm.elements[itemNameElement];
		var thisDiscountTotal = thisForm.elements[itemNameElement + 1];
		
		var subTotal = calculateSubTotal(formIndex);
		var percentDiscountVal = (parseFloat(unitDiscountItem.value.substr(-1)) * subTotal) / 100.00;
		alert (percentDiscountVal);
		thisDiscountTotal.value = currencyFormat(percentDiscountVal);
		
	}
	//================================================================================
	function drawPercentDiscountSelect(formIndex, itemName) {
	//================================================================================

		document.write ("<SELECT NAME='" + itemName +"' onChange='calculatePercentDiscount(" + formIndex +
			", \"" +  itemName + "\")'>");
		for (var i = 0; i<25; ++i)
			document.write("<OPTION VALUE='" + i + "'>" + i);
		document.write("</SELECT>");
	}
	
	//================================================================================
	function drawPercentDiscountItem (formIndex) {
	//================================================================================
		document.write("<TR>");
		document.write("<TD>" + this.desc + "</TD>");
		document.write("<TD><INPUT TYPE=TEXT size=10 onFocus='blur()' value='" + this.percent + "%'></TD>");
		document.write("<TD>");		
		drawPercentDiscountSelect(formIndex, this.itemName);
		document.write("</TD>");
		document.write("<TD><INPUT TYPE=TEXT size=10 onFocus='blur()' VALUE='$0.00'></TD>");
		document.write("</tr>");
		
		var thisForm = document.forms[formIndex];
	}


	//================================================================================
	function PercentDiscountItem (itemName, text, percent) {
	//================================================================================
		this.itemName = itemName;
		this.desc = text;
		this.percent = percent;
		this.draw = drawPercentDiscountItem;
	} 

	//================================================================================
	function FlatDiscountItem (text, flatDiscount) {
	//================================================================================
		this.desc = text;
		this.flatDiscount = flatDiscount;
	} 
	
	//================================================================================
	function generateSelect(elementNumber, maxItems) {
	//================================================================================
	document.write ("<SELECT onChange='changeValue(0," + elementNumber + ")'>");
var maxTicketCount = (maxItems > 0)?maxItems:25;
/*
alert (maxItems);
*/
		for (var i = 0; i<=maxTicketCount; ++i)
		document.write("<OPTION VALUE='" + i + "'>" + i);
		document.write("</SELECT>");
	}
	//================================================================================
	function generateLineItemEntry (itemNum, li) {
	//================================================================================
		document.write("<TR><TD class=tableStyle bgcolor=" + colorArray[itemNum%(colorArray.length)] + ">" + li.desc + "</TD>");
if (li.maxItems)
	mItems = li.maxItems;
else
	mItems = -1;
		document.write("<TD  bgcolor=" + colorArray[itemNum%(colorArray.length)] + "><INPUT TYPE=TEXT onfocus='this.blur();' ALIGN=RIGHT SIZE=10 READONLY VALUE=" + currencyFormat(li.unitPrice) + "></TD>");
		document.write("<TD ALIGN=RIGHT  bgcolor=" + colorArray[itemNum%(colorArray.length)] + ">"); + generateSelect(itemNum, mItems);; document.write("</TD>");
		document.write("<TD bgcolor=" + colorArray[itemNum%(colorArray.length)] + "><INPUT TYPE=TEXT ALIGN=RIGHT SIZE=10 READONLY onfocus='this.blur();' VALUE=$0.00></TD></TR>");		
	}
	//================================================================================
	function calculateItemTotal(unitPrice, qty) {
	//================================================================================
		var unitPriceVal = parseFloat(unitPrice);
		var qtyVal = parseInt(qty);
		var total = unitPriceVal*qtyVal;
		return (unitPriceVal * qtyVal);
	}
	//================================================================================
	function getTotalTicketsPurchased(formIndex) {
	//================================================================================
		var numTickets = 0;
		for (var j = 0; j < itemsArray.length; ++j) {
			var currentSelect = document.forms[formIndex].elements[j*3 + 1];
			var qtyStr = currentSelect.options[currentSelect.selectedIndex].value;
			numTickets += parseInt(qtyStr);
		}
		return numTickets;
	}
	
	function getIndex (formIndex, itemName) {
		var thisForm = document.forms[formIndex];
		for (var i = 0; i < thisForm.elements.length; ++i) {
			if (thisForm.elements[i].name == itemName)
			return i;
		}
		return -1;
	}
	//================================================================================
	function populatePurchaseCode () {
	//================================================================================
	var thisForm = document.forms.ticketForm;
	//	Calculate all the purchases with the number of tickets
		thisForm.item_number.value = "";
		for (var j = 0; j < itemsArray.length; ++j) {
			var currentSelect = thisForm.elements[j*3 + 1];
			var qtyStr = currentSelect.options[currentSelect.selectedIndex].value;
			if (qtyStr != "0") {
				thisForm.item_number.value += "[" + (j+1) + ":";
				thisForm.item_number.value += qtyStr + "]";
			}
		}
	}

	//================================================================================
	function changeValue(formIndex, rowIndex) {
	//================================================================================
		var thisForm = document.forms[formIndex];
		var priceStr = document.forms[formIndex].elements[rowIndex*3 + 0].value;
		priceStr = priceStr.substr(1);
		var currentSelect = thisForm.elements[rowIndex*3 + 1];
		var qtyStr = currentSelect.options[currentSelect.selectedIndex].value;
		
		var printValue = currencyFormat(calculateItemTotal(priceStr, qtyStr));
		thisForm.elements[rowIndex*3 + 2].value = printValue;
		var elementIndex = getIndex(formIndex, discountTable[0]);
		if (elementIndex != -1)
			thisForm.elements[elementIndex + 1].value = currencyFormat(calculatePercentDiscount(formIndex, discountTable[0]));
		//if (curServiceCharge > 0.0) // Changed...
		   thisForm.TotalServiceCharge.value = currencyFormat(getTotalTicketsPurchased(formIndex) * parseFloat(thisForm.ServiceCharge.value.substr(1)));
		thisForm.Total.value = calculateTotal(formIndex);
	}
	//================================================================================
	function generatePercentDiscountEntry(text, unitDiscount) {
	//================================================================================
	document.write("<TR>");
		document.write("<TD ALIGN=RIGHT>" + text + "</TD>");
		document.write(("<TD>" + unitDiscount + "%</TD>"));
		document.write("<TD>");
		document.write("</TD>");
		document.write("<TD><INPUT TYPE=TEXT Name='DiscountEntry' SIZE=10 onfocus='this.blur();' READONLY></TD>");
		document.write("</TR>"); 
	}
	
	//================================================================================
	function generateServiceChargeEntry(text, unitCharge) {
	//================================================================================
																	  
		if ((curServiceCharge = parseFloat(unitCharge)) == 0.00) {
		   document.write ("<INPUT TYPE='HIDDEN' NAME='ServiceCharge' value='$0.00'>");
		   document.write ("<INPUT TYPE='HIDDEN' NAME='TotalServiceCharge' value='$0.00'>");
		   //curServiceCharge = 0.0;
		   return;	
		}																		
		document.write("<TR>");
		document.write("<TR><TD colspan=4><BR></TD></TR>");
		document.write("<TD class=tableStyle ALIGN=RIGHT bgcolor=#cfcfaf>" + text + "</TD>");
		document.write("<TD bgcolor=#cfcfaf><INPUT TYPE=TEXT NAME='ServiceCharge' Value='$" + unitCharge + "' SIZE=10 onfocus='this.blur();' readonly></TD>");
		document.write("<TD bgcolor=#cfcfaf><BR></TD>");
		document.write("<TD bgcolor=#cfcfaf><INPUT TYPE=TEXT Name='TotalServiceCharge'  SIZE=10 onfocus='this.blur();'></TD>");
		document.write("</TR>");
	}
	//================================================================================
	function generateTotalEntry(formIndex) {
	//================================================================================
		// Leave a gap
		document.write("<TR><TD colspan=4><BR></TD></TR>");		//	Now to the real thing
		document.write("<TR><TD class=tableStyle BGCOLOR=RED colspan=3><B>T o t a l&nbsp;&nbsp;&nbsp;</B></TD>");
		document.write("<TD BGCOLOR=RED><INPUT TYPE=TEXT NAME='Total' size=10 onfocus='this.blur();'></TD></TR>");
	}
	
	//================================================================================
	function generatePersonalInfoEntry (formIndex) {
	//================================================================================
		document.write("<TABLE BGCOLOR=#cfbfaf border=1 width=60%>");
		document.write("<TR><TD align=center style='font-weight:bold' colspan=3><font size=+2>2. Personal Information</font><font size=-2 color=red><BR>(<i> * means a mandatory field</i>)</font></TD></TR>");
		document.write("<TR><TD class=comp>*</TD><TD class=tableStyle align=right>Last Name: </TD>");
		document.write ("<TD class=tableStyle align=left><INPUT TYPE=TEXT size=20 NAME='lastName'></TD></TR>");
		document.write("<TR><TD class=comp>*</TD><TD class=tableStyle align=right>First Name: </TD>");
		document.write ("<TD class=tableStyle align=left><INPUT TYPE=TEXT size=20 NAME='firstName'></TD></TR>");
		document.write("<TR><TD class=comp>*</TD><TD class=tableStyle align=right>Daytime Phone Number (with Area Code): </TD>");
		document.write ("<TD class=tableStyle align=left><INPUT TYPE=TEXT size=20 NAME='phoneNumber'></TD></TR>");
		document.write("<TR><TD class=comp>*</TD><TD class=tableStyle align=right>Email Address: </TD>");
		document.write ("<TD class=tableStyle align=left><INPUT TYPE=TEXT size=30 NAME='emailAddress'></TD></TR>");
		document.write("<TR><TD class=comp>*</TD><TD class=tableStyle align=right>Mailing Address: </TD>");
		document.write ("<TD class=tableStyle align=left>Street Address:<INPUT TYPE=TEXT size=25 NAME='streetAddress'>");
		document.write ("<BR>City: <INPUT TYPE=TEXT SIZE=20 NAME='city'><BR>State: <INPUT TYPE=TEXT SIZE=2 NAME='state'> Zip: <INPUT TYPE=TEXT size=10 Name='zip'></TD></TR>");
		document.write("</TABLE>");
	}

	//================================================================================
	function processTicketForm() {
	//================================================================================
		var thisForm = document.forms.ticketForm;
		populatePurchaseCode();	//	0 being the form number
		thisForm.numTickets.value = getTotalTicketsPurchased (0);
		
		var missingItems = new Array();
		var count = 0;
		//	1. Check if total is non-zero
		if (thisForm.elements.Total.value == "") {
			missingItems[count++] = "You haven't purchased any tickets!";
		}
		var totalAmt = parseFloat (thisForm.elements.Total.value.substr(1));
		if (totalAmt <= 0.00) {
			missingItems[count++] = "You haven't purchased any tickets!";
		}
		//	2. Check if all personal information has been filled out
		if (thisForm.elements.BuyerName.value =="") {
			missingItems[count++] = "You haven't provided your Name.";
		}

		if (thisForm.elements.BuyerEmail.value =="") {
			missingItems[count++] = "You must provide a valid email address.";
		}
		if (missingItems.length > 0) {
			var alertStr = "Sorry, we can't process your form for the following reasons:\n\n";
			for (var i = 0; i < missingItems.length; ++i)
				alertStr += missingItems[i] + "\n";
			alert (alertStr);
			return false;
		}
		else {
			var totalAmtStr = thisForm.Total.value;
			var totalAmt = totalAmtStr.substr(1);
			thisForm.amount.value = totalAmt;
			return true;
		}
		
	}

	
//=================================================================================
function generateTicketTable (serviceCharge) {
//=================================================================================
		 document.write ("<TABLE border=1 width=75% align='center'>");
			document.write ("<TR><TD align=CENTER colspan=4><img src='http://www.paypal.com/images/logo_cards_150x26.gif'></TD></TR><TR><TD align=center colspan=4><font ><b>Ticket Information</b></font></TD></TR>");
		 document.write ("<TR><TD  align=center style='font-weight: bold'>Ticket Category</TD><TD  align=center style='font-weight: bold'>Price/Ticket</TD>");
			document.write ("<TD align=center style='font-weight:bold'># of Tickets</TD><TD align=center style='font-weight:bold'>Total</TD></TR>");
		 for (var j = 0; j < itemsArray.length; ++j) {
				generateLineItemEntry (j, itemsArray[j]);
		}
		generateServiceChargeEntry("Service Charge/Ticket<BR>(Non-refundable)", serviceCharge);
		generateTotalEntry ();

		document.write ("<TR><TD COLSPAN=4><BR></TD></TR>");
		document.write ("<TR><TD align=center colspan=4><b >Buyer Information</b></TD></TR>");
		document.write ("<TR><TD class=tableStyle COLSPAN=4 bgcolor=#dfcfAb>Name:<INPUT TYPE='Text' NAME='BuyerName' size=45></TD></TR>");
		document.write ("<TR><TD class=tableStyle COLSPAN=4 bgcolor=#dfcfAb>Email: <INPUT TYPE='Text' NAME='BuyerEmail' size=45></TD></TR>");
		document.write ("<TR><TD COLSPAN=4><BR></TD></TR>");
		document.write ("</TABLE>");
}
