/* functions.js v1.0 2006/3/16 - RH */

function openwin(loc,title,options) {
  window.open(loc,title,options);
}

/* function uReq - Universial XMLHttpRequest 
 *
 * Returns a valid HTTP request for all browsers 
 */

function uReq() {
  var XMLHttp = false;

  if (window.XMLHttpRequest) { // Non-IE browsers
    XMLHttp = new XMLHttpRequest();
    if (XMLHttp.overrideMimeType) { //fix for older browsers
      XMLHttp.overrideMimeType('text/xml');
    }     
  } else if (window.ActiveXObject) { // IE
    try {
      XMLHttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
        XMLHttp = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (e) { XMLHttp = false; }
    }
  }
  
  return XMLHttp;
}

/* function ajaxInit() - Ajax Initialization function 
 * 
 * Attempts to initialize Ajax. If XML is not supported, or 
 * the getElementById method is not available, redirects to a non-Ajax
 * version of the page
 */

function ajaxInit() {

  var XMLHttp = uReq();
  if ((!XMLHttp) || (!document.getElementById)) {
    alert("Error! AJAX failed to initialize!");
  }
}

function switchIntro() {
  var creationIntro=document.getElementById("creationIntro");
  var evolutionIntro=document.getElementById("evolutionIntro");
  var switchButton=document.getElementById("switchButton");
  if(creationIntro.style.visibility=="hidden") {
    creationIntro.style.visibility="visible";
    creationIntro.style.position="static";
    evolutionIntro.style.visibility="hidden";
    evolutionIntro.style.position="absolute";
    switchButton.value = "Click here for the evolution-friendly version";
  }
  else {
    creationIntro.style.visibility="hidden";
    creationIntro.style.position="absolute";
    evolutionIntro.style.visibility="visible";
    evolutionIntro.style.position="static";
    switchButton.value ="Click here for the creationism-friendly version";
  }
}

