/*
 * This script written by Joshua Paine 2005-7 <http://letterblock.com/>
 * Links are appreciated. Telling me when you use this is really appreciated.
 * Nothing is required: I hereby place the code contained in this file in
 * the public domain and disclaim any and all proprietary rights to it.
 *
 * Documentation at http://demo.fairsky.us/javascript/png.html
 * Last Update: 2007-02-20
 *
 * This file is meant to be included with IE conditional comments and defer="true".
 */
 
/*@cc_on @*/
/*@if (@_win32)
window.attachEvent("onload", PNGuin);

function PNGuin()
{
	if(PNGuin.run) return true;
	PNGuin.run = true;
	function getTrans()
	{
		if(PNGuin.TransparentGIf) return PNGuin.TransparentGIF;
		var x = 0;
		var src = '';
		var ss = document.getElementsByTagName('script');
		while(x<ss.length)
		{
			src = ss[x].src.replace('pnguin.js','transparent.gif');
			if(src!=ss[x++].src) return src;
		}
		alert('PNGuin could not guess location of transparent.gif.');
	}
	var el, img, imgs, x, w, h, src, sm;
	for(x=0; x<document.all.length; x++)
	{ // Do background PNGs
		el = document.all[x];
		if(el.className.indexOf('PNGuin')!=-1)
		{
			src = el.currentStyle.backgroundImage;
			src = src.substring(5,src.length-2);
			if(!el.currentStyle.hasLayout) el.style.zoom='100%';
			el.style.backgroundImage='none';
			sm = (el.className.indexOf('PNGuin:Scale')!=-1) ? 'scale' : 'crop';
			el.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+src+"',sizingMethod='"+sm+"')";
		}
	}
	imgs  = document.getElementsByTagName('img');
	for(x=0; x<imgs.length; x++)
	{ // Do IMG PNGs
		img = imgs[x];
		src = img.src;
		if((/\.png$/i).test(src) || (/\.png\?/i).test(src))
		{
			img.width = img.width; img.height = img.height; // Doesn't seem right, does it?
			img.src = getTrans();
			img.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+src+"',sizingMethod='scale')";
		}
	}
	return true;
}

// Must change this to the location of a transparent GIF on your server.
// You know you have one. (Be sure to make the path such that it will work
// from any folder on your server where you plan on using this. E.g., use
// a path beginning with a '/' or with 'http://'.)
//
// You can leave it blank if you name the file 'transparent.gif' and put it 
// in the same folder as this pnguin.js file.
PNGuin.TransparentGIF = '';

PNGuin();
/*@end @*/
