///////////////////////////////////////////////////////////////////
//	//
//	Javascript functions for tix/SYS On-Line Film Guide	//
//	//
//	copyright (c) 2000 synercom/edi - All Rights Reserved	//
//	//
//	written by Arne F. Hermann	//
//	//
//	//
////////////////////////////////////////////////////////////////////
loadSwapImages();
function goParent(loc){
        var parentwin = window.opener;
	var grandparentwin = parentwin.opener;
	if(grandparentwin){
	     grandparentwin.location.href=loc;
	     window.close();
	}
	if(parentwin){
	       parentwin.location.href=loc;
		window.close();
        }
}
function SearchFG() {
	var SearchTerm = document.forms['SearchForm'].SearchTerm.value;
	var SearchType = "";
	var numElems = document.SearchForm.SearchType.length;
	for (i=0;i<numElems;i++) {
	if (document.SearchForm.SearchType[i].checked) {
	SearchType = document.SearchForm.SearchType[i].value;
	break;
	}
	}
	window.location="/cgi-bin/tixSYS/search.pl?"+SearchType+","+SearchTerm;
}
function DirBioPopUp(DirNumber) {
	window.open("/tixSYS/filmguide/dirbio.php?DirectorID="+DirNumber,'Director','toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=350,height=400,top=100')
}
function PSourcePopUp(PSource) {
	window.open("/tixSYS/filmguide/psource.php?PS_ID="+PSource,'PrintSource','toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=325,height=400,top=100')
}
function LegendPopUp() {
	window.open('/tixSYS/filmguide/legend.html','Legend','toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=450,height=680,top=100');
}
//Function to initially set the filters to whatever was
//	previously selected
function SetFilters() {
	//set the selected venue
	var numElems = document.VenueSelector.VenueSelect.length;
	var Sel = document.DispVars.DispVenue.value;
	for (i=0;i<numElems;i++) {
	if (document.VenueSelector.VenueSelect.options[i].value == Sel) {
	document.VenueSelector.VenueSelect.selectedIndex = i;
	break;
	}
	}
}
function SubmitTixForm() {
	//alert("This will go on the secure server before going live! >>>1 AFH");
//alert(document.TixOrderForm.CardType.value);
	//this will submit the form to the secure server; the script there will then send
	// the user back to a welcome page that will use ONLOAD to send the order cookie
	// because the secure server will only capture the reg info and cannot send a cookie
	// readable on this server
	var OkUpdate = 1;
	if (document.TixOrderForm.First.value == "") {
	alert("You must fill in the First Name field before you can submit this order.");
	OkUpdate = 0;
	}
	if (document.TixOrderForm.Last.value == "") {
	alert("You must fill in the Last Name field before you can submit this order.");
	OkUpdate = 0;
	}
	if (document.TixOrderForm.Address1.value == "") {
	alert("You must fill in the Address field before you can submit this order.");
	OkUpdate = 0;
	}
	if (document.TixOrderForm.City.value == "") {
	alert("You must fill in the City field before you can submit this order.");
	OkUpdate = 0;
	}
	if (document.TixOrderForm.State.value + document.TixOrderForm.State.value == "") {
	alert("You must fill in the State/Province field before you can submit this order.");
	OkUpdate = 0;
	}
	if (document.TixOrderForm.Zip.value == "") {
	alert("You must fill in the Zip/Postal Code field before you can submit this order.");
	OkUpdate = 0;
	}
	if (document.TixOrderForm.email.value == "") {
	alert("You must give us a valid eMail address before you can submit this order.");
	OkUpdate = 0;
	}
	if (document.TixOrderForm.Tel1Area.value == "" || document.TixOrderForm.Tel11.value == "" || document.TixOrderForm.Tel12.value == "") {
	alert("You must fill in a valid telephone number before you can submit this order.");
	OkUpdate = 0;
	}
	if (document.TixOrderForm.CardType.value == "") {
	alert("You have not selected a Credit Card Type.");
	OkUpdate = 0;
	}
// MUST DO LUHN CHECK HERE ON THE CARD - Server-side will do this and send user back...
	if (document.TixOrderForm.CardNum1.value + document.TixOrderForm.CardNum2.value + document.TixOrderForm.CardNum3.value == "") {
	alert("You have not entered a valid Credit Card Number.");
	OkUpdate = 0;
	}
//	if (document.TixOrderForm.CardExp.value.length != 5) {
//	alert("You have not entered a valid Credit Card Expiry Date.");
//	OkUpdate = 0;
//	}
	if (OkUpdate) {
	document.forms.TixOrderForm.submit();
	}
	return;
}
function AddTix(FCode) {
	var qq = "";
	var Elem = "";
	var OkUpdate = 1;
	var numelems = document.forms[0].elements.length;
	for (var ii=0; ii < numelems; ii=ii+1) {
	Elem = document.forms[0].elements[ii].name;
	}
	qq = eval("document.forms[0]."+ FCode + ".selectedIndex");
	if (qq == 0) {
	alert("You have not selected a quantity!	Please try again.")
	OkUpdate = 0;
	}
	if (OkUpdate) {
	window.location = "/cgi-bin/tixSYS/updtplanner.pl?ADD+" + FCode + qq;
	}
return;
}
function newWindow(FC) {
	var H = screen.height - 100;
	var W = 750;
	var AtX = 25;
	var AtY = 25;
	NewWindow=window.open("/tixSYS/filmguide/templates/php/filmnote.php?FCode=" + FC,"popup","width=" + W + ",height=" + H + ",left=" + AtX + ",top=" + AtY + ",scrollbars=yes,toolbar=no,status=yes,directories=no,location=no,resizable=yes,menubar=no");
}
function ViewPlanner(PkgFill) {
	var time = new Date();
	var sec = ""+time.getHours() + time.getMinutes() + time.getSeconds();
	if (PkgFill == 1) {
	window.location="/cgi-bin/tixSYS/addplannerPKG.pl?"+sec;
	}
	else {
	window.location="/cgi-bin/tixSYS/viewenv.pl?"+sec;
	}
}
function AddCode(FCode) {
	window.location = "/cgi-bin/tixSYS/addplanner.pl?ADD+" + FCode;
}
function AddWindow(FC) {
	var W = screen.width * .96;
	if (W > 748) {W=748;}
	var H = screen.height * .9;
	var AtX = Math.floor(screen.width * .03);
	var AtY = Math.floor(screen.height * .05);
	NewWindow=window.open("/cgi-bin/tixSYS/filmnote.pl?key+" + FC,"popup","width=" + W + ",height=" + H +
",left=" + AtX + ",top=" + AtY + ",scrollbars=yes,toolbar=no,status=yes,directories=no,location=no,resizable=yes,menubar=no");
}
function ValidateCard() {
//CHECK FOR BLANK CARDNUM AT SENDORDER! AND TOTAL TIX > 0
	var fail=0;
	var CType = document.forms[0].CardType.value;
	var CardNum = document.forms[0].CardNumber.value;
	switch (CType) {
	case "VISA":
	if (CardNum.substr(0,1) != "4") {
	fail=1;
	}
	break;
	case "MasterCard":
	//	if (CardNum.substr(0,1) != "5") {
	//	fail=1;
	//	}
	alert("VISA is the only Credit-Card we accept.");
	break;
	case "American Express":
	//	if (CardNum.substr(0,1) != "3") {
	//	fail=1;
	//	}
	alert("VISA is the only Credit-Card we accept.");
	break;
	}
	if (fail == 1) {
	alert("The Credit-Card Type is not valid for the Card Number.\nPlease select the correct Card Type and then re-enter the Card Number.");
	document.forms[0].CardNumber.value = "";
	return;
	}
	if (MOD10(CardNum) != 1) {
	alert("The Credit-Card Number is NOT VALID.\nPlease select the correct Card Type and then re-enter the Card Number.");
	document.forms[0].CardNumber.value = "";
	return;
	}
}
function MOD10(C) {
	//CreditCare Mod 10 (Luhn) check routine
	C = C.replace(/\D/g, "");
	var X = 0;
	var CNT = 1;
	for (var ii = C.length-2; ii>-1; ii--) {
	CNT++;
	if ( (CNT/2) == Math.floor(CNT/2)) {
	var Y = parseFloat(C.substr(ii,1)) * 2;
	if (Y > 9) {X += 1 + (Y % 10);}
	else {X += Y;}
	}
	else {
	Y = parseFloat(C.substr(ii,1));
	X += Y;
	}
	}
	X = ((Math.floor(X/10)+1)*10 - X) % 10;
	if (X != C.substr(C.length - 1) ) {return 0;}
return 1;
}
function SoldOut(FCode) {
	alert ("We're sorry, " + FCode + " is now sold out.");
}
function ClearPlanner(retProg,PkgFill) {
 if (confirm("Click OK to CLEAR your cart of all Ticket Selections\n(you will have to start from scratch). If you don't\nwant to clear your cart, click CANCEL.")) {
	if (PkgFill == 1) {
	var time = new Date();
	var sec = ""+time.getHours() + time.getMinutes() + time.getSeconds();
	window.location="/cgi-bin/tixSYS/clearpkgplanner.pl?"+sec;
	}
	else {
	window.location="/cgi-bin/tixSYS/clearplanner.pl";
	}
	}
}
function WicketClosed() {
	alert ("WARNING, WARNING, WARNING ............. The Ticket Wicket is Temporarily CLOSED.	Your ticket Planner will retain your selections until the service is available again.");
}
function UpdtCode(FCode,Pkg) {
	var WinName = window.name;
	if (Pkg == 1) {
	window.location="/cgi-bin/tixSYS/addplannerPKG.pl?ADD=" + FCode + ";RETURN=" + WinName;
	}
	else {
	document.AddCodeForm.AddCode.value = FCode;
	hAddWin=window.open("/tixSYS/filmguide/AddToPlanner.html","AddWindow","width=400,height=200,left=200,top=300,scrollbars=no,toolbar=no,status=no,directories=no,location=no,menubar=no,resizable=no");
	}
}
function AddToCart(FCode,Pkg) {
	var WinName = window.name;
	if (Pkg == 1) {
		document.AddCodeForm.AddCode.value = FCode;
		hAddWin=window.open("/tixSYS/filmguide/addtoplannerpkg.php?FCode=" + FCode,"AddWindow","width=400,height=200,left=200,top=300,scrollbars=no,toolbar=no,status=no,directories=no,location=no,menubar=no,resizable=no");
	}
	else {
		document.AddCodeForm.AddCode.value = FCode;
		hAddWin=window.open("/tixSYS/filmguide/addtoplanner.php?FCode=" + FCode,"AddWindow","width=400,height=200,left=200,top=300,scrollbars=no,toolbar=no,status=no,directories=no,location=no,menubar=no,resizable=no");
	}
}
function AddToPkg(FCode,PageFrom) {
		document.AddCodeForm.AddCode.value = FCode;
		hAddWin=window.open("/tixSYS/filmguide/addtoplannerpkg.php?FCode=" + FCode + "?PageFrom="+PageFrom,"AddWindow","width=400,height=200,left=200,top=300,scrollbars=no,toolbar=no,status=no,directories=no,location=no,menubar=no,resizable=no");
}
function UpdtPkgCode(FCode) {
	//Get the selected quantity for this FCode
	var QQ = 0;
	var time = new Date();
	var sec = ""+time.getHours() + time.getMinutes() + time.getSeconds();
	QQ = eval("document.PkgPlanner." + FCode + ".selectedIndex");
	window.location="/cgi-bin/tixSYS/sendpkgorder.pl?UPD=" + FCode + ";Q="+QQ+";Dt="+sec;
}
function UpdatePkg() {
	if (confirm("Click OK to update your Package Ticket Order. If you have not finished selecting shows, click CANCEL. After Finalizing, you will receive an Order Confirmation page which will show all details of your order. Note that you will receive vouchers for any ticket entitlements for which you did not select tickets.")) {
	window.location="/cgi-bin/tixSYS/updatepkgorder.pl";
	}
	return;
}
function getCookieVal (offset) {
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1)
	endstr = document.cookie.length;
	return unescape(document.cookie.substring(offset, endstr));
}
//	Function to correct for 2.x Mac date bug.
function FixCookieDate (date) {
	var base = new Date(0);
	var skew = base.getTime(); // dawn of (Unix) time - should be 0
	if (skew > 0)	// Except on the Mac - ahead of its time
	date.setTime (date.getTime() - skew);
}
//	Function to return the value of the cookie specified by "name".
function GetCookie (name) {
	var arg = name + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	while (i < clen) {
	var j = i + alen;
	if (document.cookie.substring(i, j) == arg)
	return getCookieVal (j);
	i = document.cookie.indexOf(" ", i) + 1;
	if (i == 0) break;
	}
	return "NOTSET";
}
//	Function to create or update a cookie.
function SetCookie (name,value,expires,path,domain,secure) {
	path="/";
	document.cookie = name + "=" + escape (value) +
	((expires) ? "; expires=" + expires.toGMTString() : "") +
	((path) ? "; path=" + path : "") +
	((domain) ? "; domain=" + domain : "") +
	((secure) ? "; secure" : "");
}
//	Function to delete a cookie. (Sets expiration date to start of epoch)
function DeleteCookie (name,path,domain) {
	path="/";
	if (GetCookie(name)) {
	document.cookie = name + "=" +
	((path) ? "; path=" + path : "") +
	((domain) ? "; domain=" + domain : "") +
	"; expires=Thu, 01-Jan-70 00:00:01 GMT";
	}
}
function SoldOut(FCode) {
	alert ("We're sorry, " + FCode + " is now sold out.");
}
function ConfirmFinalize () {
//used to be submit form validations here...
	if (document.OrderForm.OrderAmount.value == 0) {
	alert("You have not selected any tickets!\nSelect ticket quantities using the drop down boxes before you submit your order.");
	return;
	}
	if (confirm("Click OK to update your Ticket Order. If you have not finished selecting\nshows, click CANCEL.	Clicking OK will charge your credit card with the\nOrder Total shown; your tickets will be waiting for you at the Will-Call\nStation of your first screening.	All order details, including the Will-Call\nlocation and date will be shown on your Order Confirmation Page. The\nprocess may take a minute due to credit-card authorization time.")) {
	document.OrderForm.submit()
	}
	return;
}
function ConfirmUpdate (SysActive) {
	// removed from viff
	//if (SysActive != "1") {
	//alert("We're sorry but the On-line Ticketing Order Update is temporarily OFF-LINE.	You can keep adding shows to your Ticket Planner but will not be able to update your order until we're back on-line.	Please try updating your order later.	Also, please note that you will not be able to update orders between 8:00pm and 9:00pm.");
	//return;
	//}
	if (confirm("Click OK to go to the checkout page where you can\nselect quantities to purchase for the shows you've\nselected.	If you have not finished selecting shows,\nclick CANCEL.")) {
	window.location = "/cgi-bin/tixSYS/orderupdt.pl";
	}
	return;
}
function ConfirmCart (SysActive) {
	// removed from viff
	//if (SysActive != "1") {
	//alert("We're sorry but the On-line Ticketing Order Update is temporarily OFF-LINE.	You can keep adding shows to your Ticket Planner but will not be able to update your order until we're back on-line.	Please try updating your order later.	Also, please note that you will not be able to update orders between 8:00pm and 9:00pm.");
	//return;
	//}
//	if (confirm("Click OK to go to the Order Form. You will need to provide your registration\ninformation, and then you will be able to select quantities to purchase for the\nshows you've selected.	If you have not finished selecting shows, click CANCEL.")) {
	window.location = "https://secure.mauifilmfestival.com/tixSYS/filmguide/TicketOrderForm.php";
//	}
	return;
}
function UpdateTotals(FCode,SChgType,SChgAmt,MaxTix) {

var Amount = 0;
var Quantity = 0;
var DAmount = "";
var HChgAmount = 0;
var pr="";
var qq = "";
var Elem = "";
var numelems = document.OrderForm.length;
for (var ii=0; ii < numelems; ii=ii+1) {
	Elem = document.OrderForm.elements[ii];
	FCode = Elem.name;
	if (FCode.substr(0,1) == "Q"){
		pr = eval("document.OrderForm.Price" + FCode.substr(1) + ".value");
		qq = Elem.selectedIndex;
		Amount += qq * pr;
		if (FCode.substr(1,1) != "i") {
			//eval qty for NON-ITEMS (i.e. tickets) only
			Quantity += parseFloat(qq);
		}
		if (Quantity > MaxTix) {
			alert("You can only select a maximum of " + MaxTix + " tickets on a single ticket order.	\nThe Qty for this show will be reset to zero.")
			Quantity = Quantity - Elem.selectedIndex;
			Elem.selectedIndex = 0;
		}
	}
}
//Fix the format of Amount...
if (Amount > 0) {
	// Add in will-call handling charge
	switch (SChgType) {
	case 'P':	//Percentage of Order Total
	Amount = parseFloat(Amount) + (Amount * parseFloat(SChgAmt));
	break;
	case 'F':	//Flat Rate per Order
	Amount = parseFloat(Amount) + parseFloat(SChgAmt);
	HChgAmount = parseFloat(SChgAmt);
	break;
	case 'T':	//Flat Rate per Ticket
	Amount = parseFloat(Amount) + (parseFloat(SChgAmt) * Quantity);
	HChgAmount = parseFloat(SChgAmt) * Quantity;
	break;
}

if (document.getElementById('MailOrder').checked) {
// Hamptons Specific for $1 mail charge
	//Amount = Amount + 1;	
	//document.OrderForm.MailOrderChg.value = "1.00";
}

//Format to [nnn]n.dd
Amount = (Math.ceil(Amount * 100))/100;
DAmount = "A"+Amount;
DAmount = DAmount.substr(1);
if (DAmount.indexOf(".") < 1) {
	DAmount = DAmount + ".00";
}
else {
	DAmount = DAmount + "00";
	DAmount = DAmount.substr(0,DAmount.indexOf(".")+3);
}

HChgAmount = "A"+HChgAmount;
HChgAmount = HChgAmount.substr(1);
if (HChgAmount.indexOf(".") < 1) {
	HChgAmount = HChgAmount + ".00";
}
else {
	HChgAmount = HChgAmount + "00";
	HChgAmount = HChgAmount.substr(0,HChgAmount.indexOf(".")+3);
}

}
document.OrderForm.OrderAmount.value = DAmount;
document.OrderForm.HChgAmount.value = HChgAmount;
document.OrderForm.NumberTix.value = Quantity;
}

//php document related functions
function swapImgRestore() { //v3.0
	var i,x,a=document.sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function preloadImages() { //v3.0
	var d=document; if(d.images){ if(!d.p) d.p=new Array();
	var i,j=d.p.length,a=preloadImages.arguments; for(i=0; i<a.length; i++)
	if (a[i].indexOf("#")!=0){ d.p[j]=new Image; d.p[j++].src=a[i];}}
}
function findObj(n, d) { //v4.0
	var p,i,x;	if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
	d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=findObj(n,d.layers[i].document);
	if(!x && document.getElementById) x=document.getElementById(n); return x;
}
function swapImage() { //v3.0
	var i,j=0,x,a=swapImage.arguments; document.sr=new Array; for(i=0;i<(a.length-2);i+=3)
	if ((x=findObj(a[i]))!=null){document.sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function preloadImages() { //v3.0
	var d=document; if(d.images){ if(!d.p) d.p=new Array();
	var i,j=d.p.length,a=preloadImages.arguments; for(i=0; i<a.length; i++)
	if (a[i].indexOf("#")!=0){ d.p[j]=new Image; d.p[j++].src=a[i];}}
}
function swapImgRestore() { //v3.0
	var i,x,a=document.sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function findObj(n, d) { //v3.0
	var p,i,x;	if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
	d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=findObj(n,d.layers[i].document); return x;
}
function swapImage() { //v3.0
	var i,j=0,x,a=swapImage.arguments; document.sr=new Array; for(i=0;i<(a.length-2);i+=3)
	if ((x=findObj(a[i]))!=null){document.sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function WinOpen(height,width,url)
{
 window.open(
	url,
	"RegHelp",
	"toolbar=no,location=no,resizable=yes,scrollbars=yes,status=no,height="+height+",width="+width);
}
function WinOpenFullAttr(height,width,url,popname,fullattr)
{
 window.open(
	url,
	popname,
	fullattr + "," + "height=" + height + ",width=" + width);
}
// Form Processing Javascript
function disableForm(theform) {
	if (document.all || document.getElementById) {
	for (i = 0; i < theform.length; i++) {
	var tempobj = theform.elements[i];
	if (tempobj.type.toLowerCase() == "submit" || tempobj.type.toLowerCase() == "reset")
	tempobj.disabled = true;
	}
	//setTimeout('alert("Your form has been submitted.	Notice how the submit and reset buttons were disabled upon submission.")', 2000);
	return true;
	}
	else {
	alert("Your order is now being processed. This may take a minute or two, so please be patient. Do NOT click the submit button again or you will get an error.");
	//return false;
	}
}
function phpFilmNotePopup(FC) {
	var H = screen.height - 300;
	H = 470;	
	var W = 620;
	var AtX = 25;
	var AtY = 25;
	FilmNotePopup=window.open("/tixSYS/filmguide/filmnote.php?FCode=" + FC,"popup","width=" + W + ",height=" + H +",left=" + AtX + ",top=" + AtY + ",scrollbars=yes,toolbar=no,status=yes,directories=no,location=no,resizable=yes,menubar=no");
}
function phpProgNotePopup(FC) {
	var H = screen.height - 300;
	H = 470;	
	var W = 620;
	var AtX = 25;
	var AtY = 25;
	FilmNotePopup=window.open("/tixSYS/filmguide/prognote.php?ProgCode=" + FC,"popup","width=" + W + ",height=" + H +",left=" + AtX + ",top=" + AtY + ",scrollbars=yes,toolbar=no,status=yes,directories=no,location=no,resizable=yes,menubar=no");
}
function phpEventNotePopup(FC) {
	var H = screen.height - 300;
	H = 470;	
	var W = 620;
	var AtX = 25;
	var AtY = 25;
	FilmNotePopup=window.open("/tixSYS/filmguide/eventnote.php?EventNumber=" + FC,"popup","width=" + W + ",height=" + H +",left=" + AtX + ",top=" + AtY + ",scrollbars=yes,toolbar=no,status=yes,directories=no,location=no,resizable=yes,menubar=no");
}
function phpFeatureLookupPopup(FC) {
	var H = screen.height - 300;
	H = 470;
	var W = 620;
	var AtX = 25;
	var AtY = 25;
	FilmNotePopup=window.open("/tixSYS/filmguide/featurelookup.php?ProgCode=" + FC,"popup","width=" + W + ",height=" + H +",left=" + AtX + ",top=" + AtY + ",scrollbars=yes,toolbar=no,status=yes,directories=no,location=no,resizable=yes,menubar=no");
}
function phpDirBioPopup(DN) {
	var H = 470;
	var W = 620;
	var AtX = 50;
	var AtY = 50;
	FilmNotePopup=window.open("/tixSYS/filmguide/dirbio.php?DirectorID="+DN,"popup","width=" + W + ",height=" + H +",left=" + AtX + ",top=" + AtY + ",scrollbars=yes,toolbar=no,status=yes,directories=no,location=no,resizable=yes,menubar=no");
}
function timeGridAddTix(FCode) {
	var qq = "";
	var Elem = "";
	var OkUpdate = 1;
	var numelems = document.forms['gridform'].elements.length;
	for (var i=0; i < numelems; i=i+1) {
	Elem = document.forms['gridform'].elements[i].name;
	}
	qq = eval("document.forms['gridform']."+ FCode + ".selectedIndex");
	if (qq == 0) {
	alert("You have not selected a quantity!	Please try again.")
	OkUpdate = 0;
	}
	if (OkUpdate) {
	window.location = "/cgi-bin/tixSYS/updtplanner.pl?ADD+" + FCode + qq;
	}
return;
}
function ShowHide(id, visibility) {
	divs = document.getElementsByTagName("div");
	divs[id].style.visibility = visibility;
}
function IMDBFilmPopup(theFilmURL){
	var H = screen.height - 200;
	var W = screen.width - 200;
	var AtX = 50;
	var AtY = 50;
	FilmNotePopup=window.open("http://us.imdb.com/title/tt" + theFilmURL,"imdb","width=" + W + ",height=" + H + ",left=" + AtX + ",top=" + AtY + ",scrollbars=yes,toolbar=yes,status=yes,directories=yes,location=yes,resizable=yes,menubar=yes");
}
function IMDBDirectorPopup(theDirNum){
	var H = screen.height - 200;
	var W = screen.width - 200;
	var AtX = 50;
	var AtY = 50;
	FilmNotePopup=window.open("http://us.imdb.com/name/nm" + theDirNum,"imdb","width=" + W + ",height=" + H + ",left=" + AtX + ",top=" + AtY + ",scrollbars=yes,toolbar=yes,status=yes,directories=yes,location=yes,resizable=yes,menubar=yes");
}
function validateQuickForm(theform) {
	var result = false;
	var numElements = theform.elements.length;
	var broken = true;
	var numEntries = 0;
	var brokenEntries = 0;
	for (i = 0; i < numElements; i++){
	var contentLength = theform.elements[i].value.length;
	if(contentLength > 0){
	numEntries++;
	if(contentLength < 5){
	brokenEntries++;
	}
	}
	}
	if((brokenEntries > 0) || (numEntries == 0)){
	alert("There appears to be a problem with your form.\n	You must enter at least ONE Film Code\n and Film Codes must all be 5 characters in length.");
	result = false;
	}
	else{
	result = true;
	}
	return result;
}
function replaceSubstring(inputString, fromString, toString) {
	// Goes through the inputString and replaces every occurrence of fromString with toString
	var temp = inputString;
	if (fromString == "") {
	return inputString;
	}
	if (toString.indexOf(fromString) == -1) { // If the string being replaced is not a part of the replacement string (normal situation)
	while (temp.indexOf(fromString) != -1) {
	var toTheLeft = temp.substring(0, temp.indexOf(fromString));
	var toTheRight = temp.substring(temp.indexOf(fromString)+fromString.length, temp.length);
	temp = toTheLeft + toString + toTheRight;
	}
	} else { // String being replaced is part of replacement string (like "+" being replaced with "++") - prevent an infinite loop
	var midStrings = new Array("~", "`", "_", "^", "#");
	var midStringLen = 1;
	var midString = "";
	// Find a string that doesn't exist in the inputString to be used
	// as an "inbetween" string
	while (midString == "") {
	for (var i=0; i < midStrings.length; i++) {
	var tempMidString = "";
	for (var j=0; j < midStringLen; j++) { tempMidString += midStrings[i]; }
	if (fromString.indexOf(tempMidString) == -1) {
	midString = tempMidString;
	i = midStrings.length + 1;
	}
	}
	} // Keep on going until we build an "inbetween" string that doesn't exist
	// Now go through and do two replaces - first, replace the "fromString" with the "inbetween" string
	while (temp.indexOf(fromString) != -1) {
	var toTheLeft = temp.substring(0, temp.indexOf(fromString));
	var toTheRight = temp.substring(temp.indexOf(fromString)+fromString.length, temp.length);
	temp = toTheLeft + midString + toTheRight;
	}
	// Next, replace the "inbetween" string with the "toString"
	while (temp.indexOf(midString) != -1) {
	var toTheLeft = temp.substring(0, temp.indexOf(midString));
	var toTheRight = temp.substring(temp.indexOf(midString)+midString.length, temp.length);
	temp = toTheLeft + toString + toTheRight;
	}
	} // Ends the check to see if the string being replaced is part of the replacement string or not
	return temp; // Send the updated string back to the user
} // Ends the "replaceSubstring" function
function getCookie(name) {
	var dc = document.cookie;
	var prefix = name + "=";
	var begin = dc.indexOf("; " + prefix);
	if (begin == -1) {
	begin = dc.indexOf(prefix);
	if (begin != 0) return null;
	} else {begin += 2;}
	var end = document.cookie.indexOf(";", begin);
	if (end == -1) {end = dc.length;}
	return unescape(dc.substring(begin + prefix.length, end));
 }
function movegrid(){ // centers grid in window.
	var gridWidth = document.getElementById('venuebar').style.width;
	gridWidth = replaceSubstring(gridWidth, "px", "") 
	var winW = 630, winH = 460;
	if (parseInt(navigator.appVersion)>3) {
	if (navigator.appName=="Netscape") {
	winW = window.innerWidth;
	winH = window.innerHeight;
	}
	if (navigator.appName.indexOf("Microsoft")!=-1) {
	winW = document.body.offsetWidth;
	winH = document.body.offsetHeight;
	}
	}
	var leftoffset = (winW - gridWidth)/2 - 35;
	var allDivs = document.all.tags('div');
	var leftpx;
	for(var i = 0; i < allDivs.length; i++){
	leftpx = allDivs[i].style.left;
	if(leftpx.length > 0){
	leftpx = leftpx.substring(0,leftpx.indexOf('px'));
	var newleft = parseInt(leftpx) + leftoffset;
	allDivs[i].style.left = newleft;
	}
	}
}
var speed, currentpos=curpos1=0, alt=1, curpos2=-1
function initializeScroll(){
	if (window.parent.scrollspeed!=0){
	speed=window.parent.scrollspeed
	scrollwindow();
	}
}
function scrollwindow(){
	temp=(document.all)? document.body.scrollLeft : window.pageXOffset;
	alt=(alt==0)? 1 : 0;
	if(alt==0){
	curpos1=temp;
	}
	else{
	curpos2=temp;
	}
	window.scrollBy(speed,0);	
}
function loadSwapImages(){
	preloadImages(
	'/tixSYS/filmguide/images/spacer.gif',
	'/tixSYS/filmguide/images/subnav/detail-view.gif',
	'/tixSYS/filmguide/images/subnav/detail-view_off.gif',
	'/tixSYS/filmguide/images/subnav/detail-view_on.gif',
	'/tixSYS/filmguide/images/subnav/detailview_off.gif',
	'/tixSYS/filmguide/images/subnav/detailview_on.gif',
	'/tixSYS/filmguide/images/subnav/grid-view.gif',
	'/tixSYS/filmguide/images/subnav/grid-view_off.gif',
	'/tixSYS/filmguide/images/subnav/grid-view_on.gif',
	'/tixSYS/filmguide/images/subnav/gridview_off.gif',
	'/tixSYS/filmguide/images/subnav/gridview_on.gif',
	'/tixSYS/filmguide/images/subnav/list-view.gif',
	'/tixSYS/filmguide/images/subnav/list-view_off.gif',
	'/tixSYS/filmguide/images/subnav/list-view_on.gif',
	'/tixSYS/filmguide/images/subnav/listview_off.gif',
	'/tixSYS/filmguide/images/subnav/listview_on.gif',
	'/tixSYS/filmguide/images/subnav/navbar_country_off.gif',
	'/tixSYS/filmguide/images/subnav/navbar_country_on.gif',
	'/tixSYS/filmguide/images/subnav/navbar_director_off.gif',
	'/tixSYS/filmguide/images/subnav/navbar_director_on.gif',
	'/tixSYS/filmguide/images/subnav/navbar_schedule_off.gif',
	'/tixSYS/filmguide/images/subnav/navbar_schedule_on.gif',
	'/tixSYS/filmguide/images/subnav/navbar_search_off.gif',
	'/tixSYS/filmguide/images/subnav/navbar_search_on.gif',
	'/tixSYS/filmguide/images/subnav/navbar_title_off.gif',
	'/tixSYS/filmguide/images/subnav/navbar_title_on.gif',
	'/tixSYS/filmguide/images/subnav/schedule-view_off.gif',
	'/tixSYS/filmguide/images/subnav/schedule-view_on.gif',
	'/tixSYS/filmguide/images/alphabar/all-on.gif',
	'images/arrow_over.gif',
	'images/utility_home_over.gif',
	'images/utility_starz_over.gif',
	'images/utility_filmcal_over.gif',
	'images/utility_contact_over.gif'	
	
	);
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

