File: /home/design11/dreamweddinggroup.com/javascripts/supersized.2.0.js
/*
Supersized - Fullscreen Slideshow jQuery Plugin
By Sam Dunn (www.buildinternet.com // www.onemightyroar.com)
Version: supersized.2.0.js // Relase Date: 5/7/09
Website: www.buildinternet.com/project/supersized
Thanks to Aen for preloading, fade effect, & vertical centering
*/
(function($){
//Resize image on ready or resize
$.fn.supersized = function() {
$.inAnimation = false;
$.paused = false;
var options = $.extend($.fn.supersized.defaults, $.fn.supersized.options);
var supersize = $('#supersize');
$(document).bind("ready", function(){
$('#loading').hide();
supersize.fadeIn('fast');
$('#content').show();
if ($('#slideshow .activeslide').length == 0) $('#supersize a:first').addClass('activeslide');
if (options.slide_captions == 1) $('#slidecaption').html($('#supersize .activeslide').find('img').attr('title'));
if (options.navigation == 0) $('#navigation').hide();
//Slideshow
if (options.slideshow == 1){
if (options.slide_counter == 1){ //Initiate slide counter if active
$('#slidecounter .slidenumber').html(1);
$('#slidecounter .totalslides').html($("#supersize > *").size());
}
slideshow_interval = setInterval("nextslide()", options.slide_interval);
}
supersize.resizenow();
});
$(window).bind("resize", function(){
supersize.resizenow();
});
supersize.hide();
$('#content').hide();
};
//Adjust image size
$.fn.resizenow = function() {
var options = $.extend($.fn.supersized.defaults, $.fn.supersized.options);
return this.each(function() {
//Once the window is loaded, calculate the height of the #supersize element, so that it will resize the entire
// picture inside the part of the screen that can be seen.
var super_size_height = $(window).height() - $('#menu').height();
$('#picture_container').height(super_size_height);
$('#supersize').height(super_size_height);
//Define image ratio
var ratio = options.startheight/options.startwidth;
//Gather browser and current image size
var imagewidth = $(this).width();
var imageheight = $(this).height();
var browserwidth = $("#picture_container").width();
var browserheight = $("#picture_container").height();
var offset;
//Resize image to proper ratio
if ((browserheight/browserwidth) > ratio){
$(this).height(browserheight);
$(this).width(browserheight / ratio);
$(this).children().height(browserheight);
$(this).children().width(browserheight / ratio);
} else {
$(this).width(browserwidth);
$(this).height(browserwidth * ratio);
$(this).children().width(browserwidth);
$(this).children().height(browserwidth * ratio);
}
if (options.vertical_center == 1){
$(this).children().css('left', (browserwidth - $(this).width())/2);
$(this).children().css('top', (browserheight - $(this).height())/2);
}
return false;
});
};
$.fn.supersized.defaults = {
startwidth: 4,
startheight: 3,
vertical_center: 1,
slideshow: 1,
navigation:1,
transition: 1, //0-None, 1-Fade, 2-slide top, 3-slide right, 4-slide bottom, 5-slide left
pause_hover: 0,
slide_counter: 1,
slide_captions: 1,
slide_interval: 5000
};
})(jQuery);
//Slideshow Next Slide
function nextslide() {
if($.inAnimation) return false;
else $.inAnimation = true;
var options = $.extend($.fn.supersized.defaults, $.fn.supersized.options);
var currentslide = $('#supersize .activeslide');
currentslide.removeClass('activeslide');
if ( currentslide.length == 0 ) currentslide = $('#supersize a:last');
var nextslide = currentslide.next().length ? currentslide.next() : $('#supersize a:first');
var prevslide = nextslide.prev().length ? nextslide.prev() : $('#supersize a:last');
$('.prevslide').removeClass('prevslide');
prevslide.addClass('prevslide');
//Captions require img in <a>
if (options.slide_captions == 1) $('#slidecaption').html($(nextslide).find('img').attr('title'));
nextslide.hide().addClass('activeslide')
if (options.transition == 0){
nextslide.show(); $.inAnimation = false;
}
if (options.transition == 1){
nextslide.fadeIn(750, function(){$.inAnimation = false;});
}
if (options.transition == 2){
nextslide.show("slide", { direction: "up" }, 'slow', function(){$.inAnimation = false;});
}
if (options.transition == 3){
nextslide.show("slide", { direction: "right" }, 'slow', function(){$.inAnimation = false;});
}
if (options.transition == 4){
nextslide.show("slide", { direction: "down" }, 'slow', function(){$.inAnimation = false;});
}
if (options.transition == 5){
nextslide.show("slide", { direction: "left" }, 'slow', function(){$.inAnimation = false;});
}
//supersize.resizenow();//Fix for resize mid-transition
}
//Slideshow Previous Slide
function prevslide() {
if($.inAnimation) return false;
else $.inAnimation = true;
var options = $.extend($.fn.supersized.defaults, $.fn.supersized.options);
var currentslide = $('#supersize .activeslide');
currentslide.removeClass('activeslide');
if ( currentslide.length == 0 ) currentslide = $('#supersize a:first');
var nextslide = currentslide.prev().length ? currentslide.prev() : $('#supersize a:last');
var prevslide = nextslide.next().length ? nextslide.next() : $('#supersize a:first');
//Display slide counter
if (options.slide_counter == 1){
var slidecount = $('#slidecounter .slidenumber').html();
currentslide.prev().length ? slidecount-- : slidecount = $("#supersize > *").size();
$('#slidecounter .slidenumber').html(slidecount);
}
$('.prevslide').removeClass('prevslide');
prevslide.addClass('prevslide');
//Captions require img in <a>
if (options.slide_captions == 1) $('#slidecaption').html($(nextslide).find('img').attr('title'));
nextslide.hide().addClass('activeslide')
if (options.transition == 0){
nextslide.show(); $.inAnimation = false;
}
if (options.transition == 1){
nextslide.fadeIn(750, function(){$.inAnimation = false;});
}
if (options.transition == 2){
nextslide.show("slide", { direction: "down" }, 'slow', function(){$.inAnimation = false;});
}
if (options.transition == 3){
nextslide.show("slide", { direction: "left" }, 'slow', function(){$.inAnimation = false;});
}
if (options.transition == 4){
nextslide.show("slide", { direction: "up" }, 'slow', function(){$.inAnimation = false;});
}
if (options.transition == 5){
nextslide.show("slide", { direction: "right" }, 'slow', function(){$.inAnimation = false;});
}
// supersize.resizenow();//Fix for resize mid-transition
}