function setAPICookie() {
	var rand_no = Math.random();
	rand_no = Math.round(rand_no * 10000000);
	var exdate = new Date();
	exdate.setDate(exdate.getDate() + 200);
	document.cookie="SiteApiID" + "=" + escape(rand_no) + ";expires=" + exdate.toGMTString();
	return rand_no;
}
function getAPICookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    { 
    c_start=c_start + c_name.length+1; 
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    } 
  }
return "";
}
function urlencode(str) {
	return escape(escape(str));
}

var iAPIClientID = getAPICookie('SiteApiID');
if (iAPIClientID==null || iAPIClientID=='') {
	iAPIClientID = setAPICookie();
}

var sURL = urlencode(location.toString());
var sReferer = urlencode(document.referrer.toString());
document.write(unescape("%3Cscript src='http://api.mystream.dk/pageimpression/?url=" + sURL + "&referer=" + sReferer + "&clientid=" + iAPIClientID + "' type='text/javascript'%3E%3C/script%3E"));
