var webratetrackerurl="/jsscripts/webrate.js";

var TRKresult;
var TRKscreen, TRKwinsize, TRKcdi, TRKjava, TRKshk, TRKsvg, TRKfla;
var TRKrp, TRKmov, TRKwma, TRKpdf, TRKpdfver, TRKuserid, TRKsessionid;
var TRKnow, TRKbegin, TRKend;
var TRKnse, TRKn;

function webrate_setCookie(TRKNameOfCookie, TRKvalue, TRKexpirehours) {
	TRKExpireDate = new Date ();
  	TRKExpireDate.setTime(TRKExpireDate.getTime() + (TRKexpirehours * 3600 * 1000));
  	document.cookie = TRKNameOfCookie + "=" + escape(TRKvalue) + "; path=/" + ((TRKexpirehours == null) ? "" : "; expires=" + TRKExpireDate.toGMTString());
}
function webrate_detectIE(TRKClassID) {
	TRKresult = false;
	document.write('<SCR' + 'IPT LANGUAGE="VBScript">\n on error resume next \n TRKresult = IsObject(CreateObject("' + TRKClassID + '")) \n </SCR' + 'IPT>\n');
	if (TRKresult) return 'y';
	else return 'n';
}
function webrate_detectNS(TRKClassID) {
	TRKn = "n";
	if (TRKnse.indexOf(TRKClassID) != -1) if (navigator.mimeTypes[TRKClassID].enabledPlugin != null) TRKn = "y";
	return TRKn;
}
function webrate_getCookie(TRKNameOfCookie){
	if (document.cookie.length > 0){
		TRKbegin = document.cookie.indexOf(TRKNameOfCookie+"=");
	    if (TRKbegin != -1) {
			TRKbegin += TRKNameOfCookie.length+1; 
			TRKend = document.cookie.indexOf(";", TRKbegin);
			if (TRKend == -1) TRKend = document.cookie.length;
    	  	return unescape(document.cookie.substring(TRKbegin, TRKend));
		}
		return null; 
  	}
	return null; 
}
if (window.location.search == "" || window.location.search == "?") {
	TRKnow = new Date();
	TRKscreen=screen.width+"x"+screen.height;
	if (navigator.appName != "Netscape") { TRKcdi=screen.colorDepth; }
	else {TRKcdi=screen.pixelDepth};
	TRKjava=navigator.javaEnabled();
	TRKuserid=webrate_getCookie("AWSUSER_ID");
	TRKsessionid=webrate_getCookie("AWSSESSION_ID");
	var TRKrandomnumber=Math.floor(Math.random()*10000);
	if (TRKuserid == null || (TRKuserid=="")) { TRKuserid = "awsuser_id" + TRKnow.getTime() +"r"+ TRKrandomnumber; }
	if (TRKsessionid == null || (TRKsessionid=="")) { TRKsessionid = "awssession_id" + TRKnow.getTime() +"r"+ TRKrandomnumber; }
	webrate_setCookie("AWSUSER_ID", TRKuserid, 10000);
	webrate_setCookie("AWSSESSION_ID", TRKsessionid, 1);
	TRKuserid=""; TRKuserid=webrate_getCookie("AWSUSER_ID");
	TRKsessionid=""; TRKsessionid=webrate_getCookie("AWSSESSION_ID");
	
	var TRKnav=navigator.appName.toLowerCase();     
	var TRKagt=navigator.userAgent.toLowerCase();   

	var TRKwin  = ((TRKagt.indexOf("win")!=-1) || (TRKagt.indexOf("32bit")!=-1));
	var TRKmac  = (TRKagt.indexOf("mac")!=-1);

	var TRKns   = (TRKnav.indexOf("netscape") != -1);
	var TRKopera= (TRKnav.indexOf("opera") != -1);
	var TRKie   = (TRKagt.indexOf("msie") != -1);

    var TRKwinsize;
    if (document.documentElement && document.documentElement.clientWidth)
        TRKwinsize = document.documentElement.clientWidth + 'x' + document.documentElement.clientHeight;
    else if (document.body && document.body.clientWidth)
        TRKwinsize = document.body.clientWidth + 'x' + document.body.clientHeight;
    else
        TRKwinsize = window.innerWidth + 'x' + window.innerHeight;
	
	if (TRKie && TRKwin) {
		TRKshk = webrate_detectIE("SWCtl.SWCtl.1");
		TRKsvg = webrate_detectIE("Adobe.SVGCtl");
		TRKfla = webrate_detectIE("ShockwaveFlash.ShockwaveFlash.1");
		TRKrp  = webrate_detectIE("rmocx.RealPlayer G2 Control.1");
		TRKmov = webrate_detectIE("Quicktime.Quicktime");
		TRKwma = webrate_detectIE("wmplayer.ocx");
		TRKpdf = 'n'; TRKpdfver='';
        if (webrate_detectIE("PDF.PdfCtrl.1") == 'y') { TRKpdf = 'y'; TRKpdfver='4'; } 
	    if (webrate_detectIE('PDF.PdfCtrl.5') == 'y') { TRKpdf = 'y'; TRKpdfver='5'; } 
		if (webrate_detectIE('PDF.PdfCtrl.6') == 'y') { TRKpdf = 'y'; TRKpdfver='6'; } 
		if (webrate_detectIE('AcroPDF.PDF.1') == 'y') { TRKpdf = 'y'; TRKpdfver='7'; } 
	}
	if (TRKns || !TRKwin) {
		TRKnse = "";
		for (var TRKi=0;TRKi<navigator.mimeTypes.length;TRKi++) TRKnse += navigator.mimeTypes[TRKi].type.toLowerCase();
		TRKshk = webrate_detectNS("application/x-director","");
  		TRKsvg = webrate_detectNS("image/svg+xml","");
		if (document.implementation.hasFeature("org.w3c.dom.svg", "")) {TRKsvg = "y"; }
		TRKfla = webrate_detectNS("application/x-shockwave-flash"); 
		TRKrp  = webrate_detectNS("audio/x-pn-realaudio-plugin");
		TRKmov = webrate_detectNS("video/quicktime");
		TRKwma = webrate_detectNS("application/x-mplayer2");
		TRKpdf = webrate_detectNS("application/pdf");
        TRKpdfver='';
    }

	var imgsrc1 = webratetrackerurl+'?screen='+TRKscreen+'&win='+TRKwinsize+'&cdi='+TRKcdi+'&java='+TRKjava;
	var imgsrc2 = '&shk='+TRKshk+'&svg='+TRKsvg+'&fla='+TRKfla+'&rp='+TRKrp+'&mov='+TRKmov+'&wma='+TRKwma+'&pdf='+TRKpdf+'&uid='+TRKuserid+'&sid='+TRKsessionid;
	var imgsrc=imgsrc1+imgsrc2;
	if( document.createElementNS ) {
    	var l=document.createElementNS("http://www.w3.org/1999/xhtml","img");
        l.setAttribute("src", imgsrc );
        l.setAttribute("height", "0");
        l.setAttribute("width", "0");
        l.setAttribute("border", "0");
        document.getElementsByTagName("body")[0].appendChild(l);
	} else {
		document.write('<img style="display:none;" src="'+ imgsrc +'" height="0" width="0" border="0" />')
	}

}
