var newwindow;
function imgViewer(url)
{
	newwindow=window.open(url,'imgViewer','height=550,width=700, scrollbars=yes');
	if (window.focus) {newwindow.focus()}
}

var numRow
if (numRow == undefined) {numRow=5}

function isEven(x) { return (x%2)?false:true; }
function isOdd(x) { return !isEven(x); }
function isByFive(x) { return (x%numRow)?false:true; }
	
function infoSwap(txt, img, zlink){
var txtObj=document.getElementById('Txt');
var imgObj=document.getElementById('Img');
var linkObj=document.getElementById('zlink');
txtObj.innerHTML=txt;
imgObj.src='/file_center/product_images/' + picDir + '/' + img;
linkObj.innerHTML='<a href="javascript:imgViewer(\'/file_center/zoomify2.cfm?zoomifyImagePath=/file_center/product_images/' + picDir + '/' + zlink + '_large/\');">Zoom</a>';
}
// Write main div that holds large image, caption and zoom link
document.write('<table width="300" align="center" border="0" cellspacing="1" bgcolor="#eeeeee" cellpadding="0"><tr><td align="center" colspan="2">');
document.write('<img id="Img" src="/file_center/product_images/' + picDir + '/' + picDir + '_1.jpg" width="300" height="300" border="0" alt="' + altCaptions[0] + '"><br>');
document.write('</td></tr><tr><td align="center" width="275">');
document.write('<div id="Txt" style="font-family:Arial, Helvetica, sans-serif; font-size:12px">' + altCaptions[0] + '</div>');
document.write('</td><td align="center" width="25">');
document.write('<div id="zlink" style="font-family:Arial, Helvetica, sans-serif; font-size:12px"><a href="javascript:imgViewer(\'/file_center/zoomify2.cfm?zoomifyImagePath=/file_center/product_images/' + picDir + '/' + 1 + '_large/\');">Zoom</a></div>');
document.write('</td></tr></table>');

// Write thumbs
document.write('<br><table align="center" border="0" cellspacing="0" cellpadding="10"><tr>');
for (x=0; x<numPics; x++)
{
	// Check to see if X is even and greater than 0 then write table row
	// Write table cell and thumb with link
	if (x>0 && isByFive(x)) { document.write ('</tr><tr>'); }
	
	document.write('<td align="center" valign="top" width="75">');
	document.write('<a href="javascript: void(0)" id="product_thumb" onClick=\'infoSwap("' + altCaptions[x] + '", "' + picDir + '_' + (x+1) + '.jpg", "' + (x+1) + '")\')"><img src="/file_center/product_images/' + picDir + '/' + picDir + '_' + (x+1) + '_thumb.jpg" alt="' + altCaptions[x] + '" width="75" height="75"></a><br>');
	document.write('<font size="1" face="arial">' + altCaptions[x] + '</font></td>');				 
}
document.write('</tr></table>');

// this image is just to stretch out the div so it looks centered on the page
document.write('<img src="/images/spacer.gif" width="550" height="1"><br>');

// Create for used to pass information to pop-up viewer
document.write('<form name="forViewer">');
document.write('<input type="hidden" name="numofPics" value="' + numPics + '">');
document.write('<input type="hidden" name="picsDir" value="' + picDir + '">');
for (x=0; x<numPics; x++)
{
document.write('<input type="hidden" name="caption' + x + '" value="' + altCaptions[x] + '">');
}
document.write('</form>');
