﻿//
// jquery.faderotator-0.1:
// create closure
//
(function ($) {
    //
    // plugin definition
    //
    $.fn.fadeRotate = function (options) {
        // build main options before element iteration
        var opts = $.extend({}, $.fn.fadeRotate.defaults, options);
        // iterate and reformat each matched element
        return this.each(function () {
            /* rotator */
            var rotator = $(this);
            var items = $(opts.itemSelector, rotator);
            if (items.length > 1) {
                /* reverse order */
                items.each(function (idx) {
                    rotator.prepend(this);
                });
                /* start rotating */
                var intervalIID;
                $(window).load(function () {
                    intervalIID = setInterval(function () { rotate(rotator, opts); }, opts.delay);
                }).unload(function () {
                    clearInterval(intervalIID);
                });
            }
        });
    };
    /* private rotate method */
    function rotate(rotator, opts) {
        /* fadeOut */
        $(opts.itemSelector + ':last', rotator).fadeOut(opts.fadeDuration, function () {
            /* move to the top of the z-index pile and show */
            $(this).prependTo(rotator).show();
        });
    }
    //
    // plugin defaults
    //
    $.fn.fadeRotate.defaults = {
        itemSelector: '.rotator-item', 
        fadeDuration: 'slow', 
        delay: 5000
        //transition: 'fade|slide|expand|...'
    };
    //
    // end of closure
    //
})(jQuery);

/* 2010 Template refresh top nav functionality */
$(function () {
    /* top nav */
    /*$('.header_h2 ul li a img').css('backgroundImage', function (idx, val) {
        return 'url(' + $(this).attr("src").replace(".png", "_on.png") + ')';
    });*/
    $('.header_h2 ul li').hover(
        function () {
            if ($(this).hasClass("active") != true) {
                var test = $(this).find("img").attr("src").replace("_s1.gif", "_s2.gif");
                $(this).find("img").attr("src", test);
            }
        },
        function () {
            if ($(this).hasClass("active") != true) {
                var test = $(this).find("img").attr("src").replace("_s2.gif", "_s1.gif");
                $(this).find("img").attr("src", test);
            }
        }
    );
});
