/**********************************************************************
TINYLIB.JS : Tiniest Library

ESSENTIAL funcs used virtually throughout the whole application.
Funcs are placed in here rather than /common/Universal.asp, so that these
may be included by quickfire pages that do not want to be bloated by the
size of the Universal libray.
**********************************************************************/

// --------------------------------------------------------------------
// CORE
// --------------------------------------------------------------------

// Returns boolean indicating if o has been declared and 
//	..assigned a value besides NULL
function IsDefined(o)
{
	if ( o )
		return true;
		
	if ( typeof(o) == "number" )
		if ( o == 0 )
			return true;
			
	return false;
}


// --------------------------------------------------------------------
// STRING SUPPORT
// --------------------------------------------------------------------

// Removes leading and trailing whitespace from str
// Returns the trimmed string
function TrimString(str)
{
	if (str + "" == 'null')
		return "";
	if (str + "" == 'undefined')
		return "";

	str = str + "";         // ensure conversion to JScript string
	
	while ((str.charAt(0) == ' ') || (str.charAt(0) == '\t'))
		str = str.substring(1);

	while ((str.charAt(str.length - 1) == ' ') || (str.charAt(str.length - 1) == '\t'))
		str = str.substring(0, str.length - 1);

	return str;
}

// Netscape::Search & Replace
// strMod -- str to modify
// strSearch -- search string
// strReplace -- replacement string
// NOTE: does NOT do wildcards or Regular Expressions
function NS_Replace(strMod, strSearch, strReplace)
{
	var strCp = "";
	var iSub = strMod.indexOf(strSearch);
	
	while (iSub > -1)
	{	
		strCp   = strMod;
		strMod  = strMod.substring(0, iSub);
		strMod += strReplace;
		strMod += strCp.substring(iSub + strSearch.length, strCp.length);

		iSub = strMod.indexOf(strSearch, iSub + strReplace.length);			
	}
	
	return strMod;
}


// --------------------------------------------------------------------
// MISC
// --------------------------------------------------------------------

// Detects browser type
// Returns boolean indicating if browser is IE 4.01 or above
// CLIENT ver
function DetectBrowser()
{
	var bCompat = true;
	var iMS = navigator.userAgent.indexOf('MSIE', 0);
	
	if (iMS < 0)      // not Internet Explorer!
		bCompat = false;
	else 
	{
		var strNav = navigator.userAgent.substring(iMS + 4, 255);
		var fVer = parseFloat(strNav);
	
//	12/22/99	CEL	Added if logic for IE3.0 Browsers which do not recognize
//		screen.availHeight
		
		if (fVer < 4.01)
			bCompat = false;
		else if (screen.availHeight < 500)
			bCompat = false;
	}
	
	return bCompat;
}
// --------------------------------------------------------------------
// loginagain
// --------------------------------------------------------------------
function LogInAgain( ss_CameInPlan,ss_SuperFrameAnchor,ss_FrameAnchor, ss_nDesign) 
{
	  var plan			       = ss_CameInPlan;
	  var frameanchor		   = ss_FrameAnchor;
	  var superframeanchor	   = ss_SuperFrameAnchor;
	  var nDesign			   = ss_nDesign ;
	  var loginlocation		   = "";
	  var end_strsuperframe	   = "";
	  var end_strframeanchor   = "";

 
	  var oQSNav			   = new QS();
	  oQSNav.Flush();
	  
	  oQSNav.strURL = "/default.asp";

	  // ePlan modern 3.8		
	  if ( nDesign == 1)
	  {
	  	 end_strsuperframe = superframeanchor.lastIndexOf(".");
	  	 loginlocation = superframeanchor.substring(0,end_strsuperframe);
	  	 //alert("superframeanchor = " + loginlocation);
	  	 oQSNav.Add( "FrameAnchor", loginlocation );
	  }
	  // ePlan Classic
	  else
	  {
		 end_strframeanchor = frameanchor.lastIndexOf(".");
	  	 loginlocation = frameanchor.substring(0, end_strframeanchor );
	  	 oQSNav.Add( "FrameAnchor", loginlocation );
	  }
	  // since the plan is passed to this function without checking it's existence
	  // from various Managers this check is needed here. Maha
	  if ( plan && (plan != 'undefined') )
	  {
		  oQSNav.Add( "healthplan", plan );
	  }
	  	 loginlocation = eval(loginlocation);
		 loginlocation.location.href = oQSNav.Show();
}

// -= END of TinyLib.js =-

