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 = '/ajax/carousel/featured.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 #info .name').html( current.name ); $('#carousel #info .city').html( current.city ); $('#carousel #info .region').html( current.region ); $('#carousel #info .country').html( current.country ); var url = 'http://marinas.com/view/marina/' + current.id + '_' + escape(current.name.replace(/[\s\/]/, '_')) + ( current.city ? ( '_' + escape( current.city.replace(/[\s\/]/, '_') ) ) : '' ) + ( current.region ? ( '_' + escape( current.region.replace(/[\s\/]/, '_') ) ) : '' ); $('#carousel #info #readMore').click( function() { if ( window.parent ) { window.parent.location = url; } else { window.location = url; } return false; }); $('#carousel .clip li:eq(' + (this.currentPosition-1) + ') img').click( function() { if ( window.parent ) { window.parent.location = url; } else { window.location = url; } return false; }); } this.load = function( dataArray ) { jList = $('#carousel .clip ul'); this.dataArray = dataArray; $.each( dataArray, function( index, object ) { jList.append( $( '