//Visitors
// src="/includes/local/general/visit.js"
function hl_tag()
{
  var hl_tagurl='http://visitors.workopolis.com/visitor.gif';
  var hl_tagversion=1;
  var hl_tagtype='CorporateWorksClients_v1.0_20050527'; // Workopolis QA
  var hl_referrer=document.referrer;
  var hl_domain=document.location.hostname;
  var hl_url=document.location.pathname;
  var hl_port=document.location.port;
  var now = new Date();
  var dMonth=String(now.getUTCMonth()+1);
  var dDay=String(now.getUTCDate());
  var dHours=String(now.getUTCHours());
  var dMinutes=String(now.getUTCMinutes());
  var dSeconds=String(now.getUTCSeconds());
  if (dMonth.length==1) {dMonth='0'+dMonth};
  if (dDay.length==1) {dDay='0'+dDay};
  if (dHours.length==1) {dHours='0'+dHours};
  if (dMinutes.length==1) {dMinutes='0'+dMinutes};
  if (dSeconds.length==1) {dSeconds='0'+dSeconds};
  var hl_requestdate= String(now.getUTCFullYear())+'-'+dMonth+'-'+dDay+' '+dHours+':'+dMinutes+':'+dSeconds;
  var hl_uniqueid = String(now.getTime());
  var hl_title=document.title;
  var hl_query='';
  if (document.location.search.length>0){hl_query=document.location.search.substring(1)};
  if (hl_query.length==0) 
    {hl_query=hl_meta().substring(1);}
  else
    {hl_query+=hl_meta();}
  if (hl_query.length==0) 
    {hl_query='hl_tagtype='+hl_tagtype;}
  else
    {hl_query+='&hl_tagtype='+hl_tagtype;}
  var hl_sessionid=GetCookie("hl_sessionid");
  if (hl_sessionid == null)
  {
  	hl_sessionid=NewSessionID();
    var expirationdate=new Date(); 
  	expirationdate.setFullYear(expirationdate.getFullYear()+1);
  	SetCookie ("hl_sessionid", hl_sessionid, expirationdate, "/", ".workopolis.com", false);	
  }
  var hl_cookie=document.cookie;
  var hl_tagsource=hl_tagurl+'?hl_tagversion='+hl_tagversion+'&hl_uniqueid='+hl_uniqueid+'&hl_domain='+HLescape(hl_domain)+'&hl_url='+HLescape(hl_url)+'&hl_port='+hl_port+'&hl_query='+HLescape(hl_query)+'&hl_referrer='+HLescape(hl_referrer)+'&hl_cookie='+HLescape(hl_cookie);
  hl_tag=new Image();
  hl_tag.src=hl_tagsource;
}
function hl_meta(){
var hl_elements;
var hl_metaquery='';
if (document.all)
{
  hl_elements=document.all.tags("meta");
}
else if (document.documentElement)
{
  hl_elements=document.getElementsByTagName("meta");
}
if (typeof(hl_elements)!="undefined"){
	for (var i=1;i<=hl_elements.length;i++){
		var hl_meta=hl_elements.item(i-1);
		if (hl_meta.name)
		{
			if (hl_meta.name.indexOf('HL.')==0)
			{
				hl_metaquery+='&'+hl_meta.name.substring(3)+'='+hl_meta.content;
			}
		}
	}
}
return(hl_metaquery);
}

function NewSessionID() 
{
	var TodaysDate=new Date();
	var newid = Math.floor(999999*Math.random()+1)+"-"+TodaysDate.getFullYear()+(TodaysDate.getMonth()+1)+TodaysDate.getDate()+TodaysDate.getHours()+TodaysDate.getMinutes()+TodaysDate.getSeconds(); 
	return newid;
}

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, expires, path, domain, secure) {  

	document.cookie = name + "=" + escape (value) + 
	((expires == "") ? "" : ("; expires=" + expires.toGMTString())) + 
	((path == "") ? "" : ("; path=" + path)) +  
	((domain == "") ? "" : ("; domain=" + domain)) +    
	((secure == true) ? "; secure" : "");
}

function getCookieVal(offset) {
  var endstr = document.cookie.indexOf (";", offset);
  if (endstr == -1)
    endstr = document.cookie.length;
  return unescape(document.cookie.substring(offset, endstr));
}

function HLescape(value)
{

	if (value != null)
	{
		//a little extra paranoia doesn't hurt, since we don't want the parameters to have bad character
		//that would cause problems parsing the values later
		value=escape(value);
		value = value.replace(/\//g,"%2F");	
		value = value.replace(/\?/g,"%3F");
     		value = value.replace(/=/g,"%3D");
     		value = value.replace(/&/g,"%26");
		value = value.replace(/@/g,"%40");
	}
	else
	{
		value="";
	}

	return value

}

hl_tag();