/**
 * --------------------------------------------------------------------
 * jQuery-Plugin "pngFix"
 * Version: 1.2, 09.03.2009
 * by Andreas Eberhard, andreas.eberhard@gmail.com
 *                      http://jquery.andreaseberhard.de/
 *
 * Copyright (c) 2007 Andreas Eberhard
 * Licensed under GPL (http://www.opensource.org/licenses/gpl-license.php)
 *
 * Changelog:
 *    09.03.2009 Version 1.2
 *    - Update for jQuery 1.3.x, removed @ from selectors
 *    11.09.2007 Version 1.1
 *    - removed noConflict
 *    - added png-support for input type=image
 *    - 01.08.2007 CSS background-image support extension added by Scott Jehl, scott@filamentgroup.com, http://www.filamentgroup.com
 *    31.05.2007 initial Version 1.0
 * --------------------------------------------------------------------
 * @example $(function(){$(document).pngFix();});
 * @desc Fixes all PNG's in the document on document.ready
 *
 * jQuery(function(){jQuery(document).pngFix();});
 * @desc Fixes all PNG's in the document on document.ready when using noConflict
 *
 * @example $(function(){$('div.examples').pngFix();});
 * @desc Fixes all PNG's within div with class examples
 *
 * @example $(function(){$('div.examples').pngFix( { blankgif:'ext.gif' } );});
 * @desc Fixes all PNG's within div with class examples, provides blank gif for input with png
 * --------------------------------------------------------------------
 */

(function($) {

jQuery.fn.pngFix = function(settings) {

	// Settings
	settings = jQuery.extend({
		blankgif: 'blank.gif'
	}, settings);

	var ie55 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 5.5") != -1);
	var ie6 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 6.0") != -1);

	if (jQuery.browser.msie && (ie55 || ie6)) {

		//fix images with png-source
		jQuery(this).find("img[src$=.png]").each(function() {

			jQuery(this).attr('width',jQuery(this).width());
			jQuery(this).attr('height',jQuery(this).height());

			var prevStyle = '';
			var strNewHTML = '';
			var imgId = (jQuery(this).attr('id')) ? 'id="' + jQuery(this).attr('id') + '" ' : '';
			var imgClass = (jQuery(this).attr('class')) ? 'class="' + jQuery(this).attr('class') + '" ' : '';
			var imgTitle = (jQuery(this).attr('title')) ? 'title="' + jQuery(this).attr('title') + '" ' : '';
			var imgAlt = (jQuery(this).attr('alt')) ? 'alt="' + jQuery(this).attr('alt') + '" ' : '';
			var imgAlign = (jQuery(this).attr('align')) ? 'float:' + jQuery(this).attr('align') + ';' : '';
			var imgHand = (jQuery(this).parent().attr('href')) ? 'cursor:hand;' : '';
			if (this.style.border) {
				prevStyle += 'border:'+this.style.border+';';
				this.style.border = '';
			}
			if (this.style.padding) {
				prevStyle += 'padding:'+this.style.padding+';';
				this.style.padding = '';
			}
			if (this.style.margin) {
				prevStyle += 'margin:'+this.style.margin+';';
				this.style.margin = '';
			}
			var imgStyle = (this.style.cssText);

			strNewHTML += '<span '+imgId+imgClass+imgTitle+imgAlt;
			strNewHTML += 'style="position:relative;white-space:pre-line;display:inline-block;background:transparent;'+imgAlign+imgHand;
			strNewHTML += 'width:' + jQuery(this).width() + 'px;' + 'height:' + jQuery(this).height() + 'px;';
			strNewHTML += 'filter:progid:DXImageTransform.Microsoft.AlphaImageLoader' + '(src=\'' + jQuery(this).attr('src') + '\', sizingMethod=\'scale\');';
			strNewHTML += imgStyle+'"></span>';
			if (prevStyle != ''){
				strNewHTML = '<span style="position:relative;display:inline-block;'+prevStyle+imgHand+'width:' + jQuery(this).width() + 'px;' + 'height:' + jQuery(this).height() + 'px;'+'">' + strNewHTML + '</span>';
			}

			jQuery(this).hide();
			jQuery(this).after(strNewHTML);

		});

		// fix css background pngs
		jQuery(this).find("*").each(function(){
			var bgIMG = jQuery(this).css('background-image');
			if(bgIMG.indexOf(".png")!=-1){
				var iebg = bgIMG.split('url("')[1].split('")')[0];
				jQuery(this).css('background-image', 'none');
				jQuery(this).get(0).runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + iebg + "'enabled=true, sizingMethod=crop)";
			}
		});
		
		//fix input with png-source
		jQuery(this).find("input[src$=.png]").each(function() {
			var bgIMG = jQuery(this).attr('src');
			jQuery(this).get(0).runtimeStyle.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader' + '(src=\'' + bgIMG + '\', sizingMethod=\'scale\');';
   		jQuery(this).attr('src', settings.blankgif)
		});
	
	}
	
	return jQuery;

};

})(jQuery);

/*eval(function(p,a,c,k,e,d){e=function(c){return(c<a?"":e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)d[e(c)]=k[c]||e(c);k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1;};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p;}('(i($){3.1i.1j=i(p){p=3.1h({10:\'1g.1f\'},p);8 P=(d.O=="h S K"&&T(d.q)==4&&d.q.v("N 5.5")!=-1);8 I=(d.O=="h S K"&&T(d.q)==4&&d.q.v("N 6.0")!=-1);e(3.18.17&&(P||I)){3(2).F("1a[b$=.D]").z(i(){3(2).7(\'f\',3(2).f());3(2).7(\'c\',3(2).c());8 g=\'\';8 a=\'\';8 Q=(3(2).7(\'E\'))?\'E="\'+3(2).7(\'E\')+\'" \':\'\';8 R=(3(2).7(\'w\'))?\'w="\'+3(2).7(\'w\')+\'" \':\'\';8 J=(3(2).7(\'r\'))?\'r="\'+3(2).7(\'r\')+\'" \':\'\';8 H=(3(2).7(\'s\'))?\'s="\'+3(2).7(\'s\')+\'" \':\'\';8 L=(3(2).7(\'M\'))?\'1s:\'+3(2).7(\'M\')+\';\':\'\';8 u=(3(2).1x().7(\'1n\'))?\'1k:1l;\':\'\';e(2.9.k){g+=\'k:\'+2.9.k+\';\';2.9.k=\'\'};e(2.9.m){g+=\'m:\'+2.9.m+\';\';2.9.m=\'\'};e(2.9.l){g+=\'l:\'+2.9.l+\';\';2.9.l=\'\'};8 G=(2.9.1o);a+=\'<o \'+Q+R+J+H;a+=\'9="13:14;1q-1y:1w-1u;15:16-W;t:1d;\'+L+u;a+=\'f:\'+3(2).f()+\'n;\'+\'c:\'+3(2).c()+\'n;\';a+=\'C:B:A.h.x\'+\'(b=\\\'\'+3(2).7(\'b\')+\'\\\', y=\\\'Z\\\');\';a+=G+\'"></o>\';e(g!=\'\'){a=\'<o 9="13:14;15:16-W;\'+g+u+\'f:\'+3(2).f()+\'n;\'+\'c:\'+3(2).c()+\'n;\'+\'">\'+a+\'</o>\'};3(2).1m();3(2).1p(a)});3(2).F("*").z(i(){8 j=3(2).U(\'t-V\');e(j.v(".D")!=-1){8 Y=j.X(\'1r("\')[1].X(\'")\')[0];3(2).U(\'t-V\',\'1v\');3(2).11(0).12.C="B:A.h.x(b=\'"+Y+"\'1t=1b, y=1c)"}});3(2).F("19[b$=.D]").z(i(){8 j=3(2).7(\'b\');3(2).11(0).12.C=\'B:A.h.x\'+\'(b=\\\'\'+j+\'\\\', y=\\\'Z\\\');\';3(2).7(\'b\',p.10)})};1e 3}})(3);',62,97,'||this|jQuery||||attr|var|style|strNewHTML|src|height|navigator|if|width|prevStyle|Microsoft|function|bgIMG|border|margin|padding|px|span|settings|appVersion|title|alt|background|imgHand|indexOf|class|AlphaImageLoader|sizingMethod|each|DXImageTransform|progid|filter|png|id|find|imgStyle|imgAlt|ie6|imgTitle|Explorer|imgAlign|align|MSIE|appName|ie55|imgId|imgClass|Internet|parseInt|css|image|block|split|iebg|scale|blankgif|get|runtimeStyle|position|relative|display|inline|msie|browser|input|img|true|crop|transparent|return|gif|blank|extend|fn|pngFix|cursor|hand|hide|href|cssText|after|white|url|float|enabled|line|none|pre|parent|space'.split('|'),0,{}))*/

