/**
 * @author jonandersson
 */

var nowOnload = window.onload; // Let's save the existing assignment, if any

function replaceAllPngsForIe6()
		{

			if (navigator.appVersion.indexOf("MSIE 6") != -1)
			{
				var nodesToCheck = new Array("div", "span", "h1", "h2", "h3", "a");
				for (var i = 0; i < nodesToCheck.length; i++)
				{
					var nodesList = document.getElementsByTagName(nodesToCheck[i]);
					for (var j = 0; j < nodesList.length; j++)
					{
						var backgroundImage = getStyle(nodesList[j], "backgroundImage");
						if ((backgroundImage.indexOf(".png") != 1) && (backgroundImage != "none"))
						{
							var orgWidth = getStyle(nodesList[j], "width");
							var orgHeight = getStyle(nodesList[j], "height");
							backgroundImage = backgroundImage.replace(/url\(/gi, "");
							backgroundImage = backgroundImage.replace(/['"\)]/gi, "");        
							var autoSize = (orgWidth == "auto") || (orgHeight == "auto");
							nodesList[j].style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader (src='" + backgroundImage + "', sizingMethod='" + (autoSize ? "scale" : "crop") + "')";
							nodesList[j].style.backgroundImage = "none";
							nodesList[j].style.width = orgWidth;
							nodesList[j].style.height = orgHeight;
						}
					}
				}
			}
		    
			var imgList = document.getElementsByTagName("img");
			for(var i = 0; i < imgList.length; i++)
			{
				var img = imgList[i];
				if (img.src.indexOf(".png") != -1)
				{
					if (navigator.appVersion.indexOf("MSIE 6") != -1)
					{
						img.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader (src='" + img.src  + "')";
						img.src = "media/img/null.gif";
						if(img.parentNode.nodeName.toLowerCase() == "a")
						{
							img.onclick = function() {location.href = img.parentNode.href; }
							img.onmouseover = function()
							{
								this.style.cursor = "hand";
							}
						}
					}
					img.style.visibility = "visible";
				}
			}
		    
			function getStyle(obj,styleProp)
			{
				var x = obj;
				if (x.currentStyle)
					var y = x.currentStyle[styleProp];
				else if (window.getComputedStyle)
					var y = document.defaultView.getComputedStyle(x,null).getPropertyValue(styleProp);
				return y;
			}

		}  