var isXHTML;
function createNewEle(ele){
 if(isXHTML) 
  return document.createElementNS('http://www.w3.org/1999/xhtml', ele);
 else 
  return document.createElement(ele);
};	
 
function toplist(){
	var ele=document.getElementById('toplist');
	if (!ele) return;
	isXHTML=/html\:/.test(document.getElementsByTagName('body')[0].nodeName);
	// toplist.cz id from title
	var id=parseInt(ele.getAttribute('title'));
	if (!id) alert('TITLE attribute does not contain your TOPLIST.cz ID!');
	var img=ele.getElementsByTagName('img');
	// set new A attributes
	ele.href='http://toplist.cz/stat/'+id;
	ele.setAttribute('title','TOPLIST.cz');
	// create IMG
	var img=ele.appendChild(createNewEle('img'));
	img.setAttribute('border','0');
	img.setAttribute('width','0');
	img.setAttribute('height','0');
	img.setAttribute('alt','TOPLIST.cz');
	img.setAttribute('src','http://toplist.cz/count.asp?id='+id
		+'&http='+escape(document.referrer)
		+'&wi='+escape(window.screen.width)
		+'&he='+escape(window.screen.height)
		+'&cd='+escape(window.screen.colorDepth)
		+'&t='+escape(document.title));
}
toplist();
