$(function () {
    $('.rollover').hover(function () {
        var currentImg = $(this).attr('src');
        var file = currentImg.substring(0, currentImg.length - 4);
        var ext = currentImg.substring(currentImg.length - 4, currentImg.length);
        var hover = file + "_a" + ext;

        $(this).attr('src', hover);
        $(this).attr('hover', currentImg);
        $(this).fadeOut(0);
        $(this).fadeIn(1000);
    }, function () {
        var currentImg = $(this).attr('src');
        $(this).attr('src', $(this).attr('hover'));
        $(this).attr('hover', currentImg);
    });

    var max_img = $('img').length;
    image_order = function (index) {
        var obj = $('img')[index];
		var mstyle = $(obj).attr("style");
		var bload = true;

		if (mstyle != null) {
			if (mstyle.indexOf("opacity") >= 0) {
				bload = false;
			}
		}

		if (bload)  {
			if (index < max_img) {
				$(obj).animate({ opacity: 1.0 }, 150, function () {
					index++;
					image_order(index);
				});
			}
		} else {
			index++;
			image_order(index);
		}	
    }
    image_order(0);
});
