var carousel = function() { this.visibleItemsAtATime = 3; this.itemWidth = 180; this.dataArray = ''; this.itemHeight = 106; this.timeDelay = 400; this.currentPosition = 1; this.current = 0; this.shrinkFactor = .7; this.ajaxUrl = '/3dcarousel/ajax.php'; this.next = function() { if( this.currentPosition >= $('#carousel .clip li').size() ) this.currentPosition = 0; this.currentPosition++; this.redraw(); } this.prev = function() { if( this.currentPosition <= 1 ) this.currentPosition = $('#carousel .clip li').size() + 1; this.currentPosition--; this.redraw(); } this.redraw = function() { this.animate(); this.updateInformation(); } this.animate = function() { $('#carousel .clip ul').animate( { 'left' : -1 * ( ( this.currentPosition * this.itemWidth ) - ( this.itemWidth * 2 ) ) + 35 + 'px' }, this.timeDelay ); $('#carousel .clip li img') .css( { cursor:"auto" } ) .animate( { 'left':'25px', 'height' : this.itemHeight * this.shrinkFactor + 'px', 'paddingTop' : '15px' }, this.timeDelay ); $('#carousel .clip li:eq(' + (this.currentPosition-1) + ') img').stop().animate( { 'left':'0', 'height' : this.itemHeight + 'px', 'paddingTop' : '0' }, this.timeDelay ); $('#carousel .clip li:eq(' + ( this.currentPosition - 1 ) + ') img').css( { cursor:"pointer" } ); } this.updateInformation = function() { var current = this.dataArray[ this.currentPosition - 1 ]; $('#carousel .clip li:eq(' + (this.currentPosition-1) + ') img').click( function() { if ( window.parent ) { window.parent.location = url; } else { window.location = url; } return false; }); } } var carousel = new carousel(); $(document).ready(function() { $('').appendTo('#carousel .clip'); $('#carousel .clip ul').load( carousel.ajaxUrl, {}, function(){ carousel.next.call( carousel ); } ); $('#next').click( function() { carousel.next.call( carousel ); return false; }); $('#prev').click( function() { carousel.prev.call( carousel ); return false; }); });