

function createURL(paramMap,urlMap)
{
		
	var hl_title=urlMap.get("title");;
	var hl_tagversion=1;
	var tagurlPath="/HLTag.gif";
	var currentProto=document.location.protocol;
	//var currentProto="https:";
	var domainName = urlMap.get("reportingServer");
	var dir = urlMap.get("directorypath");
	var error = urlMap.get("error");	
	var hl_lang = paramMap.get("lang");
	
	var tagCodeBase = urlMap.get("tagcodebase");	
	var hl_tagurl=currentProto+'//'+domainName;
	hl_tagurl = hl_tagurl+dir+tagurlPath;	
    var cPath=document.location.pathname;    
    var tagFlag=false;   
    var keyValues = new Array();
    var donQuery="";
    if(urlMap.get("donationType") !=null)
    {
    	donQuery='DonationType='+urlMap.get("donationType");
    }    
    var hl_url=(hl_url)?hl_url:document.location.pathname;
    
    keyValues = paramMap.keySet();    
    if(error != "0")
    {       	
    	hl_title = "Tribute Error";
    	hl_url = "/GiftCatalog/tributeError.do"
    	donQuery='reasonCode'+"="+paramMap.get("reasonCode");
    }
    else
    {    	
    	for(var i=0;i<keyValues.length;i++)
        {    	
        	donQuery+='&'+keyValues[i]+"="+paramMap.get(keyValues[i]);
        }	
    }    
    var hl_referrer=(hl_referrer)?hl_referrer:document.referrer;
	var hl_domain=document.location.hostname;	
	
	var hl_port=document.location.port;
		
	//get universal time information for tag
	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};

	//we don't use the client time by default, but here is the format that would be passed in the application argument
	//this is the standard format we like: yyyy-mm-dd hh:nn:ss
	var hl_requestdate= String(now.getUTCFullYear())+'-'+dMonth+'-'+dDay+' '+dHours+':'+dMinutes+':'+dSeconds;
	var hl_uniqueid = String(now.getTime());

	//various unused default values (they could be appended as part of hl_query in parameter values)
	var hl_screenresolution=screen.width+'*'+screen.height;
	
	var hl_title=(typeof(hl_title)!="undefined")?hl_title:document.title; 
	//if you don't want to keep the original query values change this
	if (typeof(hl_query)=="undefined") 
	{
		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();
		}
	}
	
	hl_query+=donQuery;
	hl_lang=(hl_lang)?hl_lang:"en";
	hl_query=hl_query+
	         '&hl_screenresolution='+hl_screenresolution+
	         '&hl_title='+hl_title+
	         '&hl_lang='+hl_lang;
	         
	//this is a good place to implement a visitor cookie
	//we default to create a unique sessionid to make sure all tagged requests have a way to resolve the visit
	//note:  if we aren't allowing cookies this won't affect anything...
	var hl_sessionid=GetCookie("hl_sessionid");
	if (hl_sessionid == null)
	{
		hl_sessionid=NewSessionID();
		//set the cookie to expire at end of session for entire site
		// SetCookie ("hl_sessionid", hl_sessionid, "", "/", "", false);
		var expirationdate=new Date(); 
		expirationdate.setFullYear("2025"); 
		SetCookie ("hl_sessionid", hl_sessionid, expirationdate, "/", ".stjude.org", false);
	}

	//note:  this variable passed in the query to HitList will override the cookie value passed in normal logging
	//	 that means you could add information (if necessary) directly to the cookie by adding it to hl_cookie
	var hl_cookie=document.cookie;

	//this is the tagging information that will be sent
	//note: by default we defer to the server time, but the client time may be passed by appending the hl_requestdate parameter
	//      '&hl_requestdate='+HLescape(hl_requestdate)
	
	var hl_tagsource=hl_tagurl+
	                 '?hl_tagversion='+hl_tagversion+'&hl_tagcodebase='+tagCodeBase+'&hl_title='+HLescape(hl_title)+'&hl_screenresolution='+hl_screenresolution+'&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);
	//send the tagging information by loading 1x1 gif
	hl_tag2=new Image();	
	hl_tag2.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
}