
   // preload images for menu rollovers

   if (document.images) 
   {
      menudir = "/images/menu/";

      home1 = new Image(49,25);            home1.src = menudir + "home1.gif";
      home2 = new Image(49,25);            home2.src = menudir + "home2.gif";
      season1 = new Image(78,25);          season1.src = menudir + "season1.gif";
      season2 = new Image(78,25);          season2.src = menudir + "season2.gif";
      tickets1 = new Image(55,25);         tickets1.src = menudir + "tickets1.gif";
      tickets2 = new Image(55,25);         tickets2.src = menudir + "tickets2.gif";
      visit1 = new Image(68,25);           visit1.src = menudir + "visit1.gif";
      visit2 = new Image(68,25);           visit2.src = menudir + "visit2.gif";
      education1 = new Image(70,25);       education1.src = menudir + "education1.gif";
      education2 = new Image(70,25);       education2.src = menudir + "education2.gif";
      support1 = new Image(76,25);         support1.src = menudir + "support1.gif";
      support2 = new Image(76,25);         support2.src = menudir + "support2.gif";
      theatre1 = new Image(80,25);         theatre1.src = menudir + "theatre1.gif";
      theatre2 = new Image(80,25);         theatre2.src = menudir + "theatre2.gif";
      opportunities1 = new Image(91,25);   opportunities1.src = menudir + "opportunities1.gif";
      opportunities2 = new Image(91,25);   opportunities2.src = menudir + "opportunities2.gif";
      news1 = new Image(89,25);            news1.src = menudir + "news1.gif";
      news2 = new Image(89,25);            news2.src = menudir + "news2.gif";
      mail1 = new Image(79,25);            mail1.src = menudir + "mail1.gif";
      mail2 = new Image(79,25);            mail2.src = menudir + "mail2.gif";
      theatrehistory1 = new Image(110,25); theatrehistory1.src = menudir + "theatrehistory1.gif";
      theatrehistory2 = new Image(110,25); theatrehistory2.src = menudir + "theatrehistory2.gif";
      calendar1 = new Image(66,25);        calendar1.src = menudir + "calendar1.gif";
      calendar2 = new Image(66,25);        calendar2.src = menudir + "calendar2.gif";
      faq1 = new Image(39,25);             faq1.src = menudir + "faq1.gif";
      faq2 = new Image(39,25);             faq2.src = menudir + "faq2.gif";

      cart1 = new Image(19,15);            cart1.src = menudir + "cart1.gif";        
      cart2 = new Image(19,15);            cart2.src = menudir + "cart2.gif";
   }

   // simple image replacements

   function rollOn(imgID)
   {
      if (document.images) document.images[imgID].src = eval(imgID + "2.src"); 
   }

   function rollOff(imgID)
   {
      if (document.images) document.images[imgID].src = eval(imgID + "1.src"); 
   }

   function imgSwap(objID,imgID)
   {
      if (document.images) document.images[objID].src = eval(imgID + ".src");
   }

   // display zoomed image box (v2)

   function zoom(img,x,y,caption)
   {
      if (x > 548) x = 548;
      var html = '<div class="zoom"><a href="#csheet" onClick="unzoom();">' + 
         '<img src="/images/close.gif" width="50" height="18" border="0" style="float: right;" alt="" />' + 
         '<br clear="all" />' + 
         '<img src="images/enlarge/' + img + '" width="' + x + '" height="' + y + '" border="0" alt="" /></a>' + 
         '<br /><br />' + caption + '</div>';
      // alert(html);
      document.getElementById('enlarge').innerHTML = html;
   }

   // hide zoomed image box (v2)

   function unzoom()
   {
      document.getElementById('enlarge').innerHTML = "";
   }

   // textarea management

   function setMaxLength() 
   {
      var x = document.getElementsByTagName('textarea');
      var counter = document.createElement('div');
      counter.className = 'counter';
      for (var i=0;i<x.length;i++)
      {
         if (x[i].getAttribute('maxlength')) 
         {
            var counterClone = counter.cloneNode(true);
            counterClone.relatedElement = x[i];
            counterClone.innerHTML = '<span>0</span> of '+x[i].getAttribute('maxlength')+' characters';
            x[i].parentNode.insertBefore(counterClone,x[i].nextSibling);
            x[i].relatedElement = counterClone.getElementsByTagName('span')[0];
            x[i].onkeyup = x[i].onchange = checkMaxLength;
            x[i].onkeyup();
         }
      }
   }

   function checkMaxLength() 
   {
      var maxLength = this.getAttribute('maxlength');
      var currentLength = this.value.length;
      if (currentLength > maxLength)
         this.relatedElement.className = 'alert';
      else
         this.relatedElement.className = '';
      this.relatedElement.firstChild.nodeValue = currentLength;
   }

   $(function() { setMaxLength(); });


   // comment display / hide

   function showComments(id)
   {  
      $("div#commentbar" + id + " a.commentshow").fadeOut("fast",function()
      {
         $("div#commentbar" + id + " a.commentworking").fadeIn("fast",function()
         {
            $("div#comments" + id).load("/education/perspectives/students/comments.php?id=" + id,function()
            {
               $(this).slideDown("fast",function()
               {
                  $("div#commentbar" + id + " a.commentworking").fadeOut("fast",function()
                  {
                     $("div#commentbar" + id + " a.commenthide").fadeIn("fast");
                  });
               });
            });
         });
      });
   }

   function hideComments(id)
   {
      $("div#comments" + id)
         .slideUp("fast",function()
         {
            $("div#commentbar" + id + " a.commenthide").fadeOut("fast",function()
            {
               $("div#commentbar" + id + " a.commentshow").fadeIn("fast");
            });
         });
   }


