//   |----------------------------------------------------------//   | JavaSlideShow by Doug Simmons - Free for all use with    //   | email notification to the author (jester@orst.edu) upon  //   | the first usage (comments/suggestions?). Updates are 	//   | available as released, upon request.							//   |															//   | This file contains the engine to the JavaSlideShow.      //   | Modification are not recommended. Instead suggest		//   | modifications to the author..							//   |----------------------------------------------------------var CurrentSlide = "";var CurrentShow = "";var CURRENT_IMAGE = 0;var CURRENT_TEXT = 1;var CURRENT_SLIDESHOW_IMAGESET = 0;var CURRENT_SLIDESHOW_TEXTSET = 1;var myCurrentSlideShow;var SlideShowReel;var Parsed = false;//used to check if java is available from the client's browserfunction JavaIsAvailable(){	return ( navigator.javaEnabled() );}//used to check if clients browser is netscapefunction BrowserIsNetscape(){	if( navigator.appName == "Netscape" ) 		return true;}//used to change the image on the pagefunction ChangeImage(name,file) {		eval('document.images["'+name+'"].src="'+file+'"');}//used to construct our SlideShow Arrays.function buildArray(){ //Used to contruct an array	var a = buildArray.arguments;	for (i=0; i<a.length; i++)	{		this[i] = a[i];	}	  	this.length = a.length;}//parses the search part of the URL - "?show=2&slide=3"//once parsed it set the global vairables CURRENT_SLIDESHOW_IMAGESET, //CURRENT_SLIDESHOW_TEXTSET, CURRENT_IMAGE, and CURRENT_TEXT per the user's request. function parseSearchURL (){	var SearchURL = document.location.search;	var tempstring = "";	var tempvalue = "";	var foundEquals = false;		for ( i=0; i < SearchURL.length; i++ )	{		if ((SearchURL.charAt(i) != "?") && (SearchURL.charAt(i) != "&") && (i != SearchURL.length - 1))		{			if (SearchURL.charAt(i) == "=")			{				foundEquals = true;			}			else 			{				if (! (foundEquals) )				{					tempstring = tempstring + SearchURL.charAt(i);				}								else				{					tempvalue = tempvalue + SearchURL.charAt(i);				}			}		}		else		{			if (i == SearchURL.length - 1)			{				tempvalue = tempvalue + SearchURL.charAt(i);			}						tempstring = tempstring.toUpperCase();			tempvalue = tempvalue.toUpperCase();			if (tempstring == "SHOW") {				CurrentShow = tempvalue;			}			if (tempstring == "SLIDE") {				CurrentSlide = tempvalue;			}			tempstring = "";			tempvalue = "";			foundEquals = false;		}	}	if (CurrentShow != "")	{		if (( CurrentShow > (SlideShowReel.length / 2)) || ( CurrentShow < 1 ))		{			alert("The specified slide show does not exist.\nStarting with the first show in the reel.");		}		else 		{			CURRENT_SLIDESHOW_IMAGESET = ((CurrentShow * 2) - 2);			CURRENT_SLIDESHOW_TEXTSET = ((CurrentShow * 2) - 1);		}	}	if (CurrentSlide != "")	{		CURRENT_IMAGE = ((CurrentSlide * 2) - 2);		CURRENT_TEXT = ((CurrentSlide * 2) - 1);	}	Parsed = true;} //initiates the slideshow, loading the Reel, the current show, etc.//returns the Current Slideshow array. function InitSlideShow() {	if (! ( Parsed ) )		parseSearchURL();  //determine if user has defined a specific show.	var SlideShowArray = new buildArray();	var ARRAY_LENGTH = ((SlideShowReel[CURRENT_SLIDESHOW_IMAGESET].length) + (SlideShowReel[CURRENT_SLIDESHOW_TEXTSET].length));	SlideShowArray.length = ARRAY_LENGTH; 															 	if (! (SlideShowReel[CURRENT_SLIDESHOW_IMAGESET].length == SlideShowReel[CURRENT_SLIDESHOW_TEXTSET].length) )	{		alert("Error::Number of Images in SlideSet <> Number of Text in SlideSet");		return "error";	}	else										 										 	{		j = -1;		for ( i=0; i < ARRAY_LENGTH - 1; i++)		{	  		j = j + 1;			SlideShowArray[j] = SlideShowReel[CURRENT_SLIDESHOW_IMAGESET][i];			j = j + 1;			SlideShowArray[j] = SlideShowReel[CURRENT_SLIDESHOW_TEXTSET][i];		}		return SlideShowArray;	}}//Preloads the next image of the current slide show on the reel.function PreLoadNextImage (){	var Image1 = new Image();	if (CURRENT_IMAGE > myCurrentSlideShow.length - 2)		return;	//we have reached the end of our SlideShowArray	else if (CURRENT_IMAGE != 0)		Image1.src = myCurrentSlideShow[CURRENT_IMAGE + 2];	else		Image1.src = myCurrentSlideShow[CURRENT_IMAGE];	return; }//Advances the slide show.function AdvanceSlideShow (){		if ((CURRENT_TEXT != myCurrentSlideShow.length - 1) && (CURRENT_IMAGE != myCurrentSlideShow.length - 2))	{		CURRENT_IMAGE = CURRENT_IMAGE + 2;		CURRENT_TEXT = CURRENT_TEXT + 2		ChangeImage("SlideImage", myCurrentSlideShow[CURRENT_IMAGE]);		if (! BrowserIsNetscape () ) {			SlideText.innerHTML = myCurrentSlideShow[CURRENT_TEXT];		}		else {			document.SlideText.document.write(myCurrentSlideShow[CURRENT_TEXT]);			document.SlideText.document.close();		}		PreLoadNextImage();	}		else if ((CURRENT_SLIDESHOW_IMAGESET != SlideShowReel.length - 2) && (CURRENT_SLIDESHOW_TEXTSET != SlideShowReel.length - 1))	{		CURRENT_SLIDESHOW_IMAGESET = CURRENT_SLIDESHOW_IMAGESET + 2;		CURRENT_SLIDESHOW_TEXTSET = CURRENT_SLIDESHOW_TEXTSET + 2;		CURRENT_IMAGE = 0;		CURRENT_TEXT = 1;		myCurrentSlideShow = InitSlideShow();		if (myCurrentSlideShow != "error") {			ChangeImage("SlideImage", myCurrentSlideShow[CURRENT_IMAGE]);			if (! BrowserIsNetscape () ) {				SlideText.innerHTML = myCurrentSlideShow[CURRENT_TEXT];			}			else {				document.SlideText.document.write(myCurrentSlideShow[CURRENT_TEXT]);				document.SlideText.document.close();			}			PreLoadNextImage();		}	}	else	{		alert("You have reached the end of the slide reel.");	}}//reverts the slide show to previously viewed slides.function RevertSlideShow (){	if ((CURRENT_TEXT != 1) && (CURRENT_IMAGE != 0))	{		CURRENT_IMAGE = CURRENT_IMAGE - 2;		CURRENT_TEXT = CURRENT_TEXT - 2;		ChangeImage("SlideImage", myCurrentSlideShow[CURRENT_IMAGE]);		if (! BrowserIsNetscape () ) {			SlideText.innerHTML = myCurrentSlideShow[CURRENT_TEXT];		}		else {			document.SlideText.document.write(myCurrentSlideShow[CURRENT_TEXT]);			document.SlideText.document.close();		}	}	else if ((CURRENT_SLIDESHOW_TEXTSET !=1 ) && (CURRENT_SLIDESHOW_IMAGESET !=0))	{		CURRENT_SLIDESHOW_IMAGESET = CURRENT_SLIDESHOW_IMAGESET - 2;		CURRENT_SLIDESHOW_TEXTSET = CURRENT_SLIDESHOW_TEXTSET - 2;		myCurrentSlideShow = InitSlideShow();		CURRENT_IMAGE = myCurrentSlideShow.length - 2;		CURRENT_TEXT = myCurrentSlideShow.length - 1;		if (myCurrentSlideShow != "error") {			ChangeImage("SlideImage", myCurrentSlideShow[CURRENT_IMAGE]);			if (! BrowserIsNetscape () ) {				SlideText.innerHTML = myCurrentSlideShow[CURRENT_TEXT];			}			else {				document.SlideText.document.write(myCurrentSlideShow[CURRENT_TEXT]);				document.SlideText.document.close();			}		}	}	else	{		alert("You have reached the beginning of the slide reel.");	}	}//Inserts the Slide Image on the projector page.function InsertSlideImage (){	if ((CURRENT_IMAGE > myCurrentSlideShow.length - 2) || (CURRENT_IMAGE < 0))	{		alert("The specified slide does not exist in this show.\nStarting with the first slide in the show.");		CURRENT_IMAGE = 0;		CURRENT_TEXT = 1;	}			document.write("<div align=center><img name=\"SlideImage\" src=\"" + myCurrentSlideShow[CURRENT_IMAGE] + "\" alt=\"SlideImage\"></div>");}//Inserts the Slide Text on the projector page.function InsertSlideText (){   if (! BrowserIsNetscape() ) {	document.write("<div align=center><span class=normaltext id=\"SlideText\">" + myCurrentSlideShow[CURRENT_TEXT] + "</span></div>" );   }   else    { 	 //document.write("<layer id=\"SlideText\">" + myCurrentSlideShow[CURRENT_TEXT] + "</layer>" );	 document.write("<br>" + myCurrentSlideShow[CURRENT_TEXT] + "<br>");   }}//Inserts the slide buttons onto the slide page... //Input required is the image location of the buttons to use.. //Note:: it looks for the images "previous.gif" and "next.gif"function InsertSlideButtons ( image_location ){	var showNext = ((CURRENT_SLIDESHOW_IMAGESET + 2) / 2);	var showPrev = showNext;	var slideNext = (((CURRENT_IMAGE + 2) / 2) + 1);	var slidePrev = (((CURRENT_IMAGE + 2) / 2) - 1);	if ( ( CURRENT_IMAGE == 0) && (CURRENT_SLIDESHOW_IMAGESET != 0) )	{		showPrev = showPrev - 1; //decrement show for previous button.		slidePrev = (SlideShowReel[CURRENT_SLIDESHOW_IMAGESET - 2].length);	}	if ( (CURRENT_IMAGE == (myCurrentSlideShow.length - 2)) && (CURRENT_SLIDESHOW_IMAGESET != (myCurrentSlideShow.length - 2)) )	{		showNext = showNext + 1; //increment show for next button.		slideNext = 1;	}   document.write("<table border=0 cellpadding=2 cellspacing=2 align=center>");  //start the table that contains the buttons.   document.write("<tr>");        if (! BrowserIsNetscape() )    { //Internet Explorer or Other.			document.write('<td onclick="javascript:RevertSlideShow();" style="cursor:hand;"><img src="' + image_location + 'images/pictures/previous.gif" alt="Previous" width="80" height="30" border="0"></td>');			document.write('<td onclick="javascript:AdvanceSlideShow();" style="cursor:hand;"><img src="' + image_location + 'images/pictures/next.gif" alt="Next" width="80" height="30" border="0"></td>');   }   else    { //Netscape.		if ( (CURRENT_SLIDESHOW_IMAGESET != 0) || (CURRENT_IMAGE != 0) )			document.write('<td><a href="' + location.pathname + '?show=' + showPrev + '&slide=' + slidePrev + '"><img src="' + image_location + 'images/pictures/previous.gif" alt="Previous" width="80" height="30" border="0"></a></td>');		if ( (CURRENT_SLIDESHOW_TEXTSET != (SlideShowReel.length - 1)) || (CURRENT_TEXT != (myCurrentSlideShow.length - 1)) )			document.write('<td><a href="' + location.pathname + '?show=' + showNext + '&slide=' + slideNext + '"><img src="' + image_location + 'images/picturesd/next.gif" alt="Next" width="80" height="30" border="0"></a></td>');   }      document.write("</tr>");   document.write("</table>"); //end the table that contains the buttons.}