function getCalendarDate()
{
   var months = new Array(13);
   months[0]  = "January";
   months[1]  = "February";
   months[2]  = "March";
   months[3]  = "April";
   months[4]  = "May";
   months[5]  = "June";
   months[6]  = "July";
   months[7]  = "August";
   months[8]  = "September";
   months[9]  = "October";
   months[10] = "November";
   months[11] = "December";
   var now         = new Date();
   var monthnumber = now.getMonth();
   var monthname   = months[monthnumber];
   var monthday    = now.getDate();
   var year        = now.getYear();
   if(year < 2000) { year = year + 1900; }
   var dateString = monthname +
                    ' ' +
                    monthday +
                    ', ' +
                    year;
   return dateString;
} // function getCalendarDate()

function getClockTime()
{
   var now    = new Date();
   var hour   = now.getHours();
   var minute = now.getMinutes();
   var second = now.getSeconds();
   var ap = "AM";
   if (hour   > 11) { ap = "PM";             }
   if (hour   > 12) { hour = hour - 12;      }
   if (hour   == 0) { hour = 12;             }
   if (hour   < 10) { hour   = "0" + hour;   }
   if (minute < 10) { minute = "0" + minute; }
   if (second < 10) { second = "0" + second; }
   var timeString = hour +
                    ':' +
                    minute +
//                    ':' +
//                    second +
                    " " +
                    ap;
   return timeString;
} // function getClockTime()

function ImposeMaxLength(Object, MaxLen){
	return (Object.value.length <= MaxLen);
}

function jemail(user, domain, suffix, subject, textprompt){
if (textprompt == "") 
document.write('<a href="' + 'mailto:' + user + '@' + domain + '.' + suffix + '?subject=' + subject + '">' + user + '@' + domain + '.' + suffix + '</a>');
else
document.write('<a href="' + 'mailto:' + user + '@' + domain + '.' + suffix + '?subject=' + subject + '">' + textprompt + '</a>');
}

function ouremail (user, subject, textprompt) {
	jemail(user, "holysepulchre", "net", subject, textprompt);
}

function externalLinks() { 
 if (!document.getElementsByTagName) return; 
 var anchors = document.getElementsByTagName("a"); 
 for (var i=0; i<anchors.length; i++) { 
   var anchor = anchors[i]; 
   if (anchor.getAttribute("href") && 
       anchor.getAttribute("rel") == "external") 
     anchor.target = "_blank"; 
 } 
}

function contentImage() {
 if (document.getElementById("noimage")) {
 		document.getElementById('content').style.backgroundImage = 'none';
 		document.getElementById('content').style.backgroundColor = '#f6f6f6';
 }
}

function goBack() {
	window.history.go(-1);
}

var thnd = setTimeout ("PictureStop()", 1000);
clearTimeout(thnd);
var isRunning = false;

function PictureChanger(imageDir) {
	var tsec=5;
	if (document.getElementById("ChangeRate").value != 0) tsec=document.getElementById("ChangeRate").value;
//      if (document.getElementById("StartButton").value != "Pressed") document.getElementById("StartButton").value = "Pressed";
      image1 = "change.php?ImageDir=" + imageDir; //name of the image generation script 
      tmp = new Date(); 
      tmp = "&amp;Time="+tmp.getTime(); 
      document.images["Changer"].src = image1+tmp; 
      thnd = setTimeout("PictureChanger('" + imageDir + "')", tsec*1000); 
} 

function PictureStop() {
	clearTimeout(thnd);
//	document.getElementById("StartButton").value = "Start";
}

function PictureToggle(imageDir) {
	if (isRunning) {
		PictureStop();
		document.getElementById("ToggleButton").src="../images/gobutton_s.jpg";
		document.getElementById("ToggleButton").title="Go";
		isRunning = false;
	}
	else {
		PictureChanger(imageDir)
		document.getElementById("ToggleButton").src="../images/pausebutton_s.jpg";
		document.getElementById("ToggleButton").title="Pause";
		isRunning = true;
	}
}	

function docWrite(locID, newElement, newText) {
	var newcontent = document.createElement(newElement);
	newcontent.appendChild(document.createTextNode(newText));
	var scr = document.getElementById(locID);
	scr.parentNode.insertBefore(newcontent,scr);
}

_LOADERS = Array();
function callAllLoaders()
{
	var i, loaderFunc;
	for(i=0; i<_LOADERS.length; i++)
	{
		loaderFunc = _LOADERS[i];
		if(loaderFunc != callAllLoaders) loaderFunc();
	}
}

function appendLoader(loaderFunc)
{
	if(window.onload && window.onload != callAllLoaders) _LOADERS[_LOADERS.length] = window.onload;
	window.onload = callAllLoaders;
	_LOADERS[_LOADERS.length] = loaderFunc;
}

appendLoader(externalLinks);
appendLoader(contentImage);

