popupWindow = null;
img = null;

	function popup(url, width, height) {
	
		url = location.href.substring(0,location.href.lastIndexOf("/")) + url;
		len = url.length;
		last3 = url.substring(len-3, len);
				
		mediaTag = (last3 == "swf") ?
			'<embed width="'+width+'" height="'+height+'" src="'+url+'" border="0"></embed>' :
			'<a href="javascript:top.close();"><img src="'+url+'" width="'+width+'" height="'+height+'" border="0" alt="close window" galleryimg="no"></a>';

		cleanUp();
		popupWindow = window.open('', '', 'width='+ width +',height='+ height);
		pd = popupWindow.document;
		pd.open();
		pd.writeln('<html>');
		pd.writeln('<head><link rel="stylesheet" href="adamtoons.css" type="text/css"></head>');
		pd.writeln('<body class="popup" marginwidth="0" marginheight="0" leftmargin="0" topmargin="0" rightmargin="0" bottommargin="0">');
		pd.writeln(mediaTag);
		pd.writeln('</body></html>');
		pd.close();
		pd.title = "adamtoons :: popup";
		popupWindow.focus();
		
	}
	
	function cleanUp() {
		if ((popupWindow) && (! popupWindow.closed)) popupWindow.close();
	}
