///////////////////////////////////////////////////////////////////
//                                                                //
//   Javascript functions for tix/SYS On-Line Film Guide          //
//                                                                //
//   copyright (c) 2000 synercom/edi - All Rights Reserved        //
//                                                                //
//   written by Arne F. Hermann                                   //
//                                                                //
//                                                                //
////////////////////////////////////////////////////////////////////
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/search.pl?"+SearchType+","+SearchTerm;
}

function DirBioPopUp(DirNumber) {
//    window.open('/filmguide/templates/dirbiopopup.html','','toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=334,height=200,top=100');
    window.open("/filmguide/dirbio.php?DR_Number="+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("/filmguide/psource.php?PS_ID="+PSource,'Director','toolbar=no,location=no,status=yes,menubar=no,scrollbars=no,resizable=yes,width=350,height=400,top=100')
}

function SORCLinkPopUp(SORCLink) {
//    window.open("www.sorc.com/somelink.asp?"+SORCLink,'','')
    window.open('/filmguide/templates/sorcpopup.html','','toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=334,height=200,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.FirstName.value == "") {
      alert("You must fill in the First Name field before you can submit this order.");
      OkUpdate = 0;
   }

   if (document.TixOrderForm.LastName.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/updtplanner.pl?ADD+" + FCode + qq;
  }
return;
}

function newWindow(FC) {
   var H = screen.height - 150;
   var W = 600;
   var AtX = 50;
   var AtY = 50;
   NewWindow=window.open("/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/addplannerPKG.pl?"+sec;
     }
     else {
        window.location="/cgi-bin/viewenv.pl?"+sec;
     }
}


function AddCode(FCode) {
   window.location = "/cgi-bin/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/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;
        }
        break;
     case "American Express":
        if (CardNum.substr(0,1) != "3") {
           fail=1;
        }
        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 Ticket Planner Selections\n(you will have to start from scratch). If you don't\nwant to clear your Planner, click CANCEL.")) {
     if (PkgFill == 1) {
        var time = new Date();
        var sec = ""+time.getHours() + time.getMinutes() + time.getSeconds();
        window.location="/cgi-bin/clearpkgplanner.pl?"+sec;
     }
     else {
        window.location="/cgi-bin/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/addplannerPKG.pl?ADD=" + FCode + ";RETURN=" + WinName;
   }
   else {
      document.AddCodeForm.AddCode.value = FCode;
      hAddWin=window.open("/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 UpdtPkgCode(FCode) {
   //Get the selected quantity for this FCode
   var QQ = 0;
   QQ = eval("document.PkgPlanner." + FCode + ".selectedIndex");
   window.location="/cgi-bin/sendpkgorder.pl?UPD=" + FCode + ";Q="+QQ;
}

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.")) {
//>>>ppp>>>>>>>>>CHANGE TO .pl! <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< < < < <<
      window.location="/cgi-bin/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 null;
}

//  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 shows, click CANCEL.  Clicking OK will charge your credit card with the Order Total shown; your tickets will be waiting for you at the Will-Call Station of your first screening.  All order details, including the Will-Call location and date will be shown on your Order Confirmation Page. The update process may take a little while due to credit-card authorization time.")) {
      document.OrderForm.submit()
   }
   return;
}

function ConfirmUpdate (SysActive) {
   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 Ticket Wicket 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/orderupdt.pl";
   }
   return;
}

function UpdateTotals(FCode,SChgType,SChgAmt,MaxTix) {
  var Amount = 0;
  var Quantity = 0;
  var DAmount = "";
  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" || FCode == "MEMBERSHIPS"){
        if (FCode == "MEMBERSHIPS") {
           pr = 1;
        }
        else {
           pr = eval("document.OrderForm.Price" + FCode.substr(1) + ".value");
        }
        qq = Elem.selectedIndex;
        Amount += qq * pr;
        if (FCode != "MEMBERSHIPS") {
           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/100));
           break;
       case 'F':                                                //Flat Rate per Order
           Amount = parseFloat(Amount) + parseFloat(SChgAmt);
           break;
        case 'T':                                                //Flat Rate per Ticket
           Amount = parseFloat(Amount) + (parseFloat(SChgAmt) * Quantity);
           break;
     }
     //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);
     }
  }
  document.OrderForm.OrderAmount.value = DAmount;
  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 phpCategoryFilter(){
   var Category        = document.CategorySelector.CategorySelect.selectedIndex;
   var DisplayDay      = document.DisplayVars.DisplayDay.value;
   var DisplayMonth    = document.DisplayVars.DisplayMonth.value;
   var DisplayYear     = document.DisplayVars.DisplayYear.value;
   var DisplayVenue    = document.DisplayVars.DisplayVenue.value;
   var DisplayRange    = document.DisplayVars.DisplayRange.value;
   var Host            = window.location.host;
   var Path            = window.location.pathname;
   var Proto           = window.location.protocol;
   Host                = Proto +"//"+Host+Path;
   var DisplayCategory = "ALL";
   switch(Category) {
      case 0:
        DisplayCategory="ALL"; break;
      case 1:
        DisplayCategory="CUARO"; break;
      case 2:		
        DisplayCategory="PREMI"; break;
      case 3:
        DisplayCategory="COFFE"; break;
      case 4:
        DisplayCategory="DOCUM"; break;
      case 5:
        DisplayCategory="HIGHS"; break;
      case 6:
        DisplayCategory="INTER"; break;
      case 7:
        DisplayCategory="VIDEO"; break;
      case 8:
        DisplayCategory="NARRA"; break;
      case 9:
        DisplayCategory="PANEL"; break;
      case 10:
        DisplayCategory="SHORT"; break;
      case 11:
        DisplayCategory="EVENT"; break;
      case 12:
        DisplayCategory="SPECI"; break;
      case 13:
        DisplayCategory="ARGEN"; break;
   }
   window.location = Host +"?Day=" + DisplayDay + "&Month=" + DisplayMonth + "&Year=" + DisplayYear + "&Venue=" + DisplayVenue + "&Category=" + DisplayCategory + "&Range=" + DisplayRange;
}

function phpVenueFilter() {
   var Venue           = document.VenueSelector.VenueSelect.selectedIndex;
   var DisplayDay      = document.DisplayVars.DisplayDay.value;
   var DisplayMonth    = document.DisplayVars.DisplayMonth.value;
   var DisplayYear     = document.DisplayVars.DisplayYear.value;
   var DisplayCategory = document.DisplayVars.DisplayCategory.value;
   var DisplayRange    = document.DisplayVars.DisplayRange.value;
   var Host            = window.location.host;
   var Path            = window.location.pathname;
   var Proto           = window.location.protocol;
   Host                = Proto +"//"+Host+Path;
   var DisplayVenue="ALL";
   switch(Venue) {
      case 0:
	    DisplayVenue="ALL"; break;  
      case 1:
	  	DisplayVenue="ARC"; break;
      case 2:
	    DisplayVenue="DGA"; break;
	  case 3:
	    DisplayVenue="DGT"; break;
      case 4:
	    DisplayVenue="DGV"; break;
      case 5:
	    DisplayVenue="LS5"; break;
      case 6:
	    DisplayVenue="OTH"; break;  
   }
   window.location = Host + "?Day=" + DisplayDay + "&Month=" + DisplayMonth + "&Year=" + DisplayYear + "&Venue=" + DisplayVenue + "&Category=" + DisplayCategory + "&Range=" + DisplayRange;
}

function phpSetFilters() {
   //set the selected venue
   var numElems = document.VenueSelector.VenueSelect.length;
   var Sel = document.DisplayVars.DisplayVenue.value;
   for (i=0;i<numElems;i++) {
      if (document.VenueSelector.VenueSelect.options[i].value == Sel) {
         document.VenueSelector.VenueSelect.selectedIndex = i;
         break;
      }
   }
   // set the selected Category
   numElems = document.CategorySelector.CategorySelect.length;
   Sel = document.DisplayVars.DisplayCategory.value;
   for (i=0;i<numElems;i++) {
      if (document.CategorySelector.CategorySelect.options[i].value == Sel) {
         document.CategorySelector.CategorySelect.selectedIndex = i;
         break;
      }
   }
}

function phpSetVenueFilter() {
   //set the selected venue
   var numElems = document.VenueSelector.VenueSelect.length;
   var Sel = document.DisplayVars.DisplayVenue.value;
   for (i=0;i<numElems;i++) {
      if (document.VenueSelector.VenueSelect.options[i].value == Sel) {
         document.VenueSelector.VenueSelect.selectedIndex = i;
         break;
      }
   }
}

function phpSetCategoryFilter(){   
   // set the selected Category
   var numElems = document.CategorySelector.CategorySelect.length;
   var Sel = document.DisplayVars.DisplayCategory.value;
   for (i=0;i<numElems;i++) {
      if (document.CategorySelector.CategorySelect.options[i].value == Sel) {
         document.CategorySelector.CategorySelect.selectedIndex = i;
         break;
      }
   }
}

function phpFilmNotePopup(FC) {
   var H = screen.height - 200;
   var W = 525;
   var AtX = 50;
   var AtY = 50;
   FilmNotePopup=window.open("/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 phpDirBioPopup(DN) {
   var H = 450;
   var W = 400;
   var AtX = 50;
   var AtY = 50;
   FilmNotePopup=window.open("/filmguide/dirbio.php?DR_Number=" + 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/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?" + 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?" + 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;
}
