

$(document).ready(function() {


   // left nav expansion handler
   $("div.mainLeftNav").click( function() {

    var thisDiv = $(this).find("div.subLeftNav");

    if ( typeof thisDiv[0] == 'undefined' ) return;

    if ( thisDiv[0].style.display == 'none' )
       $(thisDiv[0]).show("fast");
    else
       $(thisDiv[0]).hide("fast");
                                          } );



   // expand the selected category, if appropriate
   if ( typeof $("span#pageTitle")[0] != "undefined" ) {

      var curPage = $("span#pageTitle")[0].innerHTML;
      if ( typeof curPage != "undefined" ) {
         $("div.mainLeftNav").each( function() {

            var contents = $(this).children('div.subLeftNav');
            if ( typeof contents[0] != 'undefined' &&
                 contents[0].innerHTML.indexOf(curPage) != -1 ) {
                 // found the category
                 $(this).find("div.subLeftNav").show("fast");
                 return;
            }

                                           } );
      }
   }


   // bind the popup handlers
   $("img.prodImg").bind( "mouseover", handleProdMouse );

 });



function handleProdMouse( e ) {

   var thumbSrc = $(this)[0].src;

   $("div#detailPop > img")[0].src = thumbSrc.replace( /t.jpg$/, ".jpg" );
   $("div#detailPop")[0].style.position = "absolute";
   $("div#detailPop")[0].style.left = e.pageX + 20;
   $("div#detailPop")[0].style.top = e.pageY - e.clientY + 30;
   $("div#detailPop").show("fast");

   $(document).bind( "click", handleProdClose );
}



function handleProdClose( e ) {
   $(document).unbind( "click", handleProdClose );

   $("div#detailPop").hide( "fast" );
   $("div#detailPop > img")[0].src = "./assets/blank.png";
}



