﻿var curNavSection = "";
var subNavSection = "";

$(document).ready(function() {
    //Initialization code in here.

    //Fade Rollover Code
    $(".ui-fade-rollover").each(function()
    {
        if ($(this).attr("effect_loaded") == "true") return;
    
        $(this).attr("effect_loaded", "true");
        if ($(this).attr("alt") != null && curNavSection != "" && $(this).attr("alt").indexOf(curNavSection) != -1) {
            $(this).attr("src", $(this).attr("src").replace("_off", "_over"));
        }
        
        $(this).attr("effect_loaded", "true");
        if ($(this).attr("alt") != null && subNavSection != "" && $(this).attr("alt").indexOf(subNavSection) != -1) {
            $(this).attr("src", $(this).attr("src").replace("_off", "_over"));
        }
        var wrapper = "<div style='display: block; height: auto; width: auto; background-repeat: no-repeat; background-image: url(" + $(this).attr("src").replace("_off", "_over") + ")'></div>";
        if ($(this).parent().get(0).tagName == "A") {
            $(this).parent().wrap(wrapper);
        }
        else {
            $(this).wrap(wrapper);
        }

        $(this).bind("mouseenter", function(e) {
            $(this).stop().animate({ opacity: 0 }, 100);
        });
        $(this).bind("mouseleave", function(e) {
            $(this).stop().animate({ opacity: 1 }, 100);
        });
    });
    
    //TwitterFeed
//    $("#twitterFeed").tweet({
//            username: "pizzaroadie",
//            //username: "mykebates",
//            //join_text: "auto",
//            //avatar_size: 32,
//            count: 1,
//            //auto_join_text_default: "we said,",
//            //auto_join_text_ed: "we",
//            //auto_join_text_ing: "we were",
//            //auto_join_text_reply: "we replied to",
//            //auto_join_text_url: "we were checking out",
//            loading_text: "loading last tweet..."
//     });
        $("#content_pop_up").hide();
        $("#content_pop_up").hover(overPopUp, offPopUp);
        $(".popupBanner").hover(overBanner, offBanner);
    });

    var isOverBanner = false;
    var isOverPopUp = false;

    function overBanner(e) {
        isOverBanner = true;
        $("#content_pop_up").show();
    }
    function offBanner(e) {
        isOverBanner = false;
        if (!isOverBanner && !isOverPopUp) {
            setTimeout(hidePopUp, 500);
        }
    }
    function overPopUp(e) {
        isOverPopUp = true;
    }
    function offPopUp(e) {
        isOverPopUp = false;
        if (!isOverBanner && !isOverPopUp) {
            setTimeout(hidePopUp, 500);
        }
    }
    function hidePopUp() {
        if (!isOverBanner && !isOverPopUp) {
            $("#content_pop_up").hide();
        }
    }
