(function ($) {

    //all jquery functionality below
    $(document).ready(function() {

        //$(document).pngFix();

        //animated background positioning
        $('#ask') //ask kurt div
            .css( {backgroundPosition: "0px -200px"} )
            .mouseover(function(){
                $(this).stop().animate({backgroundPosition:"(0px 0px)"}, {duration:700})
            })
            .mouseout(function(){
                $(this).stop().animate({backgroundPosition:"(-50px -200px)"}, {duration:350, complete:function(){
                    $(this).css({backgroundPosition: "0px -200px"})
                }})
            });

        $('#profile img') //ask kurt bust image
            .mouseover(function(){
                $('#ask').stop().animate({backgroundPosition:"(0px 0px)"}, {duration:700})
            })
            .mouseout(function(){
                $('#ask').stop().animate({backgroundPosition:"(-50px -200px)"}, {duration:350, complete:function(){
                    $('#ask').css({backgroundPosition: "0px -200px"})
                }})
            });

        $('.topic') //nav for non-flash users
            .css( {backgroundPosition: "200px 0px"} )
            .mouseover(function(){
                $(this).stop().animate({backgroundPosition:"(-150px 0px)"}, {duration:500})
            })
            .mouseout(function(){
                $(this).stop().animate({backgroundPosition:"(200px 0px)"}, {duration:300, complete:function(){
                    $(this).css({backgroundPosition: "200px 0px"})
                }})
            });



        //browser conditional for ie6
	if(typeof document.body.style.maxHeight === "undefined") {
            //alert('ie6');

            //description functionality for non-flash users
            var max = $('.topic').length;
            var cur = 0;

            $(".topic").click(function () {
                var idx = $('.topic').index($(this));
                cur = idx + 1;
                
                $('.topic a').css('color','#8BC33E');
                $('.topic').css('backgroundColor','#F8F6E7');
                $('a', this).css('color','#00ADED'); //changes specific text color
                $(this).css('backgroundColor','#FFF'); //changes specific bg color

                $('.sliderinfo').hide();
                $('#slider img').hide().eq(idx).fadeIn(function () {
                    $('.sliderinfo').eq(idx).fadeIn();
                });
            });
            
            $('.topic').eq(cur).click(); cur++;

            var slideInterval = setInterval(function () {
                    if (cur >= max) cur = 0;
                    $('.topic').eq(cur).click(); cur++;
                }, 10000);

            $("#container_s").hover(function () {
                    clearInterval(slideInterval);
                },
                function () {
                    slideInterval = setInterval(function () {
                        if (cur >= max) cur = 0;
                        $('.topic').eq(cur).click(); cur++;
                    }, 10000);
                });

        } else {

            //slider functions
            $.fn.nivoSlider.defaults = {
                effect:'sliceDown',
                slices:15,
                animSpeed:1000,
                pauseTime:10000,
                startSlide:4,
                directionNav:false,
                directionNavHide:true,
                controlNav:true,
                controlNavThumbs:false,
                controlNavThumbsSearch: '.jpg',
                controlNavThumbsReplace: '_thumb.jpg',
                keyboardNav:true,
                pauseOnHover:true,
                manualAdvance:false,
                captionOpacity:0,
                beforeChange: function(){
                    //debugger;
                    $("div.sliderinfo").fadeOut();
                },
                afterChange: function(){
                    var idx = $("a.nivo-control").index( $("a.active", this) );
                    $("div.sliderinfo:eq("+idx+")").fadeIn();
                },
                slideshowEnd: function(){}
            };

            $('#slider').nivoSlider();
            $("#description").remove();
            
        }

    }); //end $(document).ready

}(jQuery));