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 custWindow(doc, w, h [,align, valign [, scroll] ] ) {

	function that opens window with size and optional location and scroll input

	arguments:
	'doc'		is the document that will load in the new window
	'w'			is the width of the window in pixels
	'h'			is the height of the window in pixels
	'align'		is the horizontal alignment (l, c, or r)
	'valign'	is the vertical alignment (t, m, or b)
	'scroll'	indicates whether or not to display scrollbars (yes or no)
*/
function custWindow(doc,w,h,align,valign,scroll,menubar) {
	if (custWindow.arguments.length < 7) {
		var menubar = 'no'
	}
	if (custWindow.arguments.length < 6) {
		var scroll = 'yes'
	}
	if (custWindow.arguments.length < 4) {
		var align = 'c'
		var valign = 'm'
	}
	topPos=0
	leftPos=0
	if (screen) {
		if (align == 'c') {
			leftPos = screen.width/2 - w/2
		} else {
			if (align == 'r') {
				leftPos = screen.width - w - 12
			}
		}
		if (valign == 'm') {
			topPos = screen.height/2 - h/2
		} else {
			if (valign == 'b') {
				topPos = screen.height - h - 45
			}
		}
	}
	custWin = window.open(doc,'custWin','toolbar=no,menubar='+menubar+',location=no,scrollbars='+scroll+',resizable=yes,width='+w+',height='+h+',left='+leftPos+',top='+topPos+'');
	custWin.document.close();
	custWin.focus();
}


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();
}

