﻿(function($) {
    $.fn.rollover = function(options) {
        return this.each(function(i) {

            var imgElement = $(this).find('img');
            if (!imgElement.length > 0)
                return;

            var imgNormal = imgElement.attr('src');
            var imgHover = imgNormal.replace(/\.jpg$/i, "_hover.jpg").replace(/\.gif$/i, "_hover.gif").replace(/\.png$/i, "_hover.png");

            jQuery("<img>").attr("src", imgHover);

            var imgParent = imgElement.parent();

            imgParent.css({
                backgroundImage: "url('" + imgHover + "')",
                backgroundPosition: "0px 0px",
                backgroundRepeat: "no-repeat",
                backgroundAttachment: "scroll",
                backgroundColor: "Transparent",
                height: imgElement.css("height"),
                width: imgElement.css("width"),
                display: "inline-block"
            })

            imgElement.hover(
                function() {
                    imgElement.stop();
                    imgElement.fadeTo(600, 0);
                },
            	function() {
            	    imgElement.fadeTo(500, 1.0);
            	}
            );
        });
    };

})(jQuery);


//$(window).bind('load', function() {
//    $('a.rollover').rollover();
//});
