/*
	A small global data file with the methods and variable common to all 
	versions of slides.
*/

var Index=0;
var StartStop = true;
var Direction = true;  // true is for forward, false is for revers


var OldTimeOutId, TimeOutId = -666;
var Milliseconds = 1000; // for the timeout routines
var MaxFrameRate = 60;
var MinFrameRate = 5;
var CurrentFrameRate = 30;

var Tic;
var NumSeconds;
var PauseTimeId;
var OldPauseTimeId;
var ElapsedTime
var HelpWidth = 640;
var HelpHeight =  480;

var TitleStyleName = "title";

var PcNNControlTitleStyleSheet =
".title {  font-family: Arial, Helvetica, sans-serif; font-size: 18px; font-weight: 600; color: #000000}";

var PcIEControlTitleStyleSheet =
".title {  font-family: Arial, Helvetica, sans-serif; font-size: 18px; font-weight: 400; color: #000000}";


var LoopState = true;

function increment( ){
  debug.writeln("increment()" + " " + Index);
 Index++;
 if (Index >= ThumbInfo.length){
   Index=0;
 }
}
function decrement( ){
  Index--;
 if (Index <= 0){
   Index=ThumbInfo.length;
 }
}


/*
  Write out the html to the Slide Show window 
  We have an interesting problem here, we need the documentWidth and
  documentHeight but we cant get them until the document in which they
  reside exist.  the document can't exist until we open the window,
  write to the window and then close the window.  this will cause 
  a flash of BLACK with nothing in it .  during the time the window
  blanks I have to complete the calls 
*/


function DisplaySlide(){
   var slideDoc = self.slideWindow.document;
  // IE 5 says that document is not an object, look for workaround
// trying to get around the geocities ad square problem


  slideDoc.open();

  slideDoc.writeln("<html><head>");
  slideDoc.writeln("<title>");
  slideDoc.writeln("N# " + ((Index/3) + 1) +" " + Picture[Index]);
  slideDoc.writeln("</title>\n");
  slideDoc.writeln("<style type=\"text/css\">);");
  slideDoc.writeln("<!--\n");
  slideDoc.writeln(CaptionStyleSheet + CaptionColor + '}');
  slideDoc.writeln("-->");
  slideDoc.writeln("</style>");
  slideDoc.writeln("</head>\n");

  slideDoc.writeln("<body bgcolor=\"#000000\" text=\"#FFFFFF\">\n");

  slideDoc.write("<center>\n<img name=\"slide\" src=\"");
  slideDoc.writeln(Picture[Index] +'\">');


  var titleStr = new String(Picture[Index+2]);


    slideDoc.write("<br><br>\n<span class=\"caption1\">");

  slideDoc.write(Picture[Index+2]);
  slideDoc.write("\n</span>\n</center>\n</body>\n</html>");
  slideDoc.close();


}



/* global variables to try getting around the IE5 problem. For some reason
  IE5 will not let me pass parameters to the setTimeout function another
  problem revolves around the window creation size, IE always comes up short
  in the sizing of windows.  Need to add padding to the size
*/

function SlideFunc() {
  debug.writeln("Called SlideFunc()");
//  DisplaySlide(Index);
    DisplayPicture(TheFrame, Index);

  if ( Direction)
    increment();
  else
    decrement();

  if ( StartStop == true){
  debug.writeln("What the FUCK");
   TimeOutId = window.setTimeout(SlideFunc, CurrentFrameRate * Milliseconds);
  }
  else {
     self.clearTimeout(TimeOutId);	
  }
}


/* the truth about setTimeout(), it spawns a thread to execute your function
   your time out function is run in the thread, while the current code
   continues to exectute.  
*/

function displayInWindow(beforeFunc, afterFunc, documentId){

    if (Tic < self.NumSeconds) {
        Tic=Tic+1;
        PauseTimeId = setTimeout('beforeFunc(' + documentId + ')'
               ,Milliseconds);       
    }
    else {

    self.ElapsedTime = Tic;
     Tic = 0;
     self.NumSeconds = 0;
     self.clearTimeout(PauseTimeId);
     afterFunc(documentId);
    }
}



function pause(secondsToPause, func2Execute){
   self.NumSeconds = secondsToPause;
   animate(func2Execute);
 
}



// Acutaly creates the slide controler
function initSlideController(outerWidth, outerHeight){


// lets see what platform we are on
// move the control window

/*
  if (its.nn) {
    outerHeight = outerHeight - heightDecorationSize;
    outerWidth = outerWidth - widthDecorationSize;
  }
  else {
    outerHeight = outerHeight - IeHeightOffset;
    outerWidth = outerWidth - widthDecorationSize;
  }
*/
// in case user opened the file itself
  if (self.name != "slideControl") {
      self.name = "slideControl";
      resizeTo( outerWidth, outerHeight); // the controler browser window

  }
  if ( its.ie ) {
     moveTo( screen.width - outerWidth, 
            screen.height - outerHeight - (5 * heightDecorationSize) );
  }
  else {
     moveTo( screen.width - outerWidth, 
        screen.height - outerHeight - 3 * heightDecorationSize);
 }

// window can't be created until after the body tag

}


  
/*
	there is an undocumented IE function start() so we must call this
	startApplet()
*/

function  writeStyleSheet(documentId, styleSheetString){
  documentId.writeln('<style type="text/css">');
  documentId.writeln('<!-- ');
  documentId.writeln(styleSheetString);
  documentId.writeln('--> ');
  documentId.writeln('</style>');
}

// Uses the xxxxxxxC.htm global ControlTitleStr
function displayTitle(documentId, titleStr){
  var styleSheet2use;
  documentId.open();
  documentId.writeln('<HTML><HEAD>');

  // test for mac or pc here before writing it out
  if (navigator.family == 'ie4') {
      styleSheet2use = PcIEControlTitleStyleSheet;
  }
  else if (navigator.family == 'nn4') {
     styleSheet2use = PcNNControlTitleStyleSheet;
  }
  writeStyleSheet(documentId,styleSheet2use);

  documentId.writeln('</HEAD>\n');
  writeBodyStart(documentId, BackgroundColor);
  documentId.writeln('<CENTER><DIV class="' + TitleStyleName + '">');

  documentId.writeln(titleStr);
  documentId.writeln('</DIV></CENTER>');
  documentId.writeln('</BODY>\n</HTML>');
  documentId.close();
}

function clearDocument(documentId, bGColor) {
   documentId.open();
   documentId.writeln("<html><head></head><body");
   documentId.writeln('BGCOLOR="' + bGColor + '"></body></html>');
   documentId.close();
}

function writeBodyStart(documentId, bGColor){
   documentId.writeln('<body bgcolor="' + bGColor + '">');
}

