var oRPC = new jsRPC()
    function openGallery(id)
    {
      if (id == 987)
      {
        openNationals();
        return;
      }
      showGallery(id);
      //alert('Coming soon...');
      return;
      window.open('gallery.cfm?id=' + id, 'gallery', 'width=1000,height=450');
    }

    function openEvent(id)
    {
      if (id == -1)
        openNationals();
      else
        window.open('event.cfm?id=' + id, 'gallery', 'width=850,height=450');
    }
  
    function openRegistrationComp()
    {
      window.open('/docs/Comp-Entry-Form-2010.pdf', 'gallery', 'width=850,height=680');
    }
      
    function openRegistrationConv()
    {
      window.open('registerConv.cfm', 'gallery', 'width=850,height=680');
    }
      
    function rulesConv()
    {
      window.open('/docs/Conv-RR-2010.pdf', 'docs', 'width=600,height=800');
    }
    
    function rulesComp()
    {
      window.open('/docs/Comp-RR-2009.pdf', 'gallery', 'width=600,height=800');
    }
    
    function openMap()
    {
      alert('Coming soon...');
      return;
       window.open('blah', 'gallery', 'width=400,height=400');
    }
    
    function openNewsletter()
    {
      window.open('newsletter.cfm', 'gallery', 'width=850,height=430');
    }
    
    function showGallery(id)
    {
      oRPC.href = '/get-gallery.cfm?id=' + id
      oRPC.execute();
    }
    
    function openNationals()
    {
      //var container = document.getElementById('nationals');
      //container.style.display = 'block';
    }
    
    var thumbnailScroll = 0;
    
    function handleGallery(title, galleryImages)
    {
    
      var container = document.getElementById('gallery');
      var thumbnail_container = document.getElementById('gallery_thumbnails');
      var thumbnail_matrix = document.getElementById('gallery_thumbnail_matrix');
    
      removeChildren(document.getElementById('gallery_title'));
      document.getElementById('gallery_title').appendChild(document.createTextNode(title));
      document.getElementById('gallery_img').src = galleryImages[0].fullsize_src;
      
      if (galleryImages.length > 8)
      {
        thumbnail_matrix.style.paddingTop = '15px';
        thumbnail_matrix.style.paddingBottom = '15px';
        document.getElementById('gallery_thumbnails_scroll_up').style.display = 'block';
        document.getElementById('gallery_thumbnails_scroll_down').style.display = 'block';
      }
      else
      {
        thumbnail_matrix.style.paddingTop = '0';
        thumbnail_matrix.style.paddingBottom = '0';
        document.getElementById('gallery_thumbnails_scroll_up').style.display = 'none';
        document.getElementById('gallery_thumbnails_scroll_down').style.display = 'none';
      }
      
      removeChildren(thumbnail_matrix);
      
      for (var i = 0; i < galleryImages.length; i++)
      {
        var img = document.createElement('div');
        img.style.backgroundImage = 'url(' + galleryImages[i].thumbnail_src + ')';
        img.style.backgroundPosition = '6px 6px';
        img.style.backgroundRepeat = 'no-repeat';
        img.style.padding = '5px';
        img.style.margin = '6px';
        img.style.borderStyle = 'solid';
        img.style.borderColor = 'gray';
        img.style.borderWidth = '1px';
        img.style.width = '96px';
        img.style.height = '64px'; 
        img.style.cssFloat = 'left';   
        img.style.styleFloat = 'left';   
        img.onmousedown = new Function('document.getElementById(\'gallery_img\').src = \'' + galleryImages[i].fullsize_src +'\'');
        img.onmouseover = new Function('this.style.borderColor = \'yellow\';');
        img.onmouseout = new Function('this.style.borderColor = \'gray\';');
        img.style.cursor = 'pointer';
        img.setAttribute('title', galleryImages[i].caption);
        thumbnail_matrix.appendChild(img);
        var img2 = new Image();
        img2.src = galleryImages[i].fullsize_src;
      }
      
      container.style.display = 'block';
      scrollMax = -1 * Math.ceil((galleryImages.length - 8) / 4) * (64 + 10 + 2 + 12) + 35;
      thumbnailScroll = 0;
      document.getElementById('gallery_thumbnail_matrix').style.marginTop = thumbnailScroll + 'px';
    }
    
    function scroll(dir)
    {
      var container = document.getElementById('gallery_thumbnail_matrix');
      if (((dir > 0) && (thumbnailScroll < 0)) || ((dir < 0) && (thumbnailScroll > scrollMax)))
      {
        thumbnailScroll += dir;
        if (thumbnailScroll > -1 * scrollSpeed) thumbnailScroll = 0;
        container.style.marginTop = thumbnailScroll + 'px';
      }
    }
    
    function removeChildren(el)
    {
      if ( el.hasChildNodes() )
        while ( el.childNodes.length >= 1 )
          el.removeChild( el.firstChild );
    }
    
    var scroller;
    var scrollMax = -200;
    var scrollSpeed = 4;
    
    function scrollDownStart()
    {
      scroller = setInterval('scroll(-' + scrollSpeed + ')', 20);
    }
    
    function scrollDownStop()
    {
      window.clearInterval(scroller);
    }
    
    function scrollUpStart()
    {
      scroller = setInterval('scroll(+' + scrollSpeed + ')', 20);
    }
    
    function scrollUpStop()
    {
      window.clearInterval(scroller);
    }
    
    var nationalImage = new Image();
    nationalImage.src = '/images/nationals.jpg';