function findChildTag(node, tagname) {
	if (!node) return null;
	for (var j=0; j<node.childNodes.length; j++) {
		var node2 = node.childNodes[j];
		if (node2.nodeName == tagname) {
			return node2;
		}
	}
	return null;
}

function prepareMenu() {
	/*
	var ua = navigator.userAgent.toLowerCase();
	var isOpera = ua.indexOf('opera') > -1;
	var isIE = !isOpera && ua.indexOf('msie') > -1;
	var isIE7 = !isOpera && ua.indexOf('msie 7') > -1;
	var isIE6 = isIE && !isIE7;
	*/

	navRoot = document.getElementById("nav");
	for (var i=0; i<navRoot.childNodes.length; i++) {
		var node = navRoot.childNodes[i];
		if (node.nodeName=="LI") {
			node.onmouseover = function() {
				this.className += " hover";
			}
			
			node.onmouseout=function() {
				this.className=this.className.replace("hover", "");
			}
			/*
			node = findChildTag(node, 'DIV');
			node = findChildTag(node, 'UL');

			if (!node) continue;
			for (var j=0; j<node.childNodes.length; j++) {
				var node2 = node.childNodes[j];
				if (node2.nodeName == 'LI') {
					node2.onmouseover = function() {
						this.className=this.className.replace("hover", "");
						this.className += " hover";
					}
					
					node2.onmouseout=function() {
						// this.className=this.className.replace("hover", "");
					}
				}
			}
			*/
		}
	}

	/* FIXING FUCKING Internet Explorer 7 !!! */
	var backimg = document.getElementById("backimg");
	if (backimg) {
		var back = 'company';
		switch (backimg.className) {
			case 'company':
				back = 'contact';
				break;
			case 'contact':
				back = 'company';
				break;
			case 'links':
				back = 'distributors';
				break;
			case 'distributors':
				back = 'links';
				break;
			default:
				back = backimg.className;
				break;
		}
				
		//var back = 'url(/nuevosite/assets/templates/rizobacter/images/backimg-'+back+'.jpg)';
		//backimg.style.background = back;
		//setTimeout(function() {backimg.style.background = back;}, 1000);
	}
}

	
window.onload = prepareMenu;


/*
if (screen.width <= 1024) {
	document.write('<style type="text/css">');
	document.write('#background { width: 1331px; }');
	document.write('</style>');
}
*/
