﻿var IE6Hack = Class.create({
	
	initialize: function () {
		this.IE6 = (navigator.appVersion.indexOf("MSIE 6")!=-1) ?true :false;
	},
	
	pngFix: function (pixGifUrl) {
		if (this.IE6) {
			for (var i=0;i<document.images.length;i++) {
				var imgs = document.images[i];
				this.pngFixItem(pixGifUrl,imgs);
				imgs.style.visibility = "visible";
			}
		}
	},
	
	pngFixItem: function (pixGifUrl,img) {
		if (this.IE6) {
			if (img.src.substring(img.src.length-3,img.src.length)=="png") {
				img.style.height = img.style.width = "";
				img.style.height = img.offsetHeight + "px"; img.style.width = img.offsetWidth + "px";
				img.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src=" + img.src + ",sizingMethod='scale')";
				img.src = pixGifUrl;
			}
		}
	},
	
	pngFixRoll: function (img) {
		if (this.IE6) {
			Event.observe(img,"mouseover",this.pngRoll.bindAsEventListener(this,0,1));
			Event.observe(img,"mouseout",this.pngRoll.bindAsEventListener(this,1,0));
		}
	},
	
	pngRoll: function (e,toReplace,replaceBy) {
		this.setFilter(Event.element(e),toReplace,replaceBy);
	},
	
	pngRollManual: function (o,toReplace,replaceBy) {
		this.setFilter(o,toReplace,replaceBy);
	},
	
	setFilter: function (o,toReplace,replaceBy) {
		o.style.filter = o.style.filter.replace("-"+toReplace+".png","-"+replaceBy+".png");
	}
	
});
