var popupLinkConfig = new Array;
popupLinkConfig["external"] = new Array ( "", "");
popupLinkConfig["externalmap"] = new Array ("map","width=541,height=656,left=10,top=10,status=no,toolbars=no,scrollbars=no,directories=no,location=no,menubar=no");
popupLinkConfig["newpage"] = new Array ( "", "");

$(document).ready(function () {
	initPage();
});

sfHover = function() {
    var sfEls = document.getElementById("nav").getElementsByTagName("li");
    for (var i=0; i<sfEls.length; i++) {
        sfEls[i].onmouseover=function() {
            this.className+=" sfhover";
        }
        sfEls[i].onmouseout=function() {
            this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
        }
    }
}

function initPage() {
  initPopupLinks();
    if (window.attachEvent){
        sfHover();
    }

}

function initPopupLinks()
{
  if (!document.getElementsByTagName) return true;
  var pageLinks = document.getElementsByTagName("a");
  for (var i = 0; i < pageLinks.length; i++)
  {
    if (((pageLinks[i].className != null) &&
         (pageLinks[i].className != "")) ||
        ((pageLinks[i].parentNode.className != null) &&
         (pageLinks[i].parentNode.className != "")))
    {
      var linkClass = " " + pageLinks[i].className + " ";
      if ((linkClass == "  ") && (pageLinks[i].parentNode.className != ""))
      {
        linkClass = " " + pageLinks[i].parentNode.className + " ";
      }
      for (var theKey in popupLinkConfig)
      {
        if (linkClass.indexOf(" " + theKey + " ") > -1)
        {
          if ((pageLinks[i].target == "") || (pageLinks[i].target == null))
          {
            pageLinks[i].target = (popupLinkConfig[theKey][0] != "") ? popupLinkConfig[theKey][0] : theKey;
          }
          pageLinks[i].settings = popupLinkConfig[theKey][1];
          pageLinks[i].onclick = popUp;
        }
      }
    }
  }
  return true;
}

function popUp(){
  newWin = window.open(this.href, this.target, this.settings);
  newWin.focus();
  return false;
}

/*
 * Email Defuscator - jQuery plugin 1.0 alpha
 * Copyright (c) 2007 Joakim Stai
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 */

jQuery.fn.defuscate = function( settings ) {
    settings = jQuery.extend({
        link: true
    }, settings);
    var regex = /\b([A-Z0-9._%-]+)\([^)]+\)((?:[A-Z0-9-]+\.)+[A-Z]{2,6})\b/gi;
    return this.each(function() {
        if ( $(this).is('a[@href]') ) {
            $(this).attr('href', $(this).attr('href').replace(regex, '$1@$2'));
            var is_link = true;
        }
        $(this).html($(this).html().replace(regex, (settings.link && !is_link ? '<a href="mailto:$1@$2">$1@$2</a>' : '$1@$2')));
  });
}


