/*******************************
* Rypple Learn More JS
* (c) 2010, 2Catalyze, Inc. All rights reserved
********************************/

(function($) {
    jQuery.fn.backgroundPosition = function() {
        var p = $(this).css('background-position');
        if(typeof(p) === 'undefined') return $(this).css('background-position-x') + ' ' + $(this).css('background-position-y');
        else return p;
    };
})(jQuery);


$(document).ready(function() {

/*******************************************************************************
* Alternating Rows
*******************************************************************************/
    $('.feature_list li:nth-child(odd)').addClass('altRow');

/*******************************************************************************
* Screenshot buttons
*******************************************************************************/

    // Don't make the whole box clickable if there's a link in the description
    $('.feature_list li').click(function(){
        if($(this).children('p').children('a').length == 0){
            $(this).children('a.screenshot').trigger('click');
        }
    });
    
    $('.feature_list li').hover(
        function(){
            if($(this).children('p').children('a').length != 0){
                $(this).css('cursor','auto');
            }
            $(this).addClass('highlight');
            $(this).children('p').children('strong').css('fontWeight','bold');
            var theLink = $(this).children('a.screenshot');
            var currentPos = theLink.backgroundPosition().split(' ');
            var newPos = currentPos[0] + ' ' + (parseInt(currentPos[1].substring(0, currentPos[1].length-2)) - 75) + 'px';
            theLink.css('backgroundPosition', newPos);
        },
        function(){
            $(this).removeClass('highlight');
            $(this).children('p').children('strong').css('fontWeight','normal');
            var theLink = $(this).children('a.screenshot');
            var currentPos = theLink.backgroundPosition().split(' ');
            var newPos = currentPos[0] + ' ' + (parseInt(currentPos[1].substring(0, currentPos[1].length-2)) + 75) + 'px';
            theLink.css('backgroundPosition', newPos);
        }
    );
});

