$(document).ready(function() {
    var $btabs =  $('div#banner-tabs').tabs({
        fx: {
            opacity: 'toggle'
        }
    }).tabs('rotate', 5000, true);

    var $etabs = $('#etlap-tabs').tabs();
    $("#etlap-tabs .ui-tabs-panel").each(function(i){

        var totalSize = $("#etlap-tabs .ui-tabs-panel").size() - 1;

        if (i != totalSize) {
            next = i + 2;
            $(this).append("<span class='next'><a href='#' class='next-tab mover' rel='" + next + "'><img src='/images/etlap/right.jpg' alt='' /></a></span>");
        }

        if (i != 0) {
            prev = i;
            $(this).append("<span class='prev'><a href='#' class='prev-tab mover' rel='" + prev + "'><img src='/images/etlap/left.jpg' alt='' /></a></span>");
        }

    });

    $('.next-tab, .prev-tab').click(function() {
        $etabs.tabs('select', $(this).attr("rel"));
        return false;
    });

    $("ul.subnav").parent().append("<span></span>"); //Only shows drop down trigger when js is enabled (Adds empty span tag after ul.subnav*)

    $("ul.topnav li a").hover(function() { //When trigger is clicked...

        //Following events are applied to the subnav itself (moving subnav up and down)
        $(this).parent().find("ul.subnav").slideDown('fast').show(); //Drop down the subnav on click

        $(this).parent().hover(function() {
            }, function(){
                $(this).parent().find("ul.subnav").slideUp('slow'); //When the mouse hovers out of the subnav, move it back up
            });

    //Following events are applied to the trigger (Hover events for the trigger)
    }).hover(function() {
        $(this).addClass("subhover"); //On hover over, add class "subhover"
    }, function(){  //On Hover Out
        $(this).removeClass("subhover"); //On hover out, remove class "subhover"
    });

    $('a[rel=lightbox]').lightBox();
});
