// png képek átalakítása Internet Explorer számára
// forrás: http://vbence.web.elte.hu/ie_png_alpha.html
// szerző: Varga Bence
 
function alphaFixIE() {
	var s, i, j, k;
	
	// list of rules to alter IMPORANT: in  the order of their appearence, in the stylesheets
	/*var toscan = new Array(14);
	toscan[0] = ".popup_top";
	toscan[1] = ".popup_bottom";
	toscan[2] = ".popup_content";
	toscan[3] = "TD.header";
	toscan[4] = "TD.main_menu DIV.main_menu";
	toscan[5] = "DIV.box_admin_header";
	toscan[6] = "INPUT.box_up";
	toscan[7] = "INPUT.box_down";
	toscan[8] = "INPUT.box_left";
	toscan[9] = "INPUT.box_right";
	toscan[10] = "INPUT.box_edit";
	toscan[11] = "INPUT.box_delete";
	toscan[12] = "INPUT.link_edit";
	toscan[13] = "INPUT.link_remove";*/
	
	//alert('start');
	//alert('img');
	// IMG
	var els = document.getElementsByTagName("IMG");
	for (i=0; i<els.length; i++) {
		s = els[i].src;
		if (s.toLowerCase().indexOf(".png") != -1) {
			els[i].src = "/_application/images/empty.gif";
			els[i].style.filter += "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + s + "', sizingMethod=image);";
		}
	}
 
	// CSS: background
	//alert('css');
	/*
	k = 0;
	for (i=0; i<document.styleSheets.length; i++) {
		//alert(document.styleSheets[i].href);
		if (document.styleSheets[i].href.indexOf("basic.css") == -1)
			continue;
		//alert(document.styleSheets[i].href);
		var pos = document.styleSheets[i].href.lastIndexOf("/");
		var cssDir = (pos != -1) ? document.styleSheets[i].href.substring(0, pos + 1) : "";
		for (j=0; j<document.styleSheets[i].rules.length; j++) {
			// ha meg akarod tudni a sorrendet akkor a kovetkezo resyt REM-eld ki es alerteket kapcsold be
			var ok = 0;
			//alert(document.styleSheets[i].rules[j].selectorText);
			if (k < 14)
				if (toscan[k] == document.styleSheets[i].rules[j].selectorText)
				{
					ok = 1;
					k++;
				}
			if (ok == 0)
				continue;
			var style = document.styleSheets[i].rules[j].style;
			if (style.backgroundImage.indexOf(".png") != -1) {
				//alert(document.styleSheets[i].rules[j].selectorText + " " + style.backgroundImage);
				var filename = style.backgroundImage.substring(4, style.backgroundImage.length - 1);
				if (filename.indexOf("http://") != 0 && filename.indexOf("/") != 0)
					filename = cssDir + filename;
				style.backgroundImage = "none";
				style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + filename + "', sizingMethod='crop');";
				//alert('megcsinaltam');
			}
		}
	}*/
	//alert('done');
}
//if (window.XMLHttpRequest){
//} else {
window.attachEvent("onload", alphaFixIE);
//}