// (c) Radek HULAN, http://hulan.info/
// This work is licensed under the Creative Commons Attribution License. 
//
// TOPLIST.cz statistics that works under XHTML 1.1 served with
// MIME type application/xhtml+xml as well as text/html MIME type.
 
// 16. January 2005 - Arcao replace '&amp;' to correct '&'.
 
// helper functions
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://www.toplist.cz/stat/'+id;
	ele.setAttribute('title','TOPLIST.cz');
	// create IMG
	var img=ele.appendChild(createNewEle('img'));
	img.setAttribute('alt','TOPLIST.cz');
	img.setAttribute('style','width:88px;height:60px');
	img.setAttribute('src','http://toplist.cz/count.asp?id='+id
		+'&logo=mc'
		+'&http='+escape(document.referrer)
		+'&wi='+escape(window.screen.width)
		+'&he='+escape(window.screen.height)
		+'&cd='+escape(window.screen.colorDepth)
		+'&t='+escape(document.title));
}
toplist();
