﻿$(document).ready(function () {

    // Find every class with a class of mouseover
    $(".mo").each(
    function () {



        switch (this.tagName) {
            case 'IMG': var normal = $(this).attr('src'); break;
            default: var normal = $(this).css('background-image'); break;

        }
        if (normal != '') {
            var extension = normal.substring(normal.lastIndexOf('.'), normal.length);
            var over = normal.replace(extension, '-mo' + extension);
            //var active = normal.replace(extension, '-a' + extension);


            switch (this.tagName) {
                case 'IMG':
                    $(this).bind("mouseover", function () { $(this).attr('src', over); });
                    $(this).bind("mouseout", function () { $(this).attr('src', normal); });
                    break;
                default:
                    $(this).bind("mouseover", function () { $(this).css('background-image', over); });
                    $(this).bind("mouseout", function () { $(this).css('background-image', normal); });
                    break;


            }
            $(this).bind("mousedown", function () { $(this).stop().animate({ "opacity": "0.5" }, "slow"); });

            jQuery.preLoadImages(normal, over);
        }

    });


    // Find every class with a class of mouseover
    $("img.bo").each(
    function (image) {

        var normal = $(this).attr('src');
        var background = normal.replace("_o", '');
        $(this).parent().css('background-image', "url(" + background + ")");
        //alert( $(this).parent()[0].nodeName);
        $(this).bind("mouseover", function () {

            $(this).stop().animate({ "opacity": "0" }, "slow");
        });

        $(this).bind("mouseout", function () {
            $(this).stop().animate({ "opacity": "1" }, "slow");
        });

        jQuery.preLoadImages(normal, background);

    });


});



(function ($) {
    var cache = [];
    // Arguments are image paths relative to the current page.
    $.preLoadImages = function () {
        var args_len = arguments.length;
        for (var i = args_len; i--; ) {
            var cacheImage = document.createElement('img');
            cacheImage.src = arguments[i];
            cache.push(cacheImage);
        }
    }
})(jQuery)



   function PopupPic(sPicURL) { 
     window.open( "/preview_image.htm?"+sPicURL, "",  
     "resizable=0,HEIGHT=200,WIDTH=200"); 
   }
   
