(function( $) {
	$.fn.scrollEffect = function(scrollItem, showing, fix, itemspace, topArrow, bottomArrow, slideArrow) {
		
	/*The plugin takes six parameters.
	
	scrollItem - the ID of each scroll item that the scroll is being applied to.
	showing - the number of items that are visible in the scroller.
	fix - adds more or less space at the bottom of the rapper.
	itemspace - adjusts for extra padding on each item in scroller.
	topArrow - adjusts the distance of the top arrow from the top wrapper.
	bottomArrow - adjusts the distance of the bottom wrapper from the bottom of the wrapper.
	sliderArrow - adjusts the position of both arrows horizontally.
	
	topArrow, bottomArrow, and slideArrow can be set to null and will default to the values below. */
		
		
		/*SET UP PLUGIN VARIABLES*/
		var totalPosts = 0;
		
		
		if(topArrow == null) {
			topArrow = 10;
		}
		
		if(bottomArrow == null) {
			bottomArrow = 0;
		}
		
		if(slideArrow == null) {
			slideArrow = 0;
		}
		
		var postIndex = 1;
		var obj = this;
		/*get height of applied div and apply fix*/
		var scrollHeight = (this.height()) + fix;		
		
		obj.find("#" + scrollItem).each(function(){
			totalPosts ++;
		});
		
		/*INITIALIZE SETTINGS*/
		this.find('#pagination-wrapper').css({height : scrollHeight});
		this.find('#up-arrow').css({top : topArrow});
		this.find('#up-arrow').css({right : slideArrow});
		this.find('#up-arrow').hide();	

		this.find('#up-arrow-disabled').css({top : topArrow});
		this.find('#up-arrow-disabled').css({right : slideArrow});

		this.find('#down-arrow').css({bottom : bottomArrow});
		this.find('#down-arrow').css({right : slideArrow});

		this.find('#down-arrow-disabled').css({bottom : bottomArrow});
		this.find('#down-arrow-disabled').css({right : slideArrow});
		this.find('#down-arrow-disabled').hide();

		this.find('.learn-more').css('visibility','visible');
		$('#right-column a.learn-more').css('border', '0px solid white');
	
		this.find('#down-arrow').click(function( e ) {
			//alert(postIndex);

			if(postIndex == 1) {
				obj.find('#up-arrow').fadeIn('fast');	
				obj.find('#up-arrow-disabled').fadeOut('fast');	
			}
			
			if((postIndex<=totalPosts) && (postIndex != (totalPosts - (showing -1)))) {
				postHeight = (obj.find('.post_'+postIndex).height()) + itemspace;
				
				obj.find('#pagination-slide').stop(true, true).animate({'top': '-=' + postHeight +"px"}, 2000);	
				postIndex = postIndex+1;
			}
			
			if(postIndex == (totalPosts - (showing -1))) {
				obj.find('#down-arrow').fadeOut('fast');	
				obj.find('#down-arrow-disabled').fadeIn('fast');	
			}
				
			
		});
		
		this.find('#up-arrow').click(function(e) {
			if(postIndex>1) {
				postIndex --;
				postHeight = (obj.find('.post_'+postIndex).height()) + itemspace;
				obj.find('#pagination-slide').stop(true, true).animate({'top': '+=' + postHeight +"px"}, 2000);	
			}
			if(postIndex == 1) {
				obj.find('#up-arrow').fadeOut('fast');	
				obj.find('#up-arrow-disabled').fadeIn('fast');	
				
			}
			if(postIndex != (totalPosts - 1)) {
				obj.find('#down-arrow').fadeIn('fast');	
				obj.find('#down-arrow-disabled').fadeOut('fast');	
				
			}
			//alert(slideHeight + " : " +slideIndex);
		});

	};
})(jQuery);
// JavaScript Document

