// (c) Radek HULAN, http://hulan.info/
// This work is licensed under the Creative Commons Attribution License. 
//
// NAVRCHOLU.cz statistics that works under XHTML 1.1 served with
// MIME type application/xhtml+xml as well as text/html MIME type.
 
// helper functions
var isXHTML;
function createNewEle(ele){
 if(isXHTML) 
  return document.createElementNS('http://www.w3.org/1999/xhtml', ele);
 else 
  return document.createElement(ele);
};	
 
// navrcholu.cz code
function navrcholu(){
	var ele=document.getElementById('navrcholu');
	if (!ele) return;
	isXHTML=/html\:/.test(document.getElementsByTagName('body')[0].nodeName);
	// navrcholu.cz id from title
	var id=parseInt(ele.getAttribute('title'));
	if (!id) alert('TITLE attribute does not contain your NAVRCHOLU.cz ID!');
	// some variables
	var n=navigator;
	var p=document;
	var c,t,b,j,m,r,y,d,x,w;
	d=x=w=j=0;
	// detect flash plugin in MSIE
	if(n.appVersion.indexOf("MSIE")>=0 && n.appVersion.indexOf("Win")>=0 && n.userAgent.indexOf("Opera")<0) {
		p.writeln("<s"+"cript type='text/vbscript'>");
		p.writeln("on error resume next");
		p.writeln("For i=7 to 4 Step -1");
		p.writeln(" If IsObject(CreateObject(\"ShockwaveFlash.ShockwaveFlash.\" & i)) Then"); 
		p.writeln("   n3f8q=i");
		p.writeln("   Exit For");
		p.writeln(" End If");
		p.writeln("Next");
		p.writeln("</s"+"cript>"); 
	} else 
		eval("var n3f8q=0");
	// detect flash in other browsers
	if( n.plugins && n.plugins["Shockwave Flash"]){
		t=n.plugins["Shockwave Flash"].description;
		n3f8q=parseInt(t.charAt(t.indexOf(".")-1)); 
	}
	// get other vars
	m=(n.userAgent.substring(0,8)=="Mozilla/") ? n.userAgent.substring(8,9) : 4;
	if(m>2) j=(n.javaEnabled()) ? 1 : 0;
	r=window.top.document.referrer;
	if(m>3 && screen){
		d=screen.colorDepth;
		if(d==0) d=screen.pixelDepth;
		x=screen.width;
		w=(p.all) ? top.document.body.clientWidth:top.innerWidth; 
	}
	y=new Date();
	y.setTime(y.getTime()-31536000000);
	p.cookie="nvt=1";
	c=(p.cookie.indexOf("nvt") != -1)?1:0;
	p.cookie="nvt=1; expires="+y.toGMTString();
	// set new A attributes
	ele.href='http://navrcholu.cz/Statistika/'+id+'/';
	ele.setAttribute('title','NAVRCHOLU.cz');
	// create IMG
	var img=ele.appendChild(createNewEle('img'));
	img.setAttribute('alt','NAVRCHOLU.cz');
	img.setAttribute('style','width:80px;height:15px');
	img.setAttribute('src','http://c1.navrcholu.cz/hit?site='+id+';t=o80;'
		+'fv='+n3f8q+';js='+j+';cs='+c+';ref='+escape(r)+';cd='
		+d+';sx='+x+';wx='+w+';jss=1;r='+Math.random());
}
navrcholu();
