/*
 * Written by CJ Hanson and Alex Petrescu
 * © 2007 The Buddy Group.
 * BUDeSYSTEM and other marks are trademarks or service marks of The Buddy Group.
 * All Rights Reserved.
 * Use subject to terms of a licensing agreement with licensee.
 * Contact The Buddy Group at www.thebuddygroup.com for more information.
*/


var active_el = '';
var active_sub_el = '';
var active_sub_sub_el = '';

$(document).ready(function(){
	$(".subNavItem").not(".siteNavItemActive").hover(
        function(){
            i = $(this).find('img').eq(0);
            newp = $(i).attr('src').replace('_up','_over');
            $(i).attr('src',newp);
        },
        function(){
            i = $(this).find('img').eq(0);
            newp = $(i).attr('src').replace('_over','_up');
            $(i).attr('src',newp);
			
        }
	);
	$(".subSubNavItem").not(".siteNavItemActive").hover(
        function(){
            i = $(this).find('img').eq(0);
            newp = $(i).attr('src').replace('_up','_over');
            $(i).attr('src',newp);
        },
        function(){
            i = $(this).find('img').eq(0);
            newp = $(i).attr('src').replace('_over','_up');
            $(i).attr('src',newp);
			
        }
	);
	$(".hasSubNav").hover(
        function(){
            showSubNav();
        },
        function(){ 
            return false; 
        }
    );
    $(".subNavItem").not(".hasSubNav").mouseenter(
        function(){
            hideSubNav();
        }
    );
    // set active nav item, if there is one
    if(active_el !== ''){
		makeSelected(active_el);
    }
	if(active_sub_el !== ''){
		makeSelected(active_sub_el);
    }
	if(active_sub_sub_el !== ''){
		makeSelected(active_sub_sub_el+"SubNav");
		showThis(active_sub_sub_el);
	}

});

function showThis(itm) {
	$(".isSubNavContainer").css('display','block');
	$(".leadershipSortContainer").css('display',"none");
	$("#leadershipSubNavSub").removeClass('isSubNavContainer');
	if (itm !== '') {
		i = itm + "_nav";
		$("#"+itm).css('display',"block");
	}
}

function showSubNav()
{ 
	$(".isSubNavContainer").css('display','block'); 
}

function hideSubNav()
{ 
	$(".isSubNavContainer").not(".permanant").css('display','none'); 
}

function makeSelected(itm) {
	// set active nav item, if there is one
    if(itm !== ''){
        i = $("#"+itm).find("img:eq(0)");
        newp = $(i).attr('src').replace('_up','_selected');
        $(i).attr('src',newp);
    }
}

//CAPTCHA
function setFieldValue(myFieldID, myFieldValue){
	//alert('set field: '+myFieldID+', '+myFieldValue);
	document.getElementById(myFieldID).value = myFieldValue;
}