$(document).ready(function () {
    currAnimationModValue = 300;
    $("div.hottest ul.blurbs").hide();
    $("div.hottest ul.blurbs:first").show();
    $("div.hottest li a").not($("div.hottest ul.navigation a")).bind("mouseover",function () {
        if($("body").attr("id") == "home" || $("body").attr("id") == "features") {
            thisIndex = $(this).parents("li").find("ul li").slice(0,3).index($(this).parent()[0]);
            $(this).parents("li").find("ul.blurbs li").removeClass("active").eq(thisIndex).addClass("active");
        } else {
            thisIndex = $("div.hottest ul:eq(0) li").index($(this).parents("li")[0]);
            $("div.hottest div.titles li").removeClass("active").eq(thisIndex).addClass("active");
        }
    }).bind("click", function () {
        //window.location = this.href;
        popupWin(this.href,"contentWin",'width=' + $(window).width() + ',height=' + $(window).width() + ',scrollbars=1,resizable=1,toolbar=1,menubar=1,location=1,status=1');
        return false;
    });
    $("div.hottest li.next a").bind("click", function () {
        currIndex = $("div.hottest li.item").index($("div.hottest li.item a.on").parents("li.item")[0]);
        $("div.hottest ul.blurbs").hide();
        $("div.hottest ul.blurbs:eq(" + (currIndex + 1) + ")").show();
        currAnimationMod = "-=" + currAnimationModValue + "px";
        if(currIndex > $("div.hottest li.item").size() - 2) {
            currAnimationMod = "0px";
            $("div.hottest ul.blurbs").hide();
            $("div.hottest ul.blurbs:first").show();
        }
        $("div.hottest ul.holder").animate({
            "left":currAnimationMod
        }, "slow");
        modIndex = currIndex + 1;
        if(modIndex > $("div.hottest li.content").size() - 1) {
            modIndex = 0;
        }
        $("div.hottest li.item a").removeClass("on").parents("div.hottest").find("li.item:eq(" + modIndex + ") a").addClass("on");
        
        return false;
    });
    $("div.hottest li.prev a").bind("click", function () {
        currIndex = $("div.hottest li.item").index($("div.hottest li.item a.on").parents("li.item")[0]) - 1;
        $("div.hottest ul.blurbs").hide();
        $("div.hottest ul.blurbs:eq(" + currIndex + ")").show();
        if(currIndex < 0) {
            currIndex = $("div.hottest li.content").size() - 1;
            $("div.hottest ul.blurbs").hide();
            $("div.hottest ul.blurbs:last").show();
        }
        currAnimationMod = "-" + (currIndex * currAnimationModValue) + "px";
        $("div.hottest ul.holder").animate({
            "left":currAnimationMod
        }, "slow"/*, function () {
            $("div.hottest ul.blurbs").css({opacity:1});
        }*/);
        modIndex = currIndex;
        if(modIndex < 0) {
            modIndex = $("div.hottest li.content").size() - 1;
        }
        $("div.hottest li.item a").removeClass("on").parents("div.hottest").find("li.item:eq(" + modIndex + ") a").addClass("on");
        return false;
    });
});