/*********************************************************************************************** Copyright (c) 2005 - Alf Magne Kalleland post@dhtmlgoodies.com UPDATE LOG: March, 10th, 2006 : Added support for a message while large image is loading Get this and other scripts at www.dhtmlgoodies.com You can use this script freely as long as this copyright message is kept intact. Considerably altered by Bob Pickle (c) 2010 ***********************************************************************************************/ var displayWaitMessage=true; // Display a please wait message while images are loading? var slideSpeed = 0; function gallerySlide() { if($(".arrow_left .no").is(":visible") && $(".arrow_right .no").is(":visible")) return; while(minPos > $('.slideEnd').offset().left + slideSpeed) slideSpeed++; if(slideSpeed === 0) return; var leftPos = Math.floor($('.theImages').offset().left - $('.galleryContainer').offset().left - 1); leftPos += slideSpeed; if(leftPos > $('.arrow_left').width()){ leftPos = $('.arrow_left').width(); slideSpeed = 0; } $(".theImages").css({left: leftPos + 'px'}); setTimeout('gallerySlide()', 100); return false; } function leftSpeed(e, o) { return Math.ceil(($(o).width() + 3 - (e.pageX - $(o).offset().left))/1); } function rightSpeed(e, o) { return Math.floor((-1 - (e.pageX - $(o).offset().left))/1); } function preload(images){ if(images.length > 0){ image = images.shift(); $('').attr('src', image).attr('img', image).load(function(){ $('.previewPane .largeImageCaption').before($(this)); preload(images); }).hide().addClass("largeImage"); } } function initSlideShow() { var images = []; $(".slideshow").each(function (i) { images[i] = $(this).attr("img"); }); preload(images); minPos = $('.galleryContainer').width()+$('.galleryContainer').offset().left - $('.arrow_left').width(); $('.arrow_left .no,.arrow_right .no').live("mouseenter mousemove", function(e){ preload(images); $(this).parent('.arrow_left,.arrow_right').find(".yes").show(); $(this).hide(); return false; }); $('.arrow_left .yes,.arrow_right .yes').live("mouseleave", function(e){ $(this).parent('.arrow_left,.arrow_right').find(".no").show(); $(this).hide(); }); $('.arrow_left,.arrow_right').live("mouseover click", function(e){ preload(images); gallerySlide(); return false; }); $('.arrow_left,.arrow_right').live("mousemove", function(e){ preload(images); if($(this).attr("class") == "arrow_left") slideSpeed = leftSpeed(e, this); else slideSpeed = rightSpeed(e, this); return false; }).live("mouseleave", function(e){ slideSpeed = 0; return false; }); $(".slideshow").live("mouseenter mousemove", function(e){ preload(images); $(this).css({opacity: 1}); return false; }).live("mouseleave", function(e){ $(this).css({opacity: .5}); return false; }).live("click", function(e){ obj = this; preload(images); $(".previewPane img,.waitMessage").hide(); if($(".previewPane img[img='"+$(this).attr("img")+"']").length == 0){ $('.waitMessage').show(); setTimeout(function(){ $(obj).click() }, 1000); return false; } $(".previewPane img[img='"+$(this).attr("img")+"']").each(function(){ $(this).show(); return false; }); $(".largeImageCaption").text($(this).attr("caption")); return false; }); } window.onload = initSlideShow;