(function ($) {
    // Monkey patch jQuery 1.3.1+ css() method to support CSS 'transform'
    // property uniformly across Safari/Chrome/Webkit, Firefox 3.5+, IE 9+, and Opera 11+.
    // 2009-2011 Zachary Johnson www.zachstronaut.com
    // Updated 2011.05.04 (May the fourth be with you!)
    function getTransformProperty(element)
    {
        // Try transform first for forward compatibility
        // In some versions of IE9, it is critical for msTransform to be in
        // this list before MozTranform.
        var properties = ['transform', 'WebkitTransform', 'msTransform', 'MozTransform', 'OTransform'];
        var p;
        while (p = properties.shift())
        {
            if (typeof element.style[p] != 'undefined')
            {
                return p;
            }
        }
        
        // Default to transform also
        return 'transform';
    }
    
    var _propsObj = null;
    
    var proxied = $.fn.css;
    $.fn.css = function (arg, val)
    {
        // Temporary solution for current 1.6.x incompatibility, while
        // preserving 1.3.x compatibility, until I can rewrite using CSS Hooks
        if (_propsObj === null)
        {
            if (typeof $.cssProps != 'undefined')
            {
                _propsObj = $.cssProps;
            }
            else if (typeof $.props != 'undefined')
            {
                _propsObj = $.props;
            }
            else
            {
                _propsObj = {}
            }
        }
        
        // Find the correct browser specific property and setup the mapping using
        // $.props which is used internally by jQuery.attr() when setting CSS
        // properties via either the css(name, value) or css(properties) method.
        // The problem with doing this once outside of css() method is that you
        // need a DOM node to find the right CSS property, and there is some risk
        // that somebody would call the css() method before body has loaded or any
        // DOM-is-ready events have fired.
        if
        (
            typeof _propsObj['transform'] == 'undefined'
            &&
            (
                arg == 'transform'
                ||
                (
                    typeof arg == 'object'
                    && typeof arg['transform'] != 'undefined'
                )
            )
        )
        {
            _propsObj['transform'] = getTransformProperty(this.get(0));
        }
        
        // We force the property mapping here because jQuery.attr() does
        // property mapping with jQuery.props when setting a CSS property,
        // but curCSS() does *not* do property mapping when *getting* a
        // CSS property.  (It probably should since it manually does it
        // for 'float' now anyway... but that'd require more testing.)
        //
        // But, only do the forced mapping if the correct CSS property
        // is not 'transform' and is something else.
        if (_propsObj['transform'] != 'transform')
        {
            // Call in form of css('transform' ...)
            if (arg == 'transform')
            {
                arg = _propsObj['transform'];
                
                // User wants to GET the transform CSS, and in jQuery 1.4.3
                // calls to css() for transforms return a matrix rather than
                // the actual string specified by the user... avoid that
                // behavior and return the string by calling jQuery.style()
                // directly
                if (typeof val == 'undefined' && jQuery.style)
                {
                    return jQuery.style(this.get(0), arg);
                }
            }

            // Call in form of css({'transform': ...})
            else if
            (
                typeof arg == 'object'
                && typeof arg['transform'] != 'undefined'
            )
            {
                arg[_propsObj['transform']] = arg['transform'];
                delete arg['transform'];
            }
        }
        
        return proxied.apply(this, arguments);
    };
})(jQuery);;
(function($){
    $(document).ready(function(){
        /* scary hand easter egg */
        if($(window).width() > 480 && !$('body').hasClass('logged-in')){
            var eggIsMovin = false,
                handAnimator = 0,
                handRemover = 0,
                hand,
                scaryHand = $('<img />')
                .attr('src', '/sites/all/themes/excusemefire/images/scary-hand.png')
                .load(function(){
                    $('.block-block-8 ').mouseenter(function(){
                        if(!eggIsMovin){
                            eggIsMovin = true;
                            $('body').css({overflowX: 'hidden'});
                            hand = $('<div>').attr({id: 'scary-hand'}).appendTo('body').append(scaryHand);
                            handRemover = setTimeout(function(){
                                clearTimeout(handAnimator);
                                hand.animate({
                                    top: '-2000px',
                                    right: '-400px'
                                }, 400, function(){
                                    $('body').css({overflowX: 'auto'});
                                    hand.remove();
                                    eggIsMovin = false;
                                });
                            }, 5000);
                            animator();
                        }
                    });
                });
        }
        function animator(){
            var delay = Math.abs(Math.random() * 800) + 500;
            hand.css('transform', 'rotate(' + (Math.random() * 120 - 60) + 'deg)').animate({
                        top: (-1 * (200 + Math.random() * 300)) + 'px',
                        right: (-180 + Math.random() * $(window).width()) + 'px',
                    },delay);
            handAnimator = setTimeout(animator, delay);
        }

        /*discography*/
        if($('.view-id-discography').length){
            $('<ul>').attr('id', 'discography-menu').prependTo('.view-id-discography');
            $('.view-id-discography .views-row:not(.lyric)').each(function(i){
                var str = $(this).find('.views-field-title .field-content').text();
                $(this).find('.views-field-title').remove();
                $('<li>').attr({class: 'menu-item', data: i}).appendTo('#discography-menu').text(str);
                $(this).hide();
            });
            $('.view-id-discography .menu-item').click(function(){
                var index = $(this).attr('data');
                $('.view-id-discography .menu-item.current').removeClass('current');
                $(this).addClass('current');
                $('.view-id-discography .views-row:not(.lyric).current').removeClass('current').slideUp(300);
                $('.view-id-discography .views-row:not(.lyric)').eq(index).addClass('current').slideDown(300);
            });
            $('.view-id-discography .menu-item').first().addClass('current').show();
            $('.view-id-discography .views-row:not(.lyric)').first().addClass('current').show();
        }
        $('select#mobile-menu').change(function(){
            window.location.href = $(this).val();
        });

        /* FANCYBOX */
        if($(window).width() > 480){
            $('.views-field-field-images .item-list a').addClass('fancybox-group').attr('rel', 'group');
            $("a.fancybox-group").fancybox({
                'transitionIn'  : 'none',
                'transitionOut' : 'none',
                'openSpeed'       : 0,
                'closeSpeed'      : 0,
                'nextSpeed'      : 400,
                'prevSpeed'      : 400,
                'overlayShow'   : true,
                'overlayColor'  : "black",
                'helpers'       : {
                    overlay: {
                        'opacity': 0
                    }
                },
                'margin'        : 40,
                'padding'       : 0,
                'openEffect' : 'none',
                'closeEffect' : 'none',
                'nextEffect' : 'fade',
                'prevEffect' : 'fade'
            });
        }
        $('#yourbrowsersucks .ignore').click(function(){
            $('#yourbrowsersucks').remove();
        })
    });
})(jQuery);
/*openSpeed / closeSpeed / nextSpeed / prevSpeed*/;

