/** * jNetizensCarousel 1.0 * @requires jQuery v1.2 or above * * based on: * jCarouselLite 1.0.1 * Copyright (c) 2007 Ganeshji Marwaha (gmarwaha.com) * @author Ganeshji Marwaha/ganeshread@gmail.com * http://gmarwaha.com/jquery/jcarousellite/ */(function($) { // Compliant with jquery.noConflict()$.fn.jNetizensCarousel = function(o) {    o = $.extend({        interval: 0, // do not touch!        move_by: 2,        speed: 200,        visible: 3,        div_width: "100%"    }, o || {});    return this.each(function() { // Returns the element collection. Chainable.        var div = $(this), ul = $("ul", div), li = $("li", ul), tl = li.size();        //ul.append( li.slice( 0, o.visible ).clone() );        //li = $("li", ul); // refresh li        div.css({width: o.div_width, overflow: "hidden", position: "relative", "z-index": "2", left: "0px", float: "left"});        ul.css({margin: "0", padding: "0", position: "relative", "list-style-type": "none", "z-index": "1"});        //li.css({overflow: "hidden", float: "left"});                var ulSize = width(li) * li.size(); // size of full ul(total length, not just for the visible items)        ul.css("width", ulSize+"px");        startScroll();        this.onmouseover = function(){ stopScroll(); };        this.onmouseout = function(){ startScroll(); };        function startScroll() {            if(!o.interval) {                o.interval=setInterval( function(){ move(o.move_by); }, o.speed );            }        };        function stopScroll() {            if(o.interval) {                clearInterval(o.interval);                o.interval=0;            }        };        var cur_scroll_pos = 0;        var cur_el = null;        var cur_el_pos = 0;        var cur_el_w = null;        var cur_el_nr = 0;        var rewind = false;                function move(by) {            // get width of current (first displayed) element            if( !cur_el_w ) {                cur_el = $("li:eq("+cur_el_nr+"):not(.end)", ul);                if( cur_el[0] ) {                    cur_el_w = width( cur_el );                    cur_el_nr++;                } else {                    rewind = true;                }            }            if( rewind ) {                ul.css("left", "0px" );                cur_scroll_pos = 0;                cur_el_pos = 0;                cur_el_w = null;                cur_el_nr = 0;                rewind = false;            } else {                //new_pos = css( ul, "left" ) - o.move_by;                cur_scroll_pos -= o.move_by;                ul.css("left", cur_scroll_pos + "px" );                cur_el_pos += o.move_by;                if( cur_el_pos >= cur_el_w ) {                    cur_el_pos -= cur_el_w;                    cur_el_w = null;                }            }            return false;        };    });};function css(el, prop) {    return parseInt($.css(el[0], prop)) || 0;};function width(el) {    return  el[0].offsetWidth + css(el, 'marginLeft') + css(el, 'marginRight');};function height(el) {    return el[0].offsetHeight + css(el, 'marginTop') + css(el, 'marginBottom');};})(jQuery);