﻿// *** Image Rollover ***
// Requires images with class 'rollover' to have _off and _on suffix for states
(function($) {
    
    $.fn.rollover = function(options) {
        return this.each(function(){
            jQuery(this).hover(function(){
                jQuery(this).attr("src", jQuery(this).attr("src").split('_off').join('_on'))
            }, function(){
                jQuery(this).attr("src", jQuery(this).attr("src").split('_on').join('_off'))
            });
        });    
    };

})(jQuery);

// *** IE6 PNG fix ***
// Requires setting location of a single transarent pixel gif
// Also uses rollover images with _off and _on suffix for states and class of 'rollover'
// Should be called only from a conditional IE6 script or from a script that checks the browser and version
(function($) {

    $.fn.pngfix = function(options) {
        var opts = $.extend({}, $.fn.pngfix.defaults, options);
        return this.each(function(){
            $(this).css({width: $(this).attr('width'), height: $(this).attr('height'), filter: "progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'" + $(this).attr('src') + "\', sizingMethod='" + opts.imagemethod + "')"}).attr('src', opts.imagesource);
            if ($(this).is('.'+opts.hoverclass)){
                $(this).hover(function(){$(this).css({filter: $(this).css("filter").split('_off').join('_on')})},function(){$(this).css({filter: $(this).css("filter").split('_on').join('_off')})});
            }
        });
    };

    $.fn.pngfix.defaults = {
        imagesource: '/Common/Images/x.gif',
        imagemethod: 'scale',
        hoverclass: 'rollover'
    };

})(jQuery);

// *** SWF video player change
(function($) {
    $.fn.videoadd = function(options) {
        var opts = $.extend({}, $.fn.videoadd.defaults, options);
        return this.each(function(){
            $(this).click(function(){
                var swfSrc = opts.swf + '?movie=' + $(this).attr('href') + '&autoplay=' + opts.autoplay;
                var so = new SWFObject(swfSrc, "ChannelVideo", opts.width, opts.height, opts.version, opts.background);
                so.addParam("wmode", "transparent");
                so.addParam("allowFullScreen",opts.fullscreen);
                so.write(opts.player);
                return false;
            });
        });
    };

    $.fn.videoadd.defaults = {
        swf: '/Common/Flash/video.swf',
        player: 'videoPlayer',
        width: 480,
        height: 320,
        version: 9,
        background: '#000000',
        autoplay: 'true',
        fullscreen: 'false'
    };

})(jQuery);


// rotating content function
// the only variable is c a jQuery object of elements to rotate through
// i (current) and j (next) are calculated indices of the objects
(function($) {
    $.fn.rotate = function(options) {
        var i = $(c).index($(c+":visible")[0]);
        var j = (i+1 == $(c).size()) ? 0 : i+1;
        $(c+":eq("+i+")").fadeOut(600, function(){$(c+":eq("+j+")").fadeIn();});
        $(c)[0].rotateInterval = setInterval("rotate('div.feature')",6000);
        $(c).hover(function(){
            clearInterval($(c)[0].rotateInterval);
        },function(){
            $(c)[0].rotateInterval = setInterval("rotate('div.feature')",6000);
        });
    };
    
    $.fn.rotate.defaults = {
        fadeEffect: 'true',
        fadeInterval: '600',
        rotateInterval: '6000'
    };

});
