﻿// JScript File

//Event handler to fade the selected element(s) to and from the specified amount on mouse over (hover)
$.fn.fadeOnMouseOver = function(fadeto,returnto,speed) {

    this.hover(function(){
        $(this).fadeTo(speed, fadeto); // Sets the opacity to 'fadeto'% on hover
        },function(){
        $(this).fadeTo(speed, returnto); // Sets the opacity back to 'returnto'% on mouseout
    });
};

$.fn.setBackgroundImageURL = function(newURL) {
    //alert('newURL = ' + newURL);
    var bgImageVal = 'url(' + newURL + ')'
    //alert('bg = ' + bg);
    this.css('backgroundImage', bgImageVal);
    
    //chain
    return this;
};

$.fn.setImageOnClick = function() {
    this.bind("click", function(){
        var params = $(this).attr("rel").split(";")
        var backgroundURL = params[0];
        var targetURL = params[1];

        $('.thumbnailtarget').each(function() {
            $(this).setBackgroundImageURL(backgroundURL);
        });
        $('.thumbnailtargetlink').each(function() {
            $(this).attr("href", targetURL);
        });
        
        //prevent further click processing
        return false;
    });
   
};
