var cur_start = 1; max_image = 4; maxid = 0;

function init( _maxid ) {
	maxid = _maxid;	
	//hide buttons	
	if ( maxid <= max_image) { 		
		document.getElementById( 'image_left' ).style.display = 'none';		
		document.getElementById( 'image_right' ).style.display = 'none';			
	}	
	display();
	document.getElementById( 'image_right' ).style.visibility = 'hidden';
}

function display() {
	for ( j = 1; j <= maxid; j++) 
		document.getElementById( 'image'+j ).style.display = 'none';		
	for ( i = cur_start; i < (cur_start+max_image); i++) 
		document.getElementById( 'image'+i ).style.display = '';		

	document.getElementById( 'image_left' ).style.visibility = 'visible';		
	document.getElementById( 'image_right' ).style.visibility = 'visible';					
}

function flip_left(){
	if ( cur_start > 1 ) {
		cur_start--;
		display();		
	} 
	if ( cur_start == 1)
		document.getElementById( 'image_right' ).style.visibility = 'hidden';
}

function flip_right() {
	if ( cur_start <= (maxid-max_image) ) {
		cur_start++; 
		display();	
	} 
	if ( cur_start > (maxid-max_image) )
		document.getElementById( 'image_left' ).style.visibility = 'hidden';		
}
