function trim(objText)
{
  objText= objText.replace(/^\s+|\s+$/g,""); 
  return objText;
}
//get the path name and convert it to lower case
var theURLPath = window.location.pathname.toLowerCase();
//clean up the path by replacing //+ with /
theURLPath = theURLPath.replace(/\/(\/)*/g, "/");
theURLPath = trim(theURLPath);
//generate the random number
var rnum=Math.floor(99999999 * Math.random());

//split the folders into an array
sectLevel=theURLPath.split("/"); 

//for omniture
var firstFolderSect="";
var hierSections = "tsg";
//check if this is root folder or domain only
if (sectLevel.length > 1 && sectLevel[1] != "" && sectLevel[1] != " " && sectLevel[1].lastIndexOf('.') == -1)
{
	//not root, assign first folder
	firstFolderSect = sectLevel[1];
	//hierarchy variable, default it to first folder
	hierSections = hierSections + "," + sectLevel[1];
	//loop through the directory path from url
	for (var isect2 = 2; isect2 < sectLevel.length; isect2 ++)    
	{
		//if it is not empty and not a file then add it to the list
		if (sectLevel[isect2] != "" && sectLevel[isect2] != " " &&  sectLevel[isect2].lastIndexOf('.') == -1)
		{
			hierSections = hierSections + "," + sectLevel[isect2]        
		}
	}
}
else
{
	//is root, set it to static name
	firstFolderSect = "welcomepage";
}

/* start cookie functions */
function getCookie(name){
  var dc = document.cookie;
  var prefix = name + "=";
  var begin = dc.indexOf("; " + prefix);
  if(begin == -1){
    begin = dc.indexOf(prefix);
    if(begin != 0) return null;
  }
  else begin += 2;
  var end = document.cookie.indexOf(";", begin);
  if(end == -1) end = dc.length;
  return unescape(dc.substring(begin + prefix.length, end));
}
function setCookie(name, value, expires, path, domain, secure){
  var curCookie = name + "=" + escape(value) +
      ((expires) ? "; expires=" + expires.toGMTString() : "") +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      ((secure) ? "; secure" : "");
  document.cookie = curCookie;
}
function fixDate(date){
  var base = new Date(0);
  var skew = base.getTime();
  if(skew > 0) date.setTime(date.getTime() - skew);
}
/* end cookie functions */
