function horizontal() { 

   var navItems = document.getElementById("barra").getElementsByTagName("li"); 
    
   for (var i=0; i< navItems.length; i++) { 
      if ((navItems[i].className.indexOf("menuvertical") != -1) || (navItems[i].className.indexOf("submenu") != -1)) { 
         if (navItems[i].getElementsByTagName('ul')[0] != null) { 

            navItems[i].onmouseover=function() {
								this.getElementsByTagName('a')[0].style.backgroundColor="transparent";
								if (this.className.indexOf("mapas_escolares") != -1) this.style.backgroundColor = "#e27c1c";
								if (this.className.indexOf("mapas_uso_geral") != -1) this.style.backgroundColor = "#006ab6";
								if (this.className.indexOf("mapas_especialistas") != -1) this.style.backgroundColor = "#00914d";
								this.getElementsByTagName('ul')[0].style.display="block";
								
								janela = alertX();
								if (getX(this.getElementsByTagName('ul')[0])>janela-210) {
										uls = this.getElementsByTagName('ul')[0].getElementsByTagName('ul');
										for (j=0; j<uls.length; j++) {
												uls[j].style.position = "absolute";
												uls[j].style.left = "-150px";
										}
								}
								
						} 
            navItems[i].onmouseout=function() {this.getElementsByTagName('ul')[0].style.display="none";this.style.backgroundColor = "#668da8";} 
         }
      }
   } 
} 

function alertX() {
	var myWidth = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
  } else if( document.documentElement && document.documentElement.clientWidth ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
  } else if( document.body && document.body.clientWidth ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
  }
	return myWidth;
}

function getX(obj) {
	var curleft = 0;
	if (obj.offsetParent) {
		do {
			curleft += obj.offsetLeft;
		} while (obj = obj.offsetParent);
	}
	return curleft;
}

window.onresize = alertX;
