/*! * Tiny Carousel 1.9 * http://www.baijs.nl/tinycarousel * * Copyright 2010, Maarten Baijs * Dual licensed under the MIT or GPL Version 2 licenses. * http://www.opensource.org/licenses/mit-license.php * http://www.opensource.org/licenses/gpl-2.0.php * * Date: 01 / 06 / 2011 * Depends on library: jQuery */ (function($){	$.tiny = $.tiny || { };		$.tiny.carousel = {		options: {				'padding'     : 0,            'width'       : 845,            'stepSize'    : 400,            'speed'       : 800,            'callback'    : null		}	};		$.fn.tinycarousel = function(options) {		var options = $.extend({}, $.tiny.carousel.options, options);		this.each(function(){$(this).data('jc', new Carousel($(this), options));});		return this;	};	$.fn.tinycarousel_move = function(iNum){$(this).data('jc').move(iNum);};    $.fn.tinycarousel_update = function(cW){$(this).data('jc').update(cW);};        	function Carousel(root, options){		var jcInstance = this;        var jcViewport = $('.viewport:first', root);            var jcOverview = $('.overview:first', root);        var jcButtonNext = $('.next:first', root);        var jcButtonPrev = $('.prev:first', root);        var jcOverviewWidth = 0;        var iSteps = 0;        var iCurrent = 0;		                		function _initialize(){            //alert('carousel '+$(root).attr('id')+' has been initialized');            setEvents();                                    jcOverviewWidth = _countOverviewWidth(jcOverview);            iSteps = _countISteps();            iCurrent = 0;            jcViewport.css('width', options.width);            jcOverview.css('width', jcOverviewWidth);            jcOverview.css('left', '0px');            //jcInstance.move(0);            return jcInstance;		};		function _countOverviewWidth(o) {            var width = 0;             var imgs = o.find('img');                    $.each(imgs, function(index, value) {                width += value.width;                width += 2*options.padding;            });                                return width;        }                function _countISteps() {             return Math.max(0, Math.ceil((jcOverviewWidth - options.width) / options.stepSize));        }        function setEvents(){			jcButtonNext.click(function(){jcInstance.move(1);return false;});			jcButtonPrev.click(function(){jcInstance.move(-1);return false;});				};        this.update = function(cW) {            jcOverviewWidth = cW;            			//alert('carousel '+$(root).attr('id')+' has been updated');            //jcOverviewWidth = _countOverviewWidth(jcOverview);            iSteps = _countISteps();            iCurrent = 0;            jcOverview.css('width', jcOverviewWidth);            jcOverview.css('left', '0px');		};		this.move = function(direction){			if ((iCurrent + direction) >= 0 && (iCurrent + direction) <= iSteps) {                iCurrent += direction;                var oPosition = {};                oPosition['left'] = - Math.min( iCurrent*options.stepSize, (jcOverviewWidth-options.width));                                jcOverview.animate(oPosition, {                    queue: false,                    duration: options.speed                                });            }		};        		return _initialize();	};})(jQuery);
