//    * * * viewer script * * *

//	show(dir, no, i)
//
// 1. slideshow (parameter "no" < 100)
// 	dir= name of the directory for the images inside img/
// 	images must be named "cam1.jpg", "cam2.jpg", ...
// 	no = total number of images
// 	i = start with this image number
// 	slideshow will open in a 600x600 pixel window (default)
//
// 2. viewer
// 	dir= image name without extension, must reside in img/
// 	no = width (single image, must be greater than 49)
// 	i = single image height (see above)
//
//  global settings:
//      you may overwrite them before calling show()
//      example: <a href="javascript:wBgColor='blue';show('bsp',100,100);">

var wBgColor = "white";   // HTML color name or RGB value (#0000ff)
var wWidth = 600; // window width (for slideshow)
var wHeight = 600; // window height (for slideshow)

var n; 	// number of the actual image
//var underscore = new RexExp('_',' ');

function reset() {
	wBgColor = "white";
	wWidth = 600;
	wHeight = 600;
}

function show(dir, no, i)
{
	if(no < 50) { // display a series of jpg's
		next= (i >= no) ? 1 : i+1;
		w1=window.open("", "slideshow", "width="+ wWidth + ",height="+ wHeight +",scrollbars=no");
		if(window.focus) w1.focus();
		w1.document.open();
		w1.document.writeln("<HTML><HEAD><TITLE> " +dir+ ": " +i+" von "+no+" </TITLE>");
		w1.document.writeln("<STYLE TYPE='text/css'>\na:hover {cursor:e-resize}\n</STYLE>\n</HEAD>");
		w1.document.writeln("<BODY bgcolor='" + wBgColor + "'  topmargin=0 leftmargin=0 marginheight=0 marginwidth=0\">");
		w1.document.writeln("<TABLE width='100%' height='100%' align='center'>");
		w1.document.writeln("<TR><TD align=center valign=middle>");
		w1.document.writeln("<A HREF=javascript:opener.show('"+
			dir+"',"+no+","+next+ ");>");
		w1.document.writeln("<IMG src='img/"+dir+"/cam" +i+ ".jpg' border='0' ALT='next'></A>");
		w1.document.writeln("</TD></TR></TABLE></BODY></HTML>");
		w1.document.close();
	}else{ // single image
		imgsrc = (dir.indexOf(".") != -1)? dir : dir + ".jpg";
		wTitle = (dir.indexOf(".") != -1)? dir.substring(0, dir.indexOf(".")) : dir;
		w1=window.open("", wTitle, "width=" +no+ ",height=" +i+ ",scrollbars=no");
		wTitle = wTitle.replace(/_/g, ' ');
		//if(window.resizeTo) w1.resizeTo(no, i);
		if(window.focus) w1.focus();
		w1.document.open();
		w1.document.writeln("<HTML><HEAD><TITLE>" + wTitle + "</TITLE></HEAD>");
		w1.document.writeln("<BODY bgcolor='" + wBgColor + "' BACKGROUND='img/" +imgsrc+ "'>");
		w1.document.writeln("</BODY></HTML>");
		w1.document.close();
	}
}
