// globalNav.js
// 	Contains the dynamic functionality for the drop down navigation found at the top of most templates.

// FUNCTION LIST:
// 	init();
// 	menuOn();
// 	menuOff();

var navTimeout;
var menuTimeout;
var currentMenu;
var navIsLoaded = false;

// Initializing the global navigation

// change init() to globalNavInit()
function init() {
	DynLayerInit()
	navIsLoaded = true;	// boolean to true when initialization is complete
}

// Display the dropdown menu.  // inputs: menuName  - name of the menu DIV layer without the Div.  ie. vehicles  // output: none
function menuOn(menuName) {
	if (is.ns4) return;
	var theMenu
	if (!navIsLoaded) return;	// check if initialization is complete
	if (menuTimeout) {
		clearTimeout(menuTimeout);	// clear the timeout
	}
	
	if (currentMenu) {			// hide the current menu
		theMenu = eval(currentMenu);
		theMenu.hide();
	}
	currentMenu = menuName;
	theMenu = eval(currentMenu);
	theMenu.show();				// display menuName
	// Next line commented out to match Flash nav version
}

// Hides the dropdown menus  // inputs: menuName - name of the menu DIV layer without the Div.  ie. vehicles  // outputs: none
function menuOff(menuName) {
	if (is.ns4) return;
	if (!navIsLoaded) return;	// check if initialization is complete

	if (menuTimeout) {
		clearTimeout(menuTimeout);	// clear the current timeout
	}
//	menuTimeout = setTimeout(menuName + '.hide()', 1000);		// set the new timeout
	menuTimeout = setTimeout("hideAllMenus("+menuName+")", 1000);		// set the new timeout

}

function hideAllMenus(menuName) {
	menuName.hide();
//	MM_swapImgRestore();
}

var txtDesignSearch;

// Write and show the text description layer
function buildLayer(trim) {
	if (!navIsLoaded) return;

	//var test = trimArray[trimArrayIndex].trim;
	var layerText = '';
	if (trim == 11) {
	layerText = "The Billing College is the world's leading training and information provider for telephony Billing & Customer Care.";
	}
	else if (trim == 12) {
	layerText = "Our commitment is to provide the most accurate and timely billing information available in the billing industry.";
	}
	else if (trim == 13) {
	layerText = "Our strength is our people.  Find out more about the extensive experience of our instructors and staff.";
	}
	else if (trim == 14) {
	layerText = "Learn more about the Organizations and Associations in the industry we have partnered with to make our services more accessible on a global scale.";
	}
	else if (trim == 15) {
	layerText = "Our wide range of services includes public training courses, in-house training solutions, customized training development and professional consultancy.";
	}
	else if (trim == 16) {
	layerText = "The Billing College is the world's leading training and information provider for telephony Billing & Customer Care. Find out our current course offerings.";
	}
	else if (trim == 17) {
	layerText = "Our in-house service allows you to train a full team at a special discount, in the subjects of your choice and at a location and time that suits you.";
	}
	else if (trim == 18) {
	layerText = "We have the resources to provide you the latest and most accurate information on any Billing, Customer Care, or OSS Training question.";
	}
	else if (trim == 19) {
	layerText = "Continue here to view all our contact details.  We look forward to hearing from you!";
	}
	else if (trim == 20) {
	layerText = "Check here for our current comprehensive course offerings to learn more.";
	}
	else if (trim == 21) {
	layerText = "The Billing College offers the world's leading training and information for telephony Billing & Customer Care.  View our latest Telecom courses here.";
	}
	else if (trim == 22) {
	layerText = "View our latest Utilities courses here.";
	}
	else if (trim == 30) {
	layerText = 'We have the expertise and mobility to come and teach your whole team on any related topic.  Find out more.';
	}
	else if (trim == 31) {
	layerText = "Find out the extensive resources we have to meet the particular needs of your company.";
	}
	else if (trim == 32) {
	layerText = "The leading providers and users of billing related services are enlisting the help of the Billing College to ensure their organization is prepared for any challenge.";
	}
	else if (trim == 40) {
	layerText = "Knowledge is Power.  Find out the power we can put in your hands.";
	}
	else if (trim == 41 || trim == 42) {
	layerText = "We can personalize any research efforts to target your primary objectives.";
	}
	else if (trim == 43) {
	layerText = "Take advantage of some of the knowledge we have acquired over the years with these handy references.";
	}
	else if (trim == 44) {
	layerText = "Our definitions dictionary provides key terms related to Billing, Customer Care, and OSS.";
	}
	else if (trim == 45) {
	layerText = "Our acronyms dictionary clears up all those confusing short terms used.";
	}
	else if (trim == 46) {
	layerText = "Check out our animated visual dictionary for a clearer understanding of some key concepts in the field.";
//	layerText = "Need custom definitions or searches?  Let us know and we can help meet your needs.";
	}
	else if (trim == 50) {
	layerText = "Check here for the latest news related to the billing field in your industry";
	}
	else if (trim == 51) {
	layerText = "Not sure where to find the info you need?  Contact us directly and we'll help you find what you're looking for.";
	};

	dMenuDetails.write(layerText);
	dMenuDetails.show();
	
}


// Reset text description layer to default
function resetLayer() {

  if (!navIsLoaded) return;
	
	var layerText = '';
	layerText = '';
	layerText += txtDefaultLayer;
	layerText += '';
	dMenuDetails.write(layerText);
	dMenuDetails.show();
}

// Activates the text description layer
function trimOn(trim) {
	if (is.ns4) return;
	if (!navIsLoaded) return;

	buildLayer(trim);
}


// Deactivates the text description layer
function trimOff() {
	if (is.ns4) return;
	if (!navIsLoaded) return;
	dMenuDetails.hide();

}


//used to preload the rollover images used by css in the homepage

var base = "/proto/graphics/";
var base2 = "/proto/images/";

if (document.images) {
	
	// other preloaded images needed by css rollovers, etc.  No required for it to work, but speeds up loading.
	preload_01 = new Image;	preload_01.src = base + "sel_about.gif";
	preload_02 = new Image;	preload_02.src = base + "sel_courses.gif";
	preload_03 = new Image;	preload_03.src = base + "sel_training.gif";
	preload_04 = new Image;	preload_04.src = base + "sel_research.gif";
	preload_05 = new Image;	preload_05.src = base + "sel_more.gif";
	preload_06 = new Image;	preload_06.src = base + "nav_about.jpg";
	preload_07 = new Image;	preload_07.src = base + "nav_courses.jpg";
	preload_08 = new Image;	preload_08.src = base + "nav_training.jpg";
	preload_09 = new Image;	preload_09.src = base + "nav_research.jpg";
	preload_10 = new Image;	preload_10.src = base + "nav_more.jpg";
	preload_11 = new Image;	preload_11.src = base + "nav_aboutover.jpg";
	preload_12 = new Image;	preload_12.src = base + "nav_coursesover.jpg";
	preload_13 = new Image;	preload_13.src = base + "nav_trainingover.jpg";
	preload_14 = new Image;	preload_14.src = base + "nav_researchover.jpg";
	preload_15 = new Image;	preload_15.src = base + "nav_moreover.jpg";
	
}
