/* Modified version */

				var section = "none";
				var x;
				var resetTimer;

				function init() {
					nav(section);
				}

				function nav(currentSection) {

					if (!window.documentLoaded)
						return false;

					clearReset();
					for (x = 0; x < sections.length; x++) {
						/* section images */
						if (document.getElementById("nav_" + sections[x]))
							document.getElementById("nav_" + sections[x]).src = document.getElementById("nav_" + sections[x]).src.split("_on").join("").split(".gif").join("") + ((currentSection == sections[x]) ? "_on.gif" : ".gif");
						/* subnav */
						if (document.getElementById("subnav_" + sections[x]))
							document.getElementById("subnav_" + sections[x]).style.display = ((currentSection == sections[x]) ? "block" : "none");
					}
				}

				function navReset() {
					//starts the timer to reset nav
					resetTimer = setTimeout("nav(section)", 750);
				}

				function clearReset() {
					clearTimeout(resetTimer);
				}

				function elementPositions(obj, name) {

					var width = obj.offsetWidth;
					var height = obj.offsetHeight;

					var curleft = curtop = 0;
					if (obj.offsetParent) {
						curleft = obj.offsetLeft
						curtop = obj.offsetTop
						while (obj = obj.offsetParent) {
							curleft += obj.offsetLeft
							curtop += obj.offsetTop
						}
					}

					return [curleft,curtop,width,height];
					
				} //

				function setMenusInContainer( section ){

					var subnavElement = document.getElementById("subnav_" + section);

					if (!subnavElement)
						return;

					with (subnavElement.style){

						position = "absolute";
						left = "-1000px";
						top = "-1000px";
						display = "block";

					} // with

					var subnavOptions = elementPositions( subnavElement, "subnav_" + section );
					subnavElement.style.display = "none";

					var navOptions = elementPositions( document.getElementById("nav") , "nav");
					var imageOptions = elementPositions( document.getElementById("nav_" + section),  "nav_" + section);

					var subnavWidth = parseInt ( subnavOptions[2] );
					var imageLeft = parseInt ( imageOptions[0] );
					var navRightBorder = parseInt( navOptions[0] ) + parseInt( navOptions[2] );

					var xSetPosition = 0;
					var ySetPosition = 0;

					if ( (imageLeft + subnavWidth) > navRightBorder ){
						xSetPosition = navRightBorder - subnavWidth - 75; // 75 - offset from the last image to the right border
					} else {
						xSetPosition = imageLeft;
					}

					with (subnavElement.style) {
						position = "absolute";
						left = xSetPosition + "px";
						top = ySetPosition + "px";

					} // with

					return;

				} // function

				function setMenuPositions() {

					if (!window.sections)
						return;

					for (var i = 0; i < window.sections.length; i++){
						setMenusInContainer(window.sections[ i ]);

					} // for

					return;

				} 

				window.documentLoaded = false;

				/**
				 * Should be executed when the page is loaded
				 */
				function windowOnLoad() {

					window.documentLoaded = true;
					setMenuPositions();
					correctUntispam();


					/**
					 * Fix the firefox problems with vertical alignment.
				 	 */

					if (window.navigator.userAgent.indexOf("Firefox") >= 0) {
						var imgElem;
						for (x = 0; x < sections.length; x++) {
							/* section images */
							if (imgElem = document.getElementById("nav_" + sections[x]))
									imgElem.style.verticalAlign = "top";
	
						} // for

					} // if we are in firefox

					// And to perform replacement after modificatons made by other js
					setTimeout("correctUntispam();", 500);

					if (window.afterPageLoad)
						window.afterPageLoad();

					clearReset(); 
					navReset();

				} // function

// Dummy emails corrections

				if (!window.nodeType){
					window.nodeType = {
						ELEMENT_NODE: 1,
						ATTRIBUTE_NODE: 2,
						TEXT_NODE: 3,
						CDATA_SECTION_NODE: 4,
						ENTITY_REFERENCE_NODE: 5,
						ENTITY_NODE: 6,
						PROCESSING_INSTRUCTION_NODE: 7,
						COMMENT_NODE: 8,
					 	DOCUMENT_NODE: 9,
						DOCUMENT_TYPE_NODE: 10,
						DOCUMENT_FRAGMENT_NODE: 11,
						NOTATION_NODE: 12

					};

				} // if

				function containsDummyEmail( value ){

//					var mailRe = '[a-zA-Z0-9_\\-]+\\(at\\)([a-zA-Z0-9\\-]+\\(dot\\))+[a-zA-Z0-9]{2,8}';
					var mailRe = '[a-zA-Z0-9_\\-]+&#64;([a-zA-Z0-9\\-]+&#46;)+[a-zA-Z0-9]{2,8}';

					var re = new RegExp(mailRe);
					return value.match(re);

				}

				function replaceDummyMail( value ){

//					var mailRe = '[a-zA-Z0-9_\\-]+\\(at\\)([a-zA-Z0-9\\-]+\\(dot\\))+[a-zA-Z0-9]{2,8}';
					var mailRe = '[a-zA-Z0-9_\\-]+&#64;([a-zA-Z0-9\\-]+&#46;)+[a-zA-Z0-9]{2,8}';

					var re = new RegExp(mailRe);
					var matches;

					matches = value.match(re);

					if (!matches)
						return value;

					var corrected = matches[0].replace("&#64;", "@");
					corrected = corrected.replace(/&#46;/g, ".");
					
					value = value.replace( matches[0], corrected );

					return value;

				} // function

				/**
				 * Replace dummy mail account(at)subsubdomain(dot)subdomain(dot)domain
				 * in mailto links to account@subsubdomain.subdomain.domain
				 */
				function correctUntispam(){

					// Correct all textnodes
					textNodesRunner( textNodeHandler, document.getElementsByTagName("body")[0] );

					// Correct all mailto: links
					if (!document.links)
						return;

					var i;
					for (i = 0; i < document.links.length; i++){

						if (document.links[i].protocol.toLowerCase() == 'mailto:'){

							if (containsDummyEmail( document.links[i].href )){
								document.links[i].href = 'mailto:' + replaceDummyMail( document.links[i].href );

							} // if

						} // if

					} // for

					// Correct all input elements
					var allInputs = document.getElementsByTagName("input");

					for (i = 0; i < allInputs.length; i++){
						if (allInputs[i].value && (allInputs[i].value.length > 0)) {
							if (containsDummyEmail( allInputs[i].value )){
								allInputs[i].value = replaceDummyMail( allInputs[i].value );
							} // if

						} // if

					} // for

					return;

				} // function

				/**
				 * Used to replace dummy emails to real emails in text nodes.
				 */
				function textNodeHandler( data ){

					data = replaceDummyMail( data );
					return data;
					
				} // function

				function textNodesRunner( functionToPerform, rootNode ){

					for (var i = 0; i < rootNode.childNodes.length; i++) {
						if (window.nodeType.ELEMENT_NODE == rootNode.childNodes[i].nodeType){
							textNodesRunner( functionToPerform, rootNode.childNodes[i] );
						} // if
						else if (window.nodeType.TEXT_NODE == rootNode.childNodes[i].nodeType){
							rootNode.childNodes[i].data = functionToPerform(rootNode.childNodes[i].data);
						} // if

					} // for

				} // function

				// Dummy emails corrections

				window.onload = windowOnLoad;
				window.onresize = setMenuPositions;

