// JavaScript Document

function prepareGallery() 
{
	if (!document.getElementById) return false;
	if (!document.getElementsByTagName) return false;
	if (!document.getElementById("slider")) return false;
										  
	var thumbs = document.getElementById("slider");
	var links = thumbs.getElementsByTagName("a");
	
	for (var i = 0; i < links.length; i++)
	{
		links[i].onclick = function()
		{
			return (showPic(this));
		}
	}
}

function showPic(whichPic) 
{
	var mainIMGwrap = document.getElementById("mainIMGwrap");
	var mainIMG = document.getElementById("mainIMG");
	var anchor = document.getElementById("mainIMGlink");
	var description = document.getElementById("descrip");
	var count = document.getElementById("count");
	var source = whichPic.getAttribute("href");  
	var title = whichPic.getAttribute("title"); 
	var file = whichPic.getAttribute("file");   
	var number = whichPic.getAttribute("number");
	var total = whichPic.getAttribute("total");
	var url = "ORIG/" + file;
	
	var newIMG = new Image();	
	newIMG.onload = function()
	{
		imgW = newIMG.width;
		imgH = newIMG.height;
		var windowH = windowHeight();
		var windowW = windowWidth();
		
		mainIMGwrap.style.visibility = "hidden";

		mainIMGwrap.style.marginTop = (windowH - 130 - imgH) / 2 + "px";
		mainIMGwrap.style.marginLeft = -(imgW / 2) + "px";
		mainIMG.setAttribute('src', source);
		
		description.childNodes[0].nodeValue = title; 
		count.childNodes[0].nodeValue = number + '/' + total;	
		mainIMGwrap.style.visibility = "visible";
	}
	newIMG.src = source;
	
	mainIMG.setAttribute("file", url);	
	anchor.setAttribute("href", url);
	return false;
}






function centersolo(imgHeight, imgWidth)
{
	var mainIMGwrap = document.getElementById("mainIMGwrap");
	var windowH = windowHeight();
	var windowW = windowWidth();
	
	mainIMGwrap.style.marginTop = (windowH - 130 - imgHeight) / 2 + "px";
	mainIMGwrap.style.marginLeft = -(imgWidth / 2) + "px";
	mainIMGwrap.style.visibiity = "visible";
	return false;
}



