﻿




// SEARCH : Definitions
function lookup_definition(sText)
{
if(sText==""){alert('Please select a word from the drop-down menu.');}
else{document.location.replace('/About/' + sText + '.aspx');}
}




function homepage()
{

   document.body.style.behavior='url(#default#homepage)';
   document.body.setHomePage(window.location.href);


}



// BOOKMARK : Function to store a bookmark in the client's browser
function bookmark()
{
if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)) {window.external.AddFavorite(document.location,document.title);} else if (navigator.appName == "Netscape") {window.sidebar.addPanel(document.title,document.location,"");} else {alert("Press CTRL-D (Netscape) or CTRL-T (Opera) to bookmark");}
}

// Generic Show / Hide Page Elements
function HideContent(d) {
if(d.length < 1) { return; }
document.getElementById(d).style.display = "none";
document.getElementById(d).style.visibility = "hidden";
}
function ShowContent(d) {
if(d.length < 1) { return; }
document.getElementById(d).style.display = "block";
document.getElementById(d).style.visibility = "visible";
}
function ReverseContentDisplay(d) {
if(d.length < 1) { return; }
if(document.getElementById(d).style.display == "none") { document.getElementById(d).style.display = "block"; }
else { document.getElementById(d).style.display = "none"; }
}


// Functions to load definitions from .Net into a Div using Ajax

function getQuickDefinition(url, target) {
  document.getElementById(target).innerHTML = ' <p>Fetching your Quick Definition...</p>';
  if (window.XMLHttpRequest) {
    req3 = new XMLHttpRequest();
  } else if (window.ActiveXObject) {
    req3 = new ActiveXObject("Microsoft.XMLHTTP");
  }
  if (req3 != undefined) {
    req3.onreadystatechange = function() {doneQuickDefinition(url, target);};
    req3.open("GET", url, true);
    req3.send("");
  }
}  

function doneQuickDefinition(url, target) {
  if (req3.readyState == 4) { // only if req3 is "loaded"
    if (req3.status == 200) { // only if "OK"
      document.getElementById(target).innerHTML = req3.responseText;
    } else {
      document.getElementById(target).innerHTML=" AHAH Error:\n"+ req3.status + "\n" +req3.statusText;
    }
  }
}

function loadQuickDefinition(name, div) {
	getQuickDefinition(name,div);
	return false;
}






// Functions to load random verses from .Net into a Div using Ajax

function getRandomVerse(url, target) {
  document.getElementById(target).innerHTML = ' <p>Fetching your Random Verse...</p>';
  if (window.XMLHttpRequest) {
    reqRandomVerse = new XMLHttpRequest();
  } else if (window.ActiveXObject) {
    reqRandomVerse = new ActiveXObject("Microsoft.XMLHTTP");
  }
  if (reqRandomVerse != undefined) {
    reqRandomVerse.onreadystatechange = function() {doneRandomVerse(url, target);};
    reqRandomVerse.open("GET", url, true);
    reqRandomVerse.send("");
  }
}  

function doneRandomVerse(url, target) {
  if (reqRandomVerse.readyState == 4) { // only if reqRandomVerse is "loaded"
    if (reqRandomVerse.status == 200) { // only if "OK"
      document.getElementById(target).innerHTML = reqRandomVerse.responseText;
    } else {
      document.getElementById(target).innerHTML=" AHAH Error:\n"+ reqRandomVerse.status + "\n" +reqRandomVerse.statusText;
    }
  }
}

function loadRandomVerse(name, div) {
	getRandomVerse(name,div);
	return false;
}



// Functions to load top searches from .Net into a Div using Ajax

function getTopSearches(url, target) {
  document.getElementById(target).innerHTML = ' <p>Fetching the Top Searches...</p>';
  if (window.XMLHttpRequest) {
    reqTopSearches = new XMLHttpRequest();
  } else if (window.ActiveXObject) {
    reqTopSearches = new ActiveXObject("Microsoft.XMLHTTP");
  }
  if (reqTopSearches != undefined) {
    reqTopSearches.onreadystatechange = function() {doneTopSearches(url, target);};
    reqTopSearches.open("GET", url, true);
    reqTopSearches.send("");
  }
}  

function doneTopSearches(url, target) {
  if (reqTopSearches.readyState == 4) { // only if reqTopSearches is "loaded"
    if (reqTopSearches.status == 200) { // only if "OK"
      document.getElementById(target).innerHTML = reqTopSearches.responseText;
    } else {
      document.getElementById(target).innerHTML=" AHAH Error:\n"+ reqTopSearches.status + "\n" +reqTopSearches.statusText;
    }
  }
}

function loadTopSearches(name, div) {
	getTopSearches(name,div);
	return false;
}




// Functions to load wikipedia articles from .Net into a Div using Ajax

function getWiki(url, target) {
  document.getElementById(target).innerHTML = ' <p>Fetching your Wiki Results...</p>';
  if (window.XMLHttpRequest) {
    req2 = new XMLHttpRequest();
  } else if (window.ActiveXObject) {
    req2 = new ActiveXObject("Microsoft.XMLHTTP");
  }
  if (req2 != undefined) {
    req2.onreadystatechange = function() {doneWiki(url, target);};
    req2.open("GET", url, true);
    req2.send("");
  }
}  

function doneWiki(url, target) {
  if (req2.readyState == 4) { // only if req is "loaded"
    if (req2.status == 200) { // only if "OK"
      document.getElementById(target).innerHTML = req2.responseText;
    } else {
      document.getElementById(target).innerHTML=" AHAH Error:\n"+ req2.status + "\n" +req2.statusText;
    }
  }
}

function loadWiki(name, div) {
	getWiki(name,div);
	return false;
}