

function addLoadEvent(func)
{
  // Script by Simon Willison
  // http:simon.incutio.com/
  
  var oldonload = window.onload;
  if (typeof window.onload != 'function')
  {
    window.onload = func;
  }
  else
  {
    window.onload = function()
    {
      oldonload();
      func();
    }
  }
}


// Dates
// Copyright 2006 Professional Website Design.
// For other useful scripts and tutorials, see
// http://www.professorscodingcorner.com/
// You may use or modify the script in any way
// you want, but do not remove the first four
// lines above. Although it's not required, I
// would appreciate an email to let me know
// the URL of the page where are using it.

function currentYear()
{
  if (!document.getElementById("currentyear")) return false;
  var obj = document.getElementById("currentyear");
  var today = new Date();
  var year = today.getFullYear();
  var txt = document.createTextNode(year);
  obj.appendChild(txt);
  return true;
}


function mailTo()
{
  // Copyright 2006 Professional Website Design.
  // For other useful scripts and tutorials, see
  // http://www.professorscodingcorner.com/
  // You may use or modify the script in any way
  // you want, but do not remove the first three
  // lines above. Although it's not required, I
  // would appreciate an email to let me know
  // the URL of the page where you used it.
  //
  // Modified June 24, 2007.
  // Can now have more than one email link on a
  // page. Uses Class instead of Id. Now the 
  // containing element MUST be a span.

  if (!document.getElementsByTagName("span")) return false;
  var spans = document.getElementsByTagName("span");
  for (var i=0; i<spans.length; i++)
    {
      if (spans[i].className == "mailTo")
        {
          var anch = document.createElement("a");
          var email = "mail@crewclubfitnesscenter.com";
          var mailto = "mailto:" + email;
          anch.setAttribute("href",mailto);
          spans[i].appendChild(anch);
          // abbreviated below, to fit in the sidebar
          email = "mail@ccfitnesscenter.com";
          var txt = document.createTextNode(email);
          anch.appendChild(txt);
        }
    }
  return true;
}



// Open New Window Script
// Copyright 2006 Professional Website Design
// professorscodingcorner.com
// To be used in place of the depricated atribute 'target'
// This is necessary for links appearing in a popup window

function newWindow(whichanchor)
{
  var URL = whichanchor.getAttribute("href");
  var POPUP = window.open(URL);
}


function openNewWindow()
{
  if (!document.getElementsByTagName) return false;
  var anchor = document.getElementsByTagName("a");
  for (var k=0; k<anchor.length; k++)
  {
    if (anchor[k].className == "newwindow")
    {
      anchor[k].onclick = function()
      { newWindow(this); return false; }
    }
  }
  return true;
}



// Popup Script
// Copyright 2006 Professional Website Design
// professorscodingcorner.com
// Script inspired by William Bontrager,
// willmaster.com, January 29,2001
// Extensively modified by the Professor June 22, 2008
// to be used offpage, and to handle multiple anchors

function showPopup(whichanchor) 
{
  var URL = whichanchor.getAttribute("href");
  var POPUP = window.open(URL,'popup','width=590,height=379,left=0,top=30,scrollbars=1,resizable=1');
  POPUP.focus();
  return false;
}

function Popup()
{
  if (!document.getElementsByTagName) return false;
  var anchor = document.getElementsByTagName("a");
  for (var k=0; k<anchor.length; k++)
  {
    if (anchor[k].className == "pop")
    {
      anchor[k].onclick = function()
      { showPopup(this); return false; }
    }
  }
  return true;
}


addLoadEvent(currentYear);
addLoadEvent(mailTo);
addLoadEvent(Popup);
addLoadEvent(openNewWindow);

