
$(function(){

	if( $('.moreButton') ){
		$('.moreButton').click(function(){
			// if not loading
			if( !$('.moreButton b').hasClass('loading') ){
				// adding loading indicator
				$('.moreButton b').addClass('loading');
				// ajax call for getting content
				$.get('?page='+(parseInt(currentPage)+1), function(result){
					// appending stream
					$('#stream').append(result);
					// increasing page number
					currentPage = parseInt(currentPage)+1;
					// if this is last page
					if( pageCount <= currentPage ){
						$('.moreButton').remove();
					}else{
						// changing button text
						if( currentPage % 2 == 0 ){ // mod 2
							$('.moreButton b i').addClass('more');
						}else{
							$('.moreButton b i').removeClass('more');
						}
						// removing loading indicator
						$('.moreButton b').removeClass('loading');
					}
				});
			}
			// stopping link
			return false;
		});
	}

});
