// JavaScript Document
var panel = { top: 95, height: 0, heightLeft: 0, heightRight: 0};

$(document).ready(function ()
{
  
  $(".hover")
    .hover(
      function ()
      {
        $(this).attr("src", 
                     function ()
                     {
                       return swapSrc(this);
                     }
              );       
      },
      function ()
      {        $(this).attr("src",
                     function ()
                     {
                       return swapSrc(this);
                     }
              );  
      }      
    );
  
  $(".search")
    .focusin 
    (
      function()
      {
        $(this).children(".btn").css("background", "url(/gfx/searchFieldGoBtn.png)");
      }
    )
    .focusout
    (
      function()
      {
        $(this).children(".btn").css("background", "none");
      }
    );
    
  $(".panel h4.heading")
    .wrap('<div class="heading" />');
  $(".panel div.heading").prepend('<img src="/gfx/menuHeader.png" />');
  
  
  $(window)
    .scroll
    (
      function (e)
      {
        panel.heightRight = panel.height - $("#leftPanel").height();
        
        var pos = $(window).scrollTop() - panel.top;
        if (pos<0)
          pos = 0;

        var lpos = pos;
        var rpos = pos;
          
        if (pos>panel.heightLeft)
          lpos = panel.heightLeft;

        if (pos>panel.heightRight)
          rpos = panel.heightRight;

        $("#rightPanel").css("top", rpos + "px");
        $("#leftPanel").css("top", lpos + "px");

      }
    );
  
  panel.height = $("#footer").offset().top - panel.top;
  panel.heightLeft = panel.height - $("#leftPanel").height();
  
  $(".lightbox").lightbox({
        loopImages: true,
          imageClickClose: true,
          disableNavbarLinks: true
      });
  
});

function swapSrc(target)
{
  var alt = $(target).attr("rel");
  $(target).attr("rel", $(target).attr("src"));
  return alt;
}

