var bhref;
var newwin   = null;
var picIndex = null;
var holdImg  = null;
var pathPics = null;
var maxPics  = null;
var suffix   = null;
var cableSpeed = 3000;
var dslSpeed   = 9000;
var fskSpeed   = 18000;
var ssTimer  = null;
 
//bhref = "http://www.fonddulacchurch.com/";
bhref = "http://www.fonddulacchurch.com/";

webnote = "<span class='small'>This site is best if it is viewed with the latest browser from " +
          "<a href='http://www.microsoft.com/windows/ie/default.asp' target='_blank'>Microsoft</a> or " +
           "<a href='http://channels.netscape.com/ns/browsers/default.jsp' target='_blank'>Netscape</a>, " +
           "with 1024 x 768 resolution.  Please report broken links, questions or comments to the " +
           "<a href='mailto:webmaster@fonddulacchurch.com'> Webmaster</a></span>" 

function popupPic(picPath, winTitle, width, height)
{
   if ( newwin )
      newwin.close();

   newwin = window.open("", "Title", "height=" + height + ",width=" + width);
   newwin.document.open('text/html');
   newwin.document.writeln('<HTML>');
   newwin.document.writeln('<HEAD>');
   newwin.document.writeln('<title>' + winTitle + '</title>');
   newwin.document.writeln('<link rel="stylesheet" type="text/css" href="' + bhref + 'stylesheet.css">');
   newwin.document.writeln('</HEAD>');
   newwin.document.writeln('<BODY style="margin:10;padding:0;">');
   newwin.document.writeln('<CENTER>');
   newwin.document.writeln('<IMG SRC="' + bhref + picPath + '"><BR>');
   newwin.document.writeln('<FORM style="margin:5;"><INPUT TYPE="BUTTON" VALUE="Close" onClick="window.close()"></FORM>');
   newwin.document.writeln('</CENTER>');
   newwin.document.writeln('</BODY>');
   newwin.document.writeln('</HTML>');
   newwin.document.close();

}


function popup(document, options)
{
   if ( newwin )
      newwin.close();

   newwin = window.open(bhref + document, "", options);
   newwin.focus();
}


function startSlideShow( max, path, suff, ndx, speed )
{
   if (holdImg == null ||
       typeof holdImg == 'undefined')
      holdImg  = new Image();
   maxPics  = max;
   pathPics = path;
   suffix   = suff;
   picIndex = ndx;
   setSSINDspan();
   resetImgBuffer();
   ssTimer = setInterval("runSlideShow()", speed);
}

function stopSlideShow( )
{
   clearInterval(ssTimer);
   ssTimer = null;
}


function resumeSlideShow(form)
{
   for (var i=0; i < form.dlSpeed.length; i++)
   {
      if (form.dlSpeed[i].checked)
      {
         speed = eval(form.dlSpeed[i].value);
         break;
      }
   }

   if (ssTimer != null)
      stopSlideShow();

   startSlideShow(maxPics, pathPics, suffix, picIndex, speed);
}


function resetSpeed(speed)
{
   stopSlideShow();
   startSlideShow(maxPics, pathPics, suffix, picIndex, speed);
}


function runSlideShow( )
{
   document.ssimg.src = holdImg.src;
   picIndex++;

   setSSINDspan();
   resetImgBuffer();
}


function resetImgBuffer()
{
   if ((picIndex + 1) > maxPics)
      picIndex = 0;
   holdImg.src = bhref + pathPics + (picIndex+1) + suffix;
}


function setSSINDspan( )
{
   /*----------------- Set span indicating which picture we are on ----------------*/
   if (!document.all &&
       !document.getElementById)
     return

   if (document.all)
   {
      document.all.ssind.innerHTML="Picture " + picIndex + " of " + maxPics;
   }
   else if (document.getElementById)
   {
      document.getElementById("ssind").innerHTML="Picture " + picIndex + " of " + maxPics;
   }
   /*-----------------------------------------------------------------------------*/
}

/* Used to validate Main guestbook entries */
function validateMainGuestbook()
{
   var maxChars = 1000;
   
   if (insertForm.nameText.value=='') 
   {
      alert("You have not entered a Name value.");
      return false;
   }
   else if (insertForm.messageText.value=='') 
   {
      alert ("You have not entered any Message text.");
      return false;
   }
   else if (document.insertForm.messageText.value.length > maxChars) 
   {
      alert("You message is too large. \nIt cannot be over " + maxChars + " characters.");
      return false;
   }       
   else
      return true;
}     

