
function bookmarkPage(title, url){
  if (document.all) {
    window.external.AddFavorite(url, title);
  } else if (window.sidebar) {
    window.sidebar.addPanel(title, url, "");
  }
}

function popUp(URL, width, height) {
  day = new Date();
  id = day.getTime();
  eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=' + width + ',height=' + height + ',left = 362,top = 234');");
}

function toggle(id) {
  if(document.getElementById(id).className == "hide") {
    document.getElementById(id).className="show";
  } else {
    document.getElementById(id).className="hide";
  };
}

function getFile(pURL) {
    alert("hi");
  //case thate browser is Mozilla, Safari, and Netscape
	if (window.XMLHttpRequest) {
		xmlhttp=new XMLHttpRequest();
		//after getting the file call the method gotFile
		xmlhttp.onreadystatechange=gotFile;
		//open the external sayings file
		xmlhttp.open("GET", pURL, true);
		xmlhttp.send(null);
	} else if (window.ActiveXObject) {
	  // case that brower is IE
		xmlhttp=new ActiveXObject('Microsoft.XMLHTTP');
		if (xmlhttp) {
		 xmlhttp.onreadystatechange=gotFile;
		 xmlhttp.open('GET', pURL, true);
		 xmlhttp.send();
		}
	}
}
// function to handle asynchronous call from getFile
function gotFile() {
	if (xmlhttp.readyState==4) {
		//if the file was found
		if (xmlhttp.status==200) {
		  //create the array of sayings
		  prepareSayings(xmlhttp.responseText);
		  //after array is created, display the saying
			displayRandomSaying();
		}
	}
}
function prepareSayings(str) {
  //if there are file contents
	if (str != 'undefined' && str != '') {
		//QUOTE SEPARATOR - currently separates by 5 ~~~~~
		strArr = str.split("~~~~~");
	}
}
function displayRandomSaying() {
	//get random element in array
	var randomIndex=Math.floor(Math.random() *  strArr.length);
	//set the div with id saying equal to the random saying
	document.getElementById('saying').innerHTML = strArr[randomIndex];
}
//global vars
var secs;
var timerID = null;
var timerRunning = false;
var delay = 1000;
function initializeTimer() {
	//Set the length of the timer, in seconds
	//TIMING - to change timing, update the number below
	secs = 10;
	stopClock();
	startTimer();
}
function stopClock() {
	if(timerRunning) {
		clearTimeout(timerID);
	}
	timerRunning = false;
}
function startTimer() {
  //timer actually counts backwards
	if (secs==0) {
		stopClock();
		displayRandomSaying();
		initializeTimer();
	} else {
		//self.status = secs
		secs = secs - 1
		timerRunning = true
		timerID = self.setTimeout("startTimer()", delay)
	}
}
