<!--
  /* picview javascript include */
  /* contains preloadall, loadcheck, and showNextPic functions */
  /* contains viewpic, winclose and setRadioPic functions */

var TimerID;
var waitvar = 5000;  //  5 secs
var ix = 0;
var keepgoing = 0;



function showNextPic() {
	if ((ix < document.links.length) && (keepgoing == 1) && (waitvar > 0)) {
		jsrtn = "" + document.links[ix];
		if (jsrtn.indexOf("viewpic") > -1 && (jsrtn.indexOf(",'P',") == -1) && (jsrtn.indexOf(",'M',") == -1))
		{	// yes it's a link we want , skip panoramas and movies    7/1/05
				jsrtn = jsrtn.substring(11,999);
				eval(jsrtn);		// exec picview from array of links - show the pic
			ix++;		// next link
			clearTimeout(TimerID);
        		TimerID=setTimeout("showNextPic()",waitvar);  // wait x secs before recursing
		}
		else {	// skip this entry and recurse immediately
			ix++;		// next link
    		    	showNextPic();  	// go round again
		}
	}
	else if (ix >= document.links.length) {
		if (waitvar == 10001) {		// changed to = versus > 10000
			ix = 0;		// start over
        		showNextPic();
		}
		else {
		keepgoing = 0;
		winclose();		// close window
		}
	}
}

function loadcheck() {
	loadedimgs++;		// show status of how many pre-loaded
	var myNewOption = new Option("pre-loading pics. " + loadedimgs + "/" + imgcount + " ","5000");
	document.formzero.ShowCtl.options[0] = myNewOption;
	document.formzero.ShowCtl.options[0].selected = -1;	// 12/12/01
	if (loadedimgs >= imgcount) {	
		// enable options for slide show
		document.formzero.ShowCtl.options[0] = new Option("Show All Pics...","5000");
		document.formzero.ShowCtl.options[1] = new Option("2 Sec Intervals","2000");
		document.formzero.ShowCtl.options[2] = new Option("5 Sec Intervals","5000");
		document.formzero.ShowCtl.options[3] = new Option("10 Sec w Repeat","10001");
// add code for wait for click option  - 999s?
		document.formzero.ShowCtl.options[4] = new Option("wait for click","9999999");
		document.formzero.ShowCtl.options[0].selected = -1;
	}
}

imgs = []; // array for preloading images
var loadedimgs = 0;
var imgcount = 0;
function preloadall() {
	ix = 0;
	loadedimgs = 0;
	imgcount = 0;
	while (ix < document.links.length) {
		picurl = "" + document.links[ix];
		if (picurl.indexOf("viewpic") > -1 ) {	// yes it's a link we want
			imgcount++;
			picurl = picurl.substring(20,99);	// chop off left end
	       		picurl = picurl.replace(/','[HVP]','3'/gi, "-2.jpg");	//  12/12/01	
	       		picurl = picurl.replace(/','[HVP]','2'/gi, "-2.jpg");	// fix parameters		
	       		picurl = picurl.replace(/','[HVP]','1'/gi, "-1.jpg");	// to make real URL
			picurl = picurl.substr(0,picurl.indexOf("jpg")+3); // chop off right 12/12/01
// alert("loading url=" + picurl );
			imgs[ix]=new Image();                                                                                                               
			imgs[ix].src = picurl; 	// preload
		}
		ix++;
	}
	ix = 0;		// now set trap for load-completions  12/12/01
	while (ix < document.links.length) {
		picurl = "" + document.links[ix];
		if (picurl.indexOf("viewpic") > -1 ) {	// yes it's a link we want
			imgs[ix].onload = loadcheck;	// check when load completes 
		}
		ix++;
	}
}


var maxpic;
var HorV;
var sz = 1;
var suffix = "-1.jpg";
var longside = 660;
var shortside = 450;
var ww = 0;
var hh = 0;
var Vwin = ""; var Hwin = "";

function viewpic(image,HorV,maxpic,descr) {
	if (maxpic == 3) {     //  we have sizes 1 and 2 to choose from 
		if (document.formzero.psize[1].checked) {
			suffix = "-2.jpg";
			longside = 800;
			shortside = 620;
		} else {
			suffix = "-1.jpg";
			longside = 680;
			shortside = 470;
		}
	} else { 
		if (maxpic == 2) {  //  we have only size 2 
			suffix = "-2.jpg";
			longside = 800;
			shortside = 620; 
		} else if (maxpic == 4) {  //  we have only size 4 
			suffix = "-4.jpg";
			longside = 1100;
			shortside = 780; 
		} else {                   //  we have only size 1 
			suffix = "-1.jpg";
			longside = 680;
			shortside = 470;
		}
	}


	if (HorV == "V") {
		hh = longside;
		ww = shortside;
//		if (!Vwin.closed && Vwin.location && navigator.userAgent.toLowerCase().indexOf('chrome') > -1)  {Vwin.close()};   // If Chrome close it
		if (!Vwin.closed && Vwin.location) { 	
			wi = Vwin; 	//already open, don't open again
			wi.focus();	
		} 
		else {
			wi=window.open("", "wiV" ,"toolbar=no,width="+ww+",height="+hh+",left="+315+",scrollbars=yes,location=no,directories=no,status=yes,menubar=no,resizable=yes");
			if (!wi.opener) wi.opener = self;
			wi.focus(); 	
			Vwin = wi;	// save window handle
		}
	} else if (HorV == "P"){	// panorama, open as full screen
		ww = longside;
		hh = shortside;
//		if (!Hwin.closed && Hwin.location && navigator.userAgent.toLowerCase().indexOf('chrome') > -1)  {Hwin.close()};   // If Chrome close it
		if (!Hwin.closed && Hwin.location) {
			wi = Hwin;  	//already open, don't open again

		}
		else {
			wi=window.open("", "wiH" ,"toolbar=no,fullscreen=yes,scrollbars=yes,location=no,directories=no,status=yes,menubar=no,resizable=yes");
			if (!wi.opener) wi.opener = self;
			Hwin = wi;	// save window handle
		}
	} else {
		ww = longside;
		hh = shortside;
//	 	if (!Hwin.closed && Hwin.location && navigator.userAgent.toLowerCase().indexOf('chrome') > -1)  {Hwin.close()};   // If Chrome close it
		if (!Hwin.closed && Hwin.location) {
			if ((window.Vwin) && (!Vwin.closed)) {Vwin.close()};   // close vertical if its open
			wi = Hwin;  	//already open, don't open again
			wi.focus();	
 		}
		else {
			wi=window.open("", "wiH" ,"toolbar=no,width="+ww+",height="+hh+",left="+200+",scrollbars=yes,location=no,directories=no,status=yes,menubar=no,resizable=yes");
			if (!wi.opener) wi.opener = self;
			wi.focus(); 	
			Hwin = wi;	// save window handle
		}
	}

	wi.document.writeln('<html><head><title> Coleman Home Page - '+unescape(descr)+'</title>');
// add code for panoramas
// 000000111111111122222222223333333333444444444455555555556666666666
// 456789012345678901234567890123456789012345678901234567890123456789
	if (HorV == "P") {
		wi.document.writeln('<applet code="pmvr.class" width=100% height=650 codebase="http://dcolemans.com">');
		wi.document.writeln('<param name=image value="'+image+suffix+'">');
		wi.document.writeln('<param name=auto value=20x1>');
		if (descr.indexOf("360") > -1 ) {	// is it a 360?
			wi.document.writeln('<param name=view value=360>');
		}
		wi.document.writeln('<param name=delay value=0>');        // was value=5000
		wi.document.writeln('<param name=vcenter value=600>');    // was value=300
		wi.document.writeln('<param name=background value=000000>');
		wi.document.writeln('</applet>');
		wi.document.writeln('</head><BODY BGCOLOR="#000000" TEXT="#FFFFFF" LINK="#FFFF00" VLINK="#FF8000" ALINK="#FF0000"');
	} else {
// original code follows
		wi.document.writeln('<script> var curwidth=0;var curheight=0;var aspect=0');
		wi.document.writeln('function clk(X, Y) {if (window.event.ctrlKey){clkright(X, Y)}else {clkleft(X, Y)}}');
		if (keepgoing == 1) {		// we're flipping thru slides
			wi.document.writeln('function clkleft(X, Y) {if (opener.keepgoing == 1) {opener.keepgoing = 0;document.images[0].alt="Click to Resume";} else {opener.keepgoing = 1;document.images[0].alt="Click to Pause";opener.showNextPic();}}');	//stop the show
			wi.document.writeln('function clkright(X, Y) {asdf = 0;}');		// ignore this
// add code here with else if where click left goes forward to next slide - set keepgoing to 1
		} else {			// it's showing one at a time - allow zooming
			if (document.all) {  // only  if  document.all object is supported 
				wi.document.writeln('function clkleft(X, Y) {winWidth=document.body.offsetWidth;winHeight=document.body.offsetHeight;scrltoY = (((document.body.scrollTop + Y) / curheight) * 1.2 * curheight)-Y;scrltoX = (((document.body.scrollLeft + X) / curwidth) * 1.2 * curwidth)-X;curwidth=curwidth * 1.2;curheight=curheight * 1.2;img1.style.width=curwidth;img1.style.height=curheight;self.scrollTo(scrltoX , scrltoY)}');
				wi.document.writeln('function clkright(X, Y) {winWidth=document.body.offsetWidth;winHeight=document.body.offsetHeight;scrltoY = (((document.body.scrollTop + Y) / curheight) * .8 * curheight)-Y;scrltoX = (((document.body.scrollLeft + X) / curwidth) * .8 * curwidth)-X;curwidth=curwidth * .8;curheight=curheight * .8;img1.style.width=curwidth;img1.style.height=curheight;self.scrollTo(scrltoX , scrltoY)}');
			}
		}
		wi.document.writeln('function resetsize() {if (aspect != 0) {img1.style.width="100%";curwidth=img1.style.pixelWidth;img1.style.height=(curwidth / aspect);curheight=img1.height}}');
		wi.document.writeln('function savesize() {aspect=img1.width / img1.height;}');
		wi.document.writeln('</scr' + 'ipt>');
		wi.document.writeln('</head><BODY BGCOLOR="#000000" TEXT="#FFFFFF" LINK="#FFFF00" VLINK="#FF8000" ALINK="#FF0000"');
		if (keepgoing == 1) {		// we're flipping thru slides
			if (document.all)  {   //  only  if  document.all object is supported  
				wi.document.writeln('  onload="savesize();resetsize()" onresize="resetsize()" </a><center><div><a href="Javascript:void(null)" onclick="clk(event.x, event.y)"> <img src="'+image+suffix+'" alt="click to Pause" id="img1"></div></a>');
			} else {		// NS
				wi.document.writeln('</a><center><a href="Javascript:void(null)" onclick="Javascript:if (opener.keepgoing == 1) {opener.keepgoing = 0;return;} else {opener.keepgoing = 1;opener.showNextPic();}"> <img src="'+image+suffix+'" alt="Click to Pause/Resume" title="Click to Pause/Resume" id="img1" width="100%"></a>');
			}
		} else {
			if (document.all)   {   //   only  if  document.all object is supported
				wi.document.writeln('  onload="savesize();resetsize()" onresize="resetsize()" </a><center><div><a href="Javascript:void(null)" onclick="clk(event.x, event.y)"> <img src="'+image+suffix+'" alt="Click to Zoom In, Ctl Click to Zoom Out" id="img1"></div></a>');
			} else {		// NS
				wi.document.writeln('</a><center><a><img src="'+image+suffix+'" WIDTH="100%"></a>');
			}
		}
	}
	wi.document.write('</body></html>');  
	wi.document.close(); 
	wi.focus();
}


function winclose() {
	if ((window.Hwin) && (!Hwin.closed)) {Hwin.close()};   
// if window exists & is open, close it
	if ((window.Vwin) && (!Vwin.closed)) {Vwin.close()};   
// if window exists & is open, close it
}



function setRadioPic(returnVal) {
 if (returnVal == 1) {document.formzero.psize[0].checked=true}	//don't preload images
 else           {document.formzero.psize[1].checked=true;
		preloadall();  					// preload images
 }	
}

//-->

