function slideShow(direction) {
	if (document.images) {
		thisPicture = thisPicture + direction
		if (thisPicture > imageCount) {
			thisPicture = 0
		}
		if (thisPicture <  0) {
			thisPicture = imageCount
		}
		
		document.getElementById('slideshow-image').innerHTML = imageArray[thisPicture];
		document.getElementById('slideshow-enlarge').innerHTML = detailArray[thisPicture];
		document.getElementById('slideshow-wrapper').style.width = document.getElementById('slideshow-current-image').style.width;
		document.getElementById('slideshow-caption').innerHTML = captionArray[thisPicture];
	}
}


function thumbnailReplace(thisPicture) {
	if (document.images) {
		document.getElementById('thumbnail-replace-main-image').innerHTML = mainimageArray[thisPicture];
		document.getElementById('thumbnail-replace-enlarge').innerHTML = detailArray[thisPicture];
		document.getElementById('thumbnail-replace-caption').innerHTML = captionArray[thisPicture];
		document.getElementById('thumbnail-replace-wrapper').style.width = widthArray[thisPicture];
		document.getElementById('thumbnail-replace-thumbnail-wrapper').innerHTML = thumbnailArray[thisPicture];
	}
}

function thumbnailGrid(thisPicture, Columns) {
	var ie = document.all;

	thumb_html = "<table class='thumbnail-replace-thumbnail'><tr>";
	c = 0; i = 0;
	while (i < thumbnailArray.length) {
		if (i == thisPicture) { i++; continue; }

		if (c >= Columns) {
			thumb_html = thumb_html + '<tr>';
			c = 0;
		}
		thumb_html = thumb_html + "<td>" + thumbnailArray[i] + "</td>";
		i++; c++;
		if (c >= Columns) {
			thumb_html = thumb_html + '</tr>';
		}
	}
	while (c < Columns) {
		thumb_html = thumb_html + "<td>" + blankImage + "</td>";
		c++;
	}
	thumb_html = thumb_html + "</table>";

	if (ie) {
		if (document.images) {
			document.all['thumbnail-replace-main-image'].innerHTML = mainimageArray[thisPicture];
			document.all['thumbnail-replace-enlarge'].innerHTML = detailArray[thisPicture];
			document.all['thumbnail-replace-caption'].innerHTML = captionArray[thisPicture];
			document.all['thumbnail-replace-thumbnail-wrapper'].innerHTML = thumb_html;
		}
	} else {
		if (document.images) {
			document.getElementById('thumbnail-replace-main-image').innerHTML = mainimageArray[thisPicture];
			document.getElementById('thumbnail-replace-enlarge').innerHTML = detailArray[thisPicture];
			document.getElementById('thumbnail-replace-caption').innerHTML = captionArray[thisPicture];
			document.getElementById('thumbnail-replace-wrapper').style.width = widthArray[thisPicture];
			document.getElementById('thumbnail-replace-thumbnail-wrapper').innerHTML = thumb_html;
		}
	}
}



function popUp(image,width,height,caption,closebutton) {
	
	popup = custWindow('',parseInt(width)+50,parseInt(height)+100,'c','m');
	var popup = custWin.document;
	var content = '';
	
	content += '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"\n';
	content += '"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">\n';
	content += '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">\n';
	content += '<head>\n';
	content += '<title>Preview</title>\n';
	content += '<style type="text/css">@import url("/mc_css/default.css");</style>\n';
	content += '</head>\n';
	content += '<body>\n';
	content += '<table cellpadding="5" cellspacing="0" border="0" width="100%" style="margin-top: 15px;">\n';
	content += '<tr><td align="center"><a href="javascript:self.close();"><img src="'+image+'"></a></td></tr>\n';
	content += '<tr><td align="center">'+caption+'</td></tr>\n';
	content += '<tr><td align="center"><a href="javascript:self.close();">'+closebutton+'</a></td><tr>\n';
	content += '</table>\n';
	content += '</body>\n';
	content += '</html>\n';

	popup.write(content);
	popup.close();
}

