/**
 * this script is part of the opodo header / footer
 */

//testchange
/**
 * dom ready handler (from http://www.geekdaily.net/2007/07/27/javascript-windowonload-is-bad-mkay/)
 */
	//create onDomReady Event
	window.onDomReady = DomReady;

	//Setup the event
	function DomReady(fn) {
		//W3C
		if(document.addEventListener) {
			document.addEventListener("DOMContentLoaded", fn, false);
		}
		//IE
		else {
			document.onreadystatechange = function(){readyState(fn)}
		}
	}

	//IE execute function
	function readyState(fn) {
		//dom is ready for interaction
		if(document.readyState == "interactive") {
			fn();
		}
	}

	//execute as soon as DOM is loaded
	window.onDomReady(onReady);


/**
 * add classes function (from http://snippets.dzone.com/posts/show/2630)
 */
	function AddClassName(objElement, strClass, blnMayAlreadyExist)  {
		if ( objElement.className ) {
			var arrList = objElement.className.split(' ');
			if ( blnMayAlreadyExist ) {
				var strClassUpper = strClass.toUpperCase();
				for ( var i = 0; i < arrList.length; i++ ) {
					if ( arrList[i].toUpperCase() == strClassUpper ) {
						arrList.splice(i, 1);
						i--;
					}
				}
			}
			arrList[arrList.length] = strClass;
			objElement.className = arrList.join(' ');
		} else {
			objElement.className = strClass;
		}
	}


/**
 * highlight menus using the dom ready handler
 */
	function highlightMenu(pid) {
		element = document.getElementById('menuitem_' + pid);
		AddClassName(element, 'activeTab');
	}

	function onReady() {
		if (typeof(opodo_header_pid) != 'undefined') highlightMenu(opodo_header_pid);
	}
