fancybox |
(function($) {
var tmp, loading, overlay, wrap, outer, inner, close, nav_left, nav_right,
selectedIndex = 0,
selectedOpts = {},
selectedArray = [],
currentIndex = 0,
currentOpts = {},
currentArray = [],
ajaxLoader = null,
imgPreloader = new Image(),
imgRegExp = /\.(jpg|gif|png|bmp|jpeg)(.*)?$/i,
swfRegExp = /[^\.]\.(swf)\s*$/i,
loadingTimer, loadingFrame = 1,
start_pos, final_pos, busy = false,
shadow = 20,
fx = $.extend($('<div/>')[0], {
prop: 0
}),
titleh = 0,
isIE6 = !$.support.opacity && !window.XMLHttpRequest,
fancybox_abort = function() {
loading.hide();
imgPreloader.onerror = imgPreloader.onload = null;
if (ajaxLoader) {
ajaxLoader.abort();
}
tmp.empty();
},
fancybox_error = function() {
$.fancybox('<p id="fancybox_error">The requested content cannot be loaded.<br />Please try again later.</p>', {
'scrolling': 'no',
'padding': 20,
'transitionIn': 'none',
'transitionOut': 'none'
});
},
fancybox_get_viewport = function() {
return [$(window).width(), $(window).height(), $(document).scrollLeft(), $(document).scrollTop()];
},
fancybox_get_zoom_to = function() {
var view = fancybox_get_viewport(),
to = {},
margin = currentOpts.margin,
resize = currentOpts.autoScale,
horizontal_space = (shadow + margin) * 2,
vertical_space = (shadow + margin) * 2,
double_padding = (currentOpts.padding * 2),
ratio;
if (currentOpts.width.toString().indexOf('%') > -1) {
to.width = ((view[0] * parseFloat(currentOpts.width)) / 100) - (shadow * 2);
resize = false;
} else {
to.width = currentOpts.width + double_padding;
}
if (currentOpts.height.toString().indexOf('%') > -1) {
to.height = ((view[1] * parseFloat(currentOpts.height)) / 100) - (shadow * 2);
resize = false;
} else {
to.height = currentOpts.height + double_padding;
}
if (resize && (to.width > (view[0] - horizontal_space) || to.height > (view[1] - vertical_space))) {
if (selectedOpts.type == 'image' || selectedOpts.type == 'swf') {
horizontal_space += double_padding;
vertical_space += double_padding;
ratio = Math.min(Math.min(view[0] - horizontal_space, currentOpts.width) / currentOpts.width, Math.min(view[1] - vertical_space, currentOpts.height) / currentOpts.height);
to.width = Math.round(ratio * (to.width - double_padding)) + double_padding;
to.height = Math.round(ratio * (to.height - double_padding)) + double_padding;
} else {
to.width = Math.min(to.width, (view[0] - horizontal_space));
to.height = Math.min(to.height, (view[1] - vertical_space));
}
}
to.top = view[3] + ((view[1] - (to.height + (shadow * 2))) * 0.5);
to.left = view[2] + ((view[0] - (to.width + (shadow * 2))) * 0.5);
if (currentOpts.autoScale === false) {
to.top = Math.max(view[3] + margin, to.top);
to.left = Math.max(view[2] + margin, to.left);
}
return to;
},
fancybox_format_title = function(title) {
if (title && title.length) {
switch (currentOpts.titlePosition) {
case 'inside':
return title;
case 'over':
return '<span id="fancybox-title-over">' + title + '</span>';
default:
return '<span id="fancybox-title-wrap"><span id="fancybox-title-left"></span><span id="fancybox-title-main">' + title + '</span><span id="fancybox-title-right"></span></span>';
}
}
return false;
},
fancybox_process_title = function() {
var title = currentOpts.title,
width = final_pos.width - (currentOpts.padding * 2),
titlec = 'fancybox-title-' + currentOpts.titlePosition;
$('#fancybox-title').remove();
titleh = 0;
if (currentOpts.titleShow === false) {
return;
}
title = $.isFunction(currentOpts.titleFormat) ? currentOpts.titleFormat(title, currentArray, currentIndex, currentOpts) : fancybox_format_title(title);
if (!title || title === '') {
return;
}
$('<div id="fancybox-title" class="' + titlec + '" />').css({
'width': width,
'paddingLeft': currentOpts.padding,
'paddingRight': currentOpts.padding
}).html(title).appendTo('body');
switch (currentOpts.titlePosition) {
case 'inside':
titleh = $("#fancybox-title").outerHeight(true) - currentOpts.padding;
final_pos.height += titleh;
break;
case 'over':
$('#fancybox-title').css('bottom', currentOpts.padding);
break;
default:
$('#fancybox-title').css('bottom', $("#fancybox-title").outerHeight(true) * -1);
break;
}
$('#fancybox-title').appendTo(outer).hide();
},
fancybox_set_navigation = function() {
$(document).unbind('keydown.fb').bind('keydown.fb', function(e) {
if (e.keyCode == 27 && currentOpts.enableEscapeButton) {
e.preventDefault();
$.fancybox.close();
} else if (e.keyCode == 37) {
e.preventDefault();
$.fancybox.prev();
} else if (e.keyCode == 39) {
e.preventDefault();
$.fancybox.next();
}
});
if ($.fn.mousewheel) {
wrap.unbind('mousewheel.fb');
if (currentArray.length > 1) {
wrap.bind('mousewheel.fb', function(e, delta) {
e.preventDefault();
if (busy || delta === 0) {
return;
}
if (delta > 0) {
$.fancybox.prev();
} else {
$.fancybox.next();
}
});
}
}
if (!currentOpts.showNavArrows) {
return;
}
if ((currentOpts.cyclic && currentArray.length > 1) || currentIndex !== 0) {
nav_left.show();
}
if ((currentOpts.cyclic && currentArray.length > 1) || currentIndex != (currentArray.length - 1)) {
nav_right.show();
}
},
fancybox_preload_images = function() {
var href, objNext;
if ((currentArray.length - 1) > currentIndex) {
href = currentArray[currentIndex + 1].href;
if (typeof href !== 'undefined' && href.match(imgRegExp)) {
objNext = new Image();
objNext.src = href;
}
}
if (currentIndex > 0) {
href = currentArray[currentIndex - 1].href;
if (typeof href !== 'undefined' && href.match(imgRegExp)) {
objNext = new Image();
objNext.src = href;
}
}
},
_finish = function() {
inner.css('overflow', (currentOpts.scrolling == 'auto' ? (currentOpts.type == 'image' || currentOpts.type == 'iframe' || currentOpts.type == 'swf' ? 'hidden' : 'auto') : (currentOpts.scrolling == 'yes' ? 'auto' : 'visible')));
if (!$.support.opacity) {
inner.get(0).style.removeAttribute('filter');
wrap.get(0).style.removeAttribute('filter');
}
$('#fancybox-title').show();
if (currentOpts.hideOnContentClick) {
inner.one('click', $.fancybox.close);
}
if (currentOpts.hideOnOverlayClick) {
overlay.one('click', $.fancybox.close);
}
if (currentOpts.showCloseButton) {
close.show();
}
fancybox_set_navigation();
$(window).bind("resize.fb", $.fancybox.center);
if (currentOpts.centerOnScroll) {
$(window).bind("scroll.fb", $.fancybox.center);
} else {
$(window).unbind("scroll.fb");
}
if ($.isFunction(currentOpts.onComplete)) {
currentOpts.onComplete(currentArray, currentIndex, currentOpts);
}
busy = false;
fancybox_preload_images();
},
fancybox_draw = function(pos) {
var width = Math.round(start_pos.width + (final_pos.width - start_pos.width) * pos),
height = Math.round(start_pos.height + (final_pos.height - start_pos.height) * pos),
top = Math.round(start_pos.top + (final_pos.top - start_pos.top) * pos),
left = Math.round(start_pos.left + (final_pos.left - start_pos.left) * pos);
wrap.css({
'width': width + 'px',
'height': height + 'px',
'top': top + 'px',
'left': left + 'px'
});
width = Math.max(width - currentOpts.padding * 2, 0);
height = Math.max(height - (currentOpts.padding * 2 + (titleh * pos)), 0);
inner.css({
'width': width + 'px',
'height': height + 'px'
});
if (typeof final_pos.opacity !== 'undefined') {
wrap.css('opacity', (pos < 0.5 ? 0.5 : pos));
}
},
fancybox_get_obj_pos = function(obj) {
var pos = obj.offset();
pos.top += parseFloat(obj.css('paddingTop')) || 0;
pos.left += parseFloat(obj.css('paddingLeft')) || 0;
pos.top += parseFloat(obj.css('border-top-width')) || 0;
pos.left += parseFloat(obj.css('border-left-width')) || 0;
pos.width = obj.width();
pos.height = obj.height();
return pos;
},
fancybox_get_zoom_from = function() {
var orig = selectedOpts.orig ? $(selectedOpts.orig) : false,
from = {},
pos, view;
if (orig && orig.length) {
pos = fancybox_get_obj_pos(orig);
from = {
width: (pos.width + (currentOpts.padding * 2)),
height: (pos.height + (currentOpts.padding * 2)),
top: (pos.top - currentOpts.padding - shadow),
left: (pos.left - currentOpts.padding - shadow)
};
} else {
view = fancybox_get_viewport();
from = {
width: 1,
height: 1,
top: view[3] + view[1] * 0.5,
left: view[2] + view[0] * 0.5
};
}
return from;
},
fancybox_show = function() {
loading.hide();
if (wrap.is(":visible") && $.isFunction(currentOpts.onCleanup)) {
if (currentOpts.onCleanup(currentArray, currentIndex, currentOpts) === false) {
$.event.trigger('fancybox-cancel');
busy = false;
return;
}
}
currentArray = selectedArray;
currentIndex = selectedIndex;
currentOpts = selectedOpts;
inner.get(0).scrollTop = 0;
inner.get(0).scrollLeft = 0;
if (currentOpts.overlayShow) {
if (isIE6) {
$('select:not(#fancybox-tmp select)').filter(function() {
return this.style.visibility !== 'hidden';
}).css({
'visibility': 'hidden'
}).one('fancybox-cleanup', function() {
this.style.visibility = 'inherit';
});
}
overlay.css({
'background-color': currentOpts.overlayColor,
'opacity': currentOpts.overlayOpacity
}).unbind().show();
}
final_pos = fancybox_get_zoom_to();
fancybox_process_title();
if (wrap.is(":visible")) {
$(close.add(nav_left).add(nav_right)).hide();
var pos = wrap.position(),
equal;
start_pos = {
top: pos.top,
left: pos.left,
width: wrap.width(),
height: wrap.height()
};
equal = (start_pos.width == final_pos.width && start_pos.height == final_pos.height);
inner.fadeOut(currentOpts.changeFade, function() {
var finish_resizing = function() {
inner.html(tmp.contents()).fadeIn(currentOpts.changeFade, _finish);
};
$.event.trigger('fancybox-change');
inner.empty().css('overflow', 'hidden');
if (equal) {
inner.css({
top: currentOpts.padding,
left: currentOpts.padding,
width: Math.max(final_pos.width - (currentOpts.padding * 2), 1),
height: Math.max(final_pos.height - (currentOpts.padding * 2) - titleh, 1)
});
finish_resizing();
} else {
inner.css({
top: currentOpts.padding,
left: currentOpts.padding,
width: Math.max(start_pos.width - (currentOpts.padding * 2), 1),
height: Math.max(start_pos.height - (currentOpts.padding * 2), 1)
});
fx.prop = 0;
$(fx).animate({
prop: 1
}, {
duration: currentOpts.changeSpeed,
easing: currentOpts.easingChange,
step: fancybox_draw,
complete: finish_resizing
});
}
});
return;
}
wrap.css('opacity', 1);
if (currentOpts.transitionIn == 'elastic') {
start_pos = fancybox_get_zoom_from();
inner.css({
top: currentOpts.padding,
left: currentOpts.padding,
width: Math.max(start_pos.width - (currentOpts.padding * 2), 1),
height: Math.max(start_pos.height - (currentOpts.padding * 2), 1)
}).html(tmp.contents());
wrap.css(start_pos).show();
if (currentOpts.opacity) {
final_pos.opacity = 0;
}
fx.prop = 0;
$(fx).animate({
prop: 1
}, {
duration: currentOpts.speedIn,
easing: currentOpts.easingIn,
step: fancybox_draw,
complete: _finish
});
} else {
inner.css({
top: currentOpts.padding,
left: currentOpts.padding,
width: Math.max(final_pos.width - (currentOpts.padding * 2), 1),
height: Math.max(final_pos.height - (currentOpts.padding * 2) - titleh, 1)
}).html(tmp.contents());
wrap.css(final_pos).fadeIn(currentOpts.transitionIn == 'none' ? 0 : currentOpts.speedIn, _finish);
}
},
fancybox_process_inline = function() {
tmp.width(selectedOpts.width);
tmp.height(selectedOpts.height);
if (selectedOpts.width == 'auto') {
selectedOpts.width = tmp.width();
}
if (selectedOpts.height == 'auto') {
selectedOpts.height = tmp.height();
}
fancybox_show();
},
fancybox_process_image = function() {
busy = true;
selectedOpts.width = imgPreloader.width;
selectedOpts.height = imgPreloader.height;
$("<img />").attr({
'id': 'fancybox-img',
'src': imgPreloader.src,
'alt': selectedOpts.title
}).appendTo(tmp);
fancybox_show();
},
fancybox_start = function() {
fancybox_abort();
var obj = selectedArray[selectedIndex],
href, type, title, str, emb, selector, data;
selectedOpts = $.extend({}, $.fn.fancybox.defaults, (typeof $(obj).data('fancybox') == 'undefined' ? selectedOpts : $(obj).data('fancybox')));
title = obj.title || $(obj).title || selectedOpts.title || '';
if (obj.nodeName && !selectedOpts.orig) {
selectedOpts.orig = $(obj).children("img:first").length ? $(obj).children("img:first") : $(obj);
}
if (title === '' && selectedOpts.orig) {
title = selectedOpts.orig.attr('alt');
}
if (obj.nodeName && (/^(?:javascript|#)/i).test(obj.href)) {
href = selectedOpts.href || null;
} else {
href = selectedOpts.href || obj.href || null;
}
if (selectedOpts.type) {
type = selectedOpts.type;
if (!href) {
href = selectedOpts.content;
}
} else if (selectedOpts.content) {
type = 'html';
} else if (href) {
if (href.match(imgRegExp)) {
type = 'image';
} else if (href.match(swfRegExp)) {
type = 'swf';
} else if ($(obj).hasClass("iframe")) {
type = 'iframe';
} else if (href.match(/#/)) {
obj = href.substr(href.indexOf("#"));
type = $(obj).length > 0 ? 'inline' : 'ajax';
} else {
type = 'ajax';
}
} else {
type = 'inline';
}
selectedOpts.type = type;
selectedOpts.href = href;
selectedOpts.title = title;
if (selectedOpts.autoDimensions && selectedOpts.type !== 'iframe' && selectedOpts.type !== 'swf') {
selectedOpts.width = 'auto';
selectedOpts.height = 'auto';
}
if (selectedOpts.modal) {
selectedOpts.overlayShow = true;
selectedOpts.hideOnOverlayClick = false;
selectedOpts.hideOnContentClick = false;
selectedOpts.enableEscapeButton = false;
selectedOpts.showCloseButton = false;
}
if ($.isFunction(selectedOpts.onStart)) {
if (selectedOpts.onStart(selectedArray, selectedIndex, selectedOpts) === false) {
busy = false;
return;
}
}
tmp.css('padding', (shadow + selectedOpts.padding + selectedOpts.margin));
$('.fancybox-inline-tmp').unbind('fancybox-cancel').bind('fancybox-change', function() {
$(this).replaceWith(inner.children());
});
switch (type) {
case 'html':
tmp.html(selectedOpts.content);
fancybox_process_inline();
break;
case 'inline':
$('<div class="fancybox-inline-tmp" />').hide().insertBefore($(obj)).bind('fancybox-cleanup', function() {
$(this).replaceWith(inner.children());
}).bind('fancybox-cancel', function() {
$(this).replaceWith(tmp.children());
});
$(obj).appendTo(tmp);
fancybox_process_inline();
break;
case 'image':
busy = false;
$.fancybox.showActivity();
imgPreloader = new Image();
imgPreloader.onerror = function() {
fancybox_error();
};
imgPreloader.onload = function() {
imgPreloader.onerror = null;
imgPreloader.onload = null;
fancybox_process_image();
};
imgPreloader.src = href;
break;
case 'swf':
str = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="' + selectedOpts.width + '" height="' + selectedOpts.height + '"><param name="movie" value="' + href + '"></param>';
emb = '';
$.each(selectedOpts.swf, function(name, val) {
str += '<param name="' + name + '" value="' + val + '"></param>';
emb += ' ' + name + '="' + val + '"';
});
str += '<embed src="' + href + '" type="application/x-shockwave-flash" width="' + selectedOpts.width + '" height="' + selectedOpts.height + '"' + emb + '></embed></object>';
tmp.html(str);
fancybox_process_inline();
break;
case 'ajax':
selector = href.split('#', 2);
data = selectedOpts.ajax.data || {};
if (selector.length > 1) {
href = selector[0];
if (typeof data == "string") {
data += '&selector=' + selector[1];
} else {
data.selector = selector[1];
}
}
busy = false;
$.fancybox.showActivity();
ajaxLoader = $.ajax($.extend(selectedOpts.ajax, {
url: href,
data: data,
error: fancybox_error,
success: function(data, textStatus, XMLHttpRequest) {
if (ajaxLoader.status == 200) {
tmp.html(data);
fancybox_process_inline();
}
}
}));
break;
case 'iframe':
$('<iframe id="fancybox-frame" name="fancybox-frame' + new Date().getTime() + '" frameborder="0" hspace="0" scrolling="' + selectedOpts.scrolling + '" src="' + selectedOpts.href + '"></iframe>').appendTo(tmp);
fancybox_show();
break;
}
},
fancybox_animate_loading = function() {
if (!loading.is(':visible')) {
clearInterval(loadingTimer);
return;
}
$('div', loading).css('top', (loadingFrame * -40) + 'px');
loadingFrame = (loadingFrame + 1) % 12;
},
fancybox_init = function() {
if ($("#fancybox-wrap").length) {
return;
}
$('body').append(
tmp = $('<div id="fancybox-tmp"></div>'), loading = $('<div id="fancybox-loading"><div></div></div>'), overlay = $('<div id="fancybox-overlay"></div>'), wrap = $('<div id="fancybox-wrap"></div>'));
if (!$.support.opacity) {
wrap.addClass('fancybox-ie');
loading.addClass('fancybox-ie');
}
outer = $('<div id="fancybox-outer"></div>').append('<div class="fancy-bg" id="fancy-bg-n"></div><div class="fancy-bg" id="fancy-bg-ne"></div><div class="fancy-bg" id="fancy-bg-e"></div><div class="fancy-bg" id="fancy-bg-se"></div><div class="fancy-bg" id="fancy-bg-s"></div><div class="fancy-bg" id="fancy-bg-sw"></div><div class="fancy-bg" id="fancy-bg-w"></div><div class="fancy-bg" id="fancy-bg-nw"></div>').appendTo(wrap);
outer.append(
inner = $('<div id="fancybox-inner"></div>'), close = $('<a id="fancybox-close"></a>'),
nav_left = $('<a href="javascript:;" id="fancybox-left"><span class="fancy-ico" id="fancybox-left-ico"></span></a>'), nav_right = $('<a href="javascript:;" id="fancybox-right"><span class="fancy-ico" id="fancybox-right-ico"></span></a>'));
close.click($.fancybox.close);
loading.click($.fancybox.cancel);
nav_left.click(function(e) {
e.preventDefault();
$.fancybox.prev();
});
nav_right.click(function(e) {
e.preventDefault();
$.fancybox.next();
});
if (isIE6) {
overlay.get(0).style.setExpression('height', "document.body.scrollHeight > document.body.offsetHeight ? document.body.scrollHeight : document.body.offsetHeight + 'px'");
loading.get(0).style.setExpression('top', "(-20 + (document.documentElement.clientHeight ? document.documentElement.clientHeight/2 : document.body.clientHeight/2 ) + ( ignoreMe = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop )) + 'px'");
outer.prepend('<iframe id="fancybox-hide-sel-frame" src="javascript:\'\';" scrolling="no" frameborder="0" ></iframe>');
}
};
$.fn.fancybox = function(options) {
$(this).data('fancybox', $.extend({}, options, ($.metadata ? $(this).metadata() : {}))).unbind('click.fb').bind('click.fb', function(e) {
e.preventDefault();
if (busy) {
return;
}
busy = true;
$(this).blur();
selectedArray = [];
selectedIndex = 0;
var rel = $(this).attr('rel') || '';
if (!rel || rel == '' || rel === 'nofollow') {
selectedArray.push(this);
} else {
selectedArray = $("a[rel=" + rel + "], area[rel=" + rel + "]");
selectedIndex = selectedArray.index(this);
}
fancybox_start();
return false;
});
return this;
};
$.fancybox = function(obj) {
if (busy) {
return;
}
busy = true;
var opts = typeof arguments[1] !== 'undefined' ? arguments[1] : {};
selectedArray = [];
selectedIndex = opts.index || 0;
if ($.isArray(obj)) {
for (var i = 0, j = obj.length; i < j; i++) {
if (typeof obj[i] == 'object') {
$(obj[i]).data('fancybox', $.extend({}, opts, obj[i]));
} else {
obj[i] = $({}).data('fancybox', $.extend({
content: obj[i]
}, opts));
}
}
selectedArray = jQuery.merge(selectedArray, obj);
} else {
if (typeof obj == 'object') {
$(obj).data('fancybox', $.extend({}, opts, obj));
} else {
obj = $({}).data('fancybox', $.extend({
content: obj
}, opts));
}
selectedArray.push(obj);
}
if (selectedIndex > selectedArray.length || selectedIndex < 0) {
selectedIndex = 0;
}
fancybox_start();
};
$.fancybox.showActivity = function() {
clearInterval(loadingTimer);
loading.show();
loadingTimer = setInterval(fancybox_animate_loading, 66);
};
$.fancybox.hideActivity = function() {
loading.hide();
};
$.fancybox.next = function() {
return $.fancybox.pos(currentIndex + 1);
};
$.fancybox.prev = function() {
return $.fancybox.pos(currentIndex - 1);
};
$.fancybox.pos = function(pos) {
if (busy) {
return;
}
pos = parseInt(pos, 10);
if (pos > -1 && currentArray.length > pos) {
selectedIndex = pos;
fancybox_start();
}
if (currentOpts.cyclic && currentArray.length > 1 && pos < 0) {
selectedIndex = currentArray.length - 1;
fancybox_start();
}
if (currentOpts.cyclic && currentArray.length > 1 && pos >= currentArray.length) {
selectedIndex = 0;
fancybox_start();
}
return;
};
$.fancybox.cancel = function() {
if (busy) {
return;
}
busy = true;
$.event.trigger('fancybox-cancel');
fancybox_abort();
if (selectedOpts && $.isFunction(selectedOpts.onCancel)) {
selectedOpts.onCancel(selectedArray, selectedIndex, selectedOpts);
}
busy = false;
};
$.fancybox.close = function() {
if (busy || wrap.is(':hidden')) {
return;
}
busy = true;
if (currentOpts && $.isFunction(currentOpts.onCleanup)) {
if (currentOpts.onCleanup(currentArray, currentIndex, currentOpts) === false) {
busy = false;
return;
}
}
fancybox_abort();
$(close.add(nav_left).add(nav_right)).hide();
$('#fancybox-title').remove();
wrap.add(inner).add(overlay).unbind();
$(window).unbind("resize.fb scroll.fb");
$(document).unbind('keydown.fb');
function _cleanup() {
overlay.fadeOut('fast');
wrap.hide();
$.event.trigger('fancybox-cleanup');
inner.empty();
if ($.isFunction(currentOpts.onClosed)) {
currentOpts.onClosed(currentArray, currentIndex, currentOpts);
}
currentArray = selectedOpts = [];
currentIndex = selectedIndex = 0;
currentOpts = selectedOpts = {};
busy = false;
}
inner.css('overflow', 'hidden');
if (currentOpts.transitionOut == 'elastic') {
start_pos = fancybox_get_zoom_from();
var pos = wrap.position();
final_pos = {
top: pos.top,
left: pos.left,
width: wrap.width(),
height: wrap.height()
};
if (currentOpts.opacity) {
final_pos.opacity = 1;
}
fx.prop = 1;
$(fx).animate({
prop: 0
}, {
duration: currentOpts.speedOut,
easing: currentOpts.easingOut,
step: fancybox_draw,
complete: _cleanup
});
} else {
wrap.fadeOut(currentOpts.transitionOut == 'none' ? 0 : currentOpts.speedOut, _cleanup);
}
};
$.fancybox.resize = function() {
var c, h;
if (busy || wrap.is(':hidden')) {
return;
}
busy = true;
c = inner.wrapInner("<div style='overflow:auto'></div>").children();
h = c.height();
wrap.css({
height: h + (currentOpts.padding * 2) + titleh
});
inner.css({
height: h
});
c.replaceWith(c.children());
$.fancybox.center();
};
$.fancybox.center = function() {
busy = true;
var view = fancybox_get_viewport(),
margin = currentOpts.margin,
to = {};
to.top = view[3] + ((view[1] - ((wrap.height() - titleh) + (shadow * 2))) * 0.5);
to.left = view[2] + ((view[0] - (wrap.width() + (shadow * 2))) * 0.5);
to.top = Math.max(view[3] + margin, to.top);
to.left = Math.max(view[2] + margin, to.left);
wrap.css(to);
busy = false;
};
$.fn.fancybox.defaults = {
padding: 10,
margin: 20,
opacity: false,
modal: false,
cyclic: false,
scrolling: 'auto',
width: 560,
height: 340,
autoScale: true,
autoDimensions: true,
centerOnScroll: false,
ajax: {},
swf: {
wmode: 'transparent'
},
hideOnOverlayClick: true,
hideOnContentClick: false,
overlayShow: true,
overlayOpacity: 0.3,
overlayColor: '#666',
titleShow: true,
titlePosition: 'outside',
titleFormat: null,
transitionIn: 'fade',
transitionOut: 'fade',
speedIn: 300,
speedOut: 300,
changeSpeed: 300,
changeFade: 'fast',
easingIn: 'swing',
easingOut: 'swing',
showCloseButton: true,
showNavArrows: true,
enableEscapeButton: true,
onStart: null,
onCancel: null,
onComplete: null,
onCleanup: null,
onClosed: null
};
$(document).ready(function() {
fancybox_init();
});
})(jQuery);
| ready |
shadow | (function() {
var ua = navigator.userAgent.toLowerCase(),
S = {
version: "3.0rc1",
adapter: null,
cache: [],
client: {
isIE: ua.indexOf("msie") > -1,
isIE6: ua.indexOf("msie 6") > -1,
isIE7: ua.indexOf("msie 7") > -1,
isGecko: ua.indexOf("gecko") > -1 && ua.indexOf("safari") == -1,
isWebkit: ua.indexOf("applewebkit/") > -1,
isWindows: ua.indexOf("windows") > -1 || ua.indexOf("win32") > -1,
isMac: ua.indexOf("macintosh") > -1 || ua.indexOf("mac os x") > -1,
isLinux: ua.indexOf("linux") > -1
},
content: null,
current: -1,
dimensions: null,
gallery: [],
expando: "shadowboxCacheKey",
libraries: {
Prototype: "prototype",
jQuery: "jquery",
MooTools: "mootools",
YAHOO: "yui",
dojo: "dojo",
Ext: "ext"
},
options: {
adapter: null,
animate: true,
animateFade: true,
autoplayMovies: true,
continuous: false,
ease: function(x) {
return 1 + Math.pow(x - 1, 3)
},
enableKeys: true,
errors: {
fla: {
name: "Flash",
url: "http://www.adobe.com/products/flashplayer/"
},
qt: {
name: "QuickTime",
url: "http://www.apple.com/quicktime/download/"
},
wmp: {
name: "Windows Media Player",
url: "http://www.microsoft.com/windows/windowsmedia/"
},
f4m: {
name: "Flip4Mac",
url: "http://www.flip4mac.com/wmv_download.htm"
}
},
ext: {
img: ["png", "jpg", "jpeg", "gif", "bmp"],
swf: ["swf"],
flv: ["flv", "m4v"],
qt: ["dv", "mov", "moov", "movie", "mp4"],
wmp: ["asf", "wm", "wmv"],
qtwmp: ["avi", "mpg", "mpeg"]
},
flashParams: {
bgcolor: "#000000",
allowfullscreen: true
},
flashVars: {},
flashVersion: "9.0.115",
handleOversize: "resize",
handleUnsupported: "link",
language: "en",
onChange: null,
onClose: null,
onFinish: null,
onOpen: null,
players: ["img"],
showMovieControls: true,
skipSetup: false,
slideshowDelay: 0,
useSizzle: true,
viewportPadding: 20
},
path: "",
plugins: null,
ready: false,
regex: {
domain: /:\/\/(.*?)[:\/]/,
inline: /#(.+)$/,
rel: /^(light|shadow)box/i,
gallery: /^(light|shadow)box\[(.*?)\]/i,
unsupported: /^unsupported-(\w+)/,
param: /\s*([a-z_]*?)\s*=\s*(.+)\s*/
},
applyOptions: function(opts) {
if (opts) {
default_options = apply({}, S.options);
apply(S.options, opts)
}
},
revertOptions: function() {
apply(S.options, default_options)
},
change: function(index) {
if (!S.gallery) {
return
}
if (!S.gallery[index]) {
if (!S.options.continuous) {
return
} else {
index = index < 0 ? S.gallery.length - 1 : 0
}
}
S.current = index;
if (typeof slide_timer == "number") {
clearTimeout(slide_timer);
slide_timer = null;
slide_delay = slide_start = 0
}
if (S.options.onChange) {
S.options.onChange()
}
loadContent()
},
close: function() {
if (!active) {
return
}
active = false;
listenKeys(false);
if (S.content) {
S.content.remove();
S.content = null
}
if (typeof slide_timer == "number") {
clearTimeout(slide_timer)
}
slide_timer = null;
slide_delay = 0;
if (S.options.onClose) {
S.options.onClose()
}
S.skin.onClose();
S.revertOptions()
},
contentId: function() {
return content_id
},
error: function(msg) {
if (!S.debug) {
return
}
if (typeof window.console != "undefined" && typeof console.log == "function") {
console.log(msg)
} else {
alert(msg)
}
},
getCurrent: function() {
return S.current > -1 ? S.gallery[S.current] : null
},
hasNext: function() {
return S.gallery.length > 1 && (S.current != S.gallery.length - 1 || S.options.continuous)
},
init: function(opts) {
if (initialized) {
return
}
initialized = true;
opts = opts || {};
init_options = opts;
if (opts) {
apply(S.options, opts)
}
for (var e in S.options.ext) {
S.regex[e] = new RegExp(".(" + S.options.ext[e].join("|") + ")s*$", "i")
}
if (!S.path) {
var pathre = /(.+\/)shadowbox\.js/i,
path;
each(document.getElementsByTagName("script"), function(s) {
path = pathre.exec(s.src);
if (path) {
S.path = path[1];
return false
}
})
}
if (S.options.adapter) {
S.adapter = S.options.adapter.toLowerCase()
} else {
for (var lib in S.libraries) {
if (typeof window[lib] != "undefined") {
S.adapter = S.libraries[lib];
break
}
}
if (!S.adapter) {
S.adapter = "base"
}
}
if (S.options.useSizzle && !window.Sizzle) {
if (window.jQuery) {
window.Sizzle = jQuery.find
} else {
U.include(S.path + "libraries/sizzle/sizzle.js")
}
}
if (!S.lang) {
U.include(S.path + "languages/shadowbox-" + S.options.language + ".js")
}
each(S.options.players, function(p) {
if ((p == "swf" || p == "flv") && !window.swfobject) {
U.include(S.path + "libraries/swfobject/swfobject.js")
}
if (!S[p]) {
U.include(S.path + "players/shadowbox-" + p + ".js")
}
});
if (!S.lib) {
U.include(S.path + "adapters/shadowbox-" + S.adapter + ".js")
}
waitDom(waitLibs)
},
isActive: function() {
return active
},
isPaused: function() {
return slide_timer == "paused"
},
load: function() {
if (S.ready) {
return
}
S.ready = true;
if (S.skin.options) {
apply(S.options, S.skin.options);
apply(S.options, init_options)
}
S.skin.init();
if (!S.options.skipSetup) {
S.setup()
}
},
next: function() {
S.change(S.current + 1)
},
open: function(obj) {
if (U.isLink(obj)) {
if (S.inCache(obj)) {
obj = S.cache[obj[S.expando]]
} else {
obj = S.buildCacheObj(obj)
}
}
if (obj.constructor == Array) {
S.gallery = obj;
S.current = 0
} else {
if (!obj.gallery) {
S.gallery = [obj];
S.current = 0
} else {
S.current = null;
S.gallery = [];
each(S.cache, function(c) {
if (c.gallery && c.gallery == obj.gallery) {
if (S.current == null && c.content == obj.content && c.title == obj.title) {
S.current = S.gallery.length
}
S.gallery.push(c)
}
});
if (S.current == null) {
S.gallery.unshift(obj);
S.current = 0
}
}
}
obj = S.getCurrent();
if (obj.options) {
S.revertOptions();
S.applyOptions(obj.options)
}
var item, remove, m, format, replace, oe = S.options.errors,
msg, el;
for (var i = 0; i < S.gallery.length; ++i) {
item = S.gallery[i] = apply({}, S.gallery[i]);
remove = false;
if (m = S.regex.unsupported.exec(item.player)) {
if (S.options.handleUnsupported == "link") {
item.player = "html";
switch (m[1]) {
case "qtwmp":
format = "either";
replace = [oe.qt.url, oe.qt.name, oe.wmp.url, oe.wmp.name];
break;
case "qtf4m":
format = "shared";
replace = [oe.qt.url, oe.qt.name, oe.f4m.url, oe.f4m.name];
break;
default:
format = "single";
if (m[1] == "swf" || m[1] == "flv") {
m[1] = "fla"
}
replace = [oe[m[1]].url, oe[m[1]].name]
}
msg = S.lang.errors[format].replace(/\{(\d+)\}/g, function(m, n) {
return replace[n]
});
item.content = '<div class="sb-message">' + msg + "</div>"
} else {
remove = true
}
} else {
if (item.player == "inline") {
m = S.regex.inline.exec(item.content);
if (m) {
var el = U.get(m[1]);
if (el) {
item.content = el.innerHTML
} else {
S.error("Cannot find element with id " + m[1])
}
} else {
S.error("Cannot find element id for inline content")
}
} else {
if (item.player == "swf" || item.player == "flv") {
var version = (item.options && item.options.flashVersion) || S.options.flashVersion;
if (!swfobject.hasFlashPlayerVersion(version)) {
item.width = 310;
item.height = 177
}
}
}
}
if (remove) {
S.gallery.splice(i, 1);
if (i < S.current) {
--S.current
} else {
if (i == S.current) {
S.current = i > 0 ? i - 1 : i
}
}--i
}
}
if (S.gallery.length) {
if (!active) {
if (typeof S.options.onOpen == "function" && S.options.onOpen(obj) === false) {
return
}
S.skin.onOpen(obj, loadContent)
} else {
loadContent()
}
active = true
}
},
pause: function() {
if (typeof slide_timer != "number") {
return
}
var time = new Date().getTime();
slide_delay = Math.max(0, slide_delay - (time - slide_start));
if (slide_delay) {
clearTimeout(slide_timer);
slide_timer = "paused";
if (S.skin.onPause) {
S.skin.onPause()
}
}
},
play: function() {
if (!S.hasNext()) {
return
}
if (!slide_delay) {
slide_delay = S.options.slideshowDelay * 1000
}
if (slide_delay) {
slide_start = new Date().getTime();
slide_timer = setTimeout(function() {
slide_delay = slide_start = 0;
S.next()
}, slide_delay);
if (S.skin.onPlay) {
S.skin.onPlay()
}
}
},
previous: function() {
S.change(S.current - 1)
},
setDimensions: function(height, width, max_h, max_w, tb, lr, resizable) {
var h = height = parseInt(height),
w = width = parseInt(width),
pad = parseInt(S.options.viewportPadding) || 0;
var extra_h = 2 * pad + tb;
if (h + extra_h >= max_h) {
h = max_h - extra_h
}
var extra_w = 2 * pad + lr;
if (w + extra_w >= max_w) {
w = max_w - extra_w
}
var resize_h = height,
resize_w = width,
change_h = (height - h) / height,
change_w = (width - w) / width,
oversized = (change_h > 0 || change_w > 0);
if (resizable && oversized && S.options.handleOversize == "resize") {
if (change_h > change_w) {
w = Math.round((width / height) * h)
} else {
if (change_w > change_h) {
h = Math.round((height / width) * w)
}
}
resize_w = w;
resize_h = h
}
S.dimensions = {
height: h + tb,
width: w + lr,
inner_h: h,
inner_w: w,
top: (max_h - (h + extra_h)) / 2 + pad,
left: (max_w - (w + extra_w)) / 2 + pad,
oversized: oversized,
resize_h: resize_h,
resize_w: resize_w
}
},
setup: function(links, opts) {
each(S.findLinks(links), function(link) {
S.addCache(link, opts)
})
},
teardown: function(links) {
each(S.findLinks(links), S.removeCache)
},
findLinks: function(links) {
if (!links) {
var links = [],
rel;
each(document.getElementsByTagName("a"), function(a) {
rel = a.getAttribute("rel");
if (rel && S.regex.rel.test(rel)) {
links.push(a)
}
})
} else {
var len = links.length;
if (len) {
if (window.Sizzle) {
if (typeof links == "string") {
links = Sizzle(links)
} else {
if (len == 2 && links.push && typeof links[0] == "string" && links[1].nodeType) {
links = Sizzle(links[0], links[1])
}
}
}
} else {
links = [links]
}
}
return links
},
inCache: function(link) {
return typeof link[S.expando] == "number" && S.cache[link[S.expando]]
},
addCache: function(link, opts) {
if (!S.inCache(link)) {
link[S.expando] = S.cache.length;
S.lib.addEvent(link, "click", handleClick)
}
S.cache[link[S.expando]] = S.buildCacheObj(link, opts)
},
removeCache: function(link) {
S.lib.removeEvent(link, "click", handleClick);
S.cache[link[S.expando]] = null;
delete link[S.expando]
},
clearCache: function() {
each(S.cache, function(obj) {
S.removeCache(obj.link)
});
S.cache = []
},
buildCacheObj: function(link, opts) {
var obj = {
link: link,
title: link.getAttribute("title"),
options: apply({}, opts || {}),
content: link.href
};
if (opts) {
each(["player", "title", "height", "width", "gallery"], function(option) {
if (typeof obj.options[option] != "undefined") {
obj[option] = obj.options[option];
delete obj.options[option]
}
})
}
if (!obj.player) {
obj.player = S.getPlayer(obj.content)
}
var rel = link.getAttribute("rel");
if (rel) {
var match = rel.match(S.regex.gallery);
if (match) {
obj.gallery = escape(match[2])
}
each(rel.split(";"), function(parameter) {
match = parameter.match(S.regex.param);
if (match) {
if (match[1] == "options") {
eval("apply(obj.options," + match[2] + ")")
} else {
obj[match[1]] = match[2]
}
}
})
}
return obj
},
getPlayer: function(content) {
var r = S.regex,
p = S.plugins,
m = content.match(r.domain),
same_domain = m && document.domain == m[1];
if (content.indexOf("#") > -1 && same_domain) {
return "inline"
}
var q = content.indexOf("?");
if (q > -1) {
content = content.substring(0, q)
}
if (r.img.test(content)) {
return "img"
}
if (r.swf.test(content)) {
return p.fla ? "swf" : "unsupported-swf"
}
if (r.flv.test(content)) {
return p.fla ? "flv" : "unsupported-flv"
}
if (r.qt.test(content)) {
return p.qt ? "qt" : "unsupported-qt"
}
if (r.wmp.test(content)) {
if (p.wmp) {
return "wmp"
}
if (p.f4m) {
return "qt"
}
if (S.client.isMac) {
return p.qt ? "unsupported-f4m" : "unsupported-qtf4m"
}
return "unsupported-wmp"
}
if (r.qtwmp.test(content)) {
if (p.qt) {
return "qt"
}
if (p.wmp) {
return "wmp"
}
return S.client.isMac ? "unsupported-qt" : "unsupported-qtwmp"
}
return "iframe"
}
},
U = S.util = {
animate: function(el, p, to, d, cb) {
var from = parseFloat(S.lib.getStyle(el, p));
if (isNaN(from)) {
from = 0
}
var delta = to - from;
if (delta == 0) {
if (cb) {
cb()
}
return
}
var op = p == "opacity";
function fn(ease) {
var to = from + ease * delta;
if (op) {
U.setOpacity(el, to)
} else {
el.style[p] = to + "px"
}
}
if (!d || (!op && !S.options.animate) || (op && !S.options.animateFade)) {
fn(1);
if (cb) {
cb()
}
return
}
d *= 1000;
var begin = new Date().getTime(),
ease = S.options.ease,
end = begin + d,
time, timer = setInterval(function() {
time = new Date().getTime();
if (time >= end) {
clearInterval(timer);
fn(1);
if (cb) {
cb()
}
} else {
fn(ease((time - begin) / d))
}
}, 10)
},
apply: function(o, e) {
for (var p in e) {
o[p] = e[p]
}
return o
},
clearOpacity: function(el) {
var s = el.style;
if (window.ActiveXObject) {
if (typeof s.filter == "string" && (/alpha/i).test(s.filter)) {
s.filter = s.filter.replace(/[\w\.]*alpha\(.*?\);?/i, "")
}
} else {
s.opacity = ""
}
},
each: function(obj, fn, scope) {
for (var i = 0, len = obj.length; i < len; ++i) {
if (fn.call(scope || obj[i], obj[i], i, obj) === false) {
return
}
}
},
get: function(id) {
return document.getElementById(id)
},
include: function() {
var includes = {};
return function(file) {
if (includes[file]) {
return
}
includes[file] = true;
var head = document.getElementsByTagName("head")[0],
script = document.createElement("script");
script.src = file;
head.appendChild(script)
}
}(),
isLink: function(obj) {
if (!obj || !obj.tagName) {
return false
}
var up = obj.tagName.toUpperCase();
return up == "A" || up == "AREA"
},
removeChildren: function(el) {
while (el.firstChild) {
el.removeChild(el.firstChild)
}
},
setOpacity: function(el, o) {
var s = el.style;
if (window.ActiveXObject) {
s.zoom = 1;
s.filter = (s.filter || "").replace(/\s*alpha\([^\)]*\)/gi, "") + (o == 1 ? "" : " alpha(opacity=" + (o * 100) + ")")
} else {
s.opacity = o
}
}
},
apply = U.apply,
each = U.each,
init_options, initialized = false,
default_options = {},
content_id = "sb-content",
active = false,
slide_timer, slide_start, slide_delay = 0;
if (navigator.plugins && navigator.plugins.length) {
var names = [];
each(navigator.plugins, function(p) {
names.push(p.name)
});
names = names.join();
var f4m = names.indexOf("Flip4Mac") > -1;
S.plugins = {
fla: names.indexOf("Shockwave Flash") > -1,
qt: names.indexOf("QuickTime") > -1,
wmp: !f4m && names.indexOf("Windows Media") > -1,
f4m: f4m
}
} else {
function detectPlugin(n) {
try {
var axo = new ActiveXObject(n)
} catch (e) {}
return !!axo
}
S.plugins = {
fla: detectPlugin("ShockwaveFlash.ShockwaveFlash"),
qt: detectPlugin("QuickTime.QuickTime"),
wmp: detectPlugin("wmplayer.ocx"),
f4m: false
}
}
function waitDom(cb) {
if (document.addEventListener) {
document.addEventListener("DOMContentLoaded", function() {
document.removeEventListener("DOMContentLoaded", arguments.callee, false);
cb()
}, false)
} else {
if (document.attachEvent) {
document.attachEvent("onreadystatechange", function() {
if (document.readyState === "complete") {
document.detachEvent("onreadystatechange", arguments.callee);
cb()
}
});
if (document.documentElement.doScroll && window == window.top) {
(function() {
if (S.ready) {
return
}
try {
document.documentElement.doScroll("left")
} catch (error) {
setTimeout(arguments.callee, 0);
return
}
cb()
})()
}
}
}
if (typeof window.onload == "function") {
var oldonload = window.onload;
window.onload = function() {
oldonload();
cb()
}
} else {
window.onload = cb
}
}
function waitLibs() {
if (S.lib && S.lang) {
S.load()
} else {
setTimeout(waitLibs, 0)
}
}
function handleClick(e) {
var link;
if (U.isLink(this)) {
link = this
} else {
link = S.lib.getTarget(e);
while (!U.isLink(link) && link.parentNode) {
link = link.parentNode
}
}
S.lib.preventDefault(e);
if (link) {
S.open(link);
if (S.gallery.length) {
S.lib.preventDefault(e)
}
}
}
function listenKeys(on) {
if (!S.options.enableKeys) {
return
}
S.lib[(on ? "add" : "remove") + "Event"](document, "keydown", handleKey)
}
function handleKey(e) {
var code = S.lib.keyCode(e),
handler;
switch (code) {
case 81:
case 88:
case 27:
handler = S.close;
break;
case 37:
handler = S.previous;
break;
case 39:
handler = S.next;
break;
case 32:
handler = typeof slide_timer == "number" ? S.pause : S.play
}
if (handler) {
S.lib.preventDefault(e);
handler()
}
}
function loadContent() {
var obj = S.getCurrent();
if (!obj) {
return
}
var p = obj.player == "inline" ? "html" : obj.player;
if (typeof S[p] != "function") {
S.error("Unknown player: " + p)
}
var change = false;
if (S.content) {
S.content.remove();
change = true;
S.revertOptions();
if (obj.options) {
S.applyOptions(obj.options)
}
}
U.removeChildren(S.skin.bodyEl());
S.content = new S[p](obj);
listenKeys(false);
S.skin.onLoad(S.content, change, function() {
if (!S.content) {
return
}
if (typeof S.content.ready != "undefined") {
var id = setInterval(function() {
if (S.content) {
if (S.content.ready) {
clearInterval(id);
id = null;
S.skin.onReady(contentReady)
}
} else {
clearInterval(id);
id = null
}
}, 100)
} else {
S.skin.onReady(contentReady)
}
});
if (S.gallery.length > 1) {
var next = S.gallery[S.current + 1] || S.gallery[0];
if (next.player == "img") {
var a = new Image();
a.src = next.content
}
var prev = S.gallery[S.current - 1] || S.gallery[S.gallery.length - 1];
if (prev.player == "img") {
var b = new Image();
b.src = prev.content
}
}
}
function contentReady() {
if (!S.content) {
return
}
S.content.append(S.skin.bodyEl(), content_id, S.dimensions);
S.skin.onFinish(finishContent)
}
function finishContent() {
if (!S.content) {
return
}
if (S.content.onLoad) {
S.content.onLoad()
}
if (S.options.onFinish) {
S.options.onFinish()
}
if (!S.isPaused()) {
S.play()
}
listenKeys(true)
}
window.Shadowbox = S
})();
(function() {
var g = Shadowbox,
f = g.util,
q = false,
b = [],
m = ["sb-nav-close", "sb-nav-next", "sb-nav-play", "sb-nav-pause", "sb-nav-previous"],
o = {
markup: '<div id="sb-container"><div id="sb-overlay"></div><div id="sb-wrapper"><div id="sb-title"><div id="sb-title-inner"></div></div><div id="sb-body"><div id="sb-body-inner"></div><div id="sb-loading"><a onclick="Shadowbox.close()">{cancel}</a></div></div><div id="sb-info"><div id="sb-info-inner"><div id="sb-counter"></div><div id="sb-nav"><a id="sb-nav-close" title="{close}" onclick="Shadowbox.close()"></a><a id="sb-nav-next" title="{next}" onclick="Shadowbox.next()"></a><a id="sb-nav-play" title="{play}" onclick="Shadowbox.play()"></a><a id="sb-nav-pause" title="{pause}" onclick="Shadowbox.pause()"></a><a id="sb-nav-previous" title="{previous}" onclick="Shadowbox.previous()"></a></div><div style="clear:both"></div></div></div></div></div>',
options: {
animSequence: "sync",
autoDimensions: false,
counterLimit: 10,
counterType: "default",
displayCounter: true,
displayNav: true,
fadeDuration: 0.35,
initialHeight: 160,
initialWidth: 320,
modal: false,
overlayColor: "#000",
overlayOpacity: 0.8,
resizeDuration: 0.35,
showOverlay: true,
troubleElements: ["select", "object", "embed", "canvas"]
},
init: function() {
var s = o.markup.replace(/\{(\w+)\}/g, function(w, x) {
return g.lang[x]
});
g.lib.append(document.body, s);
if (g.client.isIE6) {
f.get("sb-body").style.zoom = 1;
var u, r, t = /url\("(.*\.png)"\)/;
f.each(m, function(w) {
u = f.get(w);
if (u) {
r = g.lib.getStyle(u, "backgroundImage").match(t);
if (r) {
u.style.backgroundImage = "none";
u.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true,src=" + r[1] + ",sizingMethod=scale);"
}
}
})
}
var v;
g.lib.addEvent(window, "resize", function() {
if (v) {
clearTimeout(v);
v = null
}
if (g.isActive()) {
v = setTimeout(function() {
o.onWindowResize();
var w = g.content;
if (w && w.onWindowResize) {
w.onWindowResize()
}
}, 50)
}
})
},
bodyEl: function() {
return f.get("sb-body-inner")
},
onOpen: function(u, r) {
e(false);
var t = g.options.autoDimensions && "height" in u ? u.height : g.options.initialHeight,
s = g.options.autoDimensions && "width" in u ? u.width : g.options.initialWidth;
f.get("sb-container").style.display = "block";
var v = p(t, s);
d(v.inner_h, v.top, false);
h(v.width, v.left, false);
i(r)
},
onLoad: function(s, t, r) {
k(true);
j(t, function() {
if (!s) {
return
}
if (!t) {
f.get("sb-wrapper").style.display = ""
}
r()
})
},
onReady: function(r) {
var t = g.content;
if (!t) {
return
}
var s = p(t.height, t.width, t.resizable);
o.resizeContent(s.inner_h, s.width, s.top, s.left, true, function() {
l(r)
})
},
onFinish: function(r) {
k(false, r)
},
onClose: function() {
i();
e(true)
},
onPlay: function() {
c("play", false);
c("pause", true)
},
onPause: function() {
c("pause", false);
c("play", true)
},
onWindowResize: function() {
var t = g.content;
if (!t) {
return
}
var s = p(t.height, t.width, t.resizable);
h(s.width, s.left, false);
d(s.inner_h, s.top, false);
var r = f.get(g.contentId());
if (r) {
if (t.resizable && g.options.handleOversize == "resize") {
r.height = s.resize_h;
r.width = s.resize_w
}
}
},
resizeContent: function(s, t, w, v, u, r) {
var y = g.content;
if (!y) {
return
}
var x = p(y.height, y.width, y.resizable);
switch (g.options.animSequence) {
case "hw":
d(x.inner_h, x.top, u, function() {
h(x.width, x.left, u, r)
});
break;
case "wh":
h(x.width, x.left, u, function() {
d(x.inner_h, x.top, u, r)
});
break;
default:
h(x.width, x.left, u);
d(x.inner_h, x.top, u, r)
}
}
};
function n() {
f.get("sb-container").style.top = document.documentElement.scrollTop + "px"
}
function e(r) {
if (r) {
f.each(b, function(s) {
s[0].style.visibility = s[1] || ""
})
} else {
b = [];
f.each(g.options.troubleElements, function(s) {
f.each(document.getElementsByTagName(s), function(t) {
b.push([t, t.style.visibility]);
t.style.visibility = "hidden"
})
})
}
}
function i(r) {
var s = f.get("sb-overlay"),
t = f.get("sb-container"),
v = f.get("sb-wrapper");
if (r) {
if (g.client.isIE6) {
n();
g.lib.addEvent(window, "scroll", n)
}
if (g.options.showOverlay) {
q = true;
s.style.backgroundColor = g.options.overlayColor;
f.setOpacity(s, 0);
if (!g.options.modal) {
g.lib.addEvent(s, "click", g.close)
}
v.style.display = "none"
}
t.style.visibility = "visible";
if (q) {
var u = parseFloat(g.options.overlayOpacity);
f.animate(s, "opacity", u, g.options.fadeDuration, r)
} else {
r()
}
} else {
if (g.client.isIE6) {
g.lib.removeEvent(window, "scroll", n)
}
g.lib.removeEvent(s, "click", g.close);
if (q) {
v.style.display = "none";
f.animate(s, "opacity", 0, g.options.fadeDuration, function() {
t.style.display = "";
v.style.display = "";
f.clearOpacity(s)
})
} else {
t.style.visibility = "hidden"
}
}
}
function c(t, r) {
var s = f.get("sb-nav-" + t);
if (s) {
s.style.display = r ? "" : "none"
}
}
function k(s, r) {
var u = f.get("sb-loading"),
w = g.getCurrent().player,
v = (w == "img" || w == "html");
if (s) {
function t() {
f.clearOpacity(u);
if (r) {
r()
}
}
f.setOpacity(u, 0);
u.style.display = "";
if (v) {
f.animate(u, "opacity", 1, g.options.fadeDuration, t)
} else {
t()
}
} else {
function t() {
u.style.display = "none";
f.clearOpacity(u);
if (r) {
r()
}
}
if (v) {
f.animate(u, "opacity", 0, g.options.fadeDuration, t)
} else {
t()
}
}
}
function a(u) {
var z = g.getCurrent();
f.get("sb-title-inner").innerHTML = z.title || "";
var C, t, x, D, s;
if (g.options.displayNav) {
C = true;
var B = g.gallery.length;
if (B > 1) {
if (g.options.continuous) {
t = s = true
} else {
t = (B - 1) > g.current;
s = g.current > 0
}
}
if (g.options.slideshowDelay > 0 && g.hasNext()) {
D = !g.isPaused();
x = !D
}
} else {
C = t = x = D = s = false
}
c("close", C);
c("next", t);
c("play", x);
c("pause", D);
c("previous", s);
var r = "";
if (g.options.displayCounter && g.gallery.length > 1) {
var B = g.gallery.length;
if (g.options.counterType == "skip") {
var y = 0,
w = B,
v = parseInt(g.options.counterLimit) || 0;
if (v < B && v > 2) {
var A = Math.floor(v / 2);
y = g.current - A;
if (y < 0) {
y += B
}
w = g.current + (v - A);
if (w > B) {
w -= B
}
}
while (y != w) {
if (y == B) {
y = 0
}
r += '<a onclick="Shadowbox.change(' + y + ');"';
if (y == g.current) {
r += ' class="sb-counter-current"'
}
r += ">" + (y++) + "</a>"
}
} else {
var r = (g.current + 1) + " " + g.lang.of + " " + B
}
}
f.get("sb-counter").innerHTML = r;
u()
}
function j(u, s) {
var y = f.get("sb-wrapper"),
B = f.get("sb-title"),
v = f.get("sb-info"),
r = f.get("sb-title-inner"),
z = f.get("sb-info-inner"),
A = parseInt(g.lib.getStyle(r, "height")) || 0,
x = parseInt(g.lib.getStyle(z, "height")) || 0;
var w = function() {
r.style.visibility = z.style.visibility = "hidden";
a(s)
};
if (u) {
f.animate(B, "height", 0, 0.35);
f.animate(v, "height", 0, 0.35);
f.animate(y, "paddingTop", A, 0.35);
f.animate(y, "paddingBottom", x, 0.35, w)
} else {
B.style.height = v.style.height = "0px";
y.style.paddingTop = A + "px";
y.style.paddingBottom = x + "px";
w()
}
}
function l(u) {
var s = f.get("sb-wrapper"),
w = f.get("sb-title"),
v = f.get("sb-info"),
z = f.get("sb-title-inner"),
y = f.get("sb-info-inner"),
x = parseInt(g.lib.getStyle(z, "height")) || 0,
r = parseInt(g.lib.getStyle(y, "height")) || 0;
z.style.visibility = y.style.visibility = "";
if (z.innerHTML != "") {
f.animate(w, "height", x, 0.35);
f.animate(s, "paddingTop", 0, 0.35)
}
f.animate(v, "height", r, 0.35);
f.animate(s, "paddingBottom", 0, 0.35, u)
}
function d(u, z, y, r) {
var A = f.get("sb-body"),
x = f.get("sb-wrapper"),
w = parseInt(u),
v = parseInt(z);
if (y) {
f.animate(A, "height", w, g.options.resizeDuration);
f.animate(x, "top", v, g.options.resizeDuration, r)
} else {
A.style.height = w + "px";
x.style.top = v + "px";
if (r) {
r()
}
}
}
function h(x, z, y, r) {
var v = f.get("sb-wrapper"),
u = parseInt(x),
t = parseInt(z);
if (y) {
f.animate(v, "width", u, g.options.resizeDuration);
f.animate(v, "left", t, g.options.resizeDuration, r)
} else {
v.style.width = u + "px";
v.style.left = t + "px";
if (r) {
r()
}
}
}
function p(r, u, t) {
var s = f.get("sb-body-inner");
sw = f.get("sb-wrapper"), so = f.get("sb-overlay"), tb = sw.offsetHeight - s.offsetHeight, lr = sw.offsetWidth - s.offsetWidth, max_h = so.offsetHeight, max_w = so.offsetWidth;
g.setDimensions(r, u, max_h, max_w, tb, lr, t);
return g.dimensions
}
g.skin = o
})();
| ready |