﻿/* Credits to Cattus at http://cattus.hyperphp.com/ here, but feel free to remove this notice. */

var path_to_blank_gif_image = "blank.gif"; // Här skriver du vägen till en helt transparent gif-bild 

function fixPng()
{
	var ie_ver	= parseFloat(navigator.appVersion.substr(navigator.appVersion.indexOf("MSIE ")+5));
	if( ie_ver >= 5.5 && ie_ver < 7 ) 
	{
		var objects = document.getElementsByTagName('*');
		for( var i=0; i<objects.length; i++ )
		{
			var elm = objects[i];
			var backgroundImage = elm.currentStyle['backgroundImage'];
			
			if(backgroundImage == "none")
				backgroundImage = elm.currentStyle['background'];

			if(typeof backgroundImage == "undefined" || backgroundImage == "none")
				backgroundImage = elm.src;
			if(typeof backgroundImage != "undefined" && backgroundImage != "none" && backgroundImage != "")
			{
				if(backgroundImage.indexOf('url(') != -1)
					backgroundImage = backgroundImage.substr(backgroundImage.indexOf('url("')+5, backgroundImage.indexOf('")')-backgroundImage.indexOf('url("')-5);
				
				var sizingMethod = 'crop';
				if(elm.tagName.toUpperCase() == "IMG" || elm.tagName.toUpperCase() == "IMAGE") 
				{
					sizingMethod = 'scale';
					elm.width  = elm.offsetWidth;
					elm.height = elm.offsetHeight;
					elm.src = path_to_blank_gif_image;
				} else elm.style.backgroundImage = 'none';
				
				elm.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+backgroundImage+"', sizingMethod='"+sizingMethod+"')";
			}
		}
	}
}

var prevonload = window.onload;
if (typeof window.onload != 'function') window.onload = fixPng;
else window.onload = function() { prevonload(); fixPng(); };