/*
 * jQuery IEPngHack plugin method a
 * Version a.02  (03/05/2007)
 * @requires jQuery v1.1.1
 *
 * Examples at: http://khurshid.com/jquery/iepnghack/
 * Copyright (c) 2007 Khurshid M.
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 */
 /**
  *
  * @example
  *
  * $('img[@src$=.png]').IEPNGHack();
  *
  * @get all images with png extension and apply the hack
  *
  * @name IEPNGHack
  * @type jQuery
  * @cat Plugins/Image
  * @return jQuery
  * @author jQuery Community
  */
 
(function($) {
	
	$.fn.IEPNGHack = function() {
		if (isltIE7!=true) { // process only IE lt 7
			return false;
		}
		this.each(function(){
			var $$ = $(this);
			var hack = "<span";
			hack += $$.attr('id') ? " id=\""+ $$.attr('id') +"\"" : "";
			hack += $$.attr('class') ? " class=\""+ $$.attr('class') +"\"" : "";
			hack += " style=\"display:inline-block;";
			if ($$.parent().attr('href')) {
				hack += " cursor:pointer;";
			}
			hack += $$.attr('style') + ";";
			hack += " width:"+ $$.width() +"px;height:"+ $$.height() +"px;";
			hack += " filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+ $$.attr('src') +"',sizingMethod='scale')";
			hack += " \"></span>";
			$$.wrap(hack).hide();
		})
	};
	
	var isltIE7 = function() {
		if ($.browser.msie) { // processing IE only
			var agent = navigator.userAgent;
			var version = agent.match(/MSIE (\d+(?:\.\d+)+(?:b\d*)?)/); // get IE browser version
			return (version[1]<7); // return true if IE version less then 7, otherwise return false
		}
	}();

})(jQuery);