function COPBadge()
{
	this.siteUrl = "http://apps.panda.org/cop2/";
	this.strings = new Array();
		
	this.init = function(org)
	{	
		this.org = org;	
		this.copBadge = this.getElementById("copbadge");	
		
		var head = document.getElementsByTagName("head")[0];		
		this.addCSS(head, "css/copbadge.css");		
		
		if(this.ie6)
		{
			this.addCSS(head, "css/copbadge.ie6.css");
		}
		
		if(swfobject.hasFlashPlayerVersion("9.0.28.0"))
		{
			this.addCSS(head, org + "/copbadge.css");		
			
			this.copBadgeHtml = document.createElement("div");
			this.copBadge.appendChild(this.copBadgeHtml);
			
			var flashvars = {"url": this.siteUrl + "php/badge.php?org=" + this.org, "callback": "copBadge.loadHtml"};
			var params = {menu: "false", allowscriptaccess : "always"};
			swfobject.embedSWF(this.siteUrl + "swf/copwidget.swf", "copbadgeflash", "1px", "1px", "9.0.28.0", this.siteUrl + "swf/expressInstall.swf", flashvars, params);
		}
	}
	
	this.loadHtml = function(content)
	{
		this.copBadgeHtml.innerHTML = content;	

		if(this.ie6)
		{
			this.pngfixImg(document.getElementById("copstatusindicatorimg"), 90, 90);
		}		
	}
	
	this.getElementById = function(id)
	{
		var element = document.getElementById(id);
		if(!element)
		{
			throw "element not found. id:" + id;
		}
		return element;
	}	

	this.addCSS = function(head, path)
	{
		var link = document.createElement("link")
		link.rel = "stylesheet";
		link.type = "text/css";
		link.href = this.siteUrl + path;
		head.appendChild(link);	
	}

	this.pngfixImg = function(element, width, height)
	{
		var src = element.src;
		var style = element.style;
		style.width = width + "px";
		style.height = height + "px";
		style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "', sizingMethod='scale')";
		element.src = this.siteUrl + "images/blank.gif";
	}
}

var copBadge = new COPBadge();