
$(document).ready(function () {
  displayButtons();  
} );


function displayButtons() {

	var pages		= $('#col2_content').children().length;
	var currentPage = $('#col2_content > .visiblePage:first');
	
	var pageExists	= currentPage.attr('id') === undefined;
		
	if(!pageExists) {
	
		var position	= parseInt( currentPage.attr('id').substring( 4 ) );
		var prev		= $('#pagePrevious');
		var next		= $('#pageNext');
		
		if( position == 1 )
			prev.hide();
		else
			prev.show();
		
		if( position == pages )
			next.hide();
		else
			next.show();
	}
}

function pageBreak( mode ) {

	var currentPage = $('#col2_content > .visiblePage:first');
	var position	= parseInt( currentPage.attr('id').substring( 4 ) );
	var pages		= $('#col2_content').children().length;
	var displayPage	= '';
	
	if( mode == 'next' && position < pages ) {
		displayPage = currentPage.next();
	} else if ( mode == 'previous' && position > 1 ) {
		displayPage = currentPage.prev();
	}
	
	if( displayPage != '' ) {		
		currentPage.toggleClass('visiblePage');
		currentPage.toggleClass('hiddenPage');
		
		displayPage.toggleClass('hiddenPage');
		displayPage.toggleClass('visiblePage');
	}

	displayButtons();
}

/*
function pageBreak( mode, parentId, siblingsClassName ) {
	
	var pages		= $('#col2_content > .pageBreak');
	var count		= pages.length;
	var position	= 0;

	if( count > 0 ) {
	
		for( var i = 0; i < count; i++ ) {

			pages[i].hide();
		}
	}
}
*/
