
$(document).ready(function(){
// Temporarily forcing menu classes until NewMenu object is updated
$('ul li:first-child').addClass('first');
$('ul li:last-child').addClass('last');
});
/*
* FancyBox - jQuery Plugin
* Simple and fancy lightbox alternative
*
* Examples and documentation at: http://fancybox.net
*
* Copyright (c) 2008 - 2010 Janis Skarnelis
* That said, it is hardly a one-person project. Many people have submitted bugs, code, and offered their advice freely. Their support is greatly appreciated.
*
* Version: 1.3.4 (11/11/2010)
* Requires: jQuery v1.3+
*
* Dual licensed under the MIT and GPL licenses:
*   http://www.opensource.org/licenses/mit-license.php
*   http://www.gnu.org/licenses/gpl.html
*/
;(function($) {
var tmp, loading, overlay, wrap, outer, content, close, title, 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,
titleHeight = 0, titleStr = '', start_pos, final_pos, busy = false, fx = $.extend($('<div/>')[0], { prop: 0 }),
isIE6 = $.browser.msie && $.browser.version < 7 && !window.XMLHttpRequest,
/*
* Private methods
*/
_abort = function() {
loading.hide();
imgPreloader.onerror = imgPreloader.onload = null;
if (ajaxLoader) {
ajaxLoader.abort();
}
tmp.empty();
},
_error = function() {
if (false === selectedOpts.onError(selectedArray, selectedIndex, selectedOpts)) {
loading.hide();
busy = false;
return;
}
selectedOpts.titleShow = false;
selectedOpts.width = 'auto';
selectedOpts.height = 'auto';
tmp.html( '<p id="fancybox-error">The requested content cannot be loaded.<br />Please try again later.</p>' );
_process_inline();
},
_start = function() {
var obj = selectedArray[ selectedIndex ],
href,
type,
title,
str,
emb,
ret;
_abort();
selectedOpts = $.extend({}, $.fn.fancybox.defaults, (typeof $(obj).data('fancybox') == 'undefined' ? selectedOpts : $(obj).data('fancybox')));
ret = selectedOpts.onStart(selectedArray, selectedIndex, selectedOpts);
if (ret === false) {
busy = false;
return;
} else if (typeof ret == 'object') {
selectedOpts = $.extend(selectedOpts, ret);
}
title = selectedOpts.title || (obj.nodeName ? $(obj).attr('title') : obj.title) || '';
if (obj.nodeName && !selectedOpts.orig) {
selectedOpts.orig = $(obj).children("img:first").length ? $(obj).children("img:first") : $(obj);
}
if (title === '' && selectedOpts.orig && selectedOpts.titleFromAlt) {
title = selectedOpts.orig.attr('alt');
}
href = selectedOpts.href || (obj.nodeName ? $(obj).attr('href') : obj.href) || null;
if ((/^(?:javascript)/i).test(href) || href == '#') {
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.indexOf("#") === 0) {
type = 'inline';
} else {
type = 'ajax';
}
}
if (!type) {
_error();
return;
}
if (type == 'inline') {
obj	= href.substr(href.indexOf("#"));
type = $(obj).length > 0 ? 'inline' : 'ajax';
}
selectedOpts.type = type;
selectedOpts.href = href;
selectedOpts.title = title;
if (selectedOpts.autoDimensions) {
if (selectedOpts.type == 'html' || selectedOpts.type == 'inline' || selectedOpts.type == 'ajax') {
selectedOpts.width = 'auto';
selectedOpts.height = 'auto';
} else {
selectedOpts.autoDimensions = false;
}
}
if (selectedOpts.modal) {
selectedOpts.overlayShow = true;
selectedOpts.hideOnOverlayClick = false;
selectedOpts.hideOnContentClick = false;
selectedOpts.enableEscapeButton = false;
selectedOpts.showCloseButton = false;
}
selectedOpts.padding = parseInt(selectedOpts.padding, 10);
selectedOpts.margin = parseInt(selectedOpts.margin, 10);
tmp.css('padding', (selectedOpts.padding + selectedOpts.margin));
$('.fancybox-inline-tmp').unbind('fancybox-cancel').bind('fancybox-change', function() {
$(this).replaceWith(content.children());
});
switch (type) {
case 'html' :
tmp.html( selectedOpts.content );
_process_inline();
break;
case 'inline' :
if ( $(obj).parent().is('#fancybox-content') === true) {
busy = false;
return;
}
$('<div class="fancybox-inline-tmp" />')
.hide()
.insertBefore( $(obj) )
.bind('fancybox-cleanup', function() {
$(this).replaceWith(content.children());
}).bind('fancybox-cancel', function() {
$(this).replaceWith(tmp.children());
});
$(obj).appendTo(tmp);
_process_inline();
break;
case 'image':
busy = false;
$.fancybox.showActivity();
imgPreloader = new Image();
imgPreloader.onerror = function() {
_error();
};
imgPreloader.onload = function() {
busy = true;
imgPreloader.onerror = imgPreloader.onload = null;
_process_image();
};
imgPreloader.src = href;
break;
case 'swf':
selectedOpts.scrolling = 'no';
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);
_process_inline();
break;
case 'ajax':
busy = false;
$.fancybox.showActivity();
selectedOpts.ajax.win = selectedOpts.ajax.success;
ajaxLoader = $.ajax($.extend({}, selectedOpts.ajax, {
url	: href,
data : selectedOpts.ajax.data || {},
error : function(XMLHttpRequest, textStatus, errorThrown) {
if ( XMLHttpRequest.status > 0 ) {
_error();
}
},
success : function(data, textStatus, XMLHttpRequest) {
var o = typeof XMLHttpRequest == 'object' ? XMLHttpRequest : ajaxLoader;
if (o.status == 200) {
if ( typeof selectedOpts.ajax.win == 'function' ) {
ret = selectedOpts.ajax.win(href, data, textStatus, XMLHttpRequest);
if (ret === false) {
loading.hide();
return;
} else if (typeof ret == 'string' || typeof ret == 'object') {
data = ret;
}
}
tmp.html( data );
_process_inline();
}
}
}));
break;
case 'iframe':
_show();
break;
}
},
_process_inline = function() {
var
w = selectedOpts.width,
h = selectedOpts.height;
if (w.toString().indexOf('%') > -1) {
w = parseInt( ($(window).width() - (selectedOpts.margin * 2)) * parseFloat(w) / 100, 10) + 'px';
} else {
w = w == 'auto' ? 'auto' : w + 'px';
}
if (h.toString().indexOf('%') > -1) {
h = parseInt( ($(window).height() - (selectedOpts.margin * 2)) * parseFloat(h) / 100, 10) + 'px';
} else {
h = h == 'auto' ? 'auto' : h + 'px';
}
tmp.wrapInner('<div style="width:' + w + ';height:' + h + ';overflow: ' + (selectedOpts.scrolling == 'auto' ? 'auto' : (selectedOpts.scrolling == 'yes' ? 'scroll' : 'hidden')) + ';position:relative;"></div>');
selectedOpts.width = tmp.width();
selectedOpts.height = tmp.height();
_show();
},
_process_image = function() {
selectedOpts.width = imgPreloader.width;
selectedOpts.height = imgPreloader.height;
$("<img />").attr({
'id' : 'fancybox-img',
'src' : imgPreloader.src,
'alt' : selectedOpts.title
}).appendTo( tmp );
_show();
},
_show = function() {
var pos, equal;
loading.hide();
if (wrap.is(":visible") && false === currentOpts.onCleanup(currentArray, currentIndex, currentOpts)) {
$.event.trigger('fancybox-cancel');
busy = false;
return;
}
busy = true;
$(content.add( overlay )).unbind();
$(window).unbind("resize.fb scroll.fb");
$(document).unbind('keydown.fb');
if (wrap.is(":visible") && currentOpts.titlePosition !== 'outside') {
wrap.css('height', wrap.height());
}
currentArray = selectedArray;
currentIndex = selectedIndex;
currentOpts = selectedOpts;
if (currentOpts.overlayShow) {
overlay.css({
'background-color' : currentOpts.overlayColor,
'opacity' : currentOpts.overlayOpacity,
'cursor' : currentOpts.hideOnOverlayClick ? 'pointer' : 'auto',
'height' : $(document).height()
});
if (!overlay.is(':visible')) {
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.show();
}
} else {
overlay.hide();
}
final_pos = _get_zoom_to();
_process_title();
if (wrap.is(":visible")) {
$( close.add( nav_left ).add( nav_right ) ).hide();
pos = wrap.position(),
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);
content.fadeTo(currentOpts.changeFade, 0.3, function() {
var finish_resizing = function() {
content.html( tmp.contents() ).fadeTo(currentOpts.changeFade, 1, _finish);
};
$.event.trigger('fancybox-change');
content
.empty()
.removeAttr('filter')
.css({
'border-width' : currentOpts.padding,
'width'	: final_pos.width - currentOpts.padding * 2,
'height' : selectedOpts.autoDimensions ? 'auto' : final_pos.height - titleHeight - currentOpts.padding * 2
});
if (equal) {
finish_resizing();
} else {
fx.prop = 0;
$(fx).animate({prop: 1}, {
duration : currentOpts.changeSpeed,
easing : currentOpts.easingChange,
step : _draw,
complete : finish_resizing
});
}
});
return;
}
wrap.removeAttr("style");
content.css('border-width', currentOpts.padding);
if (currentOpts.transitionIn == 'elastic') {
start_pos = _get_zoom_from();
content.html( tmp.contents() );
wrap.show();
if (currentOpts.opacity) {
final_pos.opacity = 0;
}
fx.prop = 0;
$(fx).animate({prop: 1}, {
duration : currentOpts.speedIn,
easing : currentOpts.easingIn,
step : _draw,
complete : _finish
});
return;
}
if (currentOpts.titlePosition == 'inside' && titleHeight > 0) {
title.show();
}
content
.css({
'width' : final_pos.width - currentOpts.padding * 2,
'height' : selectedOpts.autoDimensions ? 'auto' : final_pos.height - titleHeight - currentOpts.padding * 2
})
.html( tmp.contents() );
wrap
.css(final_pos)
.fadeIn( currentOpts.transitionIn == 'none' ? 0 : currentOpts.speedIn, _finish );
},
_format_title = function(title) {
if (title && title.length) {
if (currentOpts.titlePosition == 'float') {
return '<table id="fancybox-title-float-wrap" cellpadding="0" cellspacing="0"><tr><td id="fancybox-title-float-left"></td><td id="fancybox-title-float-main">' + title + '</td><td id="fancybox-title-float-right"></td></tr></table>';
}
return '<div id="fancybox-title-' + currentOpts.titlePosition + '">' + title + '</div>';
}
return false;
},
_process_title = function() {
titleStr = currentOpts.title || '';
titleHeight = 0;
title
.empty()
.removeAttr('style')
.removeClass();
if (currentOpts.titleShow === false) {
title.hide();
return;
}
titleStr = $.isFunction(currentOpts.titleFormat) ? currentOpts.titleFormat(titleStr, currentArray, currentIndex, currentOpts) : _format_title(titleStr);
if (!titleStr || titleStr === '') {
title.hide();
return;
}
title
.addClass('fancybox-title-' + currentOpts.titlePosition)
.html( titleStr )
.appendTo( 'body' )
.show();
switch (currentOpts.titlePosition) {
case 'inside':
title
.css({
'width' : final_pos.width - (currentOpts.padding * 2),
'marginLeft' : currentOpts.padding,
'marginRight' : currentOpts.padding
});
titleHeight = title.outerHeight(true);
title.appendTo( outer );
final_pos.height += titleHeight;
break;
case 'over':
title
.css({
'marginLeft' : currentOpts.padding,
'width'	: final_pos.width - (currentOpts.padding * 2),
'bottom' : currentOpts.padding
})
.appendTo( outer );
break;
case 'float':
title
.css('left', parseInt((title.width() - final_pos.width - 40)/ 2, 10) * -1)
.appendTo( wrap );
break;
default:
title
.css({
'width' : final_pos.width - (currentOpts.padding * 2),
'paddingLeft' : currentOpts.padding,
'paddingRight' : currentOpts.padding
})
.appendTo( wrap );
break;
}
title.hide();
},
_set_navigation = function() {
if (currentOpts.enableEscapeButton || currentOpts.enableKeyboardNav) {
$(document).bind('keydown.fb', function(e) {
if (e.keyCode == 27 && currentOpts.enableEscapeButton) {
e.preventDefault();
$.fancybox.close();
} else if ((e.keyCode == 37 || e.keyCode == 39) && currentOpts.enableKeyboardNav && e.target.tagName !== 'INPUT' && e.target.tagName !== 'TEXTAREA' && e.target.tagName !== 'SELECT') {
e.preventDefault();
$.fancybox[ e.keyCode == 37 ? 'prev' : 'next']();
}
});
}
if (!currentOpts.showNavArrows) {
nav_left.hide();
nav_right.hide();
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();
}
},
_finish = function () {
if (!$.support.opacity) {
content.get(0).style.removeAttribute('filter');
wrap.get(0).style.removeAttribute('filter');
}
if (selectedOpts.autoDimensions) {
content.css('height', 'auto');
}
wrap.css('height', 'auto');
if (titleStr && titleStr.length) {
title.show();
}
if (currentOpts.showCloseButton) {
close.show();
}
_set_navigation();
if (currentOpts.hideOnContentClick)	{
content.bind('click', $.fancybox.close);
}
if (currentOpts.hideOnOverlayClick)	{
overlay.bind('click', $.fancybox.close);
}
$(window).bind("resize.fb", $.fancybox.resize);
if (currentOpts.centerOnScroll) {
$(window).bind("scroll.fb", $.fancybox.center);
}
if (currentOpts.type == 'iframe') {
$('<iframe id="fancybox-frame" name="fancybox-frame' + new Date().getTime() + '" frameborder="0" hspace="0" ' + ($.browser.msie ? 'allowtransparency="true""' : '') + ' scrolling="' + selectedOpts.scrolling + '" src="' + currentOpts.href + '"></iframe>').appendTo(content);
}
wrap.show();
busy = false;
$.fancybox.center();
currentOpts.onComplete(currentArray, currentIndex, currentOpts);
_preload_images();
},
_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;
}
}
},
_draw = function(pos) {
var dim = {
width : parseInt(start_pos.width + (final_pos.width - start_pos.width) * pos, 10),
height : parseInt(start_pos.height + (final_pos.height - start_pos.height) * pos, 10),
top : parseInt(start_pos.top + (final_pos.top - start_pos.top) * pos, 10),
left : parseInt(start_pos.left + (final_pos.left - start_pos.left) * pos, 10)
};
if (typeof final_pos.opacity !== 'undefined') {
dim.opacity = pos < 0.5 ? 0.5 : pos;
}
wrap.css(dim);
content.css({
'width' : dim.width - currentOpts.padding * 2,
'height' : dim.height - (titleHeight * pos) - currentOpts.padding * 2
});
},
_get_viewport = function() {
return [
$(window).width() - (currentOpts.margin * 2),
$(window).height() - (currentOpts.margin * 2),
$(document).scrollLeft() + currentOpts.margin,
$(document).scrollTop() + currentOpts.margin
];
},
_get_zoom_to = function () {
var view = _get_viewport(),
to = {},
resize = currentOpts.autoScale,
double_padding = currentOpts.padding * 2,
ratio;
if (currentOpts.width.toString().indexOf('%') > -1) {
to.width = parseInt((view[0] * parseFloat(currentOpts.width)) / 100, 10);
} else {
to.width = currentOpts.width + double_padding;
}
if (currentOpts.height.toString().indexOf('%') > -1) {
to.height = parseInt((view[1] * parseFloat(currentOpts.height)) / 100, 10);
} else {
to.height = currentOpts.height + double_padding;
}
if (resize && (to.width > view[0] || to.height > view[1])) {
if (selectedOpts.type == 'image' || selectedOpts.type == 'swf') {
ratio = (currentOpts.width ) / (currentOpts.height );
if ((to.width ) > view[0]) {
to.width = view[0];
to.height = parseInt(((to.width - double_padding) / ratio) + double_padding, 10);
}
if ((to.height) > view[1]) {
to.height = view[1];
to.width = parseInt(((to.height - double_padding) * ratio) + double_padding, 10);
}
} else {
to.width = Math.min(to.width, view[0]);
to.height = Math.min(to.height, view[1]);
}
}
to.top = parseInt(Math.max(view[3] - 20, view[3] + ((view[1] - to.height - 40) * 0.5)), 10);
to.left = parseInt(Math.max(view[2] - 20, view[2] + ((view[0] - to.width - 40) * 0.5)), 10);
return to;
},
_get_obj_pos = function(obj) {
var pos = obj.offset();
pos.top += parseInt( obj.css('paddingTop'), 10 ) || 0;
pos.left += parseInt( obj.css('paddingLeft'), 10 ) || 0;
pos.top += parseInt( obj.css('border-top-width'), 10 ) || 0;
pos.left += parseInt( obj.css('border-left-width'), 10 ) || 0;
pos.width = obj.width();
pos.height = obj.height();
return pos;
},
_get_zoom_from = function() {
var orig = selectedOpts.orig ? $(selectedOpts.orig) : false,
from = {},
pos,
view;
if (orig && orig.length) {
pos = _get_obj_pos(orig);
from = {
width : pos.width + (currentOpts.padding * 2),
height : pos.height + (currentOpts.padding * 2),
top	: pos.top - currentOpts.padding - 20,
left : pos.left - currentOpts.padding - 20
};
} else {
view = _get_viewport();
from = {
width : currentOpts.padding * 2,
height : currentOpts.padding * 2,
top	: parseInt(view[3] + view[1] * 0.5, 10),
left : parseInt(view[2] + view[0] * 0.5, 10)
};
}
return from;
},
_animate_loading = function() {
if (!loading.is(':visible')){
clearInterval(loadingTimer);
return;
}
$('div', loading).css('top', (loadingFrame * -40) + 'px');
loadingFrame = (loadingFrame + 1) % 12;
};
/*
* Public methods
*/
$.fn.fancybox = function(options) {
if (!$(this).length) {
return this;
}
$(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 );
}
_start();
return;
});
return this;
};
$.fancybox = function(obj) {
var opts;
if (busy) {
return;
}
busy = true;
opts = typeof arguments[1] !== 'undefined' ? arguments[1] : {};
selectedArray = [];
selectedIndex = parseInt(opts.index, 10) || 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;
}
_start();
};
$.fancybox.showActivity = function() {
clearInterval(loadingTimer);
loading.show();
loadingTimer = setInterval(_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);
selectedArray = currentArray;
if (pos > -1 && pos < currentArray.length) {
selectedIndex = pos;
_start();
} else if (currentOpts.cyclic && currentArray.length > 1) {
selectedIndex = pos >= currentArray.length ? 0 : currentArray.length - 1;
_start();
}
return;
};
$.fancybox.cancel = function() {
if (busy) {
return;
}
busy = true;
$.event.trigger('fancybox-cancel');
_abort();
selectedOpts.onCancel(selectedArray, selectedIndex, selectedOpts);
busy = false;
};
// Note: within an iframe use - parent.$.fancybox.close();
$.fancybox.close = function() {
if (busy || wrap.is(':hidden')) {
return;
}
busy = true;
if (currentOpts && false === currentOpts.onCleanup(currentArray, currentIndex, currentOpts)) {
busy = false;
return;
}
_abort();
$(close.add( nav_left ).add( nav_right )).hide();
$(content.add( overlay )).unbind();
$(window).unbind("resize.fb scroll.fb");
$(document).unbind('keydown.fb');
content.find('iframe').attr('src', isIE6 && /^https/i.test(window.location.href || '') ? 'javascript:void(false)' : 'about:blank');
if (currentOpts.titlePosition !== 'inside') {
title.empty();
}
wrap.stop();
function _cleanup() {
overlay.fadeOut('fast');
title.empty().hide();
wrap.hide();
$.event.trigger('fancybox-cleanup');
content.empty();
currentOpts.onClosed(currentArray, currentIndex, currentOpts);
currentArray = selectedOpts	= [];
currentIndex = selectedIndex = 0;
currentOpts = selectedOpts	= {};
busy = false;
}
if (currentOpts.transitionOut == 'elastic') {
start_pos = _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;
}
title.empty().hide();
fx.prop = 1;
$(fx).animate({ prop: 0 }, {
duration : currentOpts.speedOut,
easing : currentOpts.easingOut,
step : _draw,
complete : _cleanup
});
} else {
wrap.fadeOut( currentOpts.transitionOut == 'none' ? 0 : currentOpts.speedOut, _cleanup);
}
};
$.fancybox.resize = function() {
if (overlay.is(':visible')) {
overlay.css('height', $(document).height());
}
$.fancybox.center(true);
};
$.fancybox.center = function() {
var view, align;
if (busy) {
return;
}
align = arguments[0] === true ? 1 : 0;
view = _get_viewport();
if (!align && (wrap.width() > view[0] || wrap.height() > view[1])) {
return;
}
wrap
.stop()
.animate({
'top' : parseInt(Math.max(view[3] - 20, view[3] + ((view[1] - content.height() - 40) * 0.5) - currentOpts.padding)),
'left' : parseInt(Math.max(view[2] - 20, view[2] + ((view[0] - content.width() - 40) * 0.5) - currentOpts.padding))
}, typeof arguments[0] == 'number' ? arguments[0] : 200);
};
$.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>')
);
outer = $('<div id="fancybox-outer"></div>')
.append('<div class="fancybox-bg" id="fancybox-bg-n"></div><div class="fancybox-bg" id="fancybox-bg-ne"></div><div class="fancybox-bg" id="fancybox-bg-e"></div><div class="fancybox-bg" id="fancybox-bg-se"></div><div class="fancybox-bg" id="fancybox-bg-s"></div><div class="fancybox-bg" id="fancybox-bg-sw"></div><div class="fancybox-bg" id="fancybox-bg-w"></div><div class="fancybox-bg" id="fancybox-bg-nw"></div>')
.appendTo( wrap );
outer.append(
content = $('<div id="fancybox-content"></div>'),
close = $('<a id="fancybox-close"></a>'),
title = $('<div id="fancybox-title"></div>'),
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 ($.fn.mousewheel) {
wrap.bind('mousewheel.fb', function(e, delta) {
if (busy) {
e.preventDefault();
} else if ($(e.target).get(0).clientHeight == 0 || $(e.target).get(0).scrollHeight === $(e.target).get(0).clientHeight) {
e.preventDefault();
$.fancybox[ delta > 0 ? 'prev' : 'next']();
}
});
}
if (!$.support.opacity) {
wrap.addClass('fancybox-ie');
}
if (isIE6) {
loading.addClass('fancybox-ie6');
wrap.addClass('fancybox-ie6');
$('<iframe id="fancybox-hide-sel-frame" src="' + (/^https/i.test(window.location.href || '') ? 'javascript:void(false)' : 'about:blank' ) + '" scrolling="no" border="0" frameborder="0" tabindex="-1"></iframe>').prependTo(outer);
}
};
$.fn.fancybox.defaults = {
padding : 10,
margin : 40,
opacity : false,
modal : false,
cyclic : false,
scrolling : 'auto',	// 'auto', 'yes' or 'no'
width : 560,
height : 340,
autoScale : true,
autoDimensions : true,
centerOnScroll : false,
ajax : {},
swf : { wmode: 'transparent' },
hideOnOverlayClick : true,
hideOnContentClick : false,
overlayShow : true,
overlayOpacity : 0.7,
overlayColor : '#777',
titleShow : true,
titlePosition : 'float', // 'float', 'outside', 'inside' or 'over'
titleFormat : null,
titleFromAlt : false,
transitionIn : 'fade', // 'elastic', 'fade' or 'none'
transitionOut : 'fade', // 'elastic', 'fade' or 'none'
speedIn : 300,
speedOut : 300,
changeSpeed : 300,
changeFade : 'fast',
easingIn : 'swing',
easingOut : 'swing',
showCloseButton	 : true,
showNavArrows : true,
enableEscapeButton : true,
enableKeyboardNav : true,
onStart : function(){},
onCancel : function(){},
onComplete : function(){},
onCleanup : function(){},
onClosed : function(){},
onError : function(){}
};
$(document).ready(function() {
$.fancybox.init();
});
})(jQuery);
/*
* jQuery doTimeout: Like setTimeout, but better! - v1.0 - 3/3/2010
* http://benalman.com/projects/jquery-dotimeout-plugin/
*
* Copyright (c) 2010 "Cowboy" Ben Alman
* Dual licensed under the MIT and GPL licenses.
* http://benalman.com/about/license/
*/
(function($){var a={},c="doTimeout",d=Array.prototype.slice;$[c]=function(){return b.apply(window,[0].concat(d.call(arguments)))};$.fn[c]=function(){var f=d.call(arguments),e=b.apply(this,[c+f[0]].concat(f));return typeof f[0]==="number"||typeof f[1]==="number"?this:e};function b(l){var m=this,h,k={},g=l?$.fn:$,n=arguments,i=4,f=n[1],j=n[2],p=n[3];if(typeof f!=="string"){i--;f=l=0;j=n[1];p=n[2]}if(l){h=m.eq(0);h.data(l,k=h.data(l)||{})}else{if(f){k=a[f]||(a[f]={})}}k.id&&clearTimeout(k.id);delete k.id;function e(){if(l){h.removeData(l)}else{if(f){delete a[f]}}}function o(){k.id=setTimeout(function(){k.fn()},j)}if(p){k.fn=function(q){if(typeof p==="string"){p=g[p]}p.apply(m,d.call(n,i))===true&&!q?o():e()};o()}else{if(k.fn){j===undefined?e():k.fn(j===false);return true}else{e()}}}})(jQuery);
﻿jQuery.fn.showLoading=function(options){var indicatorID;var settings={'addClass':'','beforeShow':'','afterShow':'','hPos':'center','vPos':'center','indicatorZIndex':5001,'overlayZIndex':5000,'parent':'','marginTop':0,'marginLeft':0,'overlayWidth':null,'overlayHeight':null};jQuery.extend(settings,options);var loadingDiv=jQuery('<div></div>');var overlayDiv=jQuery('<div></div>');if(settings.indicatorID){indicatorID=settings.indicatorID;}
else{indicatorID=jQuery(this).attr('id');}
jQuery(loadingDiv).attr('id','loading-indicator-'+indicatorID);jQuery(loadingDiv).addClass('loading-indicator');if(settings.addClass){jQuery(loadingDiv).addClass(settings.addClass);}
jQuery(overlayDiv).css('display','none');jQuery(document.body).append(overlayDiv);jQuery(overlayDiv).attr('id','loading-indicator-'+indicatorID+'-overlay');jQuery(overlayDiv).addClass('loading-indicator-overlay');if(settings.addClass){jQuery(overlayDiv).addClass(settings.addClass+'-overlay');}
var overlay_width;var overlay_height;var border_top_width=jQuery(this).css('border-top-width');var border_left_width=jQuery(this).css('border-left-width');border_top_width=isNaN(parseInt(border_top_width))?0:border_top_width;border_left_width=isNaN(parseInt(border_left_width))?0:border_left_width;var overlay_left_pos=jQuery(this).offset().left+parseInt(border_left_width);var overlay_top_pos=jQuery(this).offset().top+parseInt(border_top_width);if(settings.overlayWidth!==null){overlay_width=settings.overlayWidth;}
else{overlay_width=parseInt(jQuery(this).width())+parseInt(jQuery(this).css('padding-right'))+parseInt(jQuery(this).css('padding-left'));}
if(settings.overlayHeight!==null){overlay_height=settings.overlayWidth;}
else{overlay_height=parseInt(jQuery(this).height())+parseInt(jQuery(this).css('padding-top'))+parseInt(jQuery(this).css('padding-bottom'));}
jQuery(overlayDiv).css('width',overlay_width.toString()+'px');jQuery(overlayDiv).css('height',overlay_height.toString()+'px');jQuery(overlayDiv).css('left',overlay_left_pos.toString()+'px');jQuery(overlayDiv).css('position','absolute');jQuery(overlayDiv).css('top',overlay_top_pos.toString()+'px');jQuery(overlayDiv).css('z-index',settings.overlayZIndex);if(settings.overlayCSS){jQuery(overlayDiv).css(settings.overlayCSS);}
jQuery(loadingDiv).css('display','none');jQuery(document.body).append(loadingDiv);jQuery(loadingDiv).css('position','absolute');jQuery(loadingDiv).css('z-index',settings.indicatorZIndex);var indicatorTop=overlay_top_pos;if(settings.marginTop){indicatorTop+=parseInt(settings.marginTop);}
var indicatorLeft=overlay_left_pos;if(settings.marginLeft){indicatorLeft+=parseInt(settings.marginTop);}
if(settings.hPos.toString().toLowerCase()=='center'){jQuery(loadingDiv).css('left',(indicatorLeft+((jQuery(overlayDiv).width()-parseInt(jQuery(loadingDiv).width()))/2)).toString()+'px');}
else if(settings.hPos.toString().toLowerCase()=='left'){jQuery(loadingDiv).css('left',(indicatorLeft+parseInt(jQuery(overlayDiv).css('margin-left'))).toString()+'px');}
else if(settings.hPos.toString().toLowerCase()=='right'){jQuery(loadingDiv).css('left',(indicatorLeft+(jQuery(overlayDiv).width()-parseInt(jQuery(loadingDiv).width()))).toString()+'px');}
else{jQuery(loadingDiv).css('left',(indicatorLeft+parseInt(settings.hPos)).toString()+'px');}
if(settings.vPos.toString().toLowerCase()=='center'){jQuery(loadingDiv).css('top',(indicatorTop+((jQuery(overlayDiv).height()-parseInt(jQuery(loadingDiv).height()))/2)).toString()+'px');}
else if(settings.vPos.toString().toLowerCase()=='top'){jQuery(loadingDiv).css('top',indicatorTop.toString()+'px');}
else if(settings.vPos.toString().toLowerCase()=='bottom'){jQuery(loadingDiv).css('top',(indicatorTop+(jQuery(overlayDiv).height()-parseInt(jQuery(loadingDiv).height()))).toString()+'px');}
else{jQuery(loadingDiv).css('top',(indicatorTop+parseInt(settings.vPos)).toString()+'px');}
if(settings.css){jQuery(loadingDiv).css(settings.css);}
var callback_options={'overlay':overlayDiv,'indicator':loadingDiv,'element':this};if(typeof(settings.beforeShow)=='function'){settings.beforeShow(callback_options);}
jQuery(overlayDiv).show();jQuery(loadingDiv).show();if(typeof(settings.afterShow)=='function'){settings.afterShow(callback_options);}
return this;};jQuery.fn.hideLoading=function(options){var settings={};jQuery.extend(settings,options);if(settings.indicatorID){indicatorID=settings.indicatorID;}
else{indicatorID=jQuery(this).attr('id');}
jQuery(document.body).find('#loading-indicator-'+indicatorID).remove();jQuery(document.body).find('#loading-indicator-'+indicatorID+'-overlay').remove();return this;};
/**
* CMS Animation module
*
*
*/
var	NOT_ANIMATED		= 1,
FADE				= 2,
SLIDE_TOP			= 3,
SLIDE_BOTTOM		= 4,
SLIDE_LEFT			= 5,
SLIDE_RIGHT			= 6,
SCROLL_LEFT			= 7,
SCROLL_RIGHT		= 8,
BLOCKS_SLIDE_TOP	= 9,
BLOCKS_SLIDE_BOTTOM	= 10,
BLOCKS_SLIDE_LEFT	= 11,
BLOCKS_SLIDE_RIGHT	= 12,
BLOCKS_SWIRL		= 13,
BLOCKS_RANDOM		= 14,
SCROLL_UP			= 15,
SCROLL_DOWN			= 16;
// jQuery plugin
(function($) {
$.fn.extend({
// anim object
anim: function( options, arg1, arg2 ) {
// members
var	$this	= $(this),
data	= $this.data('anim'),
types	= [
{},
{transition:'notAnimated',			opposite:'notAnimated'},
{transition:'fade',					opposite:'fade'},
{transition:'slideTop',				opposite:'slideBottom'},
{transition:'slideBottom',			opposite:'slideTop'},
{transition:'slideLeft',			opposite:'slideRight'},
{transition:'slideRight',			opposite:'slideLeft'},
{transition:'scrollLeft',			opposite:'scrollRight'},
{transition:'scrollRight',			opposite:'scrollLeft'},
{transition:'blocksSlideTop',		opposite:'blocksSlideTop'},
{transition:'blocksSlideBottom',	opposite:'blocksSlideBottom'},
{transition:'blocksSlideLeft',		opposite:'blocksSlideLeft'},
{transition:'blocksSlideRight',		opposite:'blocksSlideRight'},
{transition:'blocksSwirl',			opposite:'blocksSwirl'},
{transition:'blocksRandom',			opposite:'blocksRandom'},
{transition:'scrollUp',				opposite:'scrollDown'},
{transition:'scrollDown',			opposite:'scrollUp'},
],
func	= {
/**
* Initialisation
*
*/
init: function() {
var	content = '';
data.locked = false;
clearTimeout( data.timer );
$this.unbind('refresh').bind('refresh', func['init']);
// make sure the containing div is position relative
$this.css({
position:	'relative',
left:		0,
top:		0
});
if ( data.data ) {
$.each(data.data, function(i, o) {
content += o;
});
$this.html(content);
}
if ( ! data.source )
data.source = $('div[adtype]', $this);
if ( ! data.source.length )
return;
// set up CSS for advert divs
$.each( data.source, function(i) {
if ( data.resize ) {
if ( $this.width() <= $(this).width() )
$this.css({width:$(this).width()});
if ( $this.height() <= $(this).height() )
$this.css({height:$(this).height()});
}
$(this).css({
display:	'none',
position:	'absolute',
'z-index':	100 + i,
left:		0,
top:		0
});
// if the ad links to somewhere then add in the html for it
if ( $(this).attr('link') == 'Yes' )
$(this).bind('click', function() {
if ( typeof _gaq !== 'undefined' )
_gaq.push(['trackEvent','Adverts','Click',$(this).attr('name')]);
url = data.adclick + '/id/' + data.current.adid + '/frame/' + $(this).attr(data.frameid);
if ( $(this).attr('new') == '1' ) {
window.open( url, '_blank' );
window.focus();
}
else
location.href = url;
return false;
}).css({cursor:'pointer'});
// add the ad to the internal list
$this.anim('add', $(this));
});
data.maxzindex = data.source.length + 200;
// add mouseover & mouseout events to all frames
data.source.unbind('mouseover mouseout')
.bind('mouseover',	func['over'])
.bind('mouseout',	func['out']);
// set up triggers so that the user can add their own events when the trigger is fired
$this.unbind('notAnimated fade slideLeft slideRight slideTop slideBottom blocksSlideTop blocksSlideBottom blocksSlideLeft blocksSlideRight blocksSwirl blocksRandom scrollUp scrollDown')
.bind('notAnimated',		func['notAnimated'])
.bind('fade',				func['fade'])
.bind('slideLeft',			func['slideLeft'])
.bind('slideRight',			func['slideRight'])
.bind('slideTop',			func['slideTop'])
.bind('slideBottom',		func['slideBottom'])
.bind('scrollLeft',			func['scrollLeft'])
.bind('scrollRight',		func['scrollRight'])
.bind('blocksSlideTop',		func['blocksSlideTop'])
.bind('blocksSlideBottom',	func['blocksSlideBottom'])
.bind('blocksSlideLeft',	func['blocksSlideLeft'])
.bind('blocksSlideRight',	func['blocksSlideRight'])
.bind('blocksSwirl',		func['blocksSwirl'])
.bind('blocksRandom',		func['blocksRandom'])
.bind('scrollUp',			func['scrollUp'])
.bind('scrollDown',			func['scrollDown'])
// start the animation
$this.anim('start');
return $this;
},
/**
* Creates blocks for a blocks animation
*
* @param object obj
*/
createBlocks: function( obj ) {
// create the blocks
for( var y = 0; y < data.ytiles + 1; y++ )
for( var x = 0; x < data.xtiles + 1; x++ )
$this.append( '<div x="'+x+'" y="'+y+'" '+data.frameid+'="'+obj.frameid+'" tile="yes" style="left:' + (x*obj.blockwidth) + ';top:' + (y*obj.blockheight) + ';"></div>' );
// assign CSS to newly created blocks
$('div['+data.frameid+'="'+obj.frameid+'"][tile]', $this).css({
margin:		0,
padding:	0,
width:		obj.blockwidth,
height:		obj.blockheight,
position:	'absolute'
});
},
/**
* Sets up a block
*
* @param integer id
* @param object options
*/
setBlock: function( options ) {
$('['+data.frameid+'="'+data.current.frameid+'"][tile][x="'+options.x+'"][y="'+options.y+'"]', $this).css({
top:					parseInt(options.y * data.current.blockheight),
left:					parseInt(options.x * data.current.blockwidth),
'background-image':		'url('+options.url+')',
'background-position':	-(options.x * data.current.blockwidth) + 'px ' + (-(options.y * data.current.blockheight) + 'px'),
'background-repeat':	'no-repeat',
'z-index':				data.maxzindex
});
},
/**
* Returns the frame number of the current frame
*
* @return integer
*/
getCurrentFrame: function() {
return data.index;
},
/**
* Returns the current frame object
*
* @return object
*/
getCurrentObject: function() {
return data.current.object;
},
/**
* Returns the number of frames within the animation
*
* @return integer
*/
getNumberOfFrames: function() {
return data.list.length;
},
/**
* Jumps to the frame number of the animation
*
* @param integer n
*/
setFrame: function( n, jump ) {
clearTimeout( data.timer );
if ( ! jump ) {
data.index = n;
$this.anim('next');
return $this;
}
data.gotoindex = parseInt(n % data.list.length) + 1;
if ( data.index > data.gotoindex - 1 )
$this.anim('previous');
else if ( data.index < data.gotoindex - 1 )
$this.anim('next');
return $this;
},
/**
* Records an impression against a advert frame
*
*/
record: function() {
if ( data.current.type != SCROLL_LEFT && data.current.type != SCROLL_RIGHT && data.current.type != SCROLL_UP && data.current.type != SCROLL_DOWN ) {
$.post(
data.adimpres + '/id/' + data.current.adid + '/frame/' + data.current.frameid
);
}
},
/**
* Adds a frame to the advert
*
* @param object obj
*/
add: function( obj ) {
// add the object to the list of advert frames
data.list.push({
adid:			$this.attr(data.id),
frameid:		obj.attr(data.frameid),
type:			parseInt(obj.attr('adtype')),
duration:		parseInt(obj.attr('duration')),
delay:			parseInt(obj.attr('delay')),
transition:		types[obj.attr('adtype')].transition,
opposite:		types[obj.attr('adtype')].opposite,
object:			obj,
zindex:			obj.css('z-index'),
width:			obj.width(),
height:			obj.height(),
blockwidth:		parseInt( obj.width() / data.xtiles ),
blockheight:	parseInt( obj.height() / data.ytiles ),
link:			obj.attr('link') == 'Yes' ? true : false,
impression:		obj.attr('impression') == 'Yes' ? true : false,
click:			obj.attr('click') == 'Yes' ? true : false,
preloaded:		false,
loading:		false
});
obj = data.list[ data.list.length - 1 ];
// if it is a block animation then set up the blocks
if ( obj.type == BLOCKS_SLIDE_TOP
|| obj.type == BLOCKS_SLIDE_BOTTOM
|| obj.type == BLOCKS_SLIDE_LEFT
|| obj.type == BLOCKS_SLIDE_RIGHT
|| obj.type == BLOCKS_SWIRL
|| obj.type == BLOCKS_RANDOM ) {
$this.anim('createBlocks', obj);
}
return $this;
},
/**
* Starts execution of the advert
*
*/
start: function() {
clearTimeout( data.timer );
if ( ! data.current ) {
data.start				= true;
data.initialise			= true;
data.current			= data.list[0];
data.originaldelay		= data.current.delay;
data.originalduration	= data.current.duration;
data.originaltransition	= data.current.transition;
data.current.duration	= 1000;
data.current.transition	= types[FADE].transition;
}
if ( data.current.type == SCROLL_LEFT || data.current.type == SCROLL_RIGHT || data.current.type == SCROLL_UP || data.current.type == SCROLL_DOWN ) {
if ( data.current.type == SCROLL_UP || data.current.type == SCROLL_DOWN ) {
var html = data.current.object.html();
do {
data.current.object.html(data.current.object.html()+html);
}
while( data.current.object.height() < data.height * 2 );
}
else if ( data.current.type == SCROLL_LEFT || data.current.type == SCROLL_RIGHT ) {
var html = data.current.object.html();
do {
data.current.object.html(data.current.object.html()+html);
}
while( data.current.object.width() < data.width * 2 );
}
data.current.delay = 1100;
if ( data.current.impression )
$this.anim('record');
}
data.index = -1;
$this.trigger('start');
$this.anim('doNext');
return $this;
},
/**
* Mouseover handler
*
*/
over: function( e ) {
if ( data.mousepause )
$this.anim('pause');
},
/**
* Mouseout handler
*
*/
out: function( e ) {
if ( data.mousepause )
$this.anim('resume');
},
/**
* Pauses the animation
*
*/
pause: function() {
if ( ! data.gotoindex ) {
data.locked = true;
$this.trigger('pause');
clearTimeout( data.timer );
}
return $this;
},
/**
* Resumes the admination
*
*/
resume: function() {
if ( ! data.gotoindex ) {
clearTimeout( data.timer );
$this.trigger('resume');
data.locked = false;
if ( data.current.type != SCROLL_LEFT && data.current.type != SCROLL_RIGHT && data.current.type != SCROLL_UP && data.current.type != SCROLL_DOWN && data.current.delay == 0 )
return $this;
data.timer = setTimeout( function() {$this.anim('next');}, (data.current.type == SCROLL_LEFT || data.current.type == SCROLL_RIGHT || data.current.type == SCROLL_UP || data.current.type == SCROLL_DOWN ? 0 : data.current.delay) );
}
return $this;
},
animate: function( type ) {
if ( data.current )
data.current.transition = types[type].transition;
else
data.list[0].transition = types[type].transition;
},
/**
* Displays a preload layer if any images have not downloaded
*
*/
preload: function() {
var	loaded = true;
$('img', data.current.object).each(function() {
if ( ! this.complete ) {
loaded = false;
return;
}
});
if ( ! loaded ) {
if ( ! data.current.loading ) {
data.current.loading = true;
$this.showLoading();
}
data.timer = setTimeout( function() {$this.anim('next');}, 250 );
return false;
}
else {
data.current.loading = false;
data.current.preloaded = true;
$this.hideLoading();
return true;
}
},
/**
* Display the next frame
*
*/
next: function() {
if ( ! data.locked ) {
clearTimeout( data.timer );
if ( data.preload && ! data.current.preloaded )
if ( ! $this.anim('preload') )
return $this;
if ( data.index++ >= data.list.length - 1 )
data.index = 0;
data.next = data.list[ data.index ];
if ( data.current.type != SCROLL_LEFT && data.current.type != SCROLL_RIGHT && data.current.type != SCROLL_UP && data.current.type != SCROLL_DOWN ) {
if ( data.current && data.list.length > 1 && data.current.opposite )
{
data.start = false;
$this.anim( data.next.transition );
}
else {
$this.anim( data.next.transition );
return $this;
}
}
data.start = true;
data.current = data.list[ data.index ];
$this.trigger( data.current.transition );
$this.trigger('next');
if ( data.initialise ) {
data.list[0].delay		= data.originaldelay;
data.list[0].duration	= data.originalduration;
data.list[0].transition	= data.originaltransition;
}
data.timer = setTimeout( function() {$this.anim('doNext');}, (data.gotoindex ? data.current.duration : (data.initialise && (data.current.type == SCROLL_LEFT || data.current.type == SCROLL_RIGHT || data.current.type == SCROLL_UP || data.current.type == SCROLL_DOWN) ? 1100 : data.current.delay)) );
data.initialise = false;
}
return $this;
},
doNext: function() {
if ( data.gotoindex ) {
data.locked = false;
if ( data.index == data.gotoindex - 1 ) {
data.gotoindex = null;
clearTimeout( data.timer );
data.timer = setTimeout( function() {$this.anim('next');}, data.current.delay );
return;
}
}
else if ( data.current.impression && data.current.type != SCROLL_LEFT && data.current.type != SCROLL_RIGHT && data.current.type != SCROLL_UP && data.current.type != SCROLL_DOWN )
$this.anim('record');
$this.anim('next');
},
/**
* Display the previous frame
*
*/
previous: function() {
if ( ! data.locked ) {
clearTimeout( data.timer );
if ( data.preload && ! data.current.preloaded )
if ( ! $this.anim('preload') )
return $this;
if ( --data.index < 0 )
data.index = data.list.length - 1;
data.next = data.list[ data.index ];
if ( data.current.type != SCROLL_LEFT && data.current.type != SCROLL_RIGHT && data.current.type != SCROLL_UP && data.current.type != SCROLL_DOWN ) {
if ( data.current && data.list.length > 1 && data.current.opposite )
{
data.start = false;
$this.anim( data.next.opposite );
}
else
return $this;
}
data.start = true;
data.current = data.list[ data.index ];
$this.trigger( data.current.opposite );
$this.trigger('previous');
data.timer = setTimeout( function() {$this.anim('doPrev');}, (data.gotoindex ? data.current.duration : data.current.delay) );
}
return $this;
},
doPrev: function() {
if ( data.gotoindex ) {
data.locked = false;
if ( data.index == data.gotoindex - 1 ) {
clearTimeout( data.timer );
data.gotoindex = null;
data.timer = setTimeout( function() {$this.anim('next');}, data.current.delay );
return;
}
$this.anim('previous');
return;
}
else if ( data.current.impression && data.current.type != SCROLL_LEFT && data.current.type != SCROLL_RIGHT && data.current.type != SCROLL_UP && data.current.type != SCROLL_DOWN )
$this.anim('record');
$this.anim('next');
},
/**
* Not animated
*
*/
notAnimated: function() {
data.current.object.css({
left:	0,
top:	0
});
// forward & reverse
if ( data.start )
data.current.object.show();
else
data.current.object.hide();
},
/**
* Fade animation
*
*/
fade: function() {
data.locked = true;
data.current.object.css({
left:	0,
top:	0
});
// forward & reverse
if ( data.start )
data.current.object.fadeIn( data.current.duration, function() { data.locked = false; } );
else
data.current.object.fadeOut( data.current.duration, function() { data.locked = false; } );
},
/**
* Scroll left animation
*
*/
scrollLeft: function() {
data.current.object.css({left:'-=1'});
if ( parseInt(data.current.object.css('left')) <= -data.current.width )
data.current.object.css({left:0});
},
/**
* Scroll right animation
*
*/
scrollRight: function() {
data.current.object.css({left:'+=1'});
if ( parseInt(data.current.object.css('left')) >= 0 )
data.current.object.css({left:-data.current.width});
},
/**
* Scroll up
*
*/
scrollUp: function() {
data.current.object.css({top:'-=1'});
if ( parseInt(data.current.object.css('top')) <= -data.current.height )
data.current.object.css({top:0});
},
/**
* Scroll down
*
*/
scrollDown: function() {
data.current.object.css({top:'+=1'});
if ( parseInt(data.current.object.css('top')) >= 0 )
data.current.object.css({top:-data.current.height});
},
/**
* Slide left animation
*
*/
slideLeft: function() {
data.locked = true;
// forward
if ( data.start )
data.current.object.css({
top:	0,
left:	data.width
})
.stop()
.show()
.animate(
{left:	'-=' + data.width},
data.current.duration,
(data.gotoindex ? 'linear' : 'swing'),
function() {
data.locked = false;
}
)
// reverse
else
data.current.object.css({
top:	0,
left:	0
})
.stop()
.animate(
{left:	'-=' + data.width},
data.next.duration,
(data.gotoindex ? 'linear' : 'swing'),
function() {
data.locked = false;
$(this).hide();
}
)
},
/**
* Slide right animation
*
*/
slideRight: function() {
data.locked = true;
// forward
if ( data.start )
data.current.object.css({
top:	0,
left:	-data.width
})
.stop()
.show()
.animate(
{left:	'+='+data.width},
data.current.duration,
(data.gotoindex ? 'linear' : 'swing'),
function() {
data.locked = false;
}
);
// reverse
else
data.current.object.css({
top:	0,
left:	0
})
.stop()
.animate(
{left:	'+='+data.width},
data.next.duration,
(data.gotoindex ? 'linear' : 'swing'),
function() {
data.locked = false;
$(this).hide();
}
);
},
/**
* Slide to the top animation
*
*/
slideTop: function() {
data.locked = true;
// forward
if ( data.start )
data.current.object.css({
left:	0,
top:	data.height
})
.stop()
.show()
.animate(
{top:	'-='+data.height},
data.current.duration,
(data.gotoindex ? 'linear' : 'swing'),
function() {
data.locked = false;
}
);
// reverse
else
data.current.object.css({
left:	0,
top:	0
})
.stop()
.animate(
{top:	'-='+data.height},
data.next.duration,
(data.gotoindex ? 'linear' : 'swing'),
function() {
data.locked = false;
$(this).hide();
}
);
},
/**
* Slide to the bottom animation
*
*/
slideBottom: function() {
data.locked = true;
// forward
if ( data.start )
data.current.object.css({
left:	0,
top:	-data.height
})
.stop()
.show()
.animate(
{top:	'+='+data.height},
data.current.duration,
(data.gotoindex ? 'linear' : 'swing'),
function() {
data.locked = false;
}
);
// reverse
else
data.current.object.css({
left:	0,
top:	0
})
.stop()
.animate(
{top:	'+='+data.height},
data.next.duration,
(data.gotoindex ? 'linear' : 'swing'),
function() {
data.locked = false;
$(this).hide();
}
);
},
/**
* Blocks sliding to the top animation
*
*/
blocksSlideTop: function() {
var	img = data.current.object.find('img');
data.locked = true;
data.current.object.css({
top:	0,
left:	0
});
if ( data.start ) {
for( var y = data.ytiles, n = 1; y >= 0; y--, n++ )
for( var x = 0; x <= data.xtiles; x++ ) {
$this.anim('setBlock', {x:x, y:y, url:img.attr('src')});
$('['+data.frameid+'="'+data.current.frameid+'"][tile][x="'+x+'"][y="'+y+'"]', $this)
.hide()
.delay( parseInt(data.current.duration / data.ytiles) )
.fadeIn( parseInt(data.current.duration / data.ytiles) * n );
}
$.doTimeout('show', data.current.duration, function() {
data.current.object.show();
$('['+data.frameid+'="'+data.current.frameid+'"][tile]', $this).hide();
data.locked = false;
data.previous.hide();
});
}
else
data.previous = data.current.object;
},
/**
* Blocks sliding to the bottom animation
*
*/
blocksSlideBottom: function() {
var	img = data.current.object.find('img');
data.locked = true;
data.current.object.css({
top:	0,
left:	0
});
if ( data.start ) {
for( var y = 0; y <= data.ytiles; y++ )
for( var x = 0; x <= data.xtiles; x++ ) {
$this.anim('setBlock', {x:x, y:y, url:img.attr('src')});
$('['+data.frameid+'="'+data.current.frameid+'"][tile][x="'+x+'"][y="'+y+'"]', $this)
.hide()
.delay( parseInt(data.current.duration / data.ytiles) )
.fadeIn( parseInt(data.current.duration / data.ytiles) * (y+1) );
}
$.doTimeout('show', data.current.duration, function() {
data.current.object.show();
$('['+data.frameid+'="'+data.current.frameid+'"][tile]', $this).hide();
data.locked = false;
data.previous.hide();
});
}
else
data.previous = data.current.object;
},
/**
* Blocks sliding to the left animation
*
*/
blocksSlideLeft: function() {
var	img = data.current.object.find('img');
data.locked = true;
data.current.object.css({
top:	0,
left:	0
});
if ( data.start ) {
for( var y = 0; y <= data.ytiles; y++ )
for( var x = data.xtiles, n = 1; x >= 0; x--, n++ ) {
$this.anim('setBlock', {x:x, y:y, url:img.attr('src')});
$('['+data.frameid+'="'+data.current.frameid+'"][tile][x="'+x+'"][y="'+y+'"]', $this)
.hide()
.delay( parseInt(data.current.duration / data.xtiles) )
.fadeIn( parseInt(data.current.duration / data.xtiles) * n );
}
$.doTimeout('show', data.current.duration, function() {
data.current.object.show();
$('['+data.frameid+'="'+data.current.frameid+'"][tile]', $this).hide();
data.locked = false;
data.previous.hide();
data.previous.css({'z-index':'+=1'});
});
}
else {
data.previous = data.current.object;
data.previous.css({'z-index':'-=1'});
}
},
/**
* Blocks sliding to the right animation
*
*/
blocksSlideRight: function() {
var	img = data.current.object.find('img');
data.locked = true;
data.current.object.css({
top:	0,
left:	0
});
if ( data.start ) {
for( var y = 0; y <= data.ytiles; y++ )
for( var x = 0; x <= data.xtiles; x++ ) {
$this.anim('setBlock', {x:x, y:y, url:img.attr('src')});
$('['+data.frameid+'="'+data.current.frameid+'"][tile][x="'+x+'"][y="'+y+'"]', $this)
.hide()
.delay( parseInt(data.current.duration / data.xtiles) )
.fadeIn( parseInt(data.current.duration / data.xtiles) * (x+1) );
}
$.doTimeout('show', data.current.duration, function() {
data.current.object.show();
$('['+data.frameid+'="'+data.current.frameid+'"][tile]', $this).hide();
data.locked = false;
data.previous.hide();
data.previous.css({'z-index':'+=1'});
});
}
else {
data.previous = data.current.object;
data.previous.css({'z-index':'-=1'});
}
},
/**
* Swirling blocks animation
*
*/
blocksSwirl: function() {
},
/**
* Random blocks animation
*
*/
blocksRandom: function() {
var	img = data.current.object.find('img');
data.locked = true;
data.current.object.css({
top:	0,
left:	0
});
if ( data.start ) {
for( var x = 0; x <= data.xtiles; x++ )
for( var y = 0; y <= data.ytiles; y++ ) {
$this.anim('setBlock', {x:x, y:y, url:img.attr('src')});
$('['+data.frameid+'="'+data.current.frameid+'"][tile][x="'+x+'"][y="'+y+'"]', $this)
.hide()
.fadeIn( Math.floor(Math.random() * data.current.duration), 'linear' );
}
$.doTimeout('show', data.current.duration, function() {
data.current.object.show();
$('['+data.frameid+'="'+data.current.frameid+'"][tile]', $this).hide();
data.locked = false;
data.previous.hide();
data.previous.css({'z-index':'+=1'});
});
}
else {
data.previous = data.current.object;
data.previous.css({'z-index':'-=1'});
}
}
};
// if calling a method
if ( typeof options == 'string' )
return func[options](arg1, arg2);
// otherwise initialising the object
else {
options				= options				|| {};
options.id		 	= options.id			|| 'adid';
options.frameid		= options.frameid		|| 'frameid';
options.name		= options.name			|| 'unnamed';
options.list		= options.list			|| [];
options.zindex		= options.zindex		|| 1000;
options.xtiles		= options.xtiles		|| 12;
options.ytiles		= options.ytiles		|| 10;
options.source		= options.source		|| null;
options.data		= options.data			|| null;
options.preload		= options.preload		|| false;
options.mousepause	= options.mousepause	|| false;
options.resize		= options.resize === false ? false : true;
options.current		= null;
options.next		= null;
options.prev		= null;
options.tiles		= null;
options.timer		= null;
options.index		= 0;
options.width		= parseInt( $this.width() );
options.height		= parseInt( $this.height() );
options.locked		= false;
options.adimpres	= '/object/NewAdvert/get/record';
options.adclick		= '/object/NewAdvert/get/redirect';
// store the prefs for this object
$this.data('anim', options);
// being initialisation
return $this.anim('init');
}
}
});
})(jQuery);