
window.onload = function() {
	//changeMenuClass(thisPage, "current");
	setOnClick;
	sfHover;
}

function changeMenuClass(id, newClass) {
	identity=document.getElementById(id);
	identity.className=newClass;
}

function openWindow(href) {
  //var width = parseInt(screen.availWidth * .8);
  //var height = parseInt(screen.availHeight * .7);
  //var x = parseInt((screen.availWidth/2) - (width/2));
  //var y = parseInt((screen.availHeight/2) - (height/2));
  //var windowFeatures = "width=" + width + ",height=" + height + ",left=" + x +",screenX=" + x +",top=" + y + ",screenY=" + y;
  //windowFeatures += ",toolbar=no,menubar=yes,location=no,scrollbars=yes,resizable=yes";
  var openWindow = this.open(href);//, "", windowFeatures);
}

function openPicture(href) {
  var width = 610;
  var height = 560;
  var x = parseInt((screen.availWidth/2) - (width/2));
  var y = parseInt((screen.availHeight/2) - (height/2));
  var windowFeatures = "width=" + width + ",height=" + height + ",left=" + x +",screenX=" + x +",top=" + y + ",screenY=" + y;
  windowFeatures += ",toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes";
  var openPicWindow = this.open(href, "pic", windowFeatures);
  openPicWindow.focus();
}

var NEW_WIN_MSG = " (opens in new window)";

function setOnClick() {
  if(!document.getElementsByTagName) {
    return;
  }
  var anchors = document.getElementsByTagName("a");
  for (var i=anchors.length; i !=0; i--) {
    var a=anchors[i-1];
	if (a.rel.indexOf("external") != -1) {
		a.title += NEW_WIN_MSG;
		a.onclick = function(){openWindow(this.href);return false;}
	}
	if (a.rel.indexOf("picture") != -1) {
		a.title += NEW_WIN_MSG;
		a.onclick = function(){openPicture(this.href);return false;}
	}
  }
}

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"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);

