/*
 *    script.js
 *    
 */   
     
$(document).ready(init);
$(window).resize(resize);

var images = null;

function init()
{
      var rollovers = $(".rollover");
      rollovers.hover(mouseenter, mouseleave);
      rollovers.click(sectionChangeBtnHandler);

      if($(".autosize").length > 0)
      {
            images = $(".image");
            images.load(imageLoaded);
            $(".autosize").width(images.length * 550);
      }
      resize();
}     

function imageLoaded()
{
      if(document.count == undefined) document.count = 1;
      if(++document.count == images.length)
      {
            var totalWidth = 0;
            for(var i=0; i<images.length; i++) totalWidth += $(images[i]).width();
            $(".autosize").width(totalWidth + 130);
      }
}

function resize()
{
      $(".viewer").height($(window).height());
}

function mouseenter(evt)
{
      $(evt.target).closest(".rollover").animate({"opacity" : "1.0"}, 100, "swing");
}

function mouseleave(evt)
{
      $(evt.target).closest(".rollover").animate({"opacity" : "0"}, 100, "swing");
}

function sectionChangeBtnHandler()
{
      $(".viewer").attr('src', $(this).attr("section"));
}

