/*
 * Initialize the menu navigation selector behavior 
 */
function navigationMenuSelectorInit() {
	initNavigationMenu();
}

/*
 * This function is used to selected the Menu Options (Header and Footer)
 */
function selectFirstLevelMenu(firstLevelMenuOption) {
	
	if(firstLevelMenuOption != null && firstLevelMenuOption != "") {
		// In a future, this should be work only for css clases
		jQuery('.firstLevelNavigationOptionHolder #' + firstLevelMenuOption).addClass('selected');
		jQuery('.firstLevelNavigationOptionHolder .' + firstLevelMenuOption).addClass('selected');
	}
}

/*
 * This function is used to selected the sub-menu Options (Subheader)
 */
function selectSecondLevelMenu(firstLevelMenuOption, secondLevelMenuOption) {
    
    if(firstLevelMenuOption != null && firstLevelMenuOption != "" && secondLevelMenuOption != null && secondLevelMenuOption != "") {
    		// In a future, this should be work only for css clases
            jQuery('.secondLevelNavigationOptionHolder #' + firstLevelMenuOption + '-' + secondLevelMenuOption).addClass('selected');
            jQuery('.secondLevelNavigationOptionHolder .' + firstLevelMenuOption + '-' + secondLevelMenuOption).addClass('selected');
    }
}

/*
 * This function is used to display the sub-menu Options (Subheader)
 */
function showSubNavMenuSelected(firstLevelMenuOption) {
	
        jQuery('#' + firstLevelMenuOption + '.selected ul').show();
}

/*
 * This function redefine in each link on the Main Nav the "On Mouse Over" and "On Mouse Out" events 
 */
function initNavigationMenu(){
	
    // For each link in the Main Nav redefine the event
    jQuery('.mainNavs .mainNavList li.mainNav').each(function () {
            
            jQuery(this).bind('mouseover', function() {
            		
            		if (jQuery(this).hasClass('selected')) {
            			return;
            		}
            	
                    // Hide the current Sub Nav Selected
                    jQuery('.mainNav.selected ul').hide();
                    
                    // Show the Sub Nav
                    jQuery('#' + jQuery(this).attr('id') + ' ul').show();
            });
            
            jQuery(this).bind('mouseout', function() {

	            	if (jQuery(this).hasClass('selected')) {
	        			return;
	        		}
            	
	            	// Show the current Sub Nav Selected
	            	jQuery('.mainNav.selected ul').show();
                    // Hide the Sub Nav
                    jQuery('#' + jQuery(this).attr('id') + ' ul').hide();
                    
            });
    });
        
}

