(function ($) {


    $(document).ready(function () {
        $("input[name='mediaFilter']").click(function () {
            $(".all").css("display", "none");
            $("." + this.value).css("display", "block");

        });
    });
    $(document).ready(function () {
        $("div.ducunit", ".genreLeftColumn").mouseover(function () { $(this).css("backgroundColor", "#3e3e3e") }
                );
        $("div.ducunit", ".genreLeftColumn").mouseout(function () { $(this).css("backgroundColor", "#111111") }
                );
        $("div.ducunit", ".featurePage").mouseover(function () { $(this).css("backgroundColor", "#ffffff") }
                );
        $("div.ducunit", ".featurePage").mouseout(function () { $(this).css("backgroundColor", "#f8f8f8") }
                );
        $(".ducunit").click(function () { window.location = $(".ducurl", this).attr("href"); });
    });



    // 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);
