//----------------------------------------------------------------------
//     Name: Dayspring.js
//  Purpose: Javascript functions used by Dayspring pages.
//----------------------------------------------------------------------

var WidthAdjust  = 25;
var HeightAdjust = 20;

function dimensions()
{
  window.status="Size: " + document.body.clientWidth + "x" + document.body.clientHeight;
  return;
}

function coordinates(event)
{
  x=event.clientX
  y=event.clientY
  window.status = "Cursor is at " + x + "," + y; 
}

function bold (myElem)
{
  myElem.style.fontWeight='bold';
  return;
}

function newWindow(url, width, height)
{
  popupWin = window.open(url, "Image", "resizable,scrollbars,width=" + width + ",height=" + height);
}

function normal (myElem)
{
  myElem.style.fontWeight='normal';
  return;
}



//----------------------------------------------------------------------
//        Name: checkBrowser ()
//     Purpose: Class defs for navigation specify, for a class named
//              div.pulldown, 'top: -13px'.  This appears to be necessary
//              for all browsers except Internet Explorer.  Purpose of
//              this function is to remove that value for each <div>
//              of class 'pulldown'.
//
//              If we have to do any other checks for browser-specific
//              stuff, this is where to do it.
//----------------------------------------------------------------------
function checkBrowser()
{
  if (navigator.userAgent.match('MSIE'))
  {
    var allDiv = document.getElementsByTagName('div');
    for (var n = 0; n < allDiv.length; n++)
    {
      var myElem = allDiv[n];
      if (myElem.className == 'pulldown')
	  {
	    myElem.style.top='0px';
	  }
    }
  }
  return;
}




  

function initMarquee()
{
  document.getElementById('welcome').style.display='block';
  if (navigator.userAgent.match('MSIE'))
  {
    document.getElementById('welcomeIE').style.display='block';
    document.getElementById('welcomeFirefox').style.display='none';
  }
  else
  {
    document.getElementById('welcomeFirefox').style.display='block';
    document.getElementById('welcomeIE').style.display='none';
  }
  return;
}



//----------------------------------------------------------------------
//      Name: hideAll (myTag, myClass)
//   Purpose: Makes invisible all elements with a specified tag
//            and a specified class, by setting the element's
//            display attribute to 'none'.
// Arguments: myTag
//            myClass
//   Returns:  
//   Example: 
//----------------------------------------------------------------------
function hideAll(myTag, myClass)
{
  var allTags = document.getElementsByTagName(myTag);
  for (var n = 0; n < allTags.length; n++)
  {
    var myElem = allTags[n];
    if (myElem.className.match(myClass))
	{
	  myElem.style.display='none';
	}
  }
  return;
}

//----------------------------------------------------------------------
//      Name: showAll (myTag, myClass)
//   Purpose: Makes visible all elements with a specified tag
//            and a specified class, by setting the element's
//            display attribute to 'block'.
// Arguments: myTag
//            myClass
//   Returns:  
//   Example: 
//----------------------------------------------------------------------
function showAll(myTag, myClass)
{
  var allTags = document.getElementsByTagName(myTag);
  for (var n = 0; n < allTags.length; n++)
  {
    var myElem = allTags[n];
    if (myElem.className.match(myClass))
	{
	  myElem.style.display='block';
	}
  }
  return;
}
function printFriendly(onoff)
{
  if (onoff == 'on')
  {
    document.getElementById('left').style.display='none';
    document.getElementById('sidebar').style.display='none';
    document.getElementById('Main').style.width='100%';
  }
  else
  {
    document.getElementById('Main').style.width='55%';
    document.getElementById('left').style.display='block';
    document.getElementById('sidebar').style.display='block';
  }
  return;
}

function normalizeAll(myTag)
{
  var allTags = document.getElementsByTagName(myTag);
  for (var n = 0; n < allTags.length; n++)
  {
    var myElem = allTags[n];
    if (myElem.className == 'inverse')
    {
      myElem.className = 'normal';
    }
  }
  return;
}
function show (myHeading, myID)
{
  hideAll('DIV', 'article');
  normalizeAll('H6');
  var myArticle = document.getElementById(myID);
  myHeading.className = 'inverse';
  myArticle.style.display = 'block';
  var allChildren = myArticle.getElementsByTagName('DIV');
  for (var int = 0; int < allChildren.length; int++)
  {
    if (allChildren[int].className.match('article'))
    {
      allChildren[int].style.display = 'block';
    }
  }
  return;
}

function togglebrick (myButton, myID)
{
  var myHeading = myButton.parentNode;
  var myArticle = document.getElementById(myID);
  if (myButton.className == 'plus')
  {
    myButton.className = 'minus';
    myButton.src='Graphics/minus.png';
    myButton.title='Click here to hide the article';
    myHeading.className = 'yellowbrick';
    myArticle.style.display = 'block';
    return;
  }
  if (myButton.className == 'minus')
  {
    myButton.className = 'plus';
    myButton.src='Graphics/plus.png';
    myButton.title='Click here to view the article';
    myHeading.className = 'yellowbrick';
    myArticle.style.display = 'none';
  }
  return;
}
function openWindow(url, width, height)
{
	if ((width + 30 > screen.width) || (height + 60 > screen.height))
	{
	        width = width + 50;
                if (width > screen.width - 80)
			width = screen.width - 80;
	        height = height + 50;
		if (height > screen.height - 110)
			height = screen.height - 110;
		popupWin = window.open(url, "Image", "resizable,scrollbars,width=" + width + ",height=" + height + ",top=25,left=25,screenX=25,screenY=25");
	}
	else
	{
	        width = width + 18;
	        height = height + 26;
		popupWin = window.open(url, "Image", "resizable,scrollbars,width=" + width + ",height=" + height + ",top=25,left=25,screenX=25,screenY=25");
	}
}

//----------------------------------------------------------------------
// Function: showPhoto
//----------------------------------------------------------------------
function showPhoto(Photo,Width,Height,Photog)
{
  if (Photog)
  {
    var pageHeight = parseInt(Height) + HeightAdjust;
    var caption = "<p style='font-family:Verdana,Arial,Helvetica,sans-serif;font-size:11pt;text-align:center;margin-top:0px;margin-bottom:0px'>Photo by " + Photog + "</p>";
  }
  else
  {
    var pageHeight = Height;
    var caption = '';
  }
  var pageWidth = parseInt(Width) + WidthAdjust;
  var properties = "height=" + pageHeight + ",width=" + pageWidth +",toolbar=no,resizable=yes,scrollbars=yes,menubar=no";
  var img="<img src='" + Photo + "'>";
  var title="<title>" + Photo + "</title>";
  OpenWindow=window.open("", "Photo", properties);
  OpenWindow.document.write("<html>");
  OpenWindow.document.write("<head>");
  OpenWindow.document.write(title)
  OpenWindow.document.write("</head>");
  OpenWindow.document.write("<body style='background-color: gainsboro;margin:0px 0px 0px 0px'>");
  OpenWindow.document.write(img);
  OpenWindow.document.write(caption);
  OpenWindow.document.write("</body>");
  OpenWindow.document.write("</html>");

  OpenWindow.document.close()
  self.name="main"
}


//----------------------------------------------------------------------
// These functions support the Dayspring calendar
//----------------------------------------------------------------------
function getToday()
{
  var objToday  = new Date();
  var intYear   = objToday.getYear();
  var intMonth  = objToday.getMonth();
  var intDay    = objToday.getDate();
  intMonth++;
  if (intMonth < 10) { intMonth = '0' + intMonth; }
  if (intDay   < 10) { intDay   = '0' + intDay; }
  if (intYear  < 2000) { intYear+=1900; }
  strToday = intYear + intMonth + intDay;
  document.getElementById(strToday).style.display='block';
  return;
}
function showDate(myId)
{
  hideAll('DIV','calendarDate');
  document.getElementById(myId).style.display='block';
  return;
}
function hideDate(myId)
{
  document.getElementById(myId).style.display='none';
  return;
}


