/*
<file_comment>
<name>functions.js</name>
<programmer>Dave Devaux</programmer>
<date>01/01/1999</date>
<description>
Repository of re-used javascript functions used throughout KC.
</description>
</file_comment>
*/

loaded = false;

/*
<function_comment>
<function_language>Javascript</function_language>
<name>read_cookie</name>
<programmer>Dave Devaux</programmer>
<date>01/01/1999</date>
<description>
Read value of cookie in Javascript.
</description>
<parameter pass="ByVal">
<name>cookie_name</name>
<description>Cookie value being read.</description>
</parameter>
</function_comment>
*/
function read_cookie(cookie_name) {
  if(document.cookie) {
    cookie_start = document.cookie.indexOf(cookie_name);
    if (cookie_start != -1) {
      cookie_val_start = (document.cookie.indexOf("=", cookie_start) + 1);
      cookie_val_end = document.cookie.indexOf(";", cookie_start);
      if (cookie_val_end == -1) {
        cookie_val_end = document.cookie.length;
      }
        cookie_val = document.cookie.substring(cookie_val_start, cookie_val_end);
    }
    else {
        cookie_val = "";
    }
  }
  else {
    cookie_val = "";
  }
  return cookie_val;
}

/*
<function_comment>
<function_language>Javascript</function_language>
<name>go_mail</name>
<programmer>Dave Devaux</programmer>
<date>01/01/1999</date>
<description>
Launch pop up window to put mail form to send email through KC.
</description>
<parameter pass="ByVal">
<name>subject</name>
<description>Subject of Email.</description>
</parameter>
<parameter pass="querystring">
<name>recipient</name>
<description>Recipient of email being sent.</description>
</parameter>
</function_comment>
*/
function go_mail (subject,recipient) {
  window.open('/kc/main/mail_frm.asp?login=' + read_cookie('LOGIN') + '&subject=' + escape(subject) + '&recipient=' + escape(recipient),'mail','toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=560,height=420');
}

/*
<function_comment>
<function_language>Javascript</function_language>
<name>go_team_room_mail</name>
<programmer>Fabrice Bonnaire</programmer>
<date>07/18/2001</date>
<description>
Specific go mail function to handle team room mail, split out from regular go_mail to not have to go through all pages.
</description>
<parameter pass="ByVal">
<name>intTeamRoomID</name>
<description>Team Room which is being affected.</description>
</parameter>
<parameter pass="ByVal">
<name>strRecipients</name>
<description>Who will be the recipients of this group email.  Has cascading effect, for example if in Private room and sending message to Members then both Moderators and Owners will also recieve email since also members.</description>
</parameter>
</function_comment>
*/
function go_team_room_mail (intTeamRoomID, strRoomType, strRecipients) {
  window.open('/kc/main/mail_frm.asp?login=' + read_cookie('LOGIN') + '&intTeamRoomID=' + escape(intTeamRoomID) + '&strRecipients=' + escape(strRecipients),'team_room_mail','toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=560,height=420');
}

/*
<function_comment>
<function_language>Javascript</function_language>
<name>go_glossary</name>
<programmer>Dave Devaux</programmer>
<date>01/01/1999</date>
<description>
Launch full glossary pop up window.
</description>
</function_comment>
*/
function go_glossary () {
  KC = read_cookie('KC');
  window.open('/kc/glossary/g_kc_frm.asp?ident=' + KC,'glossary','toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=560,height=420');
}

/*
<function_comment>
<function_language>Javascript</function_language>
<name>go_term</name>
<programmer>Dave Devaux</programmer>
<date>01/01/1999</date>
<description>
Launch individual glossary term pop up window.
</description>
<parameter pass="ByVal">
<name>ident</name>
<description>Ident of glossary term to look up for</description>
</parameter>
</function_comment>
*/
function go_term (ident) {
  window.open('/kc/glossary/g_term_frm.asp?ident='+ident,'term_win','toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=400,height=250');
}

/*
<function_comment>
<function_language>Javascript</function_language>
<name>go_ref</name>
<programmer>Dave Devaux</programmer>
<date>01/01/1999</date>
<description>
Launch individual reference pop up window.
</description>
<parameter pass="ByVal">
<name>ident</name>
<description>Ident of reference to look up for.</description>
</parameter>
'<parameter pass="ByVal">
'<name>strFunction</name>
'<description>Functionality of the Content Item that is being viewed.</description>
'</parameter>
'<parameter pass="ByVal">
'<name>strTable</name>
'<description>Table of the Content Item that is being viewed.</description>
'</parameter>
'<parameter pass="ByVal">
'<name>strContentID</name>
'<description>ID of the Content Item that is being viewed.</description>
'</parameter>
'<modification version="3.0">
'<programmer>Kevin J Donohue</programmer>
'<date>8/30/2002</date>
'<description>
Added three values that are optionally passed via the call to go_pop_up to allow content tracking
'</description>
'</modification>
</function_comment>
*/
function go_ref(ident, strFunction, strTable) {
  window.open('/kc/library/reference_go_ref_frame.asp?ident='+ident+'&strFunction='+escape(strFunction)+'&strTable='+escape(strTable)+'&strContentID='+escape(ident),'ref_win','toolbar=yes,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=560,height=420');
}

/*
<function_comment>
<function_language>Javascript</function_language>
<name>strip</name>
<programmer>Dave Devaux</programmer>
<date>01/01/1999</date>
<description>
Removes all characters in the string strip_chars from the string the_string
</description>
<parameter pass="ByVal">
<name>the_string</name>
<description>Initial string in which to look for stripping characters.</description>
</parameter>
<parameter pass="ByVal">
<name>strip_chars</name>
<description>Characters which need to be taken out of the_string.</description>
</parameter>
</function_comment>
*/
function strip(the_string,strip_chars) {
	result_string = '';
	for (i = 0; i <= (the_string.length - 1); i++) {
		if (strip_chars.indexOf(the_string.charAt(i)) == -1) {
			result_string = result_string + the_string.charAt(i);
		}
	}
	return result_string;
}

/*
<function_comment>
<function_language>Javascript</function_language>
<name>strip_others</name>
<programmer>Dave Devaux</programmer>
<date>01/01/1999</date>
<description>
 removes all characters from the string the_string that are not in the string leave_chars
</description>
<parameter pass="ByVal">
<name>the_string</name>
<description>Initial string in which to look for stripping characters.</description>
</parameter>
<parameter pass="ByVal">
<name>strip_chars</name>
<description>Characters which need to be left in the_string.</description>
</parameter>
</function_comment>
*/
function strip_others(the_string,leave_chars) {
	result_string = '';
	for (i = 0; i <= (the_string.length - 1); i++) {
		if (leave_chars.indexOf(the_string.charAt(i)) != -1) {
			result_string = result_string + the_string.charAt(i);
		}
	}
	return result_string;
}

/*
<function_comment>
<function_language>Javascript</function_language>
<name>go_building_mail</name>
<programmer>Dave Devaux</programmer>
<date>01/01/1999</date>
<description>
Launch email function specific to building.
</description>
</function_comment>
*/
function go_building_mail () {
var i,building_cookie;
	building_cookie = read_cookie('BUILDING');
	kc_ident = read_cookie('KC');
	window.open('/kc/main/bldng_mail_frm.asp?subject=' + building_cookie + '&kc_ident=' + kc_ident,'mail','toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=560,height=420');
}

/*
<function_comment>
<function_language>Javascript</function_language>
<name>go_building_mail_dm</name>
<programmer>James Kim</programmer>
<date>12/08/2004</date>
<description>
Domain manager version of go_building_mail()
</description>
</function_comment>
*/
function go_building_mail_dm () {
	kc_ident = read_cookie('KC');
	window.open('/kc/main/bldng_mail_frm.asp?subject=&kc_ident=' + kc_ident,'mail','toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=560,height=420');
}

/*
<function_comment>
<function_language>Javascript</function_language>
<name>go_notepad</name>
<programmer>Dave Devaux</programmer>
<date>01/01/1999</date>
<description>
Launch notepad function.
</description>
</function_comment>
*/
function go_notepad () {
var i,building_cookie;
	building_cookie = read_cookie('BUILDING');
	kc_ident = read_cookie('KC');
	login = read_cookie('LOGIN');
	crs_ident = read_cookie('CRS');
	window.open('/kc/notepad/notes_frm.asp?building=' + building_cookie + '&kc_ident=' + kc_ident + '&login=' + login + '&crs_ident=' + crs_ident,'notepad','toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=560,height=420');
}

/*
<function_comment>
<function_language>Javascript</function_language>
<name>seminar_go_pop_up</name>
<programmer>Fabrice Bonnaire</programmer>
<date>10/01/2001</date>
<description>
Specific pop up frame set for Seminar tool used.  Created to not conflict with go_pop_up when viewing content and allow to windows at a time.  To be used specifically in Seminar.
</description>
<parameter pass="ByVal">
<name>loc</name>
<description>Location where to go.</description>
</parameter>
</function_comment>
*/
function seminar_go_pop_up (loc) {
	new_loc = loc;
	window.open('/kc/main/pop_up_frm.asp?loc='+escape(loc),'seminar_pop_up','toolbar=yes,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=640,height=480');
}

/*
<function_comment>
<function_language>Javascript</function_language>
<name>go_pop_up</name>
<programmer>Dave Devaux</programmer>
<date>01/01/1999</date>
<description>
Launch pop window.
</description>
<parameter pass="ByVal">
<name>loc</name>
<description>Location where to go.</description>
</parameter>
'<parameter pass="ByVal">
'<name>strFunction</name>
'<description>Functionality of the Content Item that is being viewed.</description>
'</parameter>
'<parameter pass="ByVal">
'<name>strTable</name>
'<description>Table of the Content Item that is being viewed.</description>
'</parameter>
'<parameter pass="ByVal">
'<name>strContentID</name>
'<description>ID of the Content Item that is being viewed.</description>
'</parameter>
'<modification version="3.0">
'<programmer>Kevin J Donohue</programmer>
'<date>8/30/2002</date>
'<description>
Added three values that are optionally passed via the call to go_pop_up to allow content tracking
'</description>
'</modification>
'</function_comment>
*/
function go_pop_up (loc, strFunction, strTable, strContentID) {
	new_loc = loc;
	window.open('/kc/main/pop_up_frm.asp?loc='+escape(loc)+'&strFunction='+escape(strFunction)+'&strTable='+escape(strTable)+'&strContentID='+escape(strContentID),'pop_up','toolbar=yes,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=560,height=420');
}



function go_pop_up_wbt (loc, strFunction, strTable, strContentID) {
	new_loc = loc;
	window.open('/kc/main/pop_up_frm.asp?loc='+escape(loc)+'&strFunction='+escape(strFunction)+'&strTable='+escape(strTable)+'&strContentID='+escape(strContentID),'pop_up','toolbar=yes,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=750,height=950');
}
/*
<function_comment>
<function_language>Javascript</function_language>
<name>go_pop_up_alt</name>
<programmer>Fabrice Bonnaire</programmer>
<date>11/05/2001</date>
<description>
Alternate pop up if not want to take over current opening pop up window within pop up window.
</description>
<parameter pass="ByVal">
<name>loc</name>
<description>Location where to go.</description>
</parameter>
</function_comment>
*/
function go_pop_up_alt (loc) {
	new_loc = loc;
	window.open('/kc/main/pop_up_frm.asp?loc='+escape(loc),'pop_up_alt','toolbar=yes,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=560,height=420');
}

/*
<function_comment>
<function_language>Javascript</function_language>
<name>go_contrib_pop_up</name>
<programmer>Kevin J Donohue</programmer>
<date>9/4/2002</date>
<description>
Alternate pop up for user ratings'
</description>
<parameter pass="ByVal">
<name>loc</name>
<description>Location where to go.</description>
</parameter>
</function_comment>
*/
function go_contrib_pop_up (loc) {
	new_loc = loc;
	window.open('/kc/main/pop_up_frm.asp?loc='+escape(loc),'contrib_pop_up','toolbar=yes,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=560,height=420');
}

/*
<function_comment>
<function_language>Javascript</function_language>
<name>go_bookmark_pop_up</name>
<programmer>Fabrice Bonnaire</programmer>
<date>11/05/2001</date>
<description>
Pop up window where LO-Based courseware reside.
</description>
<parameter pass="ByVal">
<name>loc</name>
<description>Location where to go.</description>
</parameter>
</function_comment>
*/
function go_bookmark_pop_up (loc) {
	new_loc = loc;
	bookmarkWin = window.open('/kc/main/pop_up_frm.asp?loc='+escape(loc),'pop_up','toolbar=yes,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=560,height=420');
	bookmarkWin.creator = self;
}

/*
<function_comment>
<function_language>Javascript</function_language>
<name>go_survey</name>
<programmer>Fabrice Bonnaire</programmer>
<date>11/05/2001</date>
<description>
Survey only pop up window..
</description>
<parameter pass="ByVal">
<name>loc</name>
<description>Location where to go.</description>
</parameter>
</function_comment>
*/
function go_survey (loc) {
	new_loc = loc;
	window.open('/kc/main/pop_up_frm.asp?loc='+escape(loc),'pop_up','toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=700,height=500');
}

/*
<function_comment>
<function_language>Javascript</function_language>
<name>go_pop_up_link</name>
<programmer>Fabrice Bonnaire</programmer>
<date>11/05/2001</date>
<description>
Alternate pop up if not want to take over current opening pop up window within pop up window.
</description>
<parameter pass="ByVal">
<name>loc</name>
<description>Location where to go.</description>
</parameter>
</function_comment>
*/
function go_pop_up_link (loc) {
	top.new_win = window.open('/kc/main/pop_up_frm.asp?loc='+escape(loc), 'pop_up_link','toolbar=yes,location=no,directories=no,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=560,height=420');
	top.new_win.creator = self;
}

/*
<function_comment>
<function_language>Javascript</function_language>
<name>go_small_pop_up</name>
<programmer>Fabrice Bonnaire</programmer>
<date>11/05/2001</date>
<description>
Smaller pop up window..
</description>
<parameter pass="ByVal">
<name>loc</name>
<description>Location where to go.</description>
</parameter>
</function_comment>
*/
function go_small_pop_up (loc) {
	new_loc = loc;
	window.open('/kc/main/pop_up_frm.asp?loc='+escape(loc),'small_pop_up','toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=350,height=230');
}

/*
<function_comment>
<function_language>Javascript</function_language>
<name>go_crs_pop_up</name>
<programmer>Fabrice Bonnaire</programmer>
<date>11/05/2001</date>
<description>
Launch course specific pop up window used both when launch full course or individual LO.
</description>
<parameter pass="ByVal">
<name>loc</name>
<description>Location where to go.</description>
</parameter>
<parameter pass="ByVal">
<name>botbartype</name>
<description>Type of of bottom bar to display when entering LO based courseware.</description>
</parameter>
<modification>
<programmer>Fabrice Bonnaire</programmer>
<date>05/02/2002</date>
<description>
Allow setting of window features .
</description>
<parameter pass="ByVal">
<name>strCourseWinFeatures</name>
<description>Window launching features.</description>
</parameter>
</modification>
</function_comment>
*/
function go_crs_pop_up (loc,botbartype, strCourseWinFeatures) {
	var passbotbartype

	if (botbartype != null) {
		passbotbartype = botbartype;
	}
	else {
		passbotbartype = '';
	}

	intWidth = 0
	intHeight = 0

	strVersion = navigator.appVersion;
	strVersion = eval(strVersion.charAt(0));
	intScreenWidth = eval(screen.width);
	intScreenHeight = eval(screen.height);

	if (strVersion < 4) {
		intWidth=800;
		intHeight = 600;
	}

	intHeightOffset = 0;
	intWidthOffset = 0;

	if ((navigator.appName == "Netscape") && (strVersion > 3)) {
		intHeight = eval(screen.height);
		intWidth = eval(screen.width);
		intHeightOffset = Math.floor(intHeight * .05);
		intWidthOffset = Math.floor(intHeight * .05);
		intHeight = intHeight - (intHeightOffset * 2);
		intWidth = intWidth - (intWidthOffset * 2);
	}

	if ((intScreenWidth <= 800) && (intScreenHeight <= 600)) {
		intWidth=800;
		intHeight = 600;
	}

/*Set window sizes to fixed width of 756X538 to accomodate new SCORM/LO 508c Templates based on non-scrolling settings if non-specified in CRS table.  Fabrice Bonnaire.  05/08/2002.*/

	intWidth = 765;
	intHeight = 538;

	if (strCourseWinFeatures == '') {
		strCourseWinFeatures = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=' +intWidth + ',height=' + intHeight;
	}

	var new_window = window.open('/kc/main/crs_pop_up_frm.asp?loc='+escape(loc) + '&botbartype='  + escape(passbotbartype),'crs_pop_up', strCourseWinFeatures);
}

/*
<function_comment>
<function_language>Javascript</function_language>
<name>set_cookie</name>
<programmer>Dave Devaux</programmer>
<date>01/01/1999</date>
<description>
Set value of cookie in Javascript.
</description>
<parameter pass="ByVal">
<name>cookie_name</name>
<description>Cookie name being set.</description>
</parameter>
<parameter pass="ByVal">
<name>cookie_value</name>
<description>Cookie value being set.</description>
</parameter>
</function_comment>
*/
function set_cookie (cookie_name,cookie_value) {
  document.cookie = cookie_name + '=' + cookie_value + ';path=/kc/';
}

/*
<function_comment>
<function_language>Javascript</function_language>
<name>kill_cookie</name>
<programmer>Dave Devaux</programmer>
<date>01/01/1999</date>
<description>
Used to delete cookie in inline Javascript Tuesday,01-January-1980 12:00:00 GMT
</description>
<parameter pass="ByVal">
<name>cookie_name</name>
<description>Cookie name being deleted.</description>
</parameter>
</function_comment>
*/
function kill_cookie (cookie_name) {
  expiredate = new Date
  expiredate.setMonth(expiredate.getMonth()-1)
  document.cookie = cookie_name + '=nothing;path=/kc/;expires=expiredate.toGMTString()';
}

/*
<function_comment>
<function_language>Javascript</function_language>
<name>read_sub_cookie</name>
<programmer>Dave Devaux</programmer>
<date>01/01/1999</date>
<description>
Read sub cookie within a larger cookie.  Used mostly in Courseware.
</description>
<parameter pass="ByVal">
<name>cookie_name</name>
<description>Main cookie name being read.</description>
</parameter>
<parameter pass="ByVal">
<name>sub_cookie_name</name>
<description>Internal cookie name to be found in cookie_name and returned.</description>
</parameter>
</function_comment>
*/
function read_sub_cookie(cookie_name,sub_cookie_name) {
  cookie_val = read_cookie(cookie_name);
  sub_cookie_start = cookie_val.indexOf(sub_cookie_name);
  if (sub_cookie_start != -1) {
    sub_cookie_val_start = cookie_val.indexOf("=", sub_cookie_start) + 1;
    sub_cookie_val_end = cookie_val.indexOf("|", sub_cookie_start);
    if (sub_cookie_val_end == -1) {
      sub_cookie_val_end = cookie_val.length;
    }
      sub_cookie_val = cookie_val.substring(sub_cookie_val_start, sub_cookie_val_end);
  }
  else {
    sub_cookie_val = "";
  }
  return sub_cookie_val;
}

/*
<function_comment>
<function_language>Javascript</function_language>
<name>set_sub_cookie</name>
<programmer>Dave Devaux</programmer>
<date>01/01/1999</date>
<description>
Set sub cookie within a larger cookie.  Used mostly in Courseware.
</description>
<parameter pass="ByVal">
<name>cookie_name</name>
<description>Main cookie name being read and in which sub cookie is inserted.</description>
</parameter>
<parameter pass="ByVal">
<name>sub_cookie_name</name>
<description>Internal cookie name to be added in cookie_name.</description>
</parameter>
<parameter pass="ByVal">
<name>sub_cookie_name</name>
<description>Value of internal sub_cookie_name to be added in cookie_name.</description>
</parameter>
</function_comment>
*/
function set_sub_cookie (cookie_name,sub_cookie_name,sub_cookie_val) {

  cookie_val = read_cookie(cookie_name);

//delete old subcookie with name sub_cookie_name, if any

  sub_cookie_start = cookie_val.indexOf(sub_cookie_name);
  if (sub_cookie_start != -1) {
    sub_cookie_end = cookie_val.indexOf("|", sub_cookie_start);
    if (sub_cookie_end == -1) {
      sub_cookie_end = cookie_val.length;
    }
    cookie_val = cookie_val.substring(0,sub_cookie_start) + cookie_val.substring(sub_cookie_end + 1, cookie_val.length);
  }

//add new subcookie with name sub_cookie_name, value sub_cookie_value

  cookie_val = cookie_val + sub_cookie_name + '=' + sub_cookie_val + '|';
  document.cookie = cookie_name + '=' + cookie_val + ';path=/kc/';
}

/*
<function_comment>
<function_language>Javascript</function_language>
<name>set_next</name>
<programmer>Dave Devaux</programmer>
<date>01/01/1999</date>
<description>
Set next page location within LO-based courseware
</description>
<parameter pass="ByVal">
<name>loc</name>
<description>Location of next page of courseware set within sub cookie LOINFO.</description>
</parameter>
</function_comment>
*/
function set_next (loc) {
  set_sub_cookie('LOINFO','NEXT',loc);
}

/*
<function_comment>
<function_language>Javascript</function_language>
<name>set_prev</name>
<programmer>Dave Devaux</programmer>
<date>01/01/1999</date>
<description>
Set previous page location within LO-based courseware
</description>
<parameter pass="ByVal">
<name>loc</name>
<description>Location of previous page of courseware set within sub cookie LOINFO.</description>
</parameter>
</function_comment>
*/
function set_prev (loc) {
  set_sub_cookie('LOINFO','PREV',loc);

}

/*
<function_comment>
<function_language>Javascript</function_language>
<name>set_curr</name>
<programmer>Dave Devaux</programmer>
<date>01/01/1999</date>
<description>
Current location within LO-based courseware
</description>
<parameter pass="ByVal">
<name>loc</name>
<description>Current page of courseware set within sub cookie LOINFO.</description>
</parameter>
</function_comment>
*/
function set_curr (loc) {
  set_sub_cookie('LOINFO','CURRENT',loc);
}

/*
<function_comment>
<function_language>Javascript</function_language>
<name>display_arrows</name>
<programmer>Dave Devaux</programmer>
<date>01/01/1999</date>
<description>
Display arrows within LO courseware on Bottom bar
</description>
</function_comment>
*/
function display_arrows () {
  if (top.botbar.display_arrows != null) {
    top.botbar.display_arrows();
  }
}

/*
<function_comment>
<function_language>Javascript</function_language>
<name>enable_next</name>
<programmer>Dave Devaux</programmer>
<date>01/01/1999</date>
<description>
When called, sets new value for next page and redisplays next &amp;display_next prev arrows (so now the next arrow will be enabled)
This was taken from Bank One Code to enable the CMS Course.  Fabrice Bonnaire.  02/28/2001.
</description>
<parameter pass="ByVal">
<name>next_page</name>
<description>Location of next page of courseware.</description>
</parameter>
</function_comment>
*/
function enable_next (next_page) {
    set_next(next_page);
    display_arrows();
}

/*
<function_comment>
<function_language>Javascript</function_language>
<name>display_next</name>
<programmer>Dave Devaux</programmer>
<date>01/01/1999</date>
<description>
When called, sets new value for next page and and calls go_next from the courseware toolbar (enables courseware developer to call the next page without using the arrows on the toolbar - needed for last page of an lo if it does not have arrows displayed).  jen beers 6/13/2001
</description>
<parameter pass="ByVal">
<name>next_page</name>
<description>Location of next page of courseware.</description>
</parameter>
</function_comment>
*/
function display_next (next_page) {
    set_next(next_page);
    go_next();
}

/*
<function_comment>
<function_language>Javascript</function_language>
<name>print_frame</name>
<programmer>Dave Devaux</programmer>
<date>01/01/1999</date>
<description>
Print out specfic frame from another frame
</description>
<parameter pass="ByVal">
<name>next_page</name>
<description>Frame to be printed out.</description>
</parameter>
</function_comment>
*/
function print_frame(the_frame) {
       var OLECMDID_PRINT = 6;
        var OLECMDEXECOPT_DONTPROMPTUSER = 1;
        var OLECMDEXECOPT_PROMPTUSER = 2;
        var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';

        the_frame.focus();
        document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
        WebBrowser1.ExecWB(OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER);
        WebBrowser1.outerHTML = "";
}

/*
<function_comment>
<function_language>Javascript</function_language>
<name>CheckAll</name>
<programmer>Fabrice Bonnaire</programmer>
<date>01/01/1999</date>
<description>
Function to allow checking all checkboxes in a form.  Used mostly in content forms to select all items to either hide or activate.
</description>
</function_comment>
*/
function CheckAll() {
	for (var i=0;i<document.form.elements.length;i++) {
		var e = document.form.elements[i];
		if (e.name != 'allbox')
			e.checked = document.form.allbox.checked;
	}
}

/*
<function_comment>
<function_language>Javascript</function_language>
<name>CheckAll2</name>
<programmer>Fabrice Bonnaire</programmer>
<date>01/01/1999</date>
<description>
Function to allow checking all checkboxes in a form.  Used mostly in content forms to select all items to either hide or activate.
</description>
</function_comment>
*/
function CheckAll2() {
	for (var i=0;i<document.form2.elements.length;i++) {
		var e = document.form2.elements[i];
		if (e.name != 'allbox')
			e.checked = document.form2.allbox.checked;
	}
}

/*
<function_comment>
<function_language>Javascript</function_language>
<name>CheckAllFinal</name>
<programmer>Fabrice Bonnaire</programmer>
<date>01/01/1999</date>
<description>
Function to allow checking all checkboxes in a form.  Used mostly in content forms to select all items to either hide or activate. This is upgrade to previous since can only have one script for multiple forms on page need to pass form values to function.
</description>
<parameter pass="ByVal">
<name>PassedForm</name>
<description>Form in which checkboxes exist and need to be checked on or off.</description>
</parameter>
</function_comment>
*/
function CheckAllFinal(PassedForm) {
	for (var i=0;i<PassedForm.elements.length;i++) {
		var e = PassedForm.elements[i];
		if (e.name != 'allbox')
			e.checked = PassedForm.allbox.checked;
	}
}


/*
<function_comment>
<function_language>Javascript</function_language>
<name>SelectSelectAll</name>
<programmer>David DeVaux</programmer>
<date>02/10/2005</date>
<description>
Given a select form element object, sets the selected property of all option elements within the select object
to true, thus selecting all options for that select element.
</description>
<parameter pass="ByVal">
<name>objSelectElement</name>
<description>select form element object</description>
</parameter>
</function_comment>
*/

function SelectSelectAll(objSelectElement) {

	for (var intI = 0;  intI < objSelectElement.length; intI++) {
		var objOption = objSelectElement.options[intI];

		objOption.selected = true;
	}

	return;
}

/*
<function_comment>
<function_language>Javascript</function_language>
<name>SelectUnselectAll</name>
<programmer>David DeVaux</programmer>
<date>02/10/2005</date>
<description>
Given a select form element object, sets the selected property of all option elements within the select object
to false, thus unselecting all options for that select element.
</description>
<parameter pass="ByVal">
<name>objSelectElement</name>
<description>select form element object</description>
</parameter>
</function_comment>
*/

function SelectUnselectAll(objSelectElement) {

	for (var intI = 0;  intI < objSelectElement.length; intI++) {
		var objOption = objSelectElement.options[intI];

		objOption.selected = false;
	}

	return;
}
		


/*
<function_comment>
<function_language>Javascript</function_language>
<name>charInString</name>
<programmer>Fabrice Bonnaire</programmer>
<date>01/01/1999</date>
<description>
Used in conjuction with stripInitialWhitespace.  Looks for character in string.  From Netscape.com
</description>
<parameter pass="ByVal">
<name>c</name>
<description>Character to check</description>
</parameter>
<parameter pass="ByVal">
<name>s</name>
<description>String to check against</description>
</parameter>
</function_comment>
*/
var whitespace = " \t\n\r";

function charInString (c, s){
	for (i = 0; i < s.length; i++) {
		if (s.charAt(i) == c)
			return true;
	}
	return false
}

/*
<function_comment>
<function_language>Javascript</function_language>
<name>stripInitialWhitespace</name>
<programmer>Fabrice Bonnaire</programmer>
<date>01/01/1999</date>
<description>
Code gotten from validation code from Netscape to strip all extra white spaces in input form.  Used in conjuction with stripInitialWhitespace.  Looks for character in string
</description>
<parameter pass="ByVal">
<name>s</name>
<description>String in which to look strip out whitespace before and after string.</description>
</parameter>
</function_comment>
*/
function stripInitialWhitespace(s) {
	var i = 0;
	while ((i < s.length) && charInString (s.charAt(i), whitespace))
		i++;
		return s.substring (i, s.length);
}

/*
<function_comment>
<function_language>Javascript</function_language>
<name>is_digit</name>
<programmer>Ryan Dewalt</programmer>
<date>01/01/1999</date>
<description>
Verify if a passed character is an digits. Return true/false.
</description>
<parameter pass="ByVal">
<name>digit_char</name>
<description>Character being checked.</description>
</parameter>
</function_comment>
*/
function is_digit (digit_char) {
	if ('0123456789'.indexOf(digit_char.charAt(0)) == -1) {
		return false;
	}
	else {
		return true;
	}
}

/*
<function_comment>
<function_language>Javascript</function_language>
<name>are_digits</name>
<programmer>Ryan Dewalt</programmer>
<date>01/01/1999</date>
<description>
Verify if a string of characters are all digits. Return true/false.
</description>
<parameter pass="ByVal">
<name>digit_string</name>
<description>Character being checked.</description>
</parameter>
</function_comment>
*/
function are_digits (digit_string) {
	var i;
	for (i = 0; i <= (digit_string.length - 1);i++) {
		if (! is_digit(digit_string.charAt(i))) {
			return false;
		}
	}
	return true;
}

/*
<function_comment>
<function_language>Javascript</function_language>
<name>is_leap_year</name>
<programmer>Dave Devaux</programmer>
<date>01/01/1999</date>
<description>
Verify if a given year is a leap year or not. Return true/false.
</description>
<parameter pass="ByVal">
<name>year_string</name>
<description>Year being checked.</description>
</parameter>
</function_comment>
*/
function is_leap_year (year_string) {
	var year = eval(year_string);
	if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)) {
		return true;
	}
	else {
		return false;
	}
}

/*
<function_comment>
<function_language>Javascript</function_language>
<name>compare_date</name>
<programmer>Ken McKenzie</programmer>
<date>01/01/2001</date>
<description>
Function to ensure that if there is a date range in a form that the latter date will be greater than the original date
</description>
<parameter pass="ByVal">
<name>start_date</name>
<description>Start date to verify.</description>
</parameter>
<parameter pass="ByVal">
<name>end_date</name>
<description>End date to verify.</description>
</parameter>
<modification>
<programmer>Fabrice Bonnaire</programmer>
<date>05/01/2001</date>
<description>
Modified certain checks to ensure all scenarii
</description>
</modification>
</function_comment>
*/
function compare_date (start_date, end_date) {

	var date_year1, date_year2, date_month1, date_month2, date_day1, date_day2, month_ok, day_ok;

	/*Pad zeros in date to ensure length of 10 for date check*/
	if (start_date.length > 10) {
		return false;
	}
	if (start_date.length < 10) {
		intFirstSlash = start_date.indexOf("/");
		intLastSlash = start_date.lastIndexOf("/");
		date_month1 = start_date.substring(0, intFirstSlash)
		if (date_month1.length < 2) {
			date_month1 = '0' + date_month1
		}
		date_day1 = start_date.substring(intFirstSlash + 1, intLastSlash)
		if (date_day1.length < 2) {
			date_day1 = '0' + date_day1
		}
		date_year1 = start_date.substring(intLastSlash + 1, start_date.length)
		start_date = date_month1 + '/' + date_day1 + '/' + date_year1
	}

	date_month1 = start_date.substring(0,2);
	date_day1 = start_date.substring(3,5);
	date_year1 = start_date.substring(6,10);

	/*Pad zeros in date to ensure length of 10 for date check*/
	if (end_date.length > 10) {
		return false;
	}
	if (end_date.length < 10) {
		intFirstSlash = end_date.indexOf("/");
		intLastSlash = end_date.lastIndexOf("/");
		date_month2 = end_date.substring(0, intFirstSlash)
		if (date_month2.length < 2) {
			date_month2 = '0' + date_month2
		}
		date_day2 = end_date.substring(intFirstSlash + 1, intLastSlash)
		if (date_day2.length < 2) {
			date_day2 = '0' + date_day2
		}
		date_year2 = end_date.substring(intLastSlash + 1, end_date.length)
		end_date = date_month2 + '/' + date_day2 + '/' + date_year2
	}

	date_month2 = end_date.substring(0,2);
	date_day2 = end_date.substring(3,5);
	date_year2 = end_date.substring(6,10);

	if (date_year1 > date_year2) {
	  return false;
	}

	if (date_year1 < date_year2) {
	  return true;
	}

	if (date_month1 > date_month2) {
	  month_ok = 0;
	}
	if ((date_month1 > date_month2) && (date_year1 < date_year2)) {
	  month_ok = 1;
	}

	if (date_day1 > date_day2) {
	  day_ok = 0;
	}
	if ((date_day1 > date_day2) && (date_month1 < date_month2)) {
	  day_ok = 1;
	}
	if ((date_day1 > date_day2) && (date_month1 > date_month2)) {
	  day_ok = 2;
	}

	if (((day_ok == 0) || (month_ok == 0)) || ((day_ok == 0) && (month_ok == 1)) || ((day_ok == 2) && (month_ok == 0))) {
	  return false;
	}
	else {
	  return true;
	}
}

/*
<function_comment>
<function_language>Javascript</function_language>
<name>check_date</name>
<programmer>Dave Devaux</programmer>
<date>01/01/2000</date>
<description>
Verify that a passed date is a valid date.  Returns true/false
</description>
<parameter pass="ByVal">
<name>date_string</name>
<description>Date being verified for validity.</description>
</parameter>
</function_comment>
*/
function check_date (date_string) {

	var date_month,date_day,date_year;

	if (date_string.length > 10) {
		return false;
	}
	if (date_string.length < 8) {
		return false;
	}
	if (date_string.length < 10) {
		intFirstSlash = date_string.indexOf("/");
		intLastSlash = date_string.lastIndexOf("/");
		date_month = date_string.substring(0, intFirstSlash)
		if (date_month.length < 2) {
			date_month = '0' + date_month
		}
		date_day = date_string.substring(intFirstSlash + 1, intLastSlash)
		if (date_day.length < 2) {
			date_day = '0' + date_day
		}
		date_year = date_string.substring(intLastSlash + 1, date_string.length);
		if (date_year.length > 4) {
			return false;
		}
		date_string = date_month + '/' + date_day + '/' + date_year
	}

	date_month = date_string.substring(0,2);
	date_day = date_string.substring(3,5);
	date_year = date_string.substring(6,10);

	if (! (are_digits(date_month) && are_digits(date_day) && are_digits(date_year) && (date_string.charAt(2) == '/') && (date_string.charAt(5) == '/'))) {
		return false;
	}
	
	if (eval(date_year) < 1900) {
		return false;
	}

	if ((date_month > 12) || (date_month < 1)) {
		return false;
	}

	if (date_day < 1) {
		return false;
	}

	if (((date_month == 9) || (date_month == 4) ||(date_month == 6) || (date_month == 11)) && (date_day > 30)) {
		return false;
	}

	if (((date_month == 1) || (date_month == 3) ||(date_month == 5) || (date_month == 7) || (date_month == 8) || (date_month == 10)  || (date_month == 12))  && (date_day > 31)) {
		return false;
	}


	if ((date_month == 2) && is_leap_year(date_year) && (date_day > 29)) {
		return false;
	}

	if ((date_month == 2) && !is_leap_year(date_year) && (date_day > 28)) {
		return false;
	}

	return true;

}

/*
<function_comment>
<function_language>Javascript</function_language>
<name>go_calendar</name>
<programmer>Fabrice Bonnaire</programmer>
<date>01/01/1999</date>
<description>
Pop up calendar function taken from http://developer.netscape.com/docs/examples/?content=javascript/calendar/description.html.  fldDate parameter is full qualifying name of date field in form to be updated.  Need to make the date text field readonly status using onFocus function to focus to previous field done to work in Netscape which does NOT recognize READONLY attribute in all versions.  Need to have /kc/includes/calendar.js added as include to file display of calendar can be changed in js file.
</description>
<parameter pass="ByVal">
<name>fldDate</name>
<description>Form field which contains date being chosen from pop up window and which will be populated once date is chosen.</description>
</parameter>
</function_comment>
*/
function go_calendar(fldDate) {


//alert("sss");

	//if ((fldDate.value != '') && (! check_date(fldDate.value))) {
		//alert("The Completed field must be a valid date of the form mm/dd/yyyy. Example: 01/01/1998");
		//fldDate.focus();
		//return false;
	//}

	strVersion = navigator.appVersion;
	strVersion = eval(strVersion.charAt(0));

	//alert(top.newWin)


	if (strVersion < 4) {
		alert("You do not have the necessary browser to view this calendar function.  You must enter dates manually, using the format: mm/dd/yyyy.");
		return false;

	}

	setDateField(fldDate);

	if (top.newWin != null) {


		if (!top.newWin.closed) {
			top.newWin.close();
		}
	}

	if (navigator.appName == "Netscape") {


	

		var ScreenWidth= top.screenY + (top.innerWidth/2);
		var ScreenHeight= top.screenX + (top.innerHeight/2);
		top.newWin = window.open('/kc/main/calendar.html', 'cal', 'dependent=yes,width=210,height=250,left=' + ScreenWidth +',top=' + ScreenHeight +',titlebar=yes')
	} 

else {



		top.newWin = window.open('/kc/main/calendar.html', 'cal', 'dependent=yes,width=210,height=250,left=' + (event.screenX - 210) + ',top=' + (event.screenY - 250) + ',titlebar=yes')
	}

	
	return true;
}

/*Still needed*/
function go_job (intJobID,strKCID,strUserID) {
  window.open('/kc/apss/apss_job_frm.asp?intJobID='+ escape(intJobID) + '&strKCID=' + escape(strKCID) + '&strUserID=' + escape(strUserID),'job_win','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=560,height=420');

}
/*Still needed*/
function go_task (intTaskID,strKCID,strUserID) {
  window.open('/kc/apss/apss_task_frm.asp?intTaskID='+ escape(intTaskID) + '&strKCID=' + escape(strKCID) + '&strUserID=' + escape(strUserID),'job_win','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=560,height=420');

}

/*<function_comment>
<name>SCORMGoResource</name>
<language>JavaScript</language>
<programmer>Dave Devaux</programmer>
<date>03/08/2002</date>
<description>Launch a SCORM Resource individually.</description>
<parameter pass="ByVal">
<name>strPackageID</name>
<description>Package ID where resource is part of.</description>
</parameter>
<parameter pass="ByVal">
<name>strResourceID</name>
<description>Resource ID being lauched.</description>
<parameter pass="ByVal">
<name>strUserID</name>
<description>Ident of user launching resource.</description>
</parameter></parameter>
</function_comment>*/
function SCORMGoResource (strPackageID,strResourceID,strUserID, strSCOWinfeatures) {

	if (strSCOWinfeatures == '') {
		strSCOWinfeatures = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=765,height=535'
	}
	window.open('/kc/ilc/scorm_course_launch_frm.asp?strCourseID=' + escape(strPackageID) + '&strItemID=' + escape(strResourceID) + '&strUserID=' + escape(strUserID) + '&strCredit=credit&strMode=normal','SCORM',strSCOWinfeatures);
}

/*
'<function_comment>
<function_language>Javascript</function_language>
'<name>go_medium_pop_up</name>
'<programmer>Fabrice</programmer>
'<date>03/18/2002</date>
'<description>
'Medium sized pop up.  Created originally for SCORM Creator and displaying course information and prerequisites.  450X320.
'</description>
'<parameter pass="ByVal">
'<name>strLocation</name>
'<description>URL which pop up will display.</description>
'</parameter>
'</function_comment>
*/
function go_medium_pop_up (strLocation) {
	new_loc = strLocation;
	window.open('/kc/main/pop_up_frm.asp?loc='+escape(strLocation),'medium_pop_up','toolbar=yes,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=450,height=320');
}

/*
'<function_comment version="3.0">
<function_language>Javascript</function_language>
'<name>content_go_pop_up</name>
'<programmer>Subbu</programmer>
'<date>03/18/2002</date>
'<description>
'Pop up funciton that is used for Content Tracking.
'</description>
'<parameter pass="ByVal">
'<name>loc</name>
'<description>URL which pop up will display.</description>
'</parameter>
'<parameter pass="ByVal">
'<name>strFunction</name>
'<description>Functionality of the Content Item that is being viewed.</description>
'</parameter>
'<parameter pass="ByVal">
'<name>strTable</name>
'<description>Table of the Content Item that is being viewed.</description>
'</parameter>
'<parameter pass="ByVal">
'<name>strContentID</name>
'<description>ID of the Content Item that is being viewed.</description>
'</parameter>
'</function_comment>
*/
function content_go_pop_up (loc, strFunction, strTable, strContentID) {
	new_loc = loc;
	window.open('/kc/main/pop_up_frm.asp?loc='+escape(loc)+'&strFunction='+escape(strFunction)+'&strTable='+escape(strTable)+'&strContentID='+escape(strContentID),'content_pop_up','toolbar=yes,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=560,height=420');
}

/*
'<function_comment version="3.0">
<function_language>Javascript</function_language>
'<name>CheckUserDefault</name>
'<programmer>Subbu</programmer>
'<date>06/20/2002</date>
'<description>
'JS function that displays an alert message if the user has not performed any previous search.
'</description>
'<parameter pass="ByVal">
'<name>strFunction</name>
'<description>Identifies the function for which search is being performed.</description>
'</parameter>
'<parameter pass="ByVal">
'<name>strDefault</name>
'<description>Boolean value that determines if search has been performed or not.</description>
'</parameter>
'</function_comment>
*/
function CheckUserDefault(strFunction, strDefault)
{
	var strDefault;
	if(strDefault=='False')
	{
		alert("Your top " + strFunction + " are based on your most recent search criteria.  To perform a search, fill in the form, then click the Search button.");
		return false;
	}
	return true;
}

/*
<function_comment version="3.0">
<function_language>Javascript</function_language>
<name>checkLength</name>
<programmer>Subbu</programmer>
<date>08/08/2002</date>
<description>
Check the length of any string and return if value checked against is too large. Used to ensure that too large of values go into DB by error.
</description>
<parameter pass="ByVal">
<name>curFieldLength</name>
<description>Field being passed for checking</description>
</parameter>
<parameter pass="ByVal">
<name>intFieldLength</name>
<description>Field length to check against</description>
</parameter>
</function_comment>
*/

function checkLength(curFieldLength, intFieldLength) {
	if (curFieldLength > intFieldLength) {
		return true;
	} else {
		return false;
	}
}

/*
'<function_comment version="3.0">
<function_language>Javascript</function_language>
'<name>validateEmailAddress</name>
'<programmer>Chris Grove</programmer>
'<date>05/08/2002</date>
'<description>
'This checks an email address to see if it is formatted correctly. If not it will return false and set focus to the problematic input box.
'</description>
'<parameter pass="ByVal">
'<name>strEmailAddress</name>
'<description>The email address being validated.</description>
'</parameter>
'</function_comment>
*/
function validateEmailAddress(strEmailAddress) {

	var arrEmailAddressComponents;
	var arrEmailDomainComponents;


	strEmailAddress=stripInitialWhitespace(strEmailAddress);

	if (strEmailAddress.length == 0) {
		alert('You must enter a properly formatted Email Address.');
		return false;
	}

	arrEmailAddressComponents = strEmailAddress.toLowerCase().split('@');

	if (arrEmailAddressComponents.length != 2) {
		alert('Email Addresses must contain a single @ symbol.');
		return false;
	}

	//checking the 1st part of the email address (before the @ symbol)
	if (arrEmailAddressComponents[0].length == 0) {
		alert('Email Addresses must include the account name. \r\r Ex.  [accountname]@meridianksi.com');
		return false;
	}

	if (arrEmailAddressComponents[0].indexOf(' ') != -1) {
		alert('Email Addresses must not include spaces.');
		return false;
	}

	if (arrEmailAddressComponents[0].indexOf('/') != -1) {
		alert('Email Addresses must not contain the / character.');
		return false;
	}

	//checking the 2nd part of the email address (after the @ symbol)
	if (arrEmailAddressComponents[1].length == 0) {
		alert('Email Addresses must include domain name and top level domain. \r\r Ex.  accountname@[meridianksi.com]');
		return false;
	}

	if (arrEmailAddressComponents[1].indexOf(' ') != -1) {
		alert('Email Addresses must not include spaces.');
		return false;
	}

	if (arrEmailAddressComponents[1].indexOf('/') != -1) {
		alert('Email Addresses must not contain the / character.');
		return false;
	}

	//validating whether the domain info is in the form: accountname@[domain.tld] or accountname@[subdomain.domain.tld]   tld = top level domain (ex. .com, .net., etc.)
	arrEmailDomainComponents = arrEmailAddressComponents[1].split('.');

	if (arrEmailDomainComponents.length < 2) {
		alert('The domain portion of an Email Address must contain at least one dot(period) symbol. \r\r Ex. accountname@[meridianksi.com]');
		return false;
	}

	for (i=0; i<arrEmailDomainComponents.length; i++) {

		if (arrEmailDomainComponents[i].length == 0 && i==0) {
			alert('You must specify a domain before the first dot(period) in an Email Address. \r\r Ex.  accountname@[meridianksi].com');
			return false;
		}
		else if (arrEmailDomainComponents[i].length == 0 && i==arrEmailDomainComponents.length-1) {
			alert('You must specify a top level domain after the dot(period) in an Email Address. \r\r Ex.  .com, .gov, .edu, .net, etc...');
			return false;
		}
		else if (arrEmailDomainComponents[i].length == 0) {
			alert('You cannot have two adjacent dots(periods) in an Email Address.  They must be separated by domains or subdomains. \r\r Ex.  accountname@[meridianksi.com]     or    accountname@[users.meridianksi.com]');
			return false;
		}

	}
	return true;
}

/*
'<function_comment version="3.0">
<function_language>Javascript</function_language>
'<name>IsValidEmail</name>
'<programmer>Rachel Bickart</programmer>
'<date>01/06/2006</date>
'<description>
'Another function for determining if an Email Address is valid. This one uses a regular expression and
' only returns true/false, it does not alert the user or set focus to form fields.
'</description>
'<parameter pass="ByVal">
'<name>strEmailAddress</name>
'<description>The email address in question</description>
'</parameter>
'</function_comment>
*/
function IsValidEmail(strEmailAddress) {
	regExp = /^(\w+(('\w+)|(-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+)$/
	
	return (strEmailAddress.search(regExp) != -1);
}

/*
'<function_comment version="3.0">
<function_language>Javascript</function_language>
'<name>IsValidPhone</name>
'<programmer>Rachel Bickart</programmer>
'<date>01/06/2006</date>
'<description>
'Determines if an Phone/Fax Number is valid.
'</description>
'<parameter pass="ByVal">
'<name>strPhoneNumber</name>
'<description>The phone/fax number in question</description>
'</parameter>
'</function_comment>
*/
function IsValidPhone(strPhoneNumber) {
	regExp = /^(\(\d{3}\)|\d{3})[- \.]?\d{3}[- \.]?\d{4}$/;

	return (strPhoneNumber.search(regExp) != -1);
}

/*
'<function_comment version="3.0">
<function_language>Javascript</function_language>
'<name>IsValidZip</name>
'<programmer>Rachel Bickart</programmer>
'<date>01/06/2006</date>
'<description>
'Determines if a Zip Code is valid.
'</description>
'<parameter pass="ByVal">
'<name>strZipCode</name>
'<description>The zip code in question</description>
'</parameter>
'</function_comment>
*/
function IsValidZip(strZipCode) {
	regExp = /^\d{5}([\-]\d{4})?$/

	return (strZipCode.search(regExp) != -1);
}

/*
'<function_comment version="3.0">
<function_language>Javascript</function_language>
'<name>IsInTextMode</name>
'<programmer>Fabrice Bonnaire</programmer>
'<date>08/23/2002</date>
'<description>
'Return value defining if user is currently in Text Only view of KC or if in other view.
'</description>
'</function_comment>
*/
function IsInTextMode() {
	var strCookieValue = read_cookie("TEXTONLY")
	if (strCookieValue == 'True') {
		return true;
	} else {
		return false;
	}
}

/*
'<function_comment version="3.0">
<function_language>Javascript</function_language>
'<name>validateEmailAddress</name>
'<programmer>About.com</programmer>
'<date>08/23/2002</date>
'<description>
'Function retrieved from About.Com to add days to a date.
'</description>
'<parameter pass="ByVal">
'<name>starDate</name>
'<description>Start date to which to add days.</description>
'</parameter>
'<parameter pass="ByVal">
'<name>numDays</name>
'<description>Numbers of days to add.</description>
'</parameter>
'<parameter pass="ByVal">
'<name>numMonths</name>
'<description>Number of months to add.</description>
'</parameter>
'<parameter pass="ByVal">
'<name>numYears</name>
'<description>Number of years to add.</description>
'</parameter>
'</function_comment>
*/
function DateAdd(startDate, numDays, numMonths, numYears) {
	var returnDate = new Date(startDate.getTime());
	var yearsToAdd = numYears;

	var month = returnDate.getMonth()	+ numMonths;
	if (month > 11) {
		yearsToAdd = Math.floor((month+1)/12);
		month -= 12*yearsToAdd;
		yearsToAdd += numYears;
	}
	returnDate.setMonth(month);
	returnDate.setFullYear(returnDate.getFullYear()	+ yearsToAdd);

	returnDate.setTime(returnDate.getTime()+60000*60*24*numDays);

	return returnDate;
}

function YearAdd(startDate, numYears) {
		return DateAdd(startDate,0,0,numYears);
}

function MonthAdd(startDate, numMonths) {
		return DateAdd(startDate,0,numMonths,0);
}

function DayAdd(startDate, numDays) {
		return DateAdd(startDate,numDays,0,0);
}

/*
'<function_comment version="4.1">
<function_language>Javascript</function_language>
'<name>teamroom_go_pop_up</name>
'<programmer>Subbulakshmi Sankaran</programmer>
'<date>01/15/2004</date>
'<description>
'New popup for team rooms that has the menubar enabled in the window properties, so users can save documents.
'</description>
'<ticket>6391</ticket>
'</function_comment>
*/
function teamroom_go_pop_up (loc, strFunction, strTable, strContentID) {
new_loc = loc;
window.open('/kc/main/pop_up_frm.asp?loc='+escape(loc)+'&strFunction='+escape(strFunction)+'&strTable='+escape(strTable)+'&strContentID='+escape(strContentID),'pop_up','toolbar=yes,location=no,directories=no,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=560,height=420');
}



function go_cert_crs_pop_up (loc,botbartype, strCourseWinFeatures) {

if (confirm('Continuing to take this recertification course will archive your existing progress records.')) {
	
	go_crs_pop_up(loc,botbartype, strCourseWinFeatures);
	
} else {
	return false;
}

}


function approvalRequest (strItemType) {
	if (strItemType) {
		strItemType = strItemType.toLowerCase();
	} else {
		strItemType = "course";
	}
	
	if (confirm('You are about to request access to the selected ' + strItemType + '. If you continue, a request will be sent, and the ' + strItemType + ' will be added to your Development Record under Approval Requests. You will be notified by email when access to the ' + strItemType + ' has been approved or denied. To continue click OK. To cancel without sending the request, click Cancel.')) {
		return true;
	}
	else {
		return false;
	}
}

/*
<function_comment>
<function_language>Javascript</function_language>
<name>are_digits_or_period</name>
<programmer>Shawn Richardson</programmer>
<date>06/28/2005</date>
<description>
Verify if a string of characters are all digits and period (decimal number). Return true/false.
</description>
<parameter pass="ByVal">
<name>digit_string</name>
<description>Character being checked.</description>
</parameter>
</function_comment>
*/
function are_digits_orperiod (digit_string) {
	var i;
	for (i = 0; i <= (digit_string.length - 1);i++) {
		if (! is_digit_or_period(digit_string.charAt(i))) {
			return false;
		}
	}
	return true;
}

