$(document).ready(function () {

$( "#tabs" ).tabs();
    // Nav drop downs
    $("#nav > li").mouseover(function () {
        //$(this).children("ul").show();
        $(this).addClass("menuTabHoverLeft");
        $(this).children("a").css("background", "url(/images/back-nav-over-right.gif) right top no-repeat #1E688D");
    });

    $("#nav > li").mouseout(function () {
        //$(this).children("ul").hide();
        $(this).removeClass("menuTabHoverLeft");
        $(this).children("a").css("background", "url(/images/back-nav-right.gif) right top no-repeat");
    });

    // Billboard Banner
    $("#bannerImg1").show();
    $("#bannerImg2").css("left", "1000px");
    $("#bannerImg3").css("left", "2000px");
    $("#bannerImg4").css("left", "3000px");

    $("#billboard ul li:first").addClass("billboardHighlightLeft");
    $("#billboard ul li a:first").addClass("billboardHighlightRight");

    $("#bannerLink").click(function () {
        var content_click = $(this).attr("accesskey");
        content_click;
    });

    var showtimeout = null;
    BannerOver1();

    $("#billboard ul li a:eq(0)").mouseover(function () {

    window.clearTimeout(showtimeout);
    BannerOver1();

    });

    $("#billboard ul li a:eq(1)").mouseover(function () {

window.clearTimeout(showtimeout);
         BannerOver2();

    });

    $("#billboard ul li a:eq(2)").mouseover(function () {

 window.clearTimeout(showtimeout);
       BannerOver3();

    });
  
    $("#billboard ul li a:eq(3)").mouseover(function () {

  window.clearTimeout(showtimeout);
      BannerOver4();

    });

    function BannerOver1() {

            $("#bannerImg1").animate({ left: "0px" }, 500);
            $("#bannerImg2").animate({ left: "1000px" }, 500);
            $("#bannerImg3").animate({ left: "2000px" }, 500);
            $("#bannerImg4").animate({ left: "3000px" }, 500);
BannerActions("#billboard ul li a:eq(0)")
showtimeout = window.setTimeout(function() { BannerOver2();}, 4000);

    }

    function BannerOver2() {

        $("#bannerImg1").animate({ left: "-1000px" }, 500);
        $("#bannerImg2").animate({ left: "0px" }, 500);
        $("#bannerImg3").animate({ left: "1000px" }, 500);
        $("#bannerImg4").animate({ left: "2000px" }, 500);
BannerActions("#billboard ul li a:eq(1)")
showtimeout = window.setTimeout(function() { BannerOver3();}, 4000);

}

    function BannerOver3() {

        $("#bannerImg1").animate({ left: "-2000px" }, 500);
        $("#bannerImg2").animate({ left: "-1000px" }, 500);
        $("#bannerImg3").animate({ left: "0px" }, 500);
        $("#bannerImg4").animate({ left: "1000px" }, 500);
BannerActions("#billboard ul li a:eq(2)")
showtimeout = window.setTimeout(function() { BannerOver4();}, 4000);

}

    function BannerOver4() {

        $("#bannerImg1").animate({ left: "-3000px" }, 500);
        $("#bannerImg2").animate({ left: "-2000px" }, 500);
        $("#bannerImg3").animate({ left: "-1000px" }, 500);
        $("#bannerImg4").animate({ left: "0px" }, 500);
BannerActions("#billboard ul li a:eq(3)")
showtimeout = window.setTimeout(function() { BannerOver1();}, 4000);

}

    function BannerActions(item) {

        var content_show = $(item).parent("li").attr("title");
        $("#" + content_show).fadeIn("slow");

        var content_link = $(item).attr("href");
        $("#bannerLink").attr("href", content_link);

        var content_target = $(item).attr("target");
        $("#bannerLink").attr("target", content_target);

        var content_click = $(item).attr("accesskey");
        $("#bannerLink").attr("accesskey", content_click);

        $("#billboard ul li").removeClass("billboardHighlightLeft");
        $("#billboard ul li a").removeClass("billboardHighlightRight");

        $(item).parent("li").addClass("billboardHighlightLeft");
        $(item).addClass("billboardHighlightRight");

    }

          // Home Tabbed Container
        $("#homeTabbedContainer ul li span").click(function () {

            $("#homeTabbedContainer ul li span").removeClass("tabOn");
            $("#homeTabbedContainer ul li span").removeClass("tabOnFirst");
            $("#homeTabbedContainer ul li span").removeClass("tabOnLast");

            if ($(this) == $("#homeTabbedContainer ul li span:first")) {
                $(this).addClass("tabOnFirst");
            }
            else {

                if ($(this) == $("#homeTabbedContainer ul li span:last")) {
                    $(this).addClass("tabOnLast");
                }
                else {
                    $(this).addClass("tabOn");
                }

            }

            $("#homeTabbedContainer div").removeClass("contentOn");

            var tab = $(this).parent("li").attr("title");
            $("#" + tab).addClass("contentOn");

        });

        // PN Client Quotes
        $("#PNClientQuotes li:eq(1)").hide();

        $("#PNClientQuotesButton1 img").attr("src", "images/btn-banner-pn-on.png");

        showtimeoutCQ = window.setTimeout(function () { CommentOn2(); }, 5000);

        $("#PNClientQuotesButton1").click(function () {
            window.clearTimeout(showtimeoutCQ);
            CommentOn1();
        });

        $("#PNClientQuotesButton2").click(function () {
            window.clearTimeout(showtimeoutCQ);
            CommentOn2();
        });

        function CommentOn1() {

            $("#PNClientQuotes li:eq(0)").fadeIn("fast");
            $("#PNClientQuotes li:eq(1)").hide();
            $("#PNClientQuotes li:eq(2)").hide();
            $("#PNClientQuotesButton1 img").attr("src", "images/btn-banner-pn-on.png");
            $("#PNClientQuotesButton2 img").attr("src", "images/btn-banner-pn-off.png");
            $("#PNClientQuotesButton3 img").attr("src", "images/btn-banner-pn-off.png");
            showtimeoutCQ = window.setTimeout(function () { CommentOn2(); }, 5000);

        }

        function CommentOn2() {

            $("#PNClientQuotes li:eq(0)").hide();
            $("#PNClientQuotes li:eq(1)").fadeIn("fast");
            $("#PNClientQuotes li:eq(2)").hide();
            $("#PNClientQuotesButton1 img").attr("src", "images/btn-banner-pn-off.png");
            $("#PNClientQuotesButton2 img").attr("src", "images/btn-banner-pn-on.png");
            $("#PNClientQuotesButton3 img").attr("src", "images/btn-banner-pn-off.png");
            showtimeoutCQ = window.setTimeout(function () { CommentOn1(); }, 5000);

        }

        // PN Billboard Banner
        $("#PNBannerImages li a").hide();
        $("#PNBannerImg1").show();

        var showtimeout = null;
        PNBannerOver1();

        function PNBannerOver1() {

            $("#PNBannerImg5").fadeOut("slow");
            $("#PNBannerImg1").fadeIn("slow");

            showtimeout = window.setTimeout(function () { PNBannerOver2(); }, 4000);

        }

        function PNBannerOver2() {

            $("#PNBannerImg1").fadeOut("slow");
            $("#PNBannerImg2").fadeIn("slow");

            showtimeout = window.setTimeout(function () { PNBannerOver3(); }, 4000);

        }

        function PNBannerOver3() {

            $("#PNBannerImg2").fadeOut("slow");
            $("#PNBannerImg3").fadeIn("slow");

            showtimeout = window.setTimeout(function () { PNBannerOver4(); }, 4000);

        }

        function PNBannerOver4() {

            $("#PNBannerImg3").fadeOut("slow");
            $("#PNBannerImg4").fadeIn("slow");

            showtimeout = window.setTimeout(function () { PNBannerOver5(); }, 4000);

        }

        function PNBannerOver5() {

            $("#PNBannerImg4").fadeOut("slow");
            $("#PNBannerImg5").fadeIn("slow");

            showtimeout = window.setTimeout(function () { PNBannerOver1(); }, 4000);

        }

});

