var previousGallery = 1;

function galleryCountUp(){
	previousGallery = gallerycount;
	if (gallerycount < totalImages){
		gallerycount++;
	}
	swapit();
}

function galleryCountDown(){
	previousGallery = gallerycount;
	if( gallerycount > 1){
		gallerycount--;
	   }
	swapit();
}


function getGaleryCount(){
	previousGallery = gallerycount;
	gallerycount = Number(this.id);
	swapit();
}


function swapit(){
	document.getElementById('gallerytext').innerHTML = window[galleryname + "_" + gallerycount.toString() + "text"];
	document.getElementById('galleryImage').src = "img/" + galleryname + "/" + gallerycount.toString() + ".jpg";
	document.getElementById('numbernav').innerHTML = "<a href='#' id='leftarrow' onclick='javascript:galleryCountDown();' >&lt;&lt;&nbsp; </a>" + gallerycount.toString() + " of " + totalImages + " <a href='#'  onclick='javascript:galleryCountUp();' id='rightarrow'>&nbsp;&gt;&gt;</a>";
	
	document.getElementById('thumb' + previousGallery.toString()).className = 'galleryImageThumb';
	document.getElementById('thumb' + gallerycount.toString()).className = 'galleryImageThumbHighlight';	
}


function setuplinks() {
	swapit();
	
	for (var x = 1; x <= totalImages; x++){
		var newelementid = x.toString();
		document.getElementById(newelementid).onclick = getGaleryCount;
	}
	
}



window.onload = setuplinks;

