/*
 
Correctly handle PNG transparency in Win IE 5.5 & 6.
http://homepage.ntlworld.com/bobosola. Updated 18-Jan-2006.

Use in <HEAD> with DEFER keyword wrapped in conditional comments:
<!--[if lt IE 7]>
<script defer type="text/javascript" src="pngfix.js"></script>
<![endif]-->

*/
var baseURL = '';
if ( document.getElementById('cb_base_url') ) {
	baseURL = document.getElementById('cb_base_url').value;
}

var supported = /MSIE ((5\.5)|[6789])/.test(navigator.userAgent) &&
				navigator.platform == "Win32";
				
//if (supported) fixBgPng();

function fixBgPng() {
	if(this.style.backgroundImage && this.style.backgroundImage != null && /url\(['"]?([^"'\)]+)/.test(this.style.backgroundImage)) {
		var bgSrc = RegExp.$1;
		if(bgSrc.indexOf('.png') > -1) {
		element.runtimeStyle.filter = "progid:DXImageTransform.Microsoft." +
					"AlphaImageLoader(src='" + bgSrc + "',sizingMethod='scale')";
		// remove backgroundImage property
		element.runtimeStyle.backgroundImage = 'none';
		}
	}
}

function laterFixPng() {
	var arVersion = navigator.appVersion.split("MSIE")
	var version = parseFloat(arVersion[1])
	if ((version >= 5.5) && (document.body.filters)) {
		for(var i=0; i<document.images.length; i++)	{
			var img = document.images[i]
	      	var imgName = img.src.toUpperCase();
	      	var imgSrc = img.src;
	      	var imgHeight = img.height;
	      	var imgWidth = img.width;
	      	if (imgName.substring(imgName.length-3, imgName.length) == "PNG") {
		        var imgID = (img.id) ? "id='" + img.id + "' " : ""
	    		var imgClass = (img.className) ? "class='" + img.className + "' " : ""
	         	var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
	         	var imgStyle = "display:inline-block;" + img.style.cssText 
	         	if (img.align == "left") imgStyle = "float:left;" + imgStyle
	         	if (img.align == "right") imgStyle = "float:right;" + imgStyle
	         	if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
	         	if ( imgSrc.toUpperCase().substring(0, 4) != "HTTP" ) {
	         		if ( imgSrc.toUpperCase().substring(0, 1) == "." )
	         			imgSrc = baseURL + imgSrc.substring(1, imgSrc.length);
	         		else
	         			imgSrc = baseURL + imgSrc;
	         	}
	         	if ( imgWidth <= 0 )
	         		imgWidth = '39';
	         	if ( imgHeight <= 0 )
	         		imgHeight = '29';
	         	var strNewHTML = "<span " + imgID + imgClass + imgTitle
	         		+ " style=\"" + "width:" + imgWidth + "px; height:" + imgHeight + "px;" + imgStyle + ";"
	         		+ "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
	         		+ "(src=\'" + imgSrc + "\', sizingMethod='scale');\"></span>"
         		img.outerHTML = strNewHTML
//				alert(strNewHTML)
	         	i = i-1
	      	}
	   	}	
	}
//	if (supported) fixBgPng();
}