﻿// JScript File
var applyPositioning = true;

// Path to a transparent GIF image
var shim = 'images/transparent.gif';

// RegExp to match above GIF image name
var shim_pattern = /transparent\.gif$/i;

function SetPngs(root)
{
	if (!document.getElementsByTagName)
    {
        return;
    }
    var rootDiv = document.getElementById(root).getElementsByTagName("div");
    var rootImg = document.getElementById(root).getElementsByTagName("img");
    var rootTd = document.getElementById(root).getElementsByTagName("td");
    
    LoadPngs(rootDiv);
    LoadPngs(rootImg);
    LoadPngs(rootTd);
}

function LoadPngs(root)
{
	
	
    for (var i = root.length - 1, obj = null; (obj = root[i]); i--) {
        // background pngs
        if (obj.currentStyle.backgroundImage.match(/\.png/i) !== null) {
	        bg_fnFixPng(obj);
        }
        // image elements
        if (obj.tagName=='IMG' && obj.src.match(/\.png$/i) !== null){
	        el_fnFixPng(obj);
        }
    }
}

function bg_fnFixPng(obj) {
    var mode = 'scale';
    var bg	= obj.currentStyle.backgroundImage;
    var src = bg.substring(5,bg.length-2);
    if (obj.currentStyle.backgroundRepeat == 'no-repeat') {
        mode = 'crop';
    }
    obj.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "', sizingMethod='" + mode + "')";
    obj.style.backgroundImage = 'url('+shim+')';
}

function el_fnFixPng(img) {
    var src = img.src;
    img.style.width = img.width + "px";
    img.style.height = img.height + "px";
    img.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "', sizingMethod='scale')";
    img.src = shim;
}


