/* 2010-07-06 */
$(document).ready(function(){
  /* out gallery */
  $("#zoom, #imgShadow, .prodThumb-a[rel!='pdf']").click(function(){
    var srcL=$(this).attr("href");
    var altL=$(this).attr("title");
    $(this).colorbox({
      onOpen:function(){
        $("#cboxOverlay").css("background","#000");
        $("#cboxClose").css({"width":"25px","height":"25px"});
        switch($(this).attr("rel")){
          case "image":
            $("#gal-b-limg").fadeOut(0, function(){
              var galImg = new Image();
              $(galImg).load(function(){
                var newsiz = galImg.height +10;
                $("#gal-b-limg").html("<div id=\"for-size-temp1\" style=\"height:"+newsiz+"px; width:800px;\"></div><div id=\"for-size-temp2\" style=\"display:none\"><img src=\""+srcL+"\" alt=\""+altL+"\" style=\"-ms-interpolation-mode:bicubic;\"  /></div>")
                  .show(0, function(){
                    setTimeout(function(){
                      $.fn.colorbox.resize();
                    },400);
                    setTimeout(function(){
                      $("#cboxLoadingGraphic").hide();
                      $("#for-size-temp1").hide();
                      $("#for-size-temp2").fadeIn(300);
                    },700);
                  });
              }).error(function(){}).attr('src',srcL);
            });
            $("#gal-b-p").text(altL);
          break;
        }
      },
      onComplete:function(){
        $("#cboxLoadingGraphic").show();
      },
      onClosed:function(){
        $("#gal-b-limg").html("");
        $("#gal-b-p").text("");
        $("#cboxOverlay").css("background","#ddd");
        $("#cboxClose").css({"width":"0","height":"0"});
      },
      inline:true,
      overlayClose:true,
      scrolling:false,
      initialHeight:500,
      href:"#gal-b",
      width:"780px",
      height:"850px"
    });
  });

  /* in gallery */
  $(".gal-b-timg-a[rel!='pdf']").click(function(){
    var srcL=$(this).attr("href");
    var altL=$(this).attr("title");
    switch ($(this).attr("rel")){
      case "image":
        $("#gal-b-limg").fadeOut(50, function(){
          $("#cboxLoadingGraphic").show();
          var galImg = new Image();
          $(galImg).load(function(){
            var newsiz = galImg.height +10;
            $("#gal-b-limg").html("<div id=\"for-size-temp1\" style=\"height:"+newsiz+"px; width:800px;\"></div><div id=\"for-size-temp2\" style=\"display:none\"><img src=\""+srcL+"\" alt=\""+altL+"\" style=\"-ms-interpolation-mode:bicubic;\"  /></div>")
              .show(0, function(){
                setTimeout(function(){
                  $.fn.colorbox.resize();
                  $("#cboxLoadingGraphic").hide();
                },300);
                setTimeout(function(){
                  $("#for-size-temp1").hide();
                  $("#for-size-temp2").fadeIn(300);
                },600);
              });
          }).error(function(){}).attr('src',srcL);
        });
        $("#gal-b-p").fadeOut(50).text(altL).fadeIn("fast");
      break;
    }
    $("#cboxTitle, #cboxNext, #cboxPrevious, #cboxCurrent").hide();
  return false;
  });

  $(".popup").colorbox({iframe:true,innerWidth:600,innerHeight:450});

});

