$(document).ready(function(){
    $(".CMSListMenuHighlightedLI").append('<span class="arrowDown"></span>');
    $(".arrowDown").css("margin-left", ($(".CMSListMenuHighlightedLI").width() / 2) - 110);
    
    $(".CMSListMenuHighlightedLI .CMSListMenuHighlightedLI .arrowDown").remove();

    if($("#navigation li").has("ul").length > 0 ){
        $("#navigation li ul").before('<span class="arrowUp"></span>');
    }

    $(".join").hover(function(){
        $("#join").slideDown(200);
    });
    
    $("#join").hover(function(){
        // Do nothing
    }, function() {
        $("#join").slideUp(200);
    });   
    
    /* Navigation Hover Effects */
    var config = {
            sensitivity: 3, // number = sensitivity threshold (must be 1 or higher)
            interval: 100, // number = milliseconds for onMouseOver polling interval
            timeout: 100, // number = milliseconds delay before onMouseOut
            over: function() {
                $(this).children("ul").css("display", "none");
                $(this).children("ul").css("left", "auto");
                $(this).children("ul").slideDown(200);
                $(this).addClass("sfhover");
                $(this).children(".arrowUp").css("display", "block");
                
                if($(this).children("ul").length > 0) {
                    $(this).append('<span class="arrowDown"></span>');
                    $(this).children(".arrowDown").css("margin-left", ($(this).width() / 2) - 110);
                }

                $(this).children(".arrowUp").css("margin-left", ($(this).width() / 2) - 110);
                $(this).children("li li .arrowDown").remove();
                $(this).children("ul").css("margin-left", ($(this).width() / 2) - 97);


                if($(this).hasClass("CMSListMenuHighlightedLI")) {
                    $(this).addClass("current");
                }
                else {
                    $(this).addClass("CMSListMenuHighlightedLI");
                }
            }, // function = onMouseOver callback (REQUIRED)
            out: function() {
                if($(this).hasClass("current") != true){
                    $(this).removeClass("CMSListMenuHighlightedLI");
                    $(this).children(".arrowDown").remove();
                }
                
                $(this).children("ul").css("left", "-999em");
                $(this).removeClass("sfhover");
                $(this).children(".arrowUp").css("display", "none");
            } // function = onMouseOut callback (REQUIRED)
        }
        
        $('#navigation li').hoverIntent(config);
        /*---/ End Navigation Hover Effects */
        
        
        
        
            
        /*$("#navigation li").hover(function(){
            $(this).children("ul").css("left", "auto");
            $(this).addClass("sfhover");
            $(this).children(".arrowUp").css("display", "block");
            $(this).append('<span class="arrowDown"></span>');
            $(this).children(".arrowDown").css("margin-left", ($(this).width() / 2) - 110);
            $(this).children(".arrowUp").css("margin-left", ($(this).width() / 2) - 110);
            $(this).children("li li .arrowDown").remove();
            $(this).children("ul").css("margin-left", ($(this).width() / 2) - 97);


            if($(this).hasClass("active")) {
                $(this).addClass("current");
            }
            else {
                $(this).addClass("active");
            }

        }, function() {
            if($(this).hasClass("current") != true){
                $(this).removeClass("active");
                $(this).children(".arrowDown").remove();
            }
            $(this).children("ul").css("left", "-999em");
            $(this).removeClass("sfhover");
            $(this).children(".arrowUp").css("display", "none");
        });*/



	// Slider
	if($("#contentSlider").length > 0){
		$("#contentSlider").bxSlider({
	    	controls: false,
	    	infiniteLoop: true,
	    	pager: true,	
	    	auto: true,
	    	pause: 8000,
	    	speed: 1000
        	});
	}
	//---/ End Slider


	// Image Caption
	$(".caption").each(function(index){
		var caption = $(this).attr("alt");

		if($(this).hasClass("right")) {
			$(this).wrap('<div class="captionContainer right" />');
		}
		else {
			$(this).wrap('<div class="captionContainer" />');
		}

		$(this).parent(".captionContainer").append('<span class="captionContent">' + caption + '</span>');
		$(this).parent(".captionContainer").css("width", $(this).width());
	});
	//---/ End Image Caption



	// Two Column Border Adjustment
	if($(".col_8").height() < $(".col_4").height()){
		$(".col_8").css("height", $(".col_4").height());
	}
    
});
