// JavaScript Document

var selectedDiv=0;
var totalDivs=0;

var all_links=new Array();

var imagelink="";

function showPic (whichpic) { 

	for(i=0; i<all_links.length; i++){
		if( all_links[i] == whichpic){
			selectedDiv=i;
		}
	}

	if (document.getElementById) { 
		document.getElementById('placeholder').src = whichpic.href; 
		imagelink = whichpic.href;
		
		var pathindex = imagelink.lastIndexOf( "/" );
		var largeimagelink = "images/large/" + imagelink.substring( pathindex+1 );
		document.getElementById('large_img').href = largeimagelink; 
		//document.write( largeimagelink );

		if (whichpic.title) { 
			document.getElementById('desc').childNodes[0].nodeValue = whichpic.title;
			document.getElementById('large_img').title = whichpic.title;
		} else { 
			document.getElementById('desc').childNodes[0].nodeValue = whichpic.childNodes[0].nodeValue; 
			document.getElementById('large_img').title = whichpic.childNodes[0].nodeValue; 
		} 
		
		return false; 
	} else { 
		return true; 
	} 
}
	
	
	
function getElementbyClass(){
	var classname = "thumb";
	
	var inc=0;
	var alltags=document.all? document.all.tags("A") : document.getElementsByTagName("*");
	for (i=0; i<alltags.length; i++){
		if (alltags[i].className==classname)
			all_links[inc++]=alltags[i];
	}
	totalDivs=all_links.length;
}

/*
function selectPic( whichpic ){
	for(i=0; i<all_links.length; i++){
		if( all_links[i] == whichpic){
			selectedDiv=all_links[i];
		}
	}
	showPic( whichpic );
}*/

function showNext(){
	selectedDiv=(selectedDiv<totalDivs-1)? selectedDiv+1 : 0;
	showPic( all_links[selectedDiv] );
}


function showPrevious(){
	selectedDiv=(selectedDiv>0)? selectedDiv-1 : (totalDivs-1);
	showPic( all_links[selectedDiv] );
}


if (window.addEventListener)
	window.addEventListener("load", getElementbyClass, false);
else if (window.attachEvent)
	window.attachEvent("onload", getElementbyClass);
else if (document.getElementById)
	window.onload=getElementbyClass;