/**
 * @author Kent
 */
$(document).ready(function(){
    $('#betauser').focus();
    // Video Carousel
    $('.vidCarousel').click(function(){
        var thumbId = $(this).attr('id'),
            newVidId = $(this).attr('rel'),
            oldVidId = $('#vid-1').attr('rel');
        $('#vid-1').html('<img src="/images/icons/ajaxLoader.gif" style="margin-top: 90px;" />');
        $('#' + thumbId).fadeOut('slow');

        $.ajax({
            type: 'Post',
            url: '/video/switch',
            data: 'newVidId=' + newVidId + '&oldVidId=' + oldVidId,
            dataType: 'json',
            success: function(json) {
                    $('#vid-1').html(json.newVidContent).attr('rel',json.newVidId);
                    $('#vid-1').fadeIn('slow');
                    $('#' + thumbId + ' img').attr('src',json.oldVidImage);
                    $('#' + thumbId + ' .photoGalleryHeadline').html(json.oldVidHeadline);
                    $('#' + thumbId).attr('rel',json.oldVidId).fadeIn();
            },
            error: function() {
                    alert('Oops. There was an AJAX error. Please refresh the page and try again.');
            }
        });
    });
    // River Report
    $(".locationsHide").hide();
    $('.noGo').click(function(event){
        event.preventDefault();
    });
    $( ".reportHeader" ).click(function() {
       if($(this).hasClass('open')) {
           $(this).removeClass('open');
           $('.locationsHide').hide();
       } else {
           $(".locationsHide").hide();
           $('.reportHeader').removeClass('open');
           $(this).nextUntil('.reportHeader').show();
           $(this).addClass('open');
       }
    });
});
