// Xerox Corporation
// Purpose:	Singular file for jQuery based code for use on page UI
// 					Singular startup point for jQuery document ready tasks

if(jQuery !== null) {
	jQuery(document).ready(function() {
	   // put all your jQuery goodness in here.
	});
}

/************************************************************************************
* Util nav methods
************************************************************************************/

/*****************************************
* Author:		PHawxby
* Date:			June 18th, 2010
* Function:	Syncs up util nav options to display only those with the Id's supplied
******************************************/
function SyncUtilNavItems(enabledItemIds) {
	jQuery('div#util_search ul li').each(function() {
				var item = jQuery(this);
        var itemId = item.attr('id');

        if(jQuery.inArray(itemId, enabledItemIds) >= 0)
        {
        	HandleUtilNavItem(item, true);
        } 
        else 
        {
          HandleUtilNavItem(item, false);
        }
	});
}

/*****************************************
* Author:		PHawxby
* Date:			June 18th, 2010
* Function:	Disables the util nav item with the supplied Id
******************************************/
function DisableUtilNavItem(itemId) {
	jQuery(document).ready(function() {	
		HandleUtilNavItem(jQuery('div#util_search ul li#' + itemId + ":first"), false);
	});
}

/*****************************************
* Author:		PHawxby
* Date:			June 18th, 2010
* Function:	Enables the util nav item with the supplied id
******************************************/
function EnableUtilNavItem(itemId) {
	jQuery(document).ready(function() {
		HandleUtilNavItem(jQuery('div#util_search ul li#' + itemId+ ":first"), true);
	});
}

/*****************************************
* Author:		PHawxby
* Date:			June 18th, 2010
* Function:	Enables or disables the util nav jQuery item with the supplied id. Performs tidyup after
******************************************/
function HandleUtilNavItem(jQueryItem, enabled) {
	if(!enabled) {
		jQueryItem.append("<span>" + jQueryItem.find("a:first").text() + "</span>");
		jQueryItem.find("a").hide();
	} else {
		jQueryItem.children().hide();
		jQueryItem.find("a").show();
	}
}
