//************************************************************************************
//Start Function Library 1
//Date: 990406
//Note:  The functions  SetSubCookie and GetSubCookie 
//       assume the Full Cookie name is 'nlguest'.  Change this if necessary.
function getCookie(Name) {
	var search = Name + "="
	if (document.cookie.length > 0) { // if there are any cookies
                    offset = document.cookie.indexOf(search) 
                    if (offset != -1) { // if cookie exists 
                              offset += search.length 
                              // set index of beginning of value
                              end = document.cookie.indexOf(";", offset) 
                              // set index of end of cookie value
                              if (end == -1) 
                                        end = document.cookie.length
                              return unescape(document.cookie.substring(offset, end))
                    } 
          }
	  return ""
    }

function setCookie(name, value, expire, path) {
	if (expire == null) {
    	   var today = new Date() ;
    	   var expire = new Date() ;
    	   expire.setTime(today.getTime() + 365*24*60*60*1000) ;
	}
        document.cookie = name + "=" + escape(value)
          + ((expire == null) ? "" : ("; expires=" + expire.toGMTString()))
	  + ((path == null) ? "" : ("; path=" + path))
    }  

function clearCookie(name,path) {
    	var today = new Date() ;
    	var expire = new Date() ;
	var value = "iamdone" ;
    	expire.setTime(today.getTime() - 365*24*60*60*1000) ;
        document.cookie = name + "=" + escape(value)
          + ((expire == null) ? "" : ("; expires=" + expire.toGMTString()))
	  + ((path == null) ? "" : ("; path=" + path))
    }  

function GetSubCookie (subcookieName) {
	fullCookie=getCookie('nlguest') ;
	if (fullCookie!=null) {
		var arg = subcookieName + "=";
		var alen = arg.length;
		var clen = fullCookie.length;
		var i=0 ;
		while (i < clen) {
			var j = i + alen;
			if (fullCookie.substring(i, j) == arg)
				return getSubCookieVal (fullCookie, j);
			i = fullCookie.indexOf(" ", i) + 1;
			if (i == 0) break;
		}
	}
	return '';
    }

// "Internal" function to return the decoded value of a cookie
function getSubCookieVal (fullCookie, offset) {
   var endstr = fullCookie.indexOf (";", offset);
   if (endstr == -1)
      endstr = fullCookie.length;
   return unescape(fullCookie.substring(offset, endstr));
}

// Function to create or update a subCookie
function SetSubCookie (subcookieName,value) {

   var fullCookie= new String();
   fullCookie=getCookie('nlguest');
   //determine if the cookie exists, if it does, remove it
   if (fullCookie!=null) {
      fullCookie=RemoveSubCookie(fullCookie,subcookieName);
   } else {
      fullCookie="";
   }
   //add the subcookie to the end
   value=fullCookie + subcookieName + "=" + value + "; " ;
   setCookie("nlguest",value);
}

function RemoveSubCookie(fullCookie, subcookieName){
   if (fullCookie!=null) {
      var arg = subcookieName + "=";
      var alen = arg.length;
      var clen = fullCookie.length;
      var i=0
         while (i < clen) {
            var j = i + alen;
            if (fullCookie.substring(i, j) == arg) {
               //subCookie found.  Remove it.
               var endstr = fullCookie.indexOf (";", i);
               if (endstr == -1) {
                  return fullCookie.substring(0,i);
               } else {
                  // --- 20021222 --- csj --- added in case no space between semicolon and next item
                  if (fullCookie.substring(endstr+1,endstr+2)==" ") {
                   return fullCookie.substring(0,i) + fullCookie.substring(endstr+2,fullCookie.length);
                  } else {
                   return fullCookie.substring(0,i) + fullCookie.substring(endstr+1,fullCookie.length);
                  };
                  // --- END --- 20021222 --- csj --- added in case no space between semicolon and next item
               };
            };
            i = fullCookie.indexOf(" ", i) + 1;
            if (i == 0) break;
         };
         return fullCookie;
   };
}

// --- 20020913 --- CSJ --- added to inactivate old pages in history
function logintimeout(p_cpeid) {
 // remove overall cookie if it exists
 clearCookie("nlloginto") ;
 // create cookie itself
 setCookie("nlloginto",p_cpeid) ;
}
function logoutimeout() {
 // remove overall cookie if it exists
 clearCookie("nlloginto") ;
}
function getloginpeid() {
 // remove overall cookie if it exists
 return getCookie("nlloginto") ;
}
function nltestcookie() {
  setCookie("nltestcookie","1") ;
  if (getCookie("nltestcookie")=="1") {
   clearCookie("nltestcookie") ;
  } else {
   alert("This browser does not allow cookies as the NetLearning System requires. Please contact technical support at your facility");
  }
}

// "Internal" function to select all text win an edit field
function selectContents(fieldObject) {
   fieldObject.select();
}

// Function to return character string for Month
function nl_cmonth(p_nmonth) {
 if (p_nmonth==1)  { l_creturn="January"   ;} ;
 if (p_nmonth==2)  { l_creturn="February"  ;} ;
 if (p_nmonth==3)  { l_creturn="March"     ;} ;
 if (p_nmonth==4)  { l_creturn="April"     ;} ;
 if (p_nmonth==5)  { l_creturn="May"       ;} ;
 if (p_nmonth==6)  { l_creturn="June"      ;} ;
 if (p_nmonth==7)  { l_creturn="July"      ;} ;
 if (p_nmonth==8)  { l_creturn="August"    ;} ;
 if (p_nmonth==9)  { l_creturn="September" ;} ;
 if (p_nmonth==10) { l_creturn="October"   ;} ;
 if (p_nmonth==11) { l_creturn="November"  ;} ;
 if (p_nmonth==12) { l_creturn="December"  ;} ;
 return l_creturn ;
}

//--- 20020722 --- CSJ --- Added new functionality to pecbl-info
//function ShowDetail (co_coid) {
// window.location = "/cgi-las/cgivfp01.exe?IDCFile=pecbl-info.idc&co_coid="+co_coid ;
//}
//

function ShowDetail (co_coid,ur_urid,p_shwenr,p_goback) {
 if (ur_urid==null) {
   ur_urid = '';
 }
 if (pe_peid==null) {
   pe_peid = '';
 }
 if (pe_emid==null) {
   pe_emid = '';
 }
 if (p_shwenr==null) {
   p_shwenr = '';
 }
 if (p_goback==null) {
   p_goback = '-1';
 }
 var xdt = new Date() ;
 var xdtc = xdt.getTime() ;
 //alert(co_coid);
 //alert(ur_urid);
 //alert(pe_peid);
 //alert(pe_emid);
 window.location = "/cgi-las/cgivfp01.exe?IDCFile=pecbl-info.idc" 
                   +"&co_coid="+co_coid 
		   +"&pe_peid="+pe_peid 
		   +"&pe_emid="+pe_emid 
		   +"&ur_urid="+ur_urid 
		   +"&p_shwenr="+p_shwenr 
		   +"&p_goback="+p_goback
		   +"&xdtc="+xdtc ;
}
//--- END --- 20020722 --- CSJ --- Added new functionality to pecbl-info


function smoothadd(baseur,pe_emid,pe_last,pe_first,or_title,de_title,pg_title,su_level,nl_clientid,pe_mi,
                    pe_ssnid,pe_add1,pe_date1,pe_mail,pe_title,or_abbr,de_num,pe_custom1,im_pgorg,im_pgdep) {

 // insert smoothadd exception here
 if (nl_clientid == "DEMO") { baseur = "http://si.netlearning.us"; } ;

 // --- 20030717 --- CSJ --- add empty string to each variable to ensure no variable type errors in case
 // --- customer does not want to send some of these values and sends a null instead

 pe_emid  = ""+pe_emid  ;
 pe_last  = ""+pe_last  ;
 pe_first = ""+pe_first ;
 pe_mi    = ""+pe_mi    ;
 or_title = ""+or_title ;
 de_title = ""+de_title ;
 pg_title = ""+pg_title ;
 su_level = ""+su_level ;
 pe_ssnid = ""+pe_ssnid ;
 pe_add1  = ""+pe_add1  ;
 pe_date1 = ""+pe_date1 ;
 pe_mail  = ""+pe_mail  ;
 pe_title = ""+pe_title ;
 or_abbr  = ""+or_abbr  ;
 de_num   = ""+de_num   ;
 im_pgorg = ""+im_pgorg ;
 im_pgdep = ""+im_pgdep ;
 pe_custom1  = ""+pe_custom1  ;
 nl_clientid = ""+nl_clientid ;

 pe_first = pe_first+" "+pe_mi ;

 nextpage = baseur+"/cgi-las/cgivfp01.exe?IDCFile=smoothadd.idc"
          +"&IDC_Program=SMOOTHADD"
          +"&pe_emid="+pe_emid
          +"&pe_last="+escape(pe_last) 
          +"&pe_first="+escape(pe_first) 
          +"&or_title="+escape(or_title) 
          +"&de_title="+escape(de_title) 
          +"&pg_title="+escape(pg_title) 
          +"&nlclientid="+escape(nl_clientid) 
          +"&pe_ssnid="+escape(pe_ssnid) 
          +"&pe_add1="+escape(pe_add1) 
          +"&pe_date1="+escape(pe_date1) 
          +"&pe_mail="+escape(pe_mail) 
          +"&pe_title="+escape(pe_title) 
          +"&or_abbr="+escape(or_abbr) 
          +"&de_num="+escape(de_num) 
          +"&pe_custom1="+escape(pe_custom1) 
          +"&im_pgorg="+escape(im_pgorg) 
          +"&im_pgdep="+escape(im_pgdep) 
          +"&su_level="+su_level ; 


 browserName= navigator.appName ;
 browserVer = parseInt(navigator.appVersion) ;

 if (isIE() && browserVer>=4) {
  nHeight=screen.availHeight-25 ;
  nWidth =screen.availWidth -10 ;
  LaWindow=window.open(nextpage,"NetLearningWindow","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width="+nWidth+",height="+nHeight+",top=0,left=0") ;
 } else {
  LaWindow=window.open(nextpage,"NetLearningWindow","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes") ;
 }
}

function browserok() {
  return ( parseFloat(navigator.appVersion) >= gBrowserMin ) ;
}

function bVer() {
  // return version number (e.g., 4.03)
  return parseFloat(navigator.appVersion)
}

function isNetscape() {
  return (navigator.appName.indexOf("Netscape") > -1);
}

function isIE() {
  return (navigator.appName.indexOf("Microsoft") > -1);
}

function isAOL() {
  return (navigator.appName.indexOf("AOL") > -1);
}

function openLaStudent(lnewwin) {

 var browserVer = 1.00 ;
 browserName= navigator.appName ;
 browserVer = GetBrowserVersion(navigator.appVersion) ;

 nextpage = "/cgi-las/cgivfp01.exe?IDCFile=pecbl-login.idc" 
            + "&HTXFile="+htxfile 
            + "&loginid=&idtypen=0" ;

 if (lnewwin) {
    if (isIE() && browserVer>=4) {
     nHeight=screen.availHeight-25 ;
     nWidth =screen.availWidth -10 ;
     var LaWindow = "";
     LaWindow=window.open(nextpage,"NetLearningWindow","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width="+nWidth+",height="+nHeight+",top=0,left=0") ;
     if (LaWindow==null || LaWindow==""){
      alert("Your browser is unable to open the login page for the Student Interface. Please contact your technical support help desk. [Error: Unable to execute window.open script]");
     } else {
      if (LaWindow.closed==true) {
       alert("Your browser is unable to open the login page for the Student Interface. Please contact your technical support help desk. [Error: Window.closed property is true]");
      };
     };
    } else {
     LaWindow=window.open(nextpage,"NetLearningWindow","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes") ;
    }
 
  //LaWindow=window.open(nextpage,"NetLearningWindow","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes") ;

 } else {
  top.location = nextpage ;
 }
}

// --- 20020828 --- csj --- added to make logins easier to include from corp home pages
function openSIexternal(pbaseurl) {

 var browserVer = 1.00 ;
 browserName= navigator.appName ;
 browserVer = GetBrowserVersion(navigator.appVersion) ;

 nextpage = pbaseurl+"/cgi-las/cgivfp01.exe?IDCFile=pecbl-login.idc" 
            + "&HTXFile=pecbl-login.htx" 
            + "&loginid=&idtypen=0" ;

 if (isIE() && browserVer>=4) {
  nHeight=screen.availHeight-25 ;
  nWidth =screen.availWidth -10 ;
  LaWindow=window.open(nextpage,"NetLearningWindow","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width="+nWidth+",height="+nHeight+",top=0,left=0") ;
 } else {
  LaWindow=window.open(nextpage,"NetLearningWindow","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes") ;
 }
}


function openLaCBL(nextpage,psource) {

 var browserVer = 1.00 ;
 browserName= navigator.appName ;
 browserVer = GetBrowserVersion(navigator.appVersion) ;

if (psource == null) { psource="XXX" } ;

if (psource.toUpperCase().indexOf('IDX') > -1){
   LaCblWin=window.top.open(nextpage,'IDXWBTWin','width=1014,height=711,top=0,left=0,scrolling=0');
}else{
 if (isIE() && browserVer>=4) {
  nHeight=screen.availHeight-25 ;
  nWidth =screen.availWidth -10 ;
  LaCblWin=window.open(nextpage,"NetLCBLWindow","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width="+nWidth+",height="+nHeight+",top=0,left=0") ;
 } else {
  LaCblWin=window.open(nextpage,"NetLCBLWindow","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes") ;
  }
 }

}

function openLaCert(nextpage) {

 var browserVer = 1.00 ;
 browserName= navigator.appName ;
 browserVer = GetBrowserVersion(navigator.appVersion) ;

 if (isIE() && browserVer>=4) {
  nHeight=screen.availHeight-250 ;
  nWidth =screen.availWidth -100 ;
  LaCblWin=window.open(nextpage,"NetLCertWindow","toolbar=yes,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width="+nWidth+",height="+nHeight+",top=0,left=0") ;
 } else {
  LaCblWin=window.open(nextpage,"NetLCertWindow","toolbar=yes,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes") ;
 }

}

function openLaTrans(nextpage) {

 var browserVer = 1.00 ;
 browserName= navigator.appName ;
 browserVer = GetBrowserVersion(navigator.appVersion) ;

 if (isIE() && browserVer>=4) {
  nHeight=screen.availHeight-250 ;
  nWidth =screen.availWidth -100 ;
  LaTransWin=window.open(nextpage,"NetLTransWindow","toolbar=yes,location=no,directories=no,status=no,menubar=yes,scrollbars=yes,resizable=yes,width="+nWidth+",height="+nHeight+",top=0,left=0") ;
 } else {
  LaTransWin=window.open(nextpage,"NetLTransWindow","toolbar=yes,location=no,directories=no,status=no,menubar=yes,scrollbars=yes,resizable=yes") ;
 }

}

function closeLaStudent() {
    LaWindow.close() ;
}

function GetBrowserVersion(cVersion) {
 var nVersion=3.00 ;
 nVersion=parseFloat(cVersion) ;

 if (isIE()) {
  if (cVersion.indexOf("MSIE 5.0") > -1) {
   nVersion=5.00 ;
  }
  if (cVersion.indexOf("MSIE 5.1") > -1) {
   nVersion=5.10 ;
  }
  if (cVersion.indexOf("MSIE 5.2") > -1) {
   nVersion=5.20 ;
  }
  if (cVersion.indexOf("MSIE 5.3") > -1) {
   nVersion=5.30 ;
  }
  if (cVersion.indexOf("MSIE 5.4") > -1) {
   nVersion=5.40 ;
  }
  if (cVersion.indexOf("MSIE 5.5") > -1) {
   nVersion=5.50 ;
  }
  if (cVersion.indexOf("MSIE 5.6") > -1) {
   nVersion=5.60 ;
  }
  if (cVersion.indexOf("MSIE 5.7") > -1) {
   nVersion=5.70 ;
  }
  if (cVersion.indexOf("MSIE 5.8") > -1) {
   nVersion=5.80 ;
  }
  if (cVersion.indexOf("MSIE 5.9") > -1) {
   nVersion=5.90 ;
  }
  if (cVersion.indexOf("MSIE 6.0") > -1) {
   nVersion=6.00 ;
  }
  if (cVersion.indexOf("MSIE 6.1") > -1) {
   nVersion=6.10 ;
  }
  if (cVersion.indexOf("MSIE 6.2") > -1) {
   nVersion=6.20 ;
  }
  if (cVersion.indexOf("MSIE 6.3") > -1) {
   nVersion=6.30 ;
  }
 }
  
 return (nVersion) ;
}

function getPersonality() {
 var l_cSbid=getCookie("sb_sbid") ;
 var l_cflag=getCookie("sb_prsnlty") ;
 var l_cReturn="" ;

 if (l_cflag=="Y") {
    l_cReturn=l_cSbid ;
 }
 return l_cReturn ;
}

// CSJ added on 4/1/2001 to get function in any active frame
function menuPickPR(IDCFile,IDCProg,l_request) {

	   var xdt = new Date() ;
	   var xdtc = xdt.getTime() ;

	   //ldate1 var is only used by enroll in class program
	   nextpage='/cgi-las/cgivfp01.exe?IDCFile=' + IDCFile +'&IDC_Program=' + IDCProg
		+ '&pe_emid=' + pe_emid
		+ '&pe_peid=' + pe_peid
		+ '&ladate1=999999'
		+ '&sb_sbid=' + sb_sbid
		+ '&sq_order='+escape("11 DESC,7,6")
		+ '&p_cUrid='
		+ '&l_request=' + l_request
		+ '&xdtc=' + xdtc ;

	      top.frames[2].location=nextpage ;
}

//ProperAAn
//Date: 03.15.02
//Note:  Returns the proper A or AN depending on following word, passed as value
//Jay Hill
function properaan(ls_word) {
        ls_begin = ls_word.toUpperCase(ls_word) ;
        ls_begin = ls_begin.substring(0,1) ;
        if (ls_begin=="A" || ls_begin=="E" || ls_begin=="I" || ls_begin=="O" || ls_begin=="U" || ls_begin=="H") {
  	ls_retval = "an" ;
         } else {
  	ls_retval = "a" ;
         }
        return ls_retval ;
}

//BypassLogon
//Date: 05.17.02
//Desc: Receives the IP address, user unique ID (SSN, EmpID, Badge) and identifier of which ID is used
//Jay Hill
function bypasslogon(ls_IP,ls_ID,ls_IDType,ls_clientid) {

 ls_clientid = "" + ls_clientid ;
 if (ls_clientid!="" && ls_clientid!=" ") {   setCookie("nlclientid",ls_clientid); } ;

 // insert bypasslogon exception here
 if (ls_clientid == "DEMO") { ls_IP = "http://si.netlearning.us"; } ;
 
 if (gclandpage == undefined) 
 {
	 ls_destin = "cbl-courses" ;
 }
 else
 {
	ls_destin = gclandpage;
 }	
 //ls_destin = "" ;
 if (ls_clientid=="WEBMD") { ls_destin = "enrollcbls" } ;

 //      Determine what the user's pe_peid value is
 //      Check to see if there are any items in the To Do List - will do this check 
 //      later based on preference - for now (TVA) go to Enroll screen
 //      Go to Enroll Screen as if user had logged on

  var lidcprog = "STUDMENEMID.IDC" ;
  var lcdescrib = "Participant ID" ;
  //This is SSN
  if (ls_IDType=='0') {lidcprog = "STUDMENSSN.IDC" ; lcdescrib = "SSN" ;} ;
  //This is EMID
  if (ls_IDType=='1') {lidcprog = "STUDMENEMID.IDC" ; lcdescrib = "Employee ID" ;} ;
  //This is BADGE
  if (ls_IDType=='2') {lidcprog = "STUDMENBADGE.IDC" ; lcdescrib = "Badge" ;} ;

  if (ls_IDType=='3') {
     ls_cWhere1=escape("SELECT DE_DEID,UPPER(DE_TITLE) AS DE_TITLE,DE_ORID,OR_ORID,UPPER(OR_TITLE) AS OR_TITLE "+
       "FROM DEPART,ORGANS WHERE DE_ORID=OR_ORID ORDER BY 5,2") ;
     ls_nextpg = ls_IP + "/cgi-las/cgivfp01.exe?" 
		+ "IDCFile=ADMINPREFS.IDC"
		+ "&template=ADMINPREFS.HTX"
		+ "&cWhere1=" + ls_cWhere1
		+ "&userselected=Welcome" 
		+ "&cHostName=NetLearning" 
		+ "&nlclientid="+ls_clientid ;
  } else {
     ls_nextpg = ls_IP + "/cgi-las/cgivfp01.exe"
           + "?IDCFile="+lidcprog
           + "&loginid="+ls_ID
           + "&pe_pswd="
           + "&sb_from=" 
           + "&sb_where=" 
           + "&password=F"
           + "&idtypen=" + ls_IDType 
           + "&template=STUDMENUV.HTX" 
           + "&cHostName=" + gHostName
           + "&body_src="+ls_destin 
           + "&nlclientid="+ls_clientid ;
  };

  // --- 20040426 --- BCB/CSJ --- added to intercept non-standard characters
  if (!ValidChars(ls_ID, lcdescrib)) {
    return false;
  }

  ls_browser = navigator.appName ;
  ls_browserVer = parseInt(navigator.appVersion) ;

  if (isIE() && ls_browserVer>=4) {
   nHeight=screen.availHeight-25 ;
   nWidth =screen.availWidth -10 ;
   ls_Window = window.open(ls_nextpg,"NetLearningWindow",
"toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width="+nWidth+",height="+nHeight+",top=0,left=0");
  } else {
   ls_Window = window.open(ls_nextpg,"NetLearningWindow",
"toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes");
  }

}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function NL_logintocourse(ls_IP,ls_ID,ls_IDType,ls_colink,ls_colinktype,ls_back) {
 //ls_back==0 means close, otherwise jumps back

 if (ls_back==null) { ls_back='0' ; } ;

  //alert(ls_back);

  //This is SSN,ls_IDType=='0'
  //This is EMID,ls_IDType=='1'
  //This is BADGE,ls_IDType=='2'

  var xdt = new Date() ;
  var xdtc = xdt.getTime() ;


  ls_nextpg = "http://"+ ls_IP + "/cgi-las/cgivfp01.exe"
	   + "?IDCFile=LOGINTOCOURSE.IDC"
	   + "&IDC_Program=LOGINTOCOURSE"
           + "&ls_ID="+ls_ID
	   + "&ls_IDType=" + ls_IDType 
	   + "&ls_colink=" + ls_colink
	   + "&ls_colinktype=" + ls_colinktype 
	   + "&ls_back=" + ls_back 
	   + "&xdtc="+xdtc ;

  window.location=ls_nextpg ;

}

//--- 20020807 --- CSJ --- two functions added to get vars out of location strings easily
function getlocvarfromurl(p_curl,p_cvar) {
 var i=0;
 var lcdum="";
 var lcrtn="";
 r = p_curl.search.slice(1).split('&');
 if (r.length > 0) {
  for (var i = 0; i < r.length; i++) {
   lcdum=getStrVarVal(p_cvar,r[i]) ;
   if (lcdum.length>0) { lcrtn = lcdum ; } ;
  }
 }
 return lcrtn ;
}

function getStrVarVal(Name,lcStr) {
 // Added underscores to account for 
 // variable names that are subsets of other variable names
 var search = "_" + Name + "=" ;
 lcStr = "_"+lcStr ;
 if (lcStr.length > 0) {
  offset = lcStr.indexOf(search) ;
  if (offset != -1) {  
   offset += search.length 
   // set index of beginning of value
   end = lcStr.indexOf(";", offset) 
   // set index of end of value
   if (end == -1) { end = lcStr.length ; } ; 
   return unescape(lcStr.substring(offset, end))
  }
 }
 return ""
}
//--- END --- 20020807 --- CSJ --- two functions added to get vars out of location strings easily

//--- 20020824 --- CSJ --- added function to display calendar
function sicalendar(p_acal) {
 var i=0;
 var lcdum="";
 var lcrtn="";


 return lcrtn ;
}

//--- END --- 20020824 --- CSJ --- added function to display calendar

//--- 20020926 --- CSJ --- added Cheries date checker for record self-add in SI
	function doDateCheck(p_d2chk)
	{	
		userdate = p_d2chk;

		//check date for proper formatting and values		
		returneddate = validateDate(userdate)
		if (returneddate == false)
			return (false)
		else
			userdate = returneddate
		
		//break validated date into month, day, and year
		varmonth = parseUserDate(userdate, 1)
		varday = parseUserDate(userdate, 2)
		varyear = parseUserDate(userdate, 3)

		today = new Date()
		
		//break today's date into month, day, and year
		todaymonth = today.getMonth() + 1;
		todayday = today.getDate();
		todayyear = today.getYear();

		//check for valid month
		if(varmonth > 12 || varmonth < 1)
		{
			alert("Invalid month entered. Please reenter.")
			return(false)
		}

		//check entered date for per-month validity
		if (!dayOfMonth(varday, varmonth))
			return(false)
		
		// compare entered date to today's date
		if (!compareTime(todayyear, varyear))
		{
			alert("Date must be today's date or earlier.")
			return (false)
		}
		if (todayyear == varyear)
		{
			if (!compareTime(todaymonth, varmonth))
			{
				alert("Date must be today's date or earlier.")
				return (false)
			}
			if (todaymonth == varmonth)
			{
				if (!compareTime(todayday, varday))
				{
					alert("Date must be today's date or earlier.")
					return (false)
				}
			}

		}
		if (varyear < 1990)
		{
			alert("Date must be 1990 or later")
			return (false)
		}

		//alert("Date ok")
		return (true)
	}

	function validateDate(usDate)
	{
		//make sure that date is in XX/XX/XXXX format and that all but slashes are numerical
		validchars = "/1234567890"
		if (usDate == "")
		{
			alert("Date cannot be empty.")
			return (false)
		}

		for (i=0; i<usDate.length; i++)
		{
			number = usDate.charAt(i)
			if(validchars.indexOf(number,0) == -1)
			{
				alert("Date must be numerical, in format XX/XX/XXXX.")
				return (false)
			}
		}
	
		//make entered date a consistent format -- append 0's if needed
		if(usDate.charAt(1) == "/")
			usDate = "0" + usDate
		if(usDate.charAt(4) == "/")
			usDate = usDate.substring(0,3) + "0" + usDate.substring(3)

		if(usDate.charAt(9) == "")
		{
			alert("Year must be four digits.")
			return (false)
		}

		return (usDate)
	}


	function parseUserDate(usDate, component)
	{	
		// 1 == month, 2 == day, 3 == year
		if (component == 1)
		{
			avar = usDate.substring(0,2)
			return(avar)
		}
		
		if (component == 2)
		{
			avar = usDate.substring(3,5)
			return(avar)
		}
		if (component == 3)
		{
			avar = usDate.substring(6,10)
			return(avar)
		}
	}


	function compareTime(thistime, usertime)
	{
		if (thistime > usertime || thistime == usertime)
		{
			//usertime earlier than or equal to thistime
			return(true)	
		}
		
		//usertime later than thistime
		return(false)   
	}

	function dayOfMonth(pnday, pnmonth)
	{
		if (pnmonth == 4 || pnmonth == 6 || pnmonth == 9 || pnmonth == 11)	
		{
			if (pnday > 30)
			{
				alert("Invalid date entered.  Please reenter.")
				return(false)
			}
		}
		if (pnmonth == 2)
		{
			if (pnday > 29)
			{
				alert("Invalid date entered. Please reenter.")
				return(false)
			}
		}
		if (pnday > 31)
		{
			alert("Invalid date entered.  Please reenter.")
			return(false)
		}
		return(true)
	}
//--- END --- 20020926 --- CSJ --- added Cheries date checker for record self-add in SI

function getperpage(p_listname) {
 var l_cval = getCookie("nl"+p_listname) ;
 if (l_cval==null || l_cval=="") { setCookie("nl"+p_listname,"20"); l_cval="20";} ;
 return parseInt(l_cval);
}

function setperpage(p_listname,p_value) {
 setCookie("nl"+p_listname,""+p_value);
}

// --- 20021205 --- CSJ --- added for scorm compatibility

function nlscoGetSubCookie(subcookieName) {

	fullCookie=getCookie('nlscorm') ;
	if (fullCookie!=null) {
		var arg = subcookieName + "=";
		var alen = arg.length;
		var clen = fullCookie.length;
		var i=0 ;
		while (i < clen) {
			var j = i + alen;
			if (fullCookie.substring(i, j) == arg)
				return getSubCookieVal (fullCookie, j);
			i = fullCookie.indexOf(" ", i) + 1;
			if (i == 0) break;
		}
	}
	return '';
    }

// Function to create or update a subCookie
function nlscoClearCookie() {
 clearCookie('nlscorm');
}

function nlscoSetCookie(cCook) {
 if (cCook=="") {
   setCookie('nlscorm',"");
 } else { 
   setCookie('nlscorm',cCook);
 };
}

function nlscoSetSubCookie (subcookieName,value) {

   var fullCookie= new String();
   fullCookie=getCookie('nlscorm');
   //determine if the cookie exists, if it does, remove it
   if (fullCookie!=null) {
      fullCookie=RemoveSubCookie(fullCookie,subcookieName);
      //assure that fullCookie ends with a space -- added 3/8/2004 BCB	     
      if ( (fullCookie.length>1) && (fullCookie.indexOf(" ",fullCookie.length-1) == -1) )
      {	
	 fullCookie=fullCookie + " ";		
      }
   } else {
      fullCookie="";
   }
   //add the subcookie to the end
   value=fullCookie + subcookieName + "=" + value + "; " ;

  //alert(value);

   setCookie("nlscorm",value);
}

function nlscoFinish() {
 window.location="/cgi-las/cgivfp01.exe?IDCFile=pecbl-scorm.idc&IDC_Program=SCORM";
}

function nlscogetlocation() {
 var rtn = " ";
 rtn=unescape(nlscoGetSubCookie("cmi.core.lesson_location"));
 alert("Status: "+rtn);
}

function nlscogetstatus() {
 var rtn = " ";
 rtn=unescape(nlscoGetSubCookie("cmi.core.lesson_status"));
 alert("Status: "+rtn);
}

function nlscogetduration() {
 var rtn = " ";
 rtn=unescape(nlscoGetSubCookie("cmi.core.session_time"));
 alert("Duration: "+rtn);
}

function nlscogetscore() {
 var rtn = " ";
 rtn=unescape(nlscoGetSubCookie("cmi.core.score.raw"));
 alert("Score: "+rtn);
}

// --- END --- 20021205 --- CSJ --- added for scorm compatibility

function trimStr(stringsrc) {
    ln = stringsrc.length - 1 ;
    mystr = stringsrc ;
    //Trim the leading spaces
    while ( mystr.indexOf(" ")==0 && ln > 0) {
	mystr = mystr.substring(1,ln+1) ;
	ln = mystr.length - 1 ;
    } ;
    //Trim the trailing spaces
    while ( mystr.lastIndexOf(" ")==ln && ln > 0) {
	mystr = mystr.substring(0,ln) ;
	ln = mystr.length - 1 ;
    } ;
    if (mystr == " ") {
	mystr = "" ;
    }
    return mystr
}

function sendme(p_cClientID,lnewwin,curl,lnsubsmng) {
 var browserVer = 1.00 ;
 browserName= navigator.appName ;
 browserVer = GetBrowserVersion(navigator.appVersion) ;

 if (curl==null) { 
	curl=""; 
	if ((p_cClientID.toUpperCase().indexOf('CHPCORP') > -1) ||
		(p_cClientID.toUpperCase().indexOf('WEBMD') > -1) ||
		(p_cClientID.toUpperCase().indexOf('ROWAN') > -1) ||
		(p_cClientID.toUpperCase().indexOf('JORDAN') > -1) ||
		(p_cClientID.toUpperCase().indexOf('MONTEFIORE') > -1) ||
		(p_cClientID.toUpperCase().indexOf('BHS') > -1) ||
		(p_cClientID.toUpperCase().indexOf('OSFSAMC') > -1) ||
		(p_cClientID.toUpperCase().indexOf('MERMEM') > -1) ||
		(p_cClientID.toUpperCase().indexOf('UVA') > -1) ||
		(p_cClientID.toUpperCase().indexOf('ROWAN') > -1) ||
		(p_cClientID.toUpperCase().indexOf('ROCKFORD') > -1))
	{
		curl = "https://sis.netlearning.us";
	}

 };
 if (lnsubsmng==null) { lnsubsmng=0; };

 nextpage = curl+"/cgi-las/cgivfp01.exe?IDCFile=PECBL-LOGIN.IDC&HTXFile=pecbl-login.htx&loginid=&idtypen=0&nlclientid="+p_cClientID ;

 //alert("here");
 //alert(lnsubsmng);

 if (lnsubsmng==1) {
  nextpage =    curl+"/cgi-las/cgivfp01.exe?IDCFile=PECBL-LOGIN.IDC&HTXFile=subscriber-login.htx&loginid=&idtypen=0&nlclientid="+p_cClientID ;
 };

 //alert(nextpage);

 if (lnewwin) {
    if (isIE() && browserVer>=4) {
     nHeight=screen.availHeight-25 ;
     nWidth =screen.availWidth -10 ;
          cparams="toolbar=no,location=no,directories=no,status=no,menubar=no,"+
             "scrollbars=yes,resizable=yes,width="+nWidth+",height="+
             nHeight+",top=0,left=0" ;
     var LaWindow = "";
     LaWindow=window.open(nextpage,"NetLearningWindow",cparams) ;
     if (LaWindow==null || LaWindow==""){
      alert("Your browser is unable to open the login page for the Student Interface. Please contact your technical support help desk. [Error: Unable to execute window.open script]");
     } else {
      if (LaWindow.closed==true) {
       alert("Your browser is unable to open the login page for the Student Interface. Please contact your technical support help desk. [Error: Window.closed property is true]");
      };
     };
    } else {
     cparams="toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes";
     LaWindow=window.open(nextpage,"NetLearningWindow",cparams) ;
    }
 
 } else {
  top.location = nextpage ;
 }

}

//--- 20040426 --- added by BCB/CSJ ---- keep bad characters from passing through to server
function ValidChars(cCharString, cDescrib)
{
	aReserved = new Array("%",'"',"'","&");
	for (var nI = 0; nI < aReserved.length; nI++)
	{
		if (cCharString.indexOf(aReserved[nI]) != -1)
		{ 
		alert (cDescrib + " cannot contain a " + aReserved[nI] + " character.  Please re-enter the " + cDescrib + ".");
		return false;}
	}
	return true;
}


