﻿$(document).ready(function() {
    prepareTopNav();
    prepareSideNav();
    InputCharCount();
    HighlightInputBox();
	contentHyperlinks();
});

function prepareTopNav() {
    
    $(" div#menu li.level1 a ").hover(function() {
        $(this).animate({
            lineHeight: "25px",
            color: "#AA1428"
        }, 250);
    }, function() {
        if ($(this).is("#current"))
        {
            $(this).animate({
                lineHeight: "35px",
                color: "#AA1428"
            }, 250);
        }
        else
        {
            $(this).animate({
                lineHeight: "35px",
                color: "#000000"
            }, 250);
        }
    });
}

function contentHyperlinks() {
	$(" div#content a ").hover(function() {
        $(this).animate({
            backgroundColor: "#E6E9EB",
            color: "#969696"
        }, 250);
    }, function() {
		$(this).animate({
			backgroundColor: "#ffffff",
            color: "#AA1428"
		}, 250);
	});
}

function prepareSideNav() {
    $("#sideNavBar li ul li").hover(function() {

    $(this).animate({
            backgroundColor: "#E6E9EB"
        }, 250);
    }, function() {
        $(this).animate({
            backgroundColor: "#FFFFFF"
        }, 250);
    });
}

function InputCharCount() {
    $("[id$='_goalsTextBox']").each(function() {
        var length = 1000 - $(this).val().length;
        $(this).parent().find('.counter').html(length + ' characters');
        $(this).keyup(function() {
            var new_length = 1000 - $(this).val().length;
            if (new_length <= 0) {
                $(this).parent().find('.counter').html('Message is too long.');
            }
            else {
                $(this).parent().find('.counter').html(new_length + ' characters left');
            }
        });
    });
}

function HighlightInputBox() {
    $(':input').focus(function() {
        $(this).animate({
            backgroundColor: "#E6E9EB",
            color: "#2F4266"
        }, 250);
    });
    
    $(':input').blur(function(){
        $(this).animate({
            backgroundColor: "#FFFFFF",
            color: "#000000"
        }, 250);
    });
}
