
// This image browser has no thumb width !!

// confirm there's at least one image to zoom
if(document.getElementById('linkZoomGallery')) {
	var hasEnlarged = false;
	for (h=0;h<ZoomImg.length;h++)
		if (ZoomImg[h]!="")
			var hasEnlarged = true;
			
	document.getElementById('linkZoomGallery').style.display=(hasEnlarged)?'block':'none'; 	
}

// function to generate the thumbnails
function generateGallery(){
	// loop for initializing thumb cells
	for (i=0; i<=NewImg.length-1; i++) {
		if (NewImg[i]){
			// img has no thumb? assign itself
			if (!(Thumbs[i])||(Thumbs[i]=="")) Thumbs[i] = NewImg[i];					
			// separator between thumbs
			separator = (i!=maxThumbsPerRow-1)?'<td width="'+thumbsSep+'"> </td>':'';	
			// alt title according to the enlargement
			altTitle = (ZoomImg[i] && ZoomImg[i]!="")?'title="click to see enlarged"':'title="no zoom available"'; 	
			document.getElementById("thumbCell_"+i).innerHTML = '<table border="0" cellpadding="0" cellspacing="0"><tr><td valing="middle" aling="center"><a href="javascript:zoomImage()" '+altTitle+' onMouseOver="displayImage('+i+')"><img src="'+Thumbs[i]+'" height="'+thumbH+'" border="0" id="thumb_'+i+'" class="thumb-off" /></a></td>'+separator+'</tr></table>';
		}
		else 	
			document.getElementById("thumbCell_"+i).style.display = 'none';				
	}
	if (NewImg[0] && NewImg[0]!="")	
		displayImage(0);																		// display first image
}

var current_image=0;																			// global var stores img being showed
function displayImage(id) {
	if (id < NewImg.length) {
		current_image = id;																		// keeps 'num id' of image showed
		var mainImg = document.getElementById('mainImage');
		if (mainImg){
			mainImg.src = NewImg[id]+resizeURL; 												// changes main image and resizes it
			mainImg.alt = (id==0 && altText !="")?altText:""; 									// if first image set alt text 
			mainImg.title = mainImg.alt; 	
		}
	}
}
	
function zoomImage(){			
	var imgTitle = (displayName!="")?displayName:siteName;
	if (ZoomImg[current_image] && ZoomImg[current_image]!="") 
		popImage(ZoomImg[current_image], imgTitle);
}

// initialize the image gallery 
generateGallery();
