// set a thumb to selected 
function setImage(id){
	slideArrow(id);
	selectThumb(id);
	toggleLarge(id);
	addView(id);
	$('comments').hide() // hide the comments on page change, it will show the last page comments otherwise
}

// slide the header thumb arrow to it's place 
function slideArrow(id){
	new Effect.Parallel([new Effect.Move('arrow',{sync:true,x:eval('offset'+id),y: 0,mode:'absolute'})],
	{duration:0.2})
}

// set the selected class to the header thumb image 
function selectThumb(id){
	// reset all of them first
	$('thumb1').className='';
	$('thumb2').className='';
	$('thumb3').className='';
	$('thumb4').className='';
	// now add the class to the selected 
	$('thumb'+id).className='selected'
	$('thumb'+id).blur()
}

// show the main large image
function toggleLarge(id){
	// reset all of them first
	$('large1').hide();
	$('large2').hide();
	$('large3').hide();
	$('large4').hide();
	// now add the class to the selected 
	$('large'+id).show()
}

// adds a view to its view column
function addView(id){
	new Ajax.Updater('ajax_div','/add_view/'+id);
}

// show comments 
function showComments(id){
	new Ajax.Updater('comments','/get_comments/'+id,{onComplete:function(request){$('comments').show();Effect.ScrollTo('commentslist')}});
}

// post a comment
function postComment(id,name,body,email,permission){
	new Ajax.Updater('comments','/get_comments/'+id,{parameters:{'commentaction':1,'name':name,'body':body,'email':email,'permission':permission},onLoading:function(request){$('indicator').show()},onComplete:function(request){updateCount(id);Effect.ScrollTo('commentslist')}});
}

// update comment count display
function updateCount(id){
	new Ajax.Updater('commentcnt'+id,'/get_comment_count/'+id);
}