var currentscrolltop;

function showimage(description, image){

	if (!document.getElementById('absolute')){ return; }

	if (document.getElementById('galleryimage')){

		var theimage = document.createElement('img');
		theimage.setAttribute('src',image);
		theimage.alt = '';

		var closelink = document.createElement('span');
		closelink.style.display 		= 'block';
		closelink.style.width 			= '410px';
		closelink.style.backgroundColor	= '#ffffff';
		closelink.style.fontSize 		= '12px';
		closelink.style.textAlign 		= 'right';
		closelink.style.paddingTop		= '3px';
		closelink.style.paddingRight 	= '10px';
		closelink.style.marginLeft 		= 'auto';
		closelink.style.marginRight 	= 'auto';
		closelink.innerHTML 			= '(close)';
		
		var footer = document.createElement('p');
		footer.innerHTML = description;

		document.getElementById('galleryimage').innerHTML = '';
		document.getElementById('galleryimage').appendChild(closelink);
		document.getElementById('galleryimage').appendChild(theimage);
		document.getElementById('galleryimage').appendChild(footer);

	}
	
	if (image == ''){ 	document.getElementById('absolute').style.display = 'none'; undobody(); }
	else { 				document.getElementById('absolute').style.display = 'block'; dobody(); }

}

function undobody(){
	document.body.style.height = '';
	document.body.style.overflow = '';
	document.documentElement.scrollTop = currentscrolltop;
}
function dobody(){
	currentscrolltop = document.documentElement.scrollTop;
	document.body.style.height = '100.1%';
	document.body.style.overflow = 'hidden';
}

function sha1(elementID){
	
	if (get(elementID)){
		
		get(elementID).value = hex_sha1(get(elementID).value);
		
	}
	
}

function get(elementID){
	
	if (document.getElementById(elementID)){
		
		return document.getElementById(elementID);
		
	}
	else {
		
		return false;
		
	}
	
}

var currentcount = 0;

var currentlocation = location.href;
currentlocation = currentlocation.indexOf('#galleryanchor',0);
if (currentlocation != -1){
	
	var theparts = location.href.split('#galleryanchor');
	currentcount = parseInt(theparts[1]);
	
}

function galleryup(){
	
	// reduce currentcount
	
	if (get('galleryanchor'+(currentcount-1))){
		
		currentcount--;
		document.location =  '#galleryanchor'+currentcount;
		
	}
	else {
		document.location =  '#galleryanchor'+currentcount;
	}
	
}
function gallerydown(){
	
	if (get('galleryanchor'+(currentcount+1))){
		
		currentcount++;
		document.location =  '#galleryanchor'+currentcount;
		
	}
	else {
		document.location =  '#galleryanchor'+currentcount;
	}
	
}
