/**
 * global.js
 *
 * @author Martin Bean <martin@yourfightsite.com>
 */

$(document).ready(function() {
    $('a[rel=external]').click(function() {
        window.open(this.href);
        return false;
    });
    $('a[rel=popup]').fancybox({
        overlayColor: '#f4f4f2',
        overlayOpacity: 0.75
    });
    $('.tickets form').submit(function() {
        if ($('input[name="quantity"]', this).val() < 1) {
            alert('Please enter a quantity larger than zero.');
            return false;
        }
    });
    // SCAS
    $('form#add_note, form#add_photo, form#add_doc, form.scas_comment_form').hide();
    $('#scas_nav a').click(function() {
        var target = $(this).attr('href');
        $('form#add_note, form#add_photo, form#add_doc').hide();
        $(target).show();
        return false;
    });
    $('form.comment_form textarea').autogrow();
    $('#navigation').suckerfish();
});

jQuery.fn.suckerfish = function() {
    return this.each(function() {
        $('li', this).mouseover(function() {
            $(this).addClass('sfhover');
        });
        $('li', this).mouseout(function() {
            $(this).removeClass('sfhover');
        });
    });
};
