//--------------------------------
// Do nothing (void function placeholder)
//--------------------------------
function doNothing() {
}

//--------------------------------
// Set global date variables for copyright notice.
//--------------------------------

var today = new Date()
var year = today.getYear()
if(year < 1000){
	year += 1900
}

var monthArray = new Array("January", "February", "March", 
                   "April", "May", "June", "July", "August",
                   "September", "October", "November", "December")

//--------------------------------
// Browser checker
//--------------------------------
var browserOK = false

function checkBrowser() {
  var verStr=navigator.appVersion, app=navigator.appName, version = parseFloat(verStr)

  if (app.indexOf('Netscape') != -1) {
    //  Netscape does not implement full CCS1 behaviors.
    //  if (version >= 4.0) browserOK = true
  } else if (app.indexOf('Microsoft') != -1) {
    if (version >= 4.0 || verStr.indexOf(4.0) != -1)
     browserOK = true
  }
}

//--------------------------------
// Menu highlighter
//--------------------------------
function highlight(item) {
  if (browserOK) {
    item.style.textDecoration = "underline";
    item.style.fontWeight = 'normal';
  }
}

//--------------------------------
// Menu un-highlighter
//--------------------------------
function unhighlight(item) {
  if (browserOK) {
    item.style.textDecoration = "none";
    item.style.fontWeight = 'bold';
  }
}

//--------------------------------
// Chat Window creator.
// syntax: launchChat(room)
//
//     where room = <name of chatroom>
//--------------------------------

var newChatWindow

function launchChat(room) {
var chatURL,windowFeatures

if (room == null) {
    chatURL = "/chat/index.html"
    // chatURL = "http://socrates.adasoft.com/carelearning/chat/"
} else {
    chatURL = "/chat/" + room + ".html"
    // chatURL = "http://www.avilar.com/avilar/carelearning/chat/" + room + ".html"
    // chatURL = "http://socrates.adasoft.com/carelearning/chat/"
    }

windowFeatures = "width=550,height=420"          // ChatSpace 1.5 UI needs width=500 height=342

if (!newChatWindow || newChatWindow.closed) {

    newChatWindow = window.open(chatURL,"Chat",windowFeatures) 

    // Create .opener property if necessary for old browsers.
    if (!newChatWindow.opener) {
    	newChatWindow.opener = window
    }
} else {
    // window's already open; bring to front
    newChatWindow.focus()
    }
}

//--------------------------------
// SiteMap Window creator.
// syntax: launchSiteMap()
//--------------------------------

var newSiteMapWindow

function launchSiteMap() {

if (!newSiteMapWindow || newSiteMapWindow.closed) {
    // create the sitemap window
//    newSiteMapWindow = window.open("/avilar/carelearning/sitemap/index.php3?p=0|","SiteMap","status,menubar,scrollbars,resizable,width=325,height=300")
    newSiteMapWindow = window.open("/treemenu/index.html","SiteMap","status,menubar,scrollbars,resizable,width=325,height=375")

    // Create .opener property if necessary for old browsers.
    if (!newSiteMapWindow.opener) {
        newSiteMapWindow.opener = window
    }
} else {
    // window's already open; bring to front
    newSiteMapWindow.focus()
    }
}

//--------------------------------
// The following variables are globals, used
// by both the preLogin() and login() functions.
//--------------------------------

var WMserverPath = "/training/template/"
var WMserverExt = ".cfm"
var WMserverParam = "?USER_ORGANIZATION="

//--------------------------------
// Cookie sniffer for login
// syntax: preLogin(ckName,WMserverRole)
// requires: cookie.js
//--------------------------------

function preLogin(ckName,WMserverRole) {

// Get the cookie.
var ckValue;
ckValue = GetCookie (ckName);

// If the cookie has a non-null value, use it to log into WebMentor.
// Otherwise, display the pre_login page.
if (ckValue) {
    WMserverCmd = WMserverPath + WMserverRole + WMserverExt + WMserverParam + ckValue;
    window.location.href = WMserverCmd;
} else {
    window.location.href = "/pre_login.html";
    }
}

//--------------------------------
// Login (and optional cookie creator)
// syntax: login(ckName,ckValue,ckFlag,WMserverRole)
// requires: cookie.js
//--------------------------------

function login(ckName,ckValue,ckFlag,WMserverRole) {

// Set the cookie expiration date.
var expdate = new Date ();
FixCookieDate (expdate); // Correct for Mac date bug - call only once for given Date object!
expdate.setTime (expdate.getTime() + (365 * 24 * 60 * 60 * 1000)); // Set cookie to expire 1 year from now 

// If the user checked "Remember my state", set the cookie.
// Otherwise, delete the cookie.
if (ckFlag) {
    SetCookie (ckName,ckValue,expdate)
} else {
    DeleteCookie (ckName)
    };

// Now log in.
WMserverCmd = WMserverPath + WMserverRole + WMserverExt + WMserverParam + ckValue;
window.location.href = WMserverCmd;
}

//--------------------------------
// Launch_sample_course
// syntax: launchSampleCourse(orgID,WMserverRole)
//--------------------------------

function launchSampleCourse(orgID,WMserverRole) {

WMserverCmd = WMserverPath + WMserverRole + WMserverExt + WMserverParam + orgID;
window.location.href = WMserverCmd;
}

//--------------------------------
// setState (cookie creator)
// syntax: setState(ckName,ckValue)
// requires: cookie.js
//--------------------------------

function setState(ckName,ckValue) {

// Set the cookie expiration date.
var expdate = new Date ();
FixCookieDate (expdate); // Correct for Mac date bug - call only once for given Date object!
expdate.setTime (expdate.getTime() + (365 * 24 * 60 * 60 * 1000)); // Set cookie to expire 1 year from now 

// Set the cookie.
SetCookie (ckName,ckValue,expdate)
alert("Thank you. Now click 'Course Catalog', 'Student Login', \nor 'Administration' at the top of the window to enter \nthe eLearning system.")
}
