﻿var curNavSection = "";
var curSubNavSection = "";
var isAnimating = false;

$(document).ready(function() {



    //Header animate
    $(".headline").css({ "right": "-600px" })
    $(".headline").animate({ right: "0px" }, { "duration": 1000, "easing": "bounceout" })

    //Nav spotlight
    $('#DawntheNav').lavaLamp({
        fx: 'backout',
        speed: 1000,
        autoReturn: false
    });


    //UI Fade RollOver
    $(".ui-fade-rollover").each(function() {
        if ($(this).attr("ui-fade-rollover-effect_loaded") == "true") return;
        $(this).attr("ui-fade-rollover-effect_loaded", "true");


        if ($(this).attr("alt") != null && curNavSection != "" && $(this).attr("alt").indexOf(curNavSection) != -1) {
            $(this).attr("src", $(this).attr("src").replace("_off", "_over"));
        }

        if ($(this).attr("alt") != null && curSubNavSection != "" && $(this).attr("alt").indexOf(curSubNavSection) != -1) {
            $(this).attr("src", $(this).attr("src").replace("_off", "_over"));
        }

        //alert($(this).attr("src").replace("_off", "_over"));
        //alert($(this).parent().get(0).tagName);

        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 }, 300);
        });
        $(this).bind("mouseleave", function(e) {
            $(this).stop().animate({ opacity: 1 }, 300);
        });
    });


    //Community Guide
//    function fadeOutGuideLines() {
//        if (isAnimating == false) {
//            $("#communityGuidePop").fadeOut("fast");

//        }
//    }

//    $("#communityGuideTrigger").click(function() {
//        $("#communityGuidePop").fadeIn("fast");
//    })

//    $("#communityGuideTrigger").mouseout(function() {
//        isAnimating = false;
//        setTimeout(function() { fadeOutGuideLines(); }, 1000);

//    })

//    $("#communityGuidePop").mouseover(function() {
//        isAnimating = true;
//    })

//    $("#communityGuidePop").mouseout(function() {
//        isAnimating = false;
//        setTimeout(function() { fadeOutGuideLines(); }, 1000);
    //    })

    jQuery.fn.fadeToggle = function(speed, easing, callback) {
    return this.stop().animate({ opacity: 'toggle' }, speed, easing, callback);

    }; 

    $("#communityGuideTrigger").click(function() {
            $("#communityGuidePop").fadeToggle();
        })



    //TextArea Counter

    $(function() {
        $('.accomplishment').keyup(function() { limitChars('accomplishment', 500, 'accomplishmentCount'); })
    });

    $(function() {
        $('.balance').keyup(function() { limitChars('balance', 500, 'balanceCount'); })
    });

    $(function() {
        $('.smarter').keyup(function() { limitChars('smarter', 500, 'smarterCount'); })
    });

    $(function() {
        $('.jobdone').keyup(function() { limitChars('jobdone', 500, 'jobdoneCount'); })
    });

    //FancyBox FrontEnd
    $("a.inline").fancybox({ 'hideOnContentClick': false, 'overlayOpacity': 0.8, 'overlayColor': "#000", 'padding': 15 });
    $("a.exPage").fancybox({ 'hideOnContentClick': false, 'overlayOpacity': 0.8, 'overlayColor': "#000", 'padding': 15 });


});













