// all code (c)2003 Christopher Grocki
// Functions designed to correct display and standards problems with IE5.5 and up.
// Dependent on browserdetect_lite.js

var spaceSrc = "spacer.gif";

function fixPngIe(src) {
  // enable alpha transparency on PNG images
  // spaceSrc : path to transparent gif spacer image
  if (src)
    spaceSrc = src;
  if ((browser.isIE55 || browser.isIE6up) && browser.isWin32) {
    for( i = 0; i < document.images.length; i++ )
      if (document.images[i].src.substr(document.images[i].src.length - 4) == ".png") {
	    document.images[i].style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+document.images[i].src+"',sizingMethod='scale')";
		document.images[i].src = spaceSrc;
	  }	
  }
}

function fixThisPng(i) {
  if ((browser.isIE55 || browser.isIE6up) && browser.isWin32) {
	i.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+i.src+"',sizingMethod='scale')";
    i.src = spaceSrc;
  }
}

function fixVerticalLayerDimsIe(fixLayerId) {
  // correctly balance top and bottom margins on absolutely positioned layers
  // fixLayerId : ID of layer that requires fix
  // requested values MUST be given in pixel units
  if ((browser.isIE55 || browser.isIE6up) && browser.isWin32) {
    fixLayer = eval('document.getElementById("' + fixLayerId + '")');
    if (fixLayer.currentStyle.position == "absolute") {
	  value = /\d*/;
	  s = fixLayer.currentStyle;
	  if (s.height.match(value) < fixLayer.parentElement.clientHeight) {
	    bothMargins = fixLayer.parentElement.clientHeight - s.top.match(value)
		 - s.borderTopWidth.match(value) - s.paddingTop.match(value) 
		 - fixLayer.clientHeight - s.paddingBottom.match(value) 
		 - s.borderBottomWidth.match(value) - s.bottom.match(value);
		if (bothMargins % 2 > 0) {
		  topMargin = (bothMargins - 1) / 2;
		  bottomMargin = bothMargins - topMargin;
		}
		else
		  topMargin = bottomMargin = (bothMargins / 2);
		fixLayer.style.marginTop = topMargin;
		fixLayer.style.marginBottom = bottomMargin;
	  }
	}
  }
}