<!--

// ---------------------------------------------------------------------------------------------
// THIS IS AN ABREVIATED FORM OF stdLib.js EXCLUSIVELY for domain: nlpLearningSolutions.com  !!!
// ---------------------------------------------------------------------------------------------

// ------------------------------------------------
//  	begin:  Boilerplate Cookie Functions
// ------------------------------------------------
var expdate = new Date ();
expdate.setTime (expdate.getTime() + (14 * 24 * 60 * 60 * 1000)); // 14 days from now

function getCookieVal (offset) {
  var endstr = document.cookie.indexOf (";", offset);
  if (endstr == -1)
    endstr = document.cookie.length;
  return unescape(document.cookie.substring(offset, endstr));
}

function GetCookie (name) {
  var arg = name + "=";
  var alen = arg.length;
  var clen = document.cookie.length;
  var i = 0;
  while (i < clen) {
    var j = i + alen;
	   if (document.cookie.substring(i, j) == arg)
     return getCookieVal (j);
    i = document.cookie.indexOf(" ", i) + 1;
    if (i == 0) break;
  }
  return null;
}

function SetCookie (name, value) {
  var argv = SetCookie.arguments;
  var argc = SetCookie.arguments.length;
  var expires = (argc > 2) ? argv[2] : null;
  var path = (argc > 3) ? argv[3] : null;
  var domain = (argc > 4) ? argv[4] : null;
  var secure = (argc > 5) ? argv[5] : false;
  
  document.cookie = name + "=" + escape (value) +
    ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
    ((path == null) ? "" : ("; path=" + path)) +
    ((domain == null) ? "" : ("; domain=" + domain)) +
    ((secure == true) ? "; secure" : "");
}

function DeleteCookie (name) {
  var domain = "; domain=.nlpls.com";
  var path = "; path=/";
  var exp = new Date();
  exp.setTime (exp.getTime() - 1);  // This cookie is history
  var cval = GetCookie (name);
  if (cval != null)
    document.cookie = name + "=" + cval + domain + path + "; expires=" + exp.toGMTString();
}


// ------------------------------------------------
//  	end:  Boilerplate Cookie Functions
// ------------------------------------------------

// ------------------------------------------------
//  	BEGIN:  Ancillary Cookie Functions
// ------------------------------------------------

// ---------------------------------------------------------------------------------------
// Get values for &name=value pairs. Pass func params as strings.
// Called as: TestGetCookieParam("myCookie", "uid") // do not pass "&" in paramName string
// ---------------------------------------------------------------------------------------
function newGetCookieParam(cookieName, paramName) {
	var index    		= 0;
	var sep      		= "&";
	var paramValue  	= null;
	var start    		= 0;
	var without_sep  	= 0;
	var next_sep 		= 0;
	var eqIndex			= 0;
	var theCookieVal	= null;
	var theParamName	= "";
	var theParamCheck	= 0;
	
	// We don't pass this function the '&' in the paramName so html-ing is easy.
	// But we put it back in here so we don't find duplicate terms in param substrings.
	// Therefore, all found params must begin with '&'.
	theParamName = "&" + paramName;
	
	// theCookieVal == &q1=0&q2=0&q3=0...
	theCookieVal = GetCookie(cookieName);
	
	if ( theCookieVal != null ) {
	
		index = theCookieVal.indexOf(theParamName);
		if ( index == -1 ) return null;
		
		// alert("index: " + index );
		
		start = index + 1;
		without_sep = theCookieVal.substring(start, theCookieVal.length);
		
		// Check to make sure we're not dealing with a substring of the paramName.
		eqIndex = without_sep.indexOf("=");	
		if ( eqIndex + 1 != theParamName.length ) {
			return null;
		}
		
		next_sep = without_sep.indexOf("&");
		
		// handle last one
		if ( next_sep == -1 ) {
			paramValue = without_sep;
		} else {
			paramValue = without_sep.substring(0, next_sep);
		}				
		index = paramValue.indexOf("=");
		start = index + 1;
		paramValue = paramValue.substring(start, paramValue.length);
	}
	return paramValue;
}
	
	// We set a UID cookie for several reasons:
	// 	-- Anonymity: Visitors can fill in personal forms without giving their names.
	//	-- Referrer: How people found us -- most people can't remember, by the time we talk.
	//	-- Date first accessed: this is for us so we know the lag time between site
	//			updates and response.  Sometimes it's a long time between a first visit
	//			and a phone call.  Sometimes not.  Hopefully this is worth knowing.
	function always() {
		// if ( DomainCheck() ) { // No longer used. Domains are now separate.
		SetUIDcookie();
		gifmgr(); 
		// fixURL();
	}
	
	
	function SetUIDcookie() {
	
		var gotUID = null;
		var theCookieVal = null;
		var expdate = null;
		
		gotUID = GetCookie("NLS_UID");

		if ( gotUID == null ) {
			theCookieVal = ConstructUIDcookie();
			expdate = new Date();		
			expdate.setTime( expdate.getTime() + (365 * 24 * 60 * 60 * 1000) ); // 365 days from now
			SetCookie("NLS_UID", theCookieVal, expdate, "/", ".nlplearningsolutions.com");
		} else {
			// If it's already there, don't set it again.
		}
	}
	
	
	// Construct the value of a UID cookie.
	function ConstructUIDcookie() {
		var theUID = 0;
		var theDate = new Date();
		var theReferrer = "";
		var theCookieStr = "";
		var theScreenDimensions = screen.width + "x" + screen.height;
		
		theUID = makeRandomUID();  		// the UID is a random number
		theReferrer = getReferrer();	// the referrer is the site that linked to this page
		theCookieStr = "&uid=" + theUID + "&fa=" + theDate + "&scr=" + theScreenDimensions;
		if (theReferrer != "")
			theCookieStr = theCookieStr + "&ref=" + theReferrer;
		
		return theCookieStr;
	}

	
	// Create a random UID number
	function makeRandomUID() {
		var ia 		= 9301;
		var ic		= 49297;
		var im		= 233280;
		var number 	= 1000000;
				
		today = new Date();
		jran = today.getTime();
		jran = ( jran * ia + ic ) % im;
		
		uid = Math.ceil( ( jran / ( im * 1.0 ) ) * number);
		return uid;
	}
	
	// Get the referring page
	function getReferrer () {
		return document.referrer;
	}
	

	/*************************************************************************\
	boolean isNum(String argvalue)
	return true if argvalue contains only numeric characters,
	else return false.
	\*************************************************************************/
	function isNum(argvalue) {
		argvalue = argvalue.toString();
		
		if (argvalue.length == 0)
			return false;
		
		for (var n = 0; n < argvalue.length; n++)
			if (argvalue.substring(n, n+1) < "0" || argvalue.substring(n, n+1) > "9")
				return false;
		
		return true;
	}

	
// -------------------------------------------------------------------
//                   OTHER STANDARD FUNCTIONS
// -------------------------------------------------------------------


/* -------------------------------------------------------------------
gifmgr(): Calls the gifmgr.cgi
USAGE: HTML: 
</head>
<body onload = "always();" >
<div id="gifDiv" style="position:absolute; top:0px; left:0px; width:110px; visibility:hidden; z-index:-20; background-color:#FFFFFF; layer-background-color:#FFFFFF;"></div>
------------------------------------------------------------------- */
function gifmgr() {
	var ie5, ie6, theRandNum, theText, thisUID;
	var theUserAgent = navigator.userAgent.toLowerCase();
	var theDate = new Date ();
	theDate = escape(theDate);
	ie5 = 0;
	ie6 = 0;
	theRandNum = makeRandomUID();
	
	if (theUserAgent.indexOf('msie 5') > 0) { ie5 = 1; }
	if (theUserAgent.indexOf('msie 6') > 0) { ie6 = 1; }

	theText = '<table cellspacing=0 cellpadding=1 border=0 width=20><tr><td bgcolor=#FFFCE5>';
	theText += '<table width=100% cellspacing=0 cellpadding=2 border=0 bgcolor=#FFFCE5><tr><td align=left>';
	thisUID = newGetCookieParam("NLS_UID", "uid"); // Don't delete this line!
	theText += '<img src="http://www.nlplearningsolutions.com/cgi-bin/gifmgr.cgi?' + theDate + '">';	
	theText += '</font></td></tr></table></td></tr></table>';
	
	if (ie6||ie5) {
	       gifDiv.style.visibility = "hidden"; // "visible" // "hidden"
	       gifDiv.style.zindex = "-20";
	       gifDiv.innerHTML = theText;
	}
}

// -------------------------------------------------------------------
// Text area character limit control function
//
// Call with HTML in form like so:
//
// 		<textarea name="message2" wrap="physical" cols="28" rows="5" 
//			onKeyDown="textCntrl(document.myForm.message2, 125)" 
//		  	onKeyUp="textCntrl(document.myForm.message2, 125)" > 
//		</textarea>
//
// Note that you need both onKeyDown and onKeyUp because a user could theoretically
// fill up a field just holding a key down while his computer did a char repeat.
// -------------------------------------------------------------------

function textCntrl( field, maxlimit ) {
	if ( field.value.length > maxlimit ) {
	   field.value = field.value.substring(0, maxlimit);
	   alert("Sorry, you've reached the length limit for this answer!");
	}
}

	// -------------------------------------------
	// -------------------------------------------
	// -------------------------------------------
	// -------------------------------------------
	// -------------------------------------------
	// -------------------------------------------
	// -------------------------------------------

// -->
