/* 
$LastChangedDate: 2006-11-07 23:12:35 +1100 (Tue, 07 Nov 2006) $
$Rev: 5439 $
*/

/*
	HitDynamics Tracking Script v3.3, 16 Aug 2006 (with 1st-party cookie support)
	Copyright HitDynamics Ltd. 2006, All Rights Reserved
	@Vars:
	- dmn_id - HD ID of tracked domain. Required.
	- dmn_name - name of tracked domain. Required.
	- act_id - HD ID of domain's action. Optional.
	- val - action's revenue value. Required for every action.
	- cur - action's currency. Required for every action.
	- val_converted - action's revenue value, converted into domain's primary currency. Required for every action.
	- act_atr - action's additional attributes. Optional for every action. Syntax for these attributes is:
		attribute1_name=attribute1_value[;attribute2_name=attribute2_value...]
	- vsr_code - Unique domain-specific ID of visitor. Optional.
*/

function HDGC(d,n)
{
var c="; "+document.cookie;
var b=c.indexOf("; "+n+"=");
if (b==-1) return '';
var e=c.indexOf(";",b+1);
if (e==-1) e=c.length;
return c.substring(b+n.length+3,e);
}

function HDC(d,n,v,fv)
{
var x=new Date((new Date()).getTime()+8E10);
if (fv) document.cookie=n+"="+escape(v)+"; expires="+x.toGMTString()+"; path=/; domain="+d;
return HDGC(d,n);
}

function HDID(p,r)
{
var t=(new Date).getTime();
var c="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
var s='';
for (var i=0; i<32; i++) 
{
	var n=Math.floor(Math.random()*c.length)+3;
	n+=t; t/=64;
	if (i<p.length) n+=c.indexOf(p.charAt(i));
	if (i<r.length) n+=c.indexOf(r.charAt(i));
	s+=c.charAt(n%c.length);
}
return s;
}

function HDTrack(dmn_id, dmn_name, action_id, val, cur, val_converted, action_atr, vsr_code, hd_url)
{
var p=document.location.href.substring(0,255);
var r=document.referrer.substring(0,255);
var n=dmn_name;
var id=HDGC(n,"HD_ID")||HDGC(n,"HDSID_ID");
var fv=(id.length>=30 && id.length<=40)?0:1;
s="v=3&dmnid="+dmn_id+"&ref="+escape(r)+"&cpg="+escape(p);
s+="&dmnname="+n;
if (action_id!='')
	s+="&action_id="+action_id+"&action_atr="+escape(action_atr)+"&cost_value="+val+"&currency="+cur+"&converted="+val_converted;
if (vsr_code!='')
	s+="&vsr_code="+escape(vsr_code);
s+="&fpck="+(fv?HDC(n,"HD_ID",HDID(p,r),fv):id);
s+="&ep="+HDC(n,"HD_EP",p,fv)+"&er="+HDC(n,"HD_ER",r,fv);
s+="&xd="+HDGC(n,"HD_XD")+"&pd="+HDGC(n,"HD_PD");
s+="&vs="+HDGC(n,"HD_VS")+"&c1="+HDGC(n,"HD_C1")+"&c2="+HDGC(n,"HD_C2"); 
s+="&js=1&fv="+fv;
s+="&wdth="+screen.width+'&hght='+screen.height+"&cols="+(screen.colorDepth?screen.colorDepth:screen.pixelDepth?screen.pixelDepth:'');
document.write("<"+"script language='JavaScript' src='"+document.location.protocol+"//"+(typeof hd_url!="undefined"?hd_url:"hd.hitdynamics.com")+"/imgs.png?"+s+"'><"+"/script>");
}