var useFix = true;
var isIE6 = /msie|MSIE 6/.test(navigator.userAgent);

if (isIE6 && useFix) {
    // the ie6 png fix:
    // http://labs.unitinteractive.com/unitpngfix.php
    var clear = "http://localhost:2000/Dlx%20Develop/Script/ie6fix/clear.gif"; //path to clear.gif
    
    // BEGIN PNG FIX:
    document.write('<script type="text/javascript" id="ct" defer="defer" src="javascript:void(0)"><\/script>'); 
    var ct = document.getElementById("ct");
    ct.onreadystatechange = function() { pngfix() };

    pngfix = function() 
	{
	    var els = document.getElementsByTagName('*'), ip = /\.png/i, al = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='", i = els.length, uels = new Array(), c = 0;
	    while (i-- > 0) 
	    {
	        if (els[i].className.match(/unitPng/)) 
	        {
	            uels[c] = els[i]; c++;
	        }
	    }

	    if (uels.length == 0) pfx(els);
	    else pfx(uels); function pfx(els) 
	    {
	        i = els.length;

	        while (i-- > 0) {
	            var el = els[i], es = el.style, elc = el.currentStyle, elb = elc.backgroundImage;

	            if (el.src && el.src.match(ip) && !es.filter) {
	                es.height = el.height; es.width = el.width; es.filter = al + el.src + "',sizingMethod='crop')";
	                el.src = clear;
	            }
	            else {
	                if (elb.match(ip)) {
	                    var path = elb.split('"'), rep = (elc.backgroundRepeat == 'no-repeat') ? 'crop' : 'scale', elkids = el.getElementsByTagName('*'), j = elkids.length; es.filter = al + path[1] + "',sizingMethod='" + rep + "')";
	                    es.height = el.clientHeight + 'px'; es.backgroundImage = 'none';

	                    if (j != 0) {
	                        if (elc.position != "absolute") es.position = 'static';

	                        while (j-- > 0)
	                            if (!elkids[j].style.position)
	                                elkids[j].style.position = "relative";
						}
					}
				}
			}
	    }
	}
} //END IF IE6


function fixIe6Images() {
    if (isIE6) {
        fixProductListImageAlignment();
        //fixBgStripes();    
    }
}

//this function fixes the fixpng bug which puts images in productlisting to 
//"vertical-align top" and adjust them into "vertical-align bottom"...
function fixProductListImageAlignment() {
    // $(".highlightedFamilyItemDIV")
    var tds = $(".td_productlistimage");
	var imgs = $(".listImage");

	if (tds.length == imgs.length) {
	    for (var i = 0; (i < tds.length && i < imgs.length); i++) {
	        var img = imgs[i];
	        var td = tds[i];

	        var tdHeight = parseInt(td.offsetHeight);
	        var imageHeight = parseInt(img.offsetHeight);
	        var margin = parseInt(tdHeight - imageHeight);
            
            //adjust margin:
	        margin = margin - 8;
            //set margin top
	        img.style.marginTop = margin; 
	    }
	}
}

////fixes the bg stripes background-position attribute.
//function fixBgStripes() {
//    var bgstripesDiv = document.getElementById("bgStripesIE6");
//    alert(bgstripesDiv);

//    if (bgstripesDiv != null) {
//        bgstripesDiv.style.backgroundPosition = "50px 50px";
//        
//    }
//}
