function popup(uri, windowName, top, left, width, height)
{
	return window.open(uri, windowName, "top=" + top + ",left=" + left + ",location=no,menubar=no,resizeable=no,scrollbars=no,status=no,toolbar=no,width=" + width + ",height=" + height);
}

function clickImage(event)
{
	if (event==null) event=window.event;
	var elem=event.srcElement;
	if (elem==null) return;
	if (elem.tagName=="IMG")
	{
		if (elem.className!="popup-image" && elem.className!="bordered-popup-image") return;
		var src=elem.getAttribute("SRC");
		var i=src.lastIndexOf("_");
		var j=src.lastIndexOf(".");
		var ext=src.substring(j);
		var suffix=src.substring(i+1, j);
		var baseName=src.substring(0,i);
		var popupWidth=elem.getAttribute("cc:popup-width");
		var popupHeight=elem.getAttribute("cc:popup-height");
		var caption=elem.getAttribute("cc:popup-caption");
		if (caption==null) caption="ChampionChip";
		
		var top=(screen.height-popupHeight)/2;
		var left=(screen.width-popupWidth)/2;
		var windowName=baseName.substring(baseName.lastIndexOf("/")+1);
		var w=popup("", windowName, top, left, popupWidth, popupHeight);
		var doc=w.document;
		doc.write('<html><title>' + caption + '</title>');
		doc.write('<body style="margin: 0px;"><img src="'+ baseName + "_large" + ext +'"></body>');
		w.focus();
	}
}
document.onclick=clickImage;

function toggleDisplay(elem)
{
	if (elem.style.display=="")
	{
		elem.style.display="none";
		return false;
	}
	if (elem.style.display=="none")
	{
		elem.style.display="";
		return true;
	}	
}
