/*
 * jQuery clueTip plugin
 * Version 0.9.8  (05/22/2008)
 * @requires jQuery v1.1.4+
 * @requires Dimensions plugin (for jQuery versions < 1.2.5)
 *
 * 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 $cluetip,$cluetipInner,$cluetipOuter,$cluetipTitle,$cluetipArrows,$dropShadow,imgCount;$.fn.cluetip=function(js,options){if(typeof js=='object'){options=js;js=null;}
return this.each(function(index){var $this=$(this);var opts=$.extend(false,{},$.fn.cluetip.defaults,options||{},$.metadata?$this.metadata():$.meta?$this.data():{});var cluetipContents=false;var cluezIndex=parseInt(opts.cluezIndex,10)-1;var isActive=false,closeOnDelay=0;if(!$('#cluetip').length){$cluetipInner=$('<div id="cluetip-inner"></div>');$cluetipTitle=$('<h3 id="cluetip-title"></h3>');$cluetipOuter=$('<div id="cluetip-outer"></div>').append($cluetipInner).prepend($cluetipTitle);$cluetip=$('<div id="cluetip"></div>').css({zIndex:opts.cluezIndex}).append($cluetipOuter).append('<div id="cluetip-extra"></div>')[insertionType](insertionElement).hide();$('<div id="cluetip-waitimage"></div>').css({position:'absolute',zIndex:cluezIndex-1}).insertBefore('#cluetip').hide();$cluetip.css({position:'absolute',zIndex:cluezIndex});$cluetipOuter.css({position:'relative',zIndex:cluezIndex+1});$cluetipArrows=$('<div id="cluetip-arrows" class="cluetip-arrows"></div>').css({zIndex:cluezIndex+1}).appendTo('#cluetip');}
var dropShadowSteps=(opts.dropShadow)?+opts.dropShadowSteps:0;if(!$dropShadow){$dropShadow=$([]);for(var i=0;i<dropShadowSteps;i++){$dropShadow=$dropShadow.add($('<div></div>').css({zIndex:cluezIndex-i-1,opacity:.1,top:1+i,left:1+i}));};$dropShadow.css({position:'absolute',backgroundColor:'#000'}).prependTo($cluetip);}
var tipAttribute=$this.attr(opts.attribute),ctClass=opts.cluetipClass;if(!tipAttribute&&!opts.splitTitle&&!js)return true;if(opts.local&&opts.hideLocal){$(tipAttribute+':first').hide();}
var tOffset=parseInt(opts.topOffset,10),lOffset=parseInt(opts.leftOffset,10);var tipHeight,wHeight;var defHeight=isNaN(parseInt(opts.height,10))?'auto':(/\D/g).test(opts.height)?opts.height:opts.height+'px';var sTop,linkTop,posY,tipY,mouseY,baseline;var tipInnerWidth=isNaN(parseInt(opts.width,10))?275:parseInt(opts.width,10);var tipWidth=tipInnerWidth+(parseInt($cluetip.css('paddingLeft'))||0)+(parseInt($cluetip.css('paddingRight'))||0)+dropShadowSteps;var linkWidth=this.offsetWidth;var linkLeft,posX,tipX,mouseX,winWidth;var tipParts;var tipTitle=(opts.attribute!='title')?$this.attr(opts.titleAttribute):'';if(opts.splitTitle){if(tipTitle==undefined){tipTitle='';}
tipParts=tipTitle.split(opts.splitTitle);tipTitle=tipParts.shift();}
var localContent;var activate=function(event){if(!opts.onActivate($this)){return false;}
isActive=true;$cluetip.removeClass().css({width:tipInnerWidth});if(tipAttribute==$this.attr('href')){$this.css('cursor',opts.cursor);}
$this.attr('title','');if(opts.hoverClass){$this.addClass(opts.hoverClass);}
linkTop=posY=$this.offset().top;linkLeft=$this.offset().left;mouseX=event.pageX;mouseY=event.pageY;if($this[0].tagName.toLowerCase()!='area'){sTop=$(document).scrollTop();winWidth=$(window).width();}
if(opts.positionBy=='fixed'){posX=linkWidth+linkLeft+lOffset;$cluetip.css({left:posX});}else{posX=(linkWidth>linkLeft&&linkLeft>tipWidth)||linkLeft+linkWidth+tipWidth+lOffset>winWidth?linkLeft-tipWidth-lOffset:linkWidth+linkLeft+lOffset;if($this[0].tagName.toLowerCase()=='area'||opts.positionBy=='mouse'||linkWidth+tipWidth>winWidth){if(mouseX+20+tipWidth>winWidth){$cluetip.addClass(' cluetip-'+ctClass);posX=(mouseX-tipWidth-lOffset)>=0?mouseX-tipWidth-lOffset-parseInt($cluetip.css('marginLeft'),10)+parseInt($cluetipInner.css('marginRight'),10):mouseX-(tipWidth/2);}else{posX=mouseX+lOffset;}}
var pY=posX<0?event.pageY+tOffset:event.pageY;$cluetip.css({left:(posX>0&&opts.positionBy!='bottomTop')?posX:(mouseX+(tipWidth/2)>winWidth)?winWidth/2-tipWidth/2:Math.max(mouseX-(tipWidth/2),0)});}
wHeight=$(window).height();if(js){$cluetipInner.html(js);cluetipShow(pY);}
else if(tipParts){var tpl=tipParts.length;for(var i=0;i<tpl;i++){if(i==0){$cluetipInner.html(tipParts[i]);}else{$cluetipInner.append('<div class="split-body">'+tipParts[i]+'</div>');}};cluetipShow(pY);}
else if(!opts.local&&tipAttribute.indexOf('#')!=0){if(cluetipContents&&opts.ajaxCache){$cluetipInner.html(cluetipContents);cluetipShow(pY);}
else{var ajaxSettings=opts.ajaxSettings;ajaxSettings.url=tipAttribute;ajaxSettings.beforeSend=function(){$cluetipOuter.children().empty();if(opts.waitImage){$('#cluetip-waitimage').css({top:mouseY+20,left:mouseX+20}).show();}};ajaxSettings.error=function(){if(isActive){$cluetipInner.html('<i>sorry, the contents could not be loaded</i>');}};ajaxSettings.success=function(data){cluetipContents=opts.ajaxProcess(data);if(isActive){$cluetipInner.html(cluetipContents);}};ajaxSettings.complete=function(){imgCount=$('#cluetip-inner img').length;if(imgCount&&!$.browser.opera){$('#cluetip-inner img').load(function(){imgCount--;if(imgCount<1){$('#cluetip-waitimage').hide();if(isActive)cluetipShow(pY);}});}else{$('#cluetip-waitimage').hide();if(isActive)cluetipShow(pY);}};$.ajax(ajaxSettings);}}else if(opts.local){var $localContent=$(tipAttribute+':first');var localCluetip=$.fn.wrapInner?$localContent.wrapInner('<div></div>').children().clone(true):$localContent.html();$.fn.wrapInner?$cluetipInner.empty().append(localCluetip):$cluetipInner.html(localCluetip);cluetipShow(pY);}};var cluetipShow=function(bpY){$cluetip.addClass('cluetip-'+ctClass);if(opts.truncate){var $truncloaded=$cluetipInner.text().slice(0,opts.truncate)+'...';$cluetipInner.html($truncloaded);}
function doNothing(){};tipTitle?$cluetipTitle.show().html(tipTitle):(opts.showTitle)?$cluetipTitle.show().html('&nbsp;'):$cluetipTitle.hide();if(opts.sticky){var $closeLink=$('<div id="cluetip-close"><a href="#">'+opts.closeText+'</a></div>');(opts.closePosition=='bottom')?$closeLink.appendTo($cluetipInner):(opts.closePosition=='title')?$closeLink.prependTo($cluetipTitle):$closeLink.prependTo($cluetipInner);$closeLink.click(function(){cluetipClose();return false;});if(opts.mouseOutClose){if($.fn.hoverIntent&&opts.hoverIntent){$cluetip.hoverIntent({over:doNothing,timeout:opts.hoverIntent.timeout,out:function(){$closeLink.trigger('click');}});}else{$cluetip.hover(doNothing,function(){$closeLink.trigger('click');});}}else{$cluetip.unbind('mouseout');}}
var direction='';$cluetipOuter.css({overflow:defHeight=='auto'?'visible':'auto',height:defHeight});tipHeight=defHeight=='auto'?Math.max($cluetip.outerHeight(),$cluetip.height()):parseInt(defHeight,10);tipY=posY;baseline=sTop+wHeight;if(opts.positionBy=='fixed'){tipY=posY-opts.dropShadowSteps+tOffset;}else if((posX<mouseX&&Math.max(posX,0)+tipWidth>mouseX)||opts.positionBy=='bottomTop'){if(posY+tipHeight+tOffset>baseline&&mouseY-sTop>tipHeight+tOffset){tipY=mouseY-tipHeight-tOffset;direction='top';}else{tipY=mouseY+tOffset;direction='bottom';}}else if(posY+tipHeight+tOffset>baseline){tipY=(tipHeight>=wHeight)?sTop:baseline-tipHeight-tOffset;}else if($this.css('display')=='block'||$this[0].tagName.toLowerCase()=='area'||opts.positionBy=="mouse"){tipY=bpY-tOffset;}else{tipY=posY-opts.dropShadowSteps;}
if(direction==''){posX<linkLeft?direction='left':direction='right';}
$cluetip.css({top:tipY+'px'}).removeClass().addClass('clue-'+direction+'-'+ctClass).addClass(' cluetip-'+ctClass);if(opts.arrows){var bgY=(posY-tipY-opts.dropShadowSteps);$cluetipArrows.css({top:(/(left|right)/.test(direction)&&posX>=0&&bgY>0)?bgY+'px':/(left|right)/.test(direction)?0:''}).show();}else{$cluetipArrows.hide();}
$dropShadow.hide();$cluetip.hide()[opts.fx.open](opts.fx.open!='show'&&opts.fx.openSpeed);if(opts.dropShadow)$dropShadow.css({height:tipHeight,width:tipInnerWidth}).show();if($.fn.bgiframe){$cluetip.bgiframe();}
if(opts.delayedClose>0){closeOnDelay=setTimeout(cluetipClose,opts.delayedClose);}
opts.onShow($cluetip,$cluetipInner);};var inactivate=function(){isActive=false;$('#cluetip-waitimage').hide();if(!opts.sticky||(/click|toggle/).test(opts.activation)){cluetipClose();clearTimeout(closeOnDelay);};if(opts.hoverClass){$this.removeClass(opts.hoverClass);}
$('.cluetip-clicked').removeClass('cluetip-clicked');};var cluetipClose=function(){$cluetipOuter.parent().hide().removeClass().end().children().empty();if(tipTitle){$this.attr(opts.titleAttribute,tipTitle);}
$this.css('cursor','');if(opts.arrows)$cluetipArrows.css({top:''});};if((/click|toggle/).test(opts.activation)){$this.click(function(event){if($cluetip.is(':hidden')||!$this.is('.cluetip-clicked')){activate(event);$('.cluetip-clicked').removeClass('cluetip-clicked');$this.addClass('cluetip-clicked');}else{inactivate(event);}
this.blur();return false;});}else if(opts.activation=='focus'){$this.focus(function(event){activate(event);});$this.blur(function(event){inactivate(event);});}else{$this.click(function(){if($this.attr('href')&&$this.attr('href')==tipAttribute&&!opts.clickThrough){return false;}});var mouseTracks=function(evt){if(opts.tracking==true){var trackX=posX-evt.pageX;var trackY=tipY?tipY-evt.pageY:posY-evt.pageY;$this.mousemove(function(evt){$cluetip.css({left:evt.pageX+trackX,top:evt.pageY+trackY});});}};if($.fn.hoverIntent&&opts.hoverIntent){$this.mouseover(function(){$this.attr('title','');}).hoverIntent({sensitivity:opts.hoverIntent.sensitivity,interval:opts.hoverIntent.interval,over:function(event){activate(event);mouseTracks(event);},timeout:opts.hoverIntent.timeout,out:function(event){inactivate(event);$this.unbind('mousemove');}});}else{$this.hover(function(event){activate(event);mouseTracks(event);},function(event){inactivate(event);$this.unbind('mousemove');});}}});};$.fn.cluetip.defaults={width:275,height:'auto',cluezIndex:9700,positionBy:'auto',topOffset:15,leftOffset:15,local:false,hideLocal:true,attribute:'rel',titleAttribute:'title',splitTitle:'',showTitle:true,cluetipClass:'default',hoverClass:'',waitImage:true,cursor:'help',arrows:false,dropShadow:true,dropShadowSteps:6,sticky:false,mouseOutClose:false,activation:'hover',clickThrough:false,tracking:false,delayedClose:0,closePosition:'top',closeText:'Close',truncate:0,fx:{open:'show',openSpeed:''},hoverIntent:{sensitivity:3,interval:50,timeout:0},onActivate:function(e){return true;},onShow:function(ct,c){},ajaxCache:true,ajaxProcess:function(data){data=data.replace(/<s(cript|tyle)(.|\s)*?\/s(cript|tyle)>/g,'').replace(/<(link|title)(.|\s)*?\/(link|title)>/g,'');return data;},ajaxSettings:{dataType:'html'},debug:false};var insertionType='appendTo',insertionElement='body';$.cluetip={};$.cluetip.setup=function(options){if(options&&options.insertionType&&(options.insertionType).match(/appendTo|prependTo|insertBefore|insertAfter/)){insertionType=options.insertionType;}
if(options&&options.insertionElement){insertionElement=options.insertionElement;}};})(jQuery);

/**
* hoverIntent r5 // 2007.03.27 // jQuery 1.1.2+
* <http://cherne.net/brian/resources/jquery.hoverIntent.html>
*
* @param  f  onMouseOver function || An object with configuration options
* @param  g  onMouseOut function  || Nothing (use configuration options object)
* @author    Brian Cherne <brian@cherne.net>
*/
(function($){$.fn.hoverIntent=function(f,g){var cfg={sensitivity:7,interval:100,timeout:0};cfg=$.extend(cfg,g?{over:f,out:g}:f);var cX,cY,pX,pY;var track=function(ev){cX=ev.pageX;cY=ev.pageY;};var compare=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);if((Math.abs(pX-cX)+Math.abs(pY-cY))<cfg.sensitivity){$(ob).unbind("mousemove",track);ob.hoverIntent_s=1;return cfg.over.apply(ob,[ev]);}else{pX=cX;pY=cY;ob.hoverIntent_t=setTimeout(function(){compare(ev,ob);},cfg.interval);}};var delay=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);ob.hoverIntent_s=0;return cfg.out.apply(ob,[ev]);};var handleHover=function(e){var p=(e.type=="mouseover"?e.fromElement:e.toElement)||e.relatedTarget;while(p&&p!=this){try{p=p.parentNode;}catch(e){p=this;}}if(p==this){return false;}var ev=jQuery.extend({},e);var ob=this;if(ob.hoverIntent_t){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);}if(e.type=="mouseover"){pX=ev.pageX;pY=ev.pageY;$(ob).bind("mousemove",track);if(ob.hoverIntent_s!=1){ob.hoverIntent_t=setTimeout(function(){compare(ev,ob);},cfg.interval);}}else{$(ob).unbind("mousemove",track);if(ob.hoverIntent_s==1){ob.hoverIntent_t=setTimeout(function(){delay(ev,ob);},cfg.timeout);}}};return this.mouseover(handleHover).mouseout(handleHover);};})(jQuery);

/* global vars */
$.scriptIncludes = [];
if(!nflcsAssetPath) {
    var nflcsAssetPath = '';
}

/* ==================================================================
jQuery Extensions
================================================================== */
/**
 * @author Dmitry.Erman
 */

/*
 * Extends the getScript function of jQuery to support caching of
 * javascript files. By default it implements a cache buster.
 */
$.extend({
    getScript: function(url, callback, usecache)
    {
        // Don't reload existing scripts
        if($.scriptIncludes.toString().indexOf(url) >= 0)
        {
            //we still need to trigger the callback
            if (callback)
                //window[ 'execute' ] = function(tmp) {callback();}
                callback.apply(document);
        }else
        {
            $.scriptIncludes.push(url);
            return jQuery.ajax({
                type: "GET",
                url: url,
                data: null,
                success: callback,
                dataType: "script",
                cache : (usecache) ? usecache : true
            });

        }

    },

    chainLoad: function(arscripts, callback, usecache)
    {
        var el = arscripts.shift();
        var cb = (arscripts.length == 0)? true : false;
        if (el && cb) {
            $.getScript(el, callback, usecache);
        }
        else
        {
            if (el) {
                $.getScript(el, function(){
                    $.chainLoad(arscripts, callback, usecache);
                }, usecache);
            }
        }
    },

    ns: function(ns, data)
    {
        var root = window;

        if ((typeof(ns)) == "string")
        {
            var nsParts = ns.split(".");
            for (var i = 0; i < nsParts.length; i++)
            {
                if (typeof root[nsParts[i]] == "undefined")
                    root[nsParts[i]] = new Object();

                root = root[nsParts[i]];
            }
            root.__init = false;
        }else
        {
            if(typeof(ns) == "object")  root = ns;
        }
        if (data)
        {
            $.extend(root, data);
            root.__init = true;
        }
    },

    nsInit : function(ns, toggle)
    {
        if(toggle != null) ns.__init = toggle;
    },

    /*
     * ns: namespace
     * url: load from file in alternate location(if not specified use current folder and ns as the name of the file)
     * qkey: alias or shortcut name for the names space
     * cb: callback function
     */
    getScriptNS: function(ns, url, qkey, cb)
    {
        //check to see if the script has already been loaded
        if(typeof(window["ns"]) != "undefined" && window["ns"].__init == true) return false;


    },

    __queue: [],

    Queue: function(url, callback, usecache)
    {
        var _request = {
            u : url,
            c : callback,
            o : usecache
        }

        this.__queue.push(_request);

        //attach the execution event to the document ready state
        if(this.__queue.length == 1) $(document).ready(function(){$._runQueue();});
    },

    _runQueue: function()
    {
        var q = this.__queue, r = q.pop();

        while(r)
        {
            this.getScript(r.u, r.c, r.o);
            r = q.pop();
        }
    }
});

$(document).ready(function() {
	$('.more-photos-small').each( function(i, module) {
		if($(module).data('hasCarousel'))
			return;

		$(module).data('hasCarousel', true);

		/* R1.1
		function carouselInit(carousel) {
			if(carousel.options.size > carousel.options.visible) {
				if(carousel.options.size > 3) {
					var $pagination = $('<ul class="pagination"></ul>');

					// Previous
					$pagination.append(
						$('<li></li>').addClass('prev').append(
							$('<a></a>').attr('href', '#').html('&#0171; Prev').bind('click', function() {
								carousel.prev();
								return(false);
							})
						)
					);

					// Page
					for(var j=1; j <= carousel.options.size; j++) {
						$pagination.append(
							$('<li></li>').append(
								$('<a></a>').attr('href', '#').html('<span>' + j + '</span>').bind('click', function() {
									carousel.scroll($.jcarousel.intval($(this).text()));
									return(false);
								})
							)
						);
					}
			
					// Next
					$pagination.append(
						$('<li></li>').addClass('next').append(
							$('<a></a>').attr('href', '#').html('Next &#0187;').bind('click', function() {
								carousel.next();
								return(false);
							})
						)
					);
			
					// Append Pagination
					$(module).find('.ft').prepend( $pagination );
				}
			}
		}

		$(module).find('.bd ul').jcarousel({
			scroll: 1,
			initCallback: carouselInit,
			buttonNextHTML: null,
			buttonPrevHTML: null
		});

		*/

		// Start jCarousel
		$(module).find('.bd ul').jcarousel({
			buttonNextHTML:'<a></a>',
			buttonPrevHTML:'<a></a>'
		});
	} );
});



(function($) {
    $.fn.jcarousel = function(o) { return this.each(function() { new $jc(this, o); }); }; var defaults = { vertical: false, start: 1, offset: 1, size: null, scroll: 3, visible: null, animation: 'normal', easing: 'swing', auto: 0, wrap: null, initCallback: null, reloadCallback: null, itemLoadCallback: null, itemFirstInCallback: null, itemFirstOutCallback: null, itemLastInCallback: null, itemLastOutCallback: null, itemVisibleInCallback: null, itemVisibleOutCallback: null, buttonNextHTML: '<div></div>', buttonPrevHTML: '<div></div>', buttonNextEvent: 'click', buttonPrevEvent: 'click', buttonNextCallback: null, buttonPrevCallback: null }; $.jcarousel = function(e, o) {
        this.options = $.extend({}, defaults, o || {}); this.locked = false; this.container = null; this.clip = null; this.list = null; this.buttonNext = null; this.buttonPrev = null; this.wh = !this.options.vertical ? 'width' : 'height'; this.lt = !this.options.vertical ? 'left' : 'top'; var skin = '', split = e.className.split(' '); for (var i = 0; i < split.length; i++) { if (split[i].indexOf('jcarousel-skin') != -1) { $(e).removeClass(split[i]); var skin = split[i]; break; } }
        if (e.nodeName == 'UL' || e.nodeName == 'OL') {
            this.list = $(e); this.container = this.list.parent(); if (this.container.hasClass('jcarousel-clip')) {
                if (!this.container.parent().hasClass('jcarousel-container'))
                    this.container = this.container.wrap('<div></div>'); this.container = this.container.parent();
            } else if (!this.container.hasClass('jcarousel-container'))
                this.container = this.list.wrap('<div></div>').parent();
        } else { this.container = $(e); this.list = $(e).find('>ul,>ol,div>ul,div>ol'); }
        if (skin != '' && this.container.parent()[0].className.indexOf('jcarousel-skin') == -1)
            this.container.wrap('<div class=" ' + skin + '"></div>'); this.clip = this.list.parent(); if (!this.clip.length || !this.clip.hasClass('jcarousel-clip'))
            this.clip = this.list.wrap('<div></div>').parent(); this.buttonPrev = $('.jcarousel-prev', this.container); if (this.buttonPrev.size() == 0 && this.options.buttonPrevHTML != null)
            this.buttonPrev = this.clip.before(this.options.buttonPrevHTML).prev(); this.buttonPrev.addClass(this.className('jcarousel-prev')); this.buttonNext = $('.jcarousel-next', this.container); if (this.buttonNext.size() == 0 && this.options.buttonNextHTML != null)
            this.buttonNext = this.clip.before(this.options.buttonNextHTML).prev(); this.buttonNext.addClass(this.className('jcarousel-next')); this.clip.addClass(this.className('jcarousel-clip')); this.list.addClass(this.className('jcarousel-list')); this.container.addClass(this.className('jcarousel-container')); var di = this.options.visible != null ? Math.ceil(this.clipping() / this.options.visible) : null; var li = this.list.children('li'); var self = this; if (li.size() > 0) {
            var wh = 0, i = this.options.offset; li.each(function() { self.format(this, i++); wh += self.dimension(this, di); }); this.list.css(this.wh, wh + 'px'); if (!o || o.size === undefined)
                this.options.size = li.size();
        }
        this.container.css('display', 'block'); this.buttonNext.css('display', 'block'); this.buttonPrev.css('display', 'block'); this.funcNext = function() {self.next();}; this.funcPrev = function() {self.prev();}; $(window).bind('resize', function() {self.reload();}); if (this.options.initCallback != null)
            this.options.initCallback(this, 'init'); if ($.browser.safari) { this.buttons(false, false); $(window).bind('load', function() {self.setup();}); } else
            this.setup();
    }; var $jc = $.jcarousel; $jc.fn = $jc.prototype = { jcarousel: '0.2.3' }; $jc.fn.extend = $jc.extend = $.extend; $jc.fn.extend({ setup: function() {
        this.first = null; this.last = null; this.prevFirst = null; this.prevLast = null; this.animating = false; this.timer = null; this.tail = null; this.inTail = false; if (this.locked)
            return; this.list.css(this.lt, this.pos(this.options.offset) + 'px'); var p = this.pos(this.options.start); this.prevFirst = this.prevLast = null; this.animate(p, false);
    }, reset: function() {
        this.list.empty(); this.list.css(this.lt, '0px'); this.list.css(this.wh, '10px'); if (this.options.initCallback != null)
            this.options.initCallback(this, 'reset'); this.setup();
    }, reload: function() {
        if (this.tail != null && this.inTail)
            this.list.css(this.lt, $jc.intval(this.list.css(this.lt)) + this.tail); this.tail = null; this.inTail = false; if (this.options.reloadCallback != null)
            this.options.reloadCallback(this); if (this.options.visible != null) {
            var self = this; var di = Math.ceil(this.clipping() / this.options.visible), wh = 0, lt = 0; $('li', this.list).each(function(i) {
                wh += self.dimension(this, di); if (i + 1 < self.first)
                    lt = wh;
            }); this.list.css(this.wh, wh + 'px'); this.list.css(this.lt, -lt + 'px');
        }
        this.scroll(this.first, false);
    }, lock: function() { this.locked = true; this.buttons(); }, unlock: function() { this.locked = false; this.buttons(); }, size: function(s) {
        if (s != undefined) {
            this.options.size = s; if (!this.locked)
                this.buttons();
        }
        return this.options.size;
    }, has: function(i, i2) {
        if (i2 == undefined || !i2)
            i2 = i; if (this.options.size !== null && i2 > this.options.size)
            i2 = this.options.size; for (var j = i; j <= i2; j++) {
            var e = this.get(j); if (!e.length || e.hasClass('jcarousel-item-placeholder'))
                return false;
        }
        return true;
    }, get: function(i) { return $('.jcarousel-item-' + i, this.list); }, add: function(i, s) {
        var e = this.get(i), old = 0, add = 0; if (e.length == 0) { var c, e = this.create(i), j = $jc.intval(i); while (c = this.get(--j)) { if (j <= 0 || c.length) { j <= 0 ? this.list.prepend(e) : c.after(e); break; } } } else
            old = this.dimension(e); e.removeClass(this.className('jcarousel-item-placeholder')); typeof s == 'string' ? e.html(s) : e.empty().append(s); var di = this.options.visible != null ? Math.ceil(this.clipping() / this.options.visible) : null; var wh = this.dimension(e, di) - old; if (i > 0 && i < this.first)
            this.list.css(this.lt, $jc.intval(this.list.css(this.lt)) - wh + 'px'); this.list.css(this.wh, $jc.intval(this.list.css(this.wh)) + wh + 'px'); return e;
    }, remove: function(i) {
        var e = this.get(i); if (!e.length || (i >= this.first && i <= this.last))
            return; var d = this.dimension(e); if (i < this.first)
            this.list.css(this.lt, $jc.intval(this.list.css(this.lt)) + d + 'px'); e.remove(); this.list.css(this.wh, $jc.intval(this.list.css(this.wh)) - d + 'px');
    }, next: function() {
        this.stopAuto(); if (this.tail != null && !this.inTail)
            this.scrollTail(false); else
            this.scroll(((this.options.wrap == 'both' || this.options.wrap == 'last') && this.options.size != null && this.last == this.options.size) ? 1 : this.first + this.options.scroll);
    }, prev: function() {
        this.stopAuto(); if (this.tail != null && this.inTail)
            this.scrollTail(true); else
            this.scroll(((this.options.wrap == 'both' || this.options.wrap == 'first') && this.options.size != null && this.first == 1) ? this.options.size : this.first - this.options.scroll);
    }, scrollTail: function(b) {
        if (this.locked || this.animating || !this.tail)
            return; var pos = $jc.intval(this.list.css(this.lt)); !b ? pos -= this.tail : pos += this.tail; this.inTail = !b; this.prevFirst = this.first; this.prevLast = this.last; this.animate(pos);
    }, scroll: function(i, a) {
        if (this.locked || this.animating)
            return; this.animate(this.pos(i), a);
    }, pos: function(i) {
        if (this.locked || this.animating)
            return; if (this.options.wrap != 'circular')
            i = i < 1 ? 1 : (this.options.size && i > this.options.size ? this.options.size : i); var back = this.first > i; var pos = $jc.intval(this.list.css(this.lt)); var f = this.options.wrap != 'circular' && this.first <= 1 ? 1 : this.first; var c = back ? this.get(f) : this.get(this.last); var j = back ? f : f - 1; var e = null, l = 0, p = false, d = 0; while (back ? --j >= i : ++j < i) {
            e = this.get(j); p = !e.length; if (e.length == 0) { e = this.create(j).addClass(this.className('jcarousel-item-placeholder')); c[back ? 'before' : 'after'](e); }
            c = e; d = this.dimension(e); if (p)
                l += d; if (this.first != null && (this.options.wrap == 'circular' || (j >= 1 && (this.options.size == null || j <= this.options.size))))
                pos = back ? pos + d : pos - d;
        }
        var clipping = this.clipping(); var cache = []; var visible = 0, j = i, v = 0; var c = this.get(i - 1); while (++visible) {
            e = this.get(j); p = !e.length; if (e.length == 0) { e = this.create(j).addClass(this.className('jcarousel-item-placeholder')); c.length == 0 ? this.list.prepend(e) : c[back ? 'before' : 'after'](e); }
            c = e; var d = this.dimension(e); if (d == 0) { return 0; }
            if (this.options.wrap != 'circular' && this.options.size !== null && j > this.options.size)
                cache.push(e); else if (p)
                l += d; v += d; if (v >= clipping)
                break; j++;
        }
        for (var x = 0; x < cache.length; x++)
            cache[x].remove(); if (l > 0) { this.list.css(this.wh, this.dimension(this.list) + l + 'px'); if (back) { pos -= l; this.list.css(this.lt, $jc.intval(this.list.css(this.lt)) - l + 'px'); } }
        var last = i + visible - 1; if (this.options.wrap != 'circular' && this.options.size && last > this.options.size)
            last = this.options.size; if (j > last) {
            visible = 0, j = last, v = 0; while (++visible) {
                var e = this.get(j--); if (!e.length)
                    break; v += this.dimension(e); if (v >= clipping)
                    break;
            } 
        }
        var first = last - visible + 1; if (this.options.wrap != 'circular' && first < 1)
            first = 1; if (this.inTail && back) { pos += this.tail; this.inTail = false; }
        this.tail = null; if (this.options.wrap != 'circular' && last == this.options.size && (last - visible + 1) >= 1) {
            var m = $jc.margin(this.get(last), !this.options.vertical ? 'marginRight' : 'marginBottom'); if ((v - m) > clipping)
                this.tail = v - clipping - m;
        }
        while (i-- > first)
            pos += this.dimension(this.get(i)); this.prevFirst = this.first; this.prevLast = this.last; this.first = first; this.last = last; return pos;
    }, animate: function(p, a) {
        if (this.locked || this.animating)
            return; this.animating = true; var self = this; var scrolled = function() {
                self.animating = false; if (p == 0)
                    self.list.css(self.lt, 0); if (self.options.wrap == 'both' || self.options.wrap == 'last' || self.options.size == null || self.last < self.options.size)
                    self.startAuto(); self.buttons(); self.notify('onAfterAnimation');
            }; this.notify('onBeforeAnimation'); if (!this.options.animation || a == false) { this.list.css(this.lt, p + 'px'); scrolled(); } else { var o = !this.options.vertical ? { 'left': p} : { 'top': p }; this.list.animate(o, this.options.animation, this.options.easing, scrolled); } 
    }, startAuto: function(s) {
        if (s != undefined)
            this.options.auto = s; if (this.options.auto == 0)
            return this.stopAuto(); if (this.timer != null)
            return; var self = this; this.timer = setTimeout(function() {self.next();}, this.options.auto * 1000);
    }, stopAuto: function() {
        if (this.timer == null)
            return; clearTimeout(this.timer); this.timer = null;
    }, buttons: function(n, p) {
        if (n == undefined || n == null) {
            var n = !this.locked && this.options.size !== 0 && ((this.options.wrap && this.options.wrap != 'first') || this.options.size == null || this.last < this.options.size); if (!this.locked && (!this.options.wrap || this.options.wrap == 'first') && this.options.size != null && this.last >= this.options.size)
                n = this.tail != null && !this.inTail;
        }
        if (p == undefined || p == null) {
            var p = !this.locked && this.options.size !== 0 && ((this.options.wrap && this.options.wrap != 'last') || this.first > 1); if (!this.locked && (!this.options.wrap || this.options.wrap == 'last') && this.options.size != null && this.first == 1)
                p = this.tail != null && this.inTail;
        }
        var self = this; this.buttonNext[n ? 'bind' : 'unbind'](this.options.buttonNextEvent, this.funcNext)[n ? 'removeClass' : 'addClass'](this.className('jcarousel-next-disabled')).attr('disabled', n ? false : true); this.buttonPrev[p ? 'bind' : 'unbind'](this.options.buttonPrevEvent, this.funcPrev)[p ? 'removeClass' : 'addClass'](this.className('jcarousel-prev-disabled')).attr('disabled', p ? false : true); if (this.buttonNext.length > 0 && (this.buttonNext[0].jcarouselstate == undefined || this.buttonNext[0].jcarouselstate != n) && this.options.buttonNextCallback != null) { this.buttonNext.each(function() { self.options.buttonNextCallback(self, this, n); }); this.buttonNext[0].jcarouselstate = n; }
        if (this.buttonPrev.length > 0 && (this.buttonPrev[0].jcarouselstate == undefined || this.buttonPrev[0].jcarouselstate != p) && this.options.buttonPrevCallback != null) { this.buttonPrev.each(function() { self.options.buttonPrevCallback(self, this, p); }); this.buttonPrev[0].jcarouselstate = p; } 
    }, notify: function(evt) {
        var state = this.prevFirst == null ? 'init' : (this.prevFirst < this.first ? 'next' : 'prev'); this.callback('itemLoadCallback', evt, state); if (this.prevFirst != this.first) { this.callback('itemFirstInCallback', evt, state, this.first); this.callback('itemFirstOutCallback', evt, state, this.prevFirst); }
        if (this.prevLast != this.last) { this.callback('itemLastInCallback', evt, state, this.last); this.callback('itemLastOutCallback', evt, state, this.prevLast); }
        this.callback('itemVisibleInCallback', evt, state, this.first, this.last, this.prevFirst, this.prevLast); this.callback('itemVisibleOutCallback', evt, state, this.prevFirst, this.prevLast, this.first, this.last);
    }, callback: function(cb, evt, state, i1, i2, i3, i4) {
        if (this.options[cb] == undefined || (typeof this.options[cb] != 'object' && evt != 'onAfterAnimation'))
            return; var callback = typeof this.options[cb] == 'object' ? this.options[cb][evt] : this.options[cb]; if (!$.isFunction(callback))
            return; var self = this; if (i1 === undefined)
            callback(self, state, evt); else if (i2 === undefined)
            this.get(i1).each(function() { callback(self, this, i1, state, evt); }); else {
            for (var i = i1; i <= i2; i++)
                if (!(i >= i3 && i <= i4))
                this.get(i).each(function() { callback(self, this, i, state, evt); });
        } 
    }, create: function(i) { return this.format('<li></li>', i); }, format: function(e, i) { var $e = $(e).addClass(this.className('jcarousel-item')).addClass(this.className('jcarousel-item-' + i)); $e.attr('jcarouselindex', i); return $e; }, className: function(c) { return c + ' ' + c + (!this.options.vertical ? '-horizontal' : '-vertical'); }, dimension: function(e, d) {
        var el = e.jquery != undefined ? e[0] : e; var old = !this.options.vertical ? el.offsetWidth + $jc.margin(el, 'marginLeft') + $jc.margin(el, 'marginRight') : el.offsetHeight + $jc.margin(el, 'marginTop') + $jc.margin(el, 'marginBottom'); if (d == undefined || old == d)
            return old; var w = !this.options.vertical ? d - $jc.margin(el, 'marginLeft') - $jc.margin(el, 'marginRight') : d - $jc.margin(el, 'marginTop') - $jc.margin(el, 'marginBottom'); $(el).css(this.wh, w + 'px'); return this.dimension(el);
    }, clipping: function() { return !this.options.vertical ? this.clip[0].offsetWidth - $jc.intval(this.clip.css('borderLeftWidth')) - $jc.intval(this.clip.css('borderRightWidth')) : this.clip[0].offsetHeight - $jc.intval(this.clip.css('borderTopWidth')) - $jc.intval(this.clip.css('borderBottomWidth')); }, index: function(i, s) {
        if (s == undefined)
            s = this.options.size; return Math.round((((i - 1) / s) - Math.floor((i - 1) / s)) * s) + 1;
    } 
    }); $jc.extend({ defaults: function(d) { $.extend(defaults, d); }, margin: function(e, p) {
        if (!e)
            return 0; var el = e.jquery != undefined ? e[0] : e; if (p == 'marginRight' && $.browser.safari) { var old = { 'display': 'block', 'float': 'none', 'width': 'auto' }, oWidth, oWidth2; $.swap(el, old, function() { oWidth = el.offsetWidth; }); old['marginRight'] = 0; $.swap(el, old, function() { oWidth2 = el.offsetWidth; }); return oWidth2 - oWidth; }
        return $jc.intval($.css(el, p));
    }, intval: function(v) { v = parseInt(v); return isNaN(v) ? 0 : v; } 
    });
})(jQuery);


