// JavaScript Document
/* Code contained hereing ©2008 Howard J. Hanna III — Interactive Productions
   email: howard (dot) hanna (at) hhanna.com
  
  Use is granted to Blue Sky Productions, Inc and Allan Kobernick as support file in larger e-learning project.
  Redistribution and/or sale of this copyrighted code is prohibited without express permission from its creator.
  
   exceptions: functions readCookie and writeCookie are Dreamweaver CS3 snippets
*/
   

/*
//Lines 12-50 ARE COMMENTED OUT BECAUSE THE
//FUNCTION readCookie AND writeCookie ARE DUPLICATED
//IN ANOTHER FILE (mlearning.js). IF USING THIS FILE ON ITS OWN
//YOU MUST UNCOMMENT THESE TWO FUNCTIONS.

//This function reads the cookie
//and returns the cookie's value as a string
function readCookie(name) {
  var cookieValue = "";
  var search = name + "=";

  if(document.cookie.length > 0) { 
    offset = document.cookie.indexOf(search);
    if (offset != -1) { 
      offset += search.length;
      end = document.cookie.indexOf(";", offset);
      if (end == -1) { end = document.cookie.length; }
	  cookieValue = unescape(document.cookie.substring(offset, end));
    }
  }
  return cookieValue;
}


//This function writes the cookie
//each argument MUST be supplied
//name is a string, value is a string, hours is a number.
function writeCookie(name, value, hours){
  var expire = "";

  if(hours != null) {
    expire = new Date((new Date()).getTime() + hours * 3600000);
    expire = "; expires=" + expire.toGMTString();
  }
//  alert("name is:"+name+"value is:"+value+"hours is:"+hours);
  document.cookie = name + "=" + escape(value) + expire + "; path=/";
}
*/




//need function to define/set vars
//before passing to writeCookie
//setBookmark is passed window.document.location
//which is a URL from the document object model (DOM)
function setBookmark(sURL) {
	//define a name for the cookie
	var name = "AA_bookmark";
	//define the value
	var value = sURL;
	//define the hours in which to expiration
	var expire = 24;
	
	writeCookie(name, value, expire);
}

//need function to read cookie
//and change the current page href
//to the bookmarked URL
function getBookmark(sName) {
	var sURL = readCookie(sName);
	window.document.location.href = sURL;
}

function gotoTips(sURL) {
	window.document.location.href = sURL;
}