addLoadEvent(setupLoginBoxSwap);
addLoadEvent(setupNewWindows);


function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
	  oldonload();
	  func();
	}
  }
}


function setupNewWindows() {
	anchors = document.getElementsByTagName("a");
	for (i=0; i<anchors.length; i++) {
		if (anchors[i].className.search(/newWindow/) > -1) {
			anchors[i].onclick = function() { addNewWindow(this); return false; }
		}
	}
}

function addNewWindow(myAnchor) {
	var newLink = myAnchor.getAttribute("href");
	window.open(newLink,'MyWindow','width=500,height=450,scrollbars=1');
}


function setupLoginBoxSwap() {
  if (document.getElementById) {
    node1 = document.getElementById("switch-to-returning");
	node1.onclick = function() {
	  hideThis = document.getElementById("login-box-wrapper");
      hideThis.className += "hidden";
	  showThis = document.getElementById("login-box-returning-wrapper");
	  showThis.className = showThis.className.replace("hidden","");
	}
    node2 = document.getElementById("switch-to-new");
	node2.onclick = function() {
	  hideThis = document.getElementById("login-box-returning-wrapper");
      hideThis.className += "hidden";
	  showThis = document.getElementById("login-box-wrapper");
	  showThis.className = showThis.className.replace("hidden","");
	}
  }
}

