// include other js files
document.write('<script type="text/javascript" src="../js/images.js"></script>');
document.write('<script type="text/javascript" src="../js/links.js"></script>');
document.write('<script type="text/javascript" src="../js/popups.js"></script>');
document.write('<script type="text/javascript" src="../js/main_nav_text.js"></script>');

// config vars
// for image rollovers
var ncImgOver = '_over';  // naming convention of img file suffix for the over state
var ncClsRoll = 'roll';   // name of class for single rollover
var ncClsDblRoll = 'dbl_roll';   // name of class for double rollover
// for main image map
var imgNavMapId = 'img_nav';  // id of the image using the nav map
var navMapId = 'nav_map';  // id of the nav map
var navMapAreaActive = '';  // id of the current active area
var ncClsAreaActive = 'active'

// function called when DOM is loaded
function initPage() {
	if (arguments.callee.done) return; // quit if this function has already been called
	arguments.callee.done = true; // flag this function so called only oce
	// do stuff
	initLinks();

	if(document.getElementById('js_welding')){
		initWelding();
	}

	if(document.getElementById('js_safety')){
		initSafety();
	}
}

// for Mozilla based browsers
if (document.addEventListener) {
   document.addEventListener("DOMContentLoaded", initPage, null);
}

// for Internet Explorer
/*@cc_on @*/
/*@if (@_jscript)
   document.write('<script type="text/javascript" defer src=../js/ie_dom_loaded.js></script>');
/*@end @*/

/* for other browsers */
window.onload = initPage;


// safely handle additional onload events
function addLoadEvent(func) {
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		var oldonload = window.onload;
		window.onload = function() { oldonload(); func(); }
	}
}

// debug is called from catch clauses and parses the error object
function debug(errObj){
	var strOut = 'DEBUG Message:\n';
	for (var name in errObj){
		strOut += name + ': ' + errObj[name] + '\n';
	}
	//alert(strOut);
}

// utility function for safe class name managment
function manClsNames( action, obj, cls1, cls2 ){
	switch (action){
	case 'swap':
		obj.className = !manClsNames('check', obj, cls1) ? obj.className.replace( cls2, cls1 ) : obj.className.replace( cls1, cls2 );
		break;
	case 'add':
		if( !manClsNames('check', obj, cls1) ){ obj.className += obj.className ? ' '+cls1 : cls1; }
		break;
	case 'remove':
		var rep = obj.className.match(' '+cls1) ? ' '+cls1 : cls1;
		obj.className = obj.className.replace( rep, '' );
		break;
	case 'check':
		return new RegExp('\\b'+cls1+'\\b').test(obj.className)
		break;
	}
}