function image(n){
   $(".class-gallery .image-large").hide();
   $(".image"+n).show();
}

function popupImage(url){
   window.open(url, "image", "menubar=0,location=0,status=0,resizable=1,width=400,height=400");
}

function loadScrollbar(h){
   if($(".content-view-full").attr("scrollHeight") <= h) return false;

   var content = $(".content-view-full").html();
   $(".content-view-full").html("<div id='scroll-content'></div>");
   $("#scroll-content").html(content).css({ height: h+"px" });
   $(".content-view-full").css({ position:'relative'}).append("<div id='slider'></div>");
   $("#slider").css({ height: h+"px" }).slider({
       axis: 'vertical',
       orientation: 'vertical',
       value: 100,
       change: handleSliderChange,
       slide: handleSliderSlide});
}

function handleSliderChange(e, ui)
{
  var maxScroll = $("#scroll-content").attr("scrollHeight") - $("#scroll-content").height();
  $("#scroll-content").animate({scrollTop: (100-ui.value) * (maxScroll / 100) }, 1000);
}

function handleSliderSlide(e, ui)
{
  var maxScroll = $("#scroll-content").attr("scrollHeight") - $("#scroll-content").height();
  $("#scroll-content").attr({scrollTop: (100-ui.value) * (maxScroll / 100) });
}

var ie6offset;
function full(url, w, h, desc){
   ie6offset = (jQuery.browser.msie && jQuery.browser.version == "6.0") ? document.documentElement.scrollTop : 0;
   var lbg = $("<div class='lightbox-bg'></div>");
   lbg.css({height: '20px',
            top: ie6offset + document.documentElement.clientHeight/2,
            width: '20px',
            left: '50%'});
   $('body').append(lbg);

   lbg.click(function(){
      $(".lightbox-bg, .lightbox, .close").fadeOut(500, function(){ $(this).remove() });;
   });

   lbg.animate({width: '100%', left: '0'}, 400, function(){
   lbg.animate({height: document.documentElement.clientHeight,
                top: ie6offset,
                opacity: '0.75'}, 400, function(){

                   lbg.css({position: 'absolute', top: '0', height: document.documentElement.scrollHeight});

                   var lb = $("<div class='lightbox'><img class='lightbox-img' /></div>");
                   $('body').append(lb);
                   var img = $(".lightbox-img");
   		   var lb = $(".lightbox");
                   lb.css('display', 'none');
                   lb.css('left', (document.documentElement.clientWidth - w) / 2);
                   lb.css('top', ie6offset + (document.documentElement.clientHeight - h) / 2 - 30);
                   lb.css('width', w);
                   lb.css('height', h);
                   img.attr('src', url);
                   img.load(function(){
                      lb.fadeIn(500);
                   });
                   img.click(function(){
                      $(".lightbox-bg, .lightbox, .close").fadeOut(500, function(){ $(this).remove() });
                   });
		   var close = $("<div class='close' />");
		   close.css('left', (document.documentElement.clientWidth - w) / 2 + w - 12);
		   close.css('top', ie6offset + (document.documentElement.clientHeight - h) / 2 - 30 - 12);
		   $('body').append(close);
                   close.click(function(){
                      $(".lightbox-bg, .lightbox, .close").fadeOut(500, function(){ $(this).remove() });;
		   });
		   img.after("<div>"+decodeURIComponent(desc)+"</div>");
                });
   });
}
