﻿// simple js file that you can include to auto fix IE6 problem with PNG files and transparency
// to use just include a reference to this file.
//	<script src="/static/scripts/pngfix/pngfix.js" type="text/javascript"></script>

ve_addLoadEvent(ve_fixAllPngs);

function ve_addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}

function ve_fixAllPngs() {
	for	(var i =0; i < document.images.length; i++) {
		ve_fixPng(document.images[i]);
	}
}

function ve_fixPng(myImage) {
	var arVersion = navigator.appVersion.split("MSIE")
	var version = parseFloat(arVersion[1])
	if ((version >= 5.5) && (version < 7) && (document.body.filters)) {
		var imgID = (myImage.id) ? "id='" + myImage.id + "' " : ""
		var imgClass = (myImage.className) ? "class='" + myImage.className + "' " : ""
		var imgTitle = (myImage.title) ? "title='" + myImage.title + "' " : "title='" + myImage.alt + "' "
		var imgStyle = "display:inline-block;" + myImage.style.cssText
		var strNewHTML = "<span " + imgID + imgClass + imgTitle
                  + " style=\"" + "width:" + myImage.width
                  + "px; height:" + myImage.height
                  + "px;" + imgStyle + ";"
                  + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
                  + "(src=\'" + myImage.src + "\', sizingMethod='scale');\"></span>"
		myImage.outerHTML = strNewHTML
	}
}

