// ss.js
pic = new Array(32);
har = new Array(32);
war = new Array(32);
lab = new Array(32);
var showMode;
var curPicIndex;
var lastPictureIndex;
var AUTO = 1;
var MAN = 0;
var delayTime = 2000;
/*
SAMPLE PAGE:


<!-- ss.html-->
<html>
<head>
<title>
housess.html
</title>

<SCRIPT LANGUAGE="JavaScript" SRC="http://www.lenshouse.net/JS/ss.js"></SCRIPT>

<!-- set values -->
<script Language="JavaScript">
var	pichome="http://where_pictures_are/";



pic[0] = pichome + "house/delmar.gif";
har[0] = 320;
war[0] = 420;
lab[0] = "The house";


pic[1] = pichome + "house/delmar2.jif"
har[1] = 320;
war[1] = 420;
lab[1] = "Out Front";

pic[2] = "http://members.directvinternet.com/lenlutz1/pics/house/outfront.jpg"
har[2] = 320;
war[2] = 420;
lab[2] = "The Garden";

pic[3] = "http://members.directvinternet.com/lenlutz1/pics/house/back_yard_summer.jpg"
har[3] = 320;
war[3] = 420;

</script>


</head>
<body>
<center>
<h1>
House Slide Show (ss)
</h1>


<script language="JavaScript">
	startSlideShow();
</script>

</center>
</td>
</tr>
</table>

</center>
</body>
</html>

END SAMPLE
*/ 


function writeImg()
{
	document.write('<img name="slide" color="#CCCCCC"');
 	document.write('border="1" width="400" height="300" src="" ');
	document.writeln('>');
	document.writeln('<br>');

	document.writeln('<table width="413" border="0" ');
	document.writeln('cellpadding="0" cellspacing="5">');
	document.writeln('<tr>');
	document.writeln('<td>');
	document.writeln('<center>');
	return;
} // end writeImg()

function writeControls()
{
	butAr = new Array(4);
	var buttonHome="http://www.lenshouse.net/JS/ssbuttons/";


	butAr[1] = buttonHome + "slideshowPrev.gif";
	butAr[2] = buttonHome + "slideshowStop.gif" ;
	butAr[3] = buttonHome + "slideshowPlay.gif";
	butAr[4] = buttonHome + "slideshowNext.gif" ;

	document.write('<a href="javascript: cprev()">');
	document.write('<img src=" '+ butAr[1] + '" ');
	document.write('name="prb" title="Previous"');
	document.write('border="0" width="55" height="50"></a>');

	document.write('<a href="javascript: cstop()">');
	document.write('<img src=" ' + butAr[2] + '" ');
	document.write('name="stb" title="Stop"');
	document.write('border="0" width="55" height="50"></a>');


	document.write('<a href="javascript: cplay()">');
	document.write('<img src=" ' + butAr[3] + '" ');
	document.write('name="plb" title="Play"');
	document.write('border="0" width="55" height="50"></a>');

	document.write('<a href="javascript: cnext()">');
	document.write('<img src= "' + butAr[4] + '" ');
	document.write('name="nxb" title="Next"');
	document.write('border="0" width="55" height="50"></a>');

/*
	// form with image number
	document.write('<form name="countForm">\n');
	document.write('Image # ');
	document.write('<input type=text name="counterText" size="2">\n');
	document.write('</form>\n');
*/

	// lable box
	document.writeln('<form name="labelForm">');
	document.writeln('<input type=text name="lableText" readonly=true ');
	document.writeln('size="30" >');
	
	// document.writeln('STYLE="color: blue; font: 20pt bold" size="8">');
	document.writeln('</form>');

	return;
} // end writeControls()


function startSlideShow() 
{ 
	writeImg();
	writeControls();

	// fiqure out last PictureIndex
	for(var inx = 0 ; inx < pic.length ; inx++) {
		if(typeof(pic[inx]) == 'undefined') {
			lastPictureIndex = inx - 1;
			break;
		}
	}
	showMode = AUTO 
	curPicIndex=0 
	showSlide();
	return; 
} 


function showSlide() 
{ 
	var a = curPicIndex + 1;
	var b = lastPictureIndex + 1;

	document.slide.src = pic[curPicIndex];	
	document.slide.height = har[curPicIndex]
	document.slide.width = war[curPicIndex];
//	document.slide.title = lab[curPicIndex];
	document.slide.title = "Image " + a + " of " + b;


	if(typeof(lab[curPicIndex]) == 'undefined') {
 		document.labelForm.lableText.value =  "      "
	}
	else {
		 document.labelForm.lableText.value = lab[curPicIndex];
	}

		// if using counter
//	document.countForm.counterText.value = curPicIndex;

	if(showMode == AUTO)	{ 
		curPicIndex = curPicIndex + 1 
  			document.plb.title="Playing";
  			document.stb.title="Press To Stop";

		if(curPicIndex > lastPictureIndex) 
			curPicIndex = 0 

		timedelay(); 
	} 
	else {
		document.stb.title="Stopped";
		document.plb.title="Press To Play";
	}
	return; 
}  // end showSlide()


function timedelay() 
{ 
	timerID = setTimeout("showSlide()",delayTime); 
} 


function cprev() 
{ 
	/*
	if(showMode == AUTO) { 
		// was indexed by prev call to showSlide();
		curPicIndex  = curPicIndex  - 1;
		if(curPicIndex < 1) 
			curPicIndex = lastPictureIndex 
		return;
	}
	*/

	showMode = MAN 
 	curPicIndex  = curPicIndex  - 1;
	if(curPicIndex < 1) 
		curPicIndex = lastPictureIndex 
	showSlide() 
	return;	
} 


function cplay() 
{ 
	showMode = AUTO 
	showSlide();
} 

function cstop()
{
	showMode = MAN;
}

function cnext() 
{ 
	if(showMode == MAN) { 
		// was NOT indexed by prev call to showSlide();
		if((curPicIndex = curPicIndex + 1 ) > lastPictureIndex)
			curPicIndex = 0 
	}

	showMode = MAN;
	showSlide(); // already indexed by prev call to showSlide()

	return; 
} // end cnext
									

// end ss.js
