/*
	COPYRIGHT 1996, 2009 JAMES H. ZISCH. ALL RIGHTS RESERVED.
	CONTACT:  James H. Zisch - Computer Services (JHZ-CS) www.jhz-cs.com
*/

function buttonsInit() {
	try {
		buttonsGet();
		buttonsReset();
		buttonsDropMenusInit();
		buttonsSetSector();
		buttonsSetNavButtons();
	}
	catch (err) { errHandler(err,'buttonsInit'); }
}

function buttonsGet() {
	try {
		var f = (self.document.getElementById(ancID)) ?			self.document.getElementById(ancID) : parent.document.getElementById(ancID);
		var d = (f.contentDocument) ? f.contentDocument : f.contentWindow.document;
		var r = d.getElementById('tn').innerHTML;
		document.getElementById('tn').innerHTML = r;
	}
	catch (err) { errHandler(err,'buttonsGet'); }
}

function buttonsReset() {
	try {
		with (getCSSBySelector('#page_header').style){
			if (backgroundColor) {
				buttonBackgroundColorSelected	= backgroundColor;
				buttonBorderColorSelected		= backgroundColor;
			}
			if (color) buttonColorSelected		= color;
		}
		with (getCSSBySelector('#drop_menus').style) {
			if (backgroundColor) {
				buttonBackgroundColorOver	= backgroundColor;
				buttonBackgroundColorDown	= backgroundColor;
				buttonBackgroundColorOut	= backgroundColor;
				dropItemBgClrOut			= backgroundColor;
				buttonBorderColorOver		= borderColor;
				buttonBorderColorDown		= borderColor;
				buttonBorderColorOut		= borderColor;
			}
		}
		with (getCSSBySelector('#drop_menus a:link').style) {
			if (color) {
				buttonColorOut		= color;
				dropItemTxClrOut	= color;
			}
		}
		with (getCSSBySelector('#drop_menus a:hover').style) {
			if (color) buttonColorOver = color;
		}
		with (getCSSBySelector('#drop_menus a:active').style) {
			if (color) buttonColorDown = color;
		}
	}
	catch (err) { errHandler(err,'buttonsReset'); }
}

function buttonsDropMenusInit() {
	try {
		if (msie&&!msieOK) {
			for (var x in drop_menus) with (document.getElementById(drop_menus[x]).style) {
				visibility = 'hidden';
				display = none;
			}
			return;
		}
		for (var x in drop_menus) {
			for (var y = 0; y < document.getElementById(drop_menus[x]).childNodes.length; y++) {
				var t = document.getElementById(drop_menus[x]).childNodes[y];
				if (t.tagName && (t.tagName == 'H3' || t.tagName == 'H4' || t.tagName == 'H5' || t.tagName == 'H6') ) {
					var z = document.getElementById(t.id);
					z.onmouseover	= buttonsDropMenuOver;
					z.onmouseout	= buttonsDropMenuOut;
					z.onclick		= buttonsDropMenuClick;
					if (t.firstChild && t.firstChild.href) {
						document.getElementById(t.id).link = t.firstChild.href;
					}
				}
			}
		}
		document.getElementById('PgC').onmouseover = buttonsDropMenuHide;
	}
	catch (err) { errHandler(err,'buttonsDropMenusInit'); }
}

function buttonsSetSector() {
	try {
		if (sector && document.getElementById(sector)) with (document.getElementById(sector).style) {
			backgroundColor = buttonBackgroundColorSelected;
			color = buttonColorSelected;
			borderColor = buttonBorderColorSelected;
			if (document.getElementById('tnL_' + sector)) document.getElementById('tnL_' + sector).style.color = buttonColorSelected;
		}
	}
	catch (err) { errHandler(err,'buttonsSetSector'); }
}

function buttonsSetNavButtons() {
	try {
		for (var x in sectors) {
			with (document.getElementById(sectors[x])){
				var z = document.getElementById(sectors[x]);
				z.onmouseover	= buttonsButtonOver;
				z.onmousedown	= buttonsButtonDown;
				z.onmouseout	= buttonsButtonOut;
				if (firstChild && firstChild.title) title = firstChild.title;
				if (sectors[x].search(/search|order/i) > -1) continue;
				z.onclick = buttonsClick;
				if (firstChild && firstChild.href) document.getElementById(sectors[x]).link = firstChild.href;
			}
		}
		with (document.getElementById('search')){
			onmouseover	= buttonsButtonOver;
			onmouseout	= buttonsButtonOut;
		}

		document.getElementById('order').onclick = buttonsOrderToggle;
	}
	catch (err) { errHandler(err,'buttonsSetNavButtons'); }
}

function buttonsButtonOver() {
	try {
		if (this.id == 'search') {
			with (this.style) {
				backgroundColor	= buttonBackgroundColorOver;
				color			= buttonColorOver;
				borderColor		= buttonBorderColorOver;
			}
			document.getElementById('drop_search').style.display = 'block';
		}
		else {
			if (this.parentNode.tagName == 'TR') {
				document.getElementById('tnL_' + this.id).style.color = buttonColorOver;
				with (this.style) {
					backgroundColor	= buttonBackgroundColorOver;
					color			= buttonColorOver;
					borderColor		= buttonBorderColorOver;
				}
			}
			bsect = (this.parentNode.tagName == 'TR') ? this.id : this.parentNode.id;
			buttonsDropMenuHide();
			if (document.getElementById('drop_' + bsect)) {
				document.getElementById('drop_' + bsect).style.display = 'block';
			}
		}
		return true;
	}
	catch (err) { errHandler(err,'buttonsButtonOver'); }
}

function buttonsButtonDown() {
	try {
		if (this.parentNode.tagName == 'TR') {
			if (document.getElementById('tnL_' + this.id)) document.getElementById('tnL_' + this.id).style.color = buttonColorDown;
		}
		return true;
	}
	catch (err) { errHandler(err,'buttonsButtonDown'); }
}

function buttonsButtonOut() {
	try {
		if (this.id == 'search') {
			with (this.style) {
				backgroundColor	= buttonBackgroundColorOut;
				color			= buttonColorOut;
				borderColor		= buttonBorderColorOut;
			}
			document.getElementById('drop_search').style.display = 'none';
		}
		else {
			if (this.parentNode.tagName == 'TR') {
				if (this.id == sector) {	//	current sector
					document.getElementById('tnL_' + this.id).style.color = buttonColorSelected;
					with (this.style) {
						backgroundColor	= buttonBackgroundColorSelected;
						color			= buttonColorSelected;
						borderColor		= buttonBorderColorSelected;
					}
				}
				else {
					document.getElementById('tnL_' + this.id).style.color = buttonColorOut;
					with (document.getElementById(this.id).style) {
						backgroundColor	= buttonBackgroundColorOut;
						color			= buttonColorOut;
						borderColor		= buttonBorderColorOut;
					}
					if (this.id == 'order') with (this.style) {
						backgroundColor	= buttonRequestBackgroundColor;
						borderColor		= buttonRequestBackgroundColor;
					}
				}
				buttonsDropMenuHide();
			}
		}
		return true;
	}
	catch (err) { errHandler(err,'buttonsButtonOut'); }
}

function buttonsClick() {
	if (!this.link || buttonsSuspendButtonClick) return;
	location.href = this.link;
}

function buttonsDropMenuClick() {
	buttonsSuspendButtonClick = true;
	if (!this.link) return;
	location.href = this.link;
}

function buttonsDropMenuOver() {
	buttonsSuspendButtonClick = true;
	if (!this || !this.style || !this.firstChild.style) return;
	this.style.color			= buttonColorOver;
	this.firstChild.style.color	= buttonColorOver;
}

function buttonsDropMenuOut() {
	buttonsSuspendButtonClick = false;
	if (!this || !this.style || !this.firstChild.style) return;
	this.style.color			= buttonColorOut;
	this.firstChild.style.color	= dropItemTxClrOut;
}

function buttonsDropMenuHide() {
	for (var x in drop_menus) {
		document.getElementById(drop_menus[x]).style.display = none;
	}
}

function buttonsSearchFocus() {
	this.src = '/images/buttons/search_over.gif';
	return true;
}

function buttonsSearchOut() {
	this.src = '/images/buttons/search.gif';
	return true;
}

function buttonsOrderToggle() {
	try {
		with (document.getElementById(orderPane).style) {
			display = (display == orderPaneDispAttr) ? none : orderPaneDispAttr;
			if (document.getElementById('tnL_order')) {
				document.getElementById('tnL_order').innerHTML = (display == orderPaneDispAttr) ? orderHide : orderShow;
			}
			if (!navigator.cookieEnabled) alert(enableCookiesMsg);
			document.cookie = orderPane + '=' + display + '; path=/';
		}
		return false;
	}
	catch (err) { errHandler(err,'buttonsOrderToggle'); }
}

var	drop_menus = ['drop_about', 'drop_services', 'drop_solutions', 'drop_support', 'drop_search'];
var
	buttonBackgroundColorSelected,
	buttonBackgroundColorOver,
	buttonBackgroundColorDown,
	buttonBackgroundColorOut,
	buttonColorSelected,
	buttonColorOver,
	buttonColorDown,
	buttonColorOut,
	buttonBorderColorSelected,
	buttonBorderColorOver,
	buttonBorderColorDown,
	buttonBorderColorOut,
	dropItemBgImgOut,
	dropItemBgClrOut,
	dropItemTxClrOut;
var buttonOrderOverReset;
var buttonRequestBackgroundColor = 'silver';
var buttonsSuspendButtonClick = false;
var ancID = 'anc';
