// location of St Mike website
var urlPrefix = "http://home.comcast.net/~st-michaels";

//popup variable
var popUpID= 0;
var popUpBG = "#e0e0e0";

// images used on the navigation bar
var scheduleOn, scheduleOff;
var historyOn, historyOff;
var photosOn, photosOff;
var directionsOn, directionsOff;
var newsOn, newsOff;
var cemeteryOn, cemeteryOff;
var contactsOn, contactsOff;
var weeklyNews = "<tr><td class=\"newsTopic\">There was a problem retrieving the weekly news</td></tr>";

// load images used on this page
   if (document.images) {
      scheduleOn = new Image(85,34);
      scheduleOn.src = "./images/menu/scheduleOVER.gif";
      historyOn = new Image(85,34);
      historyOn.src = "./images/menu/historyOVER.gif";
      photosOn = new Image(85,34);
      photosOn.src = "./images/menu/photosOVER.gif";
      directionsOn = new Image(85,34);
      directionsOn.src = "./images/menu/directionsOVER.gif";
      newsOn = new Image(85,34);
      newsOn.src = "./images/menu/newsOVER.gif";
      cemeteryOn = new Image(85,34);
      cemeteryOn.src = "./images/menu/cemeteryOVER.gif";
      contactsOn = new Image(85,34);
      contactsOn.src = "./images/menu/contactsOVER.gif";

      scheduleOff = new Image(85,34);
      scheduleOff.src = "./images/menu/scheduleOFF.gif";
      historyOff = new Image(85,34);
      historyOff.src = "./images/menu/historyOFF.gif";
      photosOff = new Image(85,34);
      photosOff.src = "./images/menu/photosOFF.gif";
      directionsOff = new Image(85,34);
      directionsOff.src = "./images/menu/directionsOFF.gif";
      newsOff = new Image(85,34);
      newsOff.src = "./images/menu/newsOFF.gif";
      cemeteryOff = new Image(85,34);
      cemeteryOff.src = "./images/menu/cemeteryOFF.gif";
      contactsOff = new Image(85,34);
      contactsOff.src = "./images/menu/contactsOFF.gif";
   }

// function to show "on" images
function imgOn(imgName) {
   if (document.images) {
      document[imgName].src= eval(imgName + "On.src");
//      var imgGraphic = urlPrefix + "/images/menu/" + imgName + "OVER.gif";
//      document[imgName].src=imgGraphic;
   }
}

// function to show "off" images
function imgOff(imgName) {
   if (document.images) {
      document[imgName].src= eval(imgName + "Off.src");
   }
}

function showWeeklyNews(url) {
   var req = false;
   var element;

// For Safari, Firefox, and other non-MS browsers
   if (window.XMLHttpRequest) {
      try {
         req = new XMLHttpRequest();
      }
      catch (e) {
         req = false;
         weeklyNews = e;
      }
   }
   else if (window.ActiveXObject) {
   // For Internet Explorer on Windows
      try {
         req = new ActiveXObject("Msxml2.XMLHTTP");
      }
      catch (e) {
         try {
            req = new ActiveXObject("Microsoft.XMLHTTP");
         }
         catch (e) {
            req = false;
            weeklyNews = e;
         }
      }
   }
/*
   element = document.getElementById(id);
   if (!element) {
      alert("Bad id " + id + "passed to clientSideInclude.  You need a div or span element with this id in your page.");
      return;
   }
*/
   if (req) {
   // Synchronous request, wait till we have it all
      req.open('GET', url, false);
      req.send(null);
      weeklyNews = req.responseText;
//      element.innerHTML = req.responseText;
   }
   else {
      weeklyNews = "Sorry, your browser does not support XMLHTTPRequest objects." +
         "This page requires Internet Explorer 5 or better for Windows, " +
         "or Firefox for any system, or Safari. Other compatible browsers may also exist.";
   }
}

// create the pop-up window for photo
function showPhoto(photo, iWidth, iHeight) {

   if ((popUpID != 0) && (!popUpID.closed)) {
      popUpID.focus();
   }
   else {
      popUpID = window.open(photo,'photoPopUp','height=' + iHeight + ',width=' + iWidth + ',top=10,left=10');
   }
}

// function to format document display
function popUpDisplay(imgName,nameStr)
{
var DocStr;

   popUpID.document.open();
   docStr= '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">\n' +
  	   '<html>\n';
   popUpID.document.write(docStr);
   docStr= '<head>\n' + 
	   '<link rel="stylesheet" type="text/css" href="./styles/styles.css">\n';
   popUpID.document.write(docStr);
   docStr= '<title>'+ nameStr + '</title>\n</head>\n';
   popUpID.document.write(docStr);
   docStr= '<body>\n<p class="toplink">' + 
	   '<a class="info" href=javascript:window.close()>Close Window</a></p>\n<br/>\n';
   popUpID.document.write(docStr);
   docStr= '<img src="' + imgName + '">\n</body>\n</html>\n';
   popUpID.document.write(docStr);
   popUpID.document.bgColor= popUpBG;
   popUpID.document.close();
}

// function to pop-up a "large image" window
function popUpWindow(imgPath,nameStr,wSize,hSize)
{
   var iWidth, iHeight;

// if the popup window is already active, show it
   if ((popUpID != 0) && (!popUpID.closed)) {
      popUpID.close();
   }

   iWidth= wSize + 25;
   iHeight= hSize + 75;
   popUpID = window.open('','photoPopUp','height=' + iHeight + ',width=' + iWidth + ',menubar=no,titlebar=no,top=10,left=10');

//   popUpID = window.open('','popUpWindow',
//			'width=' + wS +	',height=' + hS +
//			',screenX=25,screenY=25,scrollbars=no' +
//			',top=25,left=25,alwaysRaised=yes,dependant=yes' +
//			'menubar=no,resizable=no,titlebar=no');

   popUpDisplay(imgPath,nameStr);
}
