var PngImage = Class.create();

PngImage.prototype = {
	
	initialize: function(src, width, height, link, title) {
		if ('object' == typeof src) {
			var arg = arguments[0];
			this.id = (arg.id) ? arg.id : null;
			this.src = arg.src;
			this.width = arg.width;
			this.height = arg.height;
			this.vspace = (arg.vspace) ? arg.vspace : 0;
			this.hspace = (arg.hspace) ? arg.hspace : 0;
			this.border = (arg.border) ? arg.border : 0;
			this.className = (arg.className) ? arg.className : null;
			this.style = (arg.style) ? arg.style : null;
			this.link = (arg.link) ? arg.link : null;
			this.title = (arg.title) ? arg.title : null;
		} else {
			this.id = null;
			this.src = src;
			this.width = width;
			this.height = height;
			this.vspace = 0;
			this.hspace = 0;
			this.border = 0;
			this.className = null;
			this.style = null;
			this.link = link;
			this.title = title;
		}
	},

	getHtml: function() {
		var image = '';
		if (this.link) image += '<a href="'+this.link+'">';
		switch (PngImage.displayMode) {
			case 'alpha':
				image += '<img src="/i/spacer.gif" ' + (this.width ? ' width="' + this.width + '"' : '') + (this.height ? ' height="' + this.height + '"' : '') + ' vspace="0" hspace="0" border="0" alt="' + (this.title ? this.title : '') + '"' + ((this.id) ? ' id="' + this.id + '"' : '') + ' style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'' + this.src + '\', sizingMethod=\'scale\');' + (null != this.style ? ' '+this.style : '') + '"' + (null != this.id ? ' id="' + this.id + '"' : '') + (null != this.className ? ' class="' + this.className + '"' : '') + ' />';
				break;
			case 'normal':
			default:
				image += '<img src="' + this.src + '"' + (this.width ? ' width="' + this.width + '"' : '') + (this.height ? ' height="' + this.height + '"' : '') + ' vspace="' + this.vspace + '" hspace="' + this.hspace + '" border="' + this.border + '" alt="' + (this.title ? this.title : '') + '"' + (null != this.title ? ' title="' + this.title + '"' : '') + ((this.id) ? ' id="' + this.id + '"' : '') + (this.className ? ' class="' + this.className + '"' : '') + (this.style ? ' style="'+this.style+'"' : '') +' />';
				break;
		}
		if (this.link) image += '</a>';
		return image;
	},

	display: function() {
		document.write(this.getHtml());
	}

}

PngImage.displayMode = (browser.isWin32 && (browser.isIE55 || browser.isIE6up)) ? 'alpha' : 'normal';

PngImage.create = function(src, width, height, link, title) {
	return new PngImage(src, width, height, link, title);
};
