/* IE 5.0 does not support the push method, so here goes */
if(Array.prototype.push == null) {
	Array.prototype.push = function(item) {
		this[this.length] = item;
		return this.length;
	};
};
/* same for shift */
if (Array.prototype.shift == null) {
  Array.prototype.shift = function() {
    var response = this[0];
    for (var i=0; i < this.length-1; i++) {
      this[i] = this[i + 1];
    };
    this.length--;
    return response;
  };
};
/*	Implement function.apply for browsers which don't support it natively
	Courtesy of Aaron Boodman - http://youngpup.net */
if (!Function.prototype.apply) {
  Function.prototype.apply = function(oScope, args) {
    var sarg = [];
    var rtrn, call;
    if (!oScope) oScope = window;
    if (!args) args = [];
    for (var i = 0; i < args.length; i++) {
      sarg[i] = "args["+i+"]";
    };
    call = "oScope.__applyTemp__(" + sarg.join(",") + ");";
    oScope.__applyTemp__ = this;
    rtrn = eval(call);
    oScope.__applyTemp__ = null;
	return rtrn;
  };
};
// Get Element By Class Name Functionality
getElementsByClassName = function (c) {
    var ret = new Array();
    var j = 0;
    var objs = document.all ? document.all : document.getElementsByTagName("*");
    for(i = 0;i<objs.length;i++){
        if(objs[i].className == c){
            ret[j] = objs[i];
            j++;
        } // if
    } // for
    return ret;
}
// Simple Uppercase F'n
function ucFirst(text) {
  return text.substring(0,1).toUpperCase() + text.substring(1);
}
// Get Cookie Value
function getCookieValue(name) {
  var pos = allcookies.indexOf(name);
  if (pos != -1) {
    var start = pos + 8;
    var end = allcookies.indexOf(";",start);
    if (end == -1) end = allcookies.length;
    var value = allcookies.substring(start, end);
    value = unescape(value);
    return value;
  }
}

// onload will process an array we can push any functions to that we want
var old = window.onload; // catch any existing onload calls 1st
window.onload = function () {
  if (old) { // execute existing onloads
    old();
  };
  for (var ii = 0; arguments.callee.actions.length > ii; ii++) {
    arguments.callee.actions[ii]();
  };
};
window.onload.actions = [];

// sIFR replace statements (for the pretty fonts)
function runMyIFR() {
  if(typeof sIFR == "function"){
    sIFR.replaceElement(named({sSelector:"body h1", 
                               sFlashSrc:"/fonts/metaBold.swf", 
                               sColor:"#ffffff", 
                               sLinkColor:"#000000", 
                               sBgColor:"#c00000", 
                               sHoverColor:"#999999", 
                               nPaddingTop:0, 
                               nPaddingRight:0, 
                               nPaddingBottom:0, 
                               nPaddingLeft:0, 
                               //sFlashVars:"textalign=center&offsetTop=6",
                               sWmode:"transparent"}));
    //sIFR.replaceElement(named({sSelector:"body caption", 
// commented out by Hessling, 15 Feb 2008
                     //          sFlashSrc:"/fonts/metaBold.swf", 
                     //          sColor:"#ffffff", 
                     //          sLinkColor:"#000000", 
                     //          sBgColor:"#c00000", 
                     //          sHoverColor:"#999999", 
                     //          nPaddingTop:0, 
                     //          nPaddingRight:10, 
                     //          nPaddingBottom:0, 
                     //         nPaddingLeft:0, 
                               //sFlashVars:"textalign=center&offsetTop=6",
                     //          sWmode:"transparent"}));
    sIFR.replaceElement(named({sSelector:"dl#event dt", 
                               sFlashSrc:"/fonts/metaBold.swf", 
                               sColor:"#ffffff", 
                               sLinkColor:"#000000", 
                               sBgColor:"#c00000", 
                               sHoverColor:"#999999", 
                               nPaddingTop:15, 
                               nPaddingRight:0, 
                               nPaddingBottom:0, 
                               nPaddingLeft:0, 
                               //sFlashVars:"textalign=center&offsetTop=6",
                               sWmode:"transparent"}));
  };
};
window.onload.actions.push(runMyIFR);

sfTarget = function() {
  var sfEls = getElementsByClassName("sfHide"); 
  var aEls = document.getElementsByTagName("a");
  document.lastTarget = null;
  for (var i=0; i<sfEls.length; i++) {
    if (sfEls[i].id) {
      if (location.hash==("#" + sfEls[i].id)) {
        sfEls[i].className+=" " + "sfTarget";
        document.lastTarget=sfEls[i];
      }
      for (var j=0; j<aEls.length; j++) {
        if (aEls[j].hash==("#" + sfEls[i].id)) aEls[j].targetEl = sfEls[i]; aEls[j].onclick = function() {
          if (document.lastTarget) document.lastTarget.className = document.lastTarget.className.replace(new RegExp(" sfTarget\\b"), "");
          if (this.targetEl) this.targetEl.className+=" sfTarget"; document.lastTarget=this.targetEl;
          return true;
        }
      }
    }
  }
}
if (window.attachEvent) window.onload.actions.push(sfTarget);

function fixLinks()
{
  if (!document.getElementsByTagName) return null;
  var server = document.location.hostname;
  var anchors = document.getElementsByTagName("a");
  var i, href, title;
  for(i=0; i < anchors.length; i++){
    if(!anchors[i].href) continue;
    href = anchors[i].href;
    title = anchors[i].title;
    if(href.indexOf(server) == -1){ // Href is not a file on my server
      if(href.indexOf("javascript:") == -1){ // Href is not a javascript call
        if(!anchors[i].onclick){ // Href does not have an onclick event
          if(href.indexOf("mailto:") == -1){ // Href is not a mailto:
            if((href.indexOf("http://") != -1) || (href.indexOf("https://") != -1)){ // Href is not relative (for Safari)
              anchors[i].setAttribute("target","_blank");
              if (anchors[i].getAttribute("title")) {
                anchors[i].setAttribute("title",title + " [This Link Will Open in a New Window]");
              } else {
                anchors[i].setAttribute("title","[This Link Will Open in a New Window]");
              }
              anchors[i].className += " newWin";
            }
          }
        }
      }
    }
  }
  return null;
}
window.onload.actions.push(fixLinks);

// Author: Mihai Bazon, http://dynarch.com/mishoo
// Use it!  Distribute it!  Sign the Petition for proper PNG support at:
// http://www.petitiononline.com/msiepng/petition.html
function fixPng() {
  var blank = new Image;
  blank.src = '/images/x.gif';
  var imgs = document.getElementsByTagName("img");
  for (var i = imgs.length; --i >= 0;) {
    var img = imgs[i];
    var src = img.src;
    if (!/\.png$/.test(src))
      continue;
    img.src = blank.src;
    var s = img.runtimeStyle;
    s.width = img.offsetWidth;
    s.height = img.offsetHeight;
    s.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "',sizingMethod='scale')";
  }
}
if (window.attachEvent) window.onload.actions.push(fixPng);