(function($) {

	// method for fading in/out an object (positioning is handled in the CSS)
	/**
	 * callback is an array with two functions 
	 * ex:
	 *		{
	 *			function() { ..fade in... },
	 *			function() { ..fade out.. }
	 *		}
	 **/
	$.fn.overlayInPlace = function( overlay, options, callback ) {		
		var func1 = function() {};
		var func2 = function() {};

		//check to see if user entered only callback and not options
		if (typeof options == "object" && options.length)
		{
			//user entered a non-empty array
			callback = options;
			options = {};
		}

		//check that callback contains functions
		if (typeof callback == "object")
		{
			try 
			{				
				func1 = (typeof callback[0] == "function" ) ? callback[0]: func1;
				func2 = (typeof callback[1] == "function" ) ? callback[1]: func2;
			}
			catch(e){}
		}

		var settings = $.extend({
			speed: 'def'
		}, options || {});

		return this.hover(
			function(){
				$(overlay).fadeIn( settings.speed, func1 );
			},
			function(){
				$(overlay).fadeOut( settings.speed, func2 );
			}
		);
	}


	$.fn.fixPNG = function() {

		var $imgs = this;
		var browserVersion = navigator.appVersion.split("MSIE");
		browserVersion = parseFloat(browserVersion[1]);

		//Not IE
		if (!$.browser.msie) 
		{
			return false;
		}

		//IE 6 and below
		if (!(browserVersion < 7 && document.body.filters))
		{
			return false;
		}
		
		$imgs.each(
			function()
			{
				var img = this;
				if (this.tagName.toLowerCase() == "img")
				{	
					var imgSource = img.src;
					var imgType = imgSource.substring(imgSource.length - 3).toLowerCase();
					if (imgType == "png")
					{		

						$(img).wrap("<span></span>");
						
						$(img).parents("span:eq(0)")
							.css(
								{
									display: "inline-block",
									width: img.width + "px",
									height: img.height + "px",
									filter: "progid:DXImageTransform.Microsoft.AlphaImageLoader (src='" + img.src + "', sizingMethod='scale')"
								}
							)
							.attr("title", (img.title) ? img.title: img.alt )
							.addClass( (img.className) ? img.className: "" );

						if (img.onclick)
						{
							$(img).click( img.onclick );
						}

						$(img).remove();
						
					}
				}
			}
		)//endof each
	};

})(jQuery);