//means its probably < IE7
if (!window.XMLHttpRequest) {
	var png = /\.png/i;
	
	// loop through all stylesheets to change backgruond images

	for (var i = document.styleSheets.length - 1; i >= 0; i--) {
		var theRules = new Array();
		theRules = document.styleSheets[i].rules;
		
		// loop through all rules in current stylesheet
		for (var c = theRules.length - 1; c >= 0; c--) {
			var thisRule = theRules[c].style;
			
			// find background using png images
			if (thisRule.backgroundImage.match(png)) {
				var src = thisRule.backgroundImage.substr(4, thisRule.backgroundImage.length - 5);
				
				// elements using png backgrounds must have a width or height specified for this to be applied
				if (thisRule.height != "" || thisRule.width != "") {
					var sizing = (thisRule.backgroundRepeat == 'no-repeat') ? 'crop' : 'scale';
					thisRule.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "', sizingMethod='" + sizing + "')";
					thisRule.background = "none";
				}
			}
		}
	}
	
	// attach event to fix img tags
	function replacePNG(parentEl, clear) {
		var imgs;
		if (parentEl != undefined && parentEl.type != "load") {
			imgs = parentEl.getElementsByTagName('img')
		} else {
			imgs = document.images;
		}
		var clear = clear || "images/clear.gif";
		
		// loop through all images
		for (var i = imgs.length - 1; i >= 0; i--) {
			var img = imgs[i];
			if (img.src && img.src.match(png)) {
				// set the height, width and filter
				img.height = img.height;
				img.width = img.width;
				img.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + img.src + "',sizingMethod='crop')";
				
				// replace the src with a transparent gif
				img.src = clear;
			}
		}
	}

	window.attachEvent('onload', replacePNG);
}