function voltar(){
	history.go(-1)
}
function activateMenu(nav) {
	/* currentStyle restricts the Javascript to IE only */
	if (document.getElementById(nav).currentStyle | 1) {  
		var navroot = document.getElementById(nav);
		
		/* Get all the list items within the menu */
		var lis=navroot.getElementsByTagName("LI");  
		for (i=0; i<lis.length; i++) {
			
		   /* If the LI has another menu level */
			if(lis[i].lastChild.tagName=="UL"){
			
				/* assign the function to the LI */
				lis[i].onmouseover=function() {	
				
				   /* display the inner menu */
				   this.lastChild.style.display="block";
				   //alert(this+" - block");
				}
				lis[i].onmouseout=function() {                       
				   this.lastChild.style.display="none";
				   //alert(this+" - none");
				}
			}
			//alert(lis[i].innerHTML);
		}
	}
}

function showElement(id) {
if(document.getElementById(id).style.display != 'block'){
		document.getElementById(id).style.display= 'block';
		document.getElementById(id).style.visibility = 'visible';
		document.getElementById(id).style.position = 'static';
	}else {
		document.getElementById(id).style.display= 'none';
		document.getElementById(id).style.visibility = 'hidden';
		document.getElementById(id).style.position = 'static';
	}
}
function inputHover (){
	//get all elements (text inputs, passwords inputs, textareas)
	var elements = document.getElementsByTagName('input');
	var j = 0;
	for (var i4 = 0; i4 < elements.length; i4++) {
		if((elements[i4].type=='text')||(elements[i4].type=='password')) {
			hovers[j] = elements[i4];
			++j;
		}
	}
	elements = document.getElementsByTagName('textarea');
	for (var i4 = 0; i4 < elements.length; i4++) {
		hovers[j] = elements[i4];
		++j;
	}
	//add focus effects
	for (var i4 = 0; i4 < hovers.length; i4++) {
		hovers[i4].onfocus = function() {this.className += "Hovered";}
		hovers[i4].onblur = function() {this.className = this.className.replace(/Hovered/g, "");}
	}
}



function getRefToDiv(divID,oDoc) {
	if( document.getElementById ) { return document.getElementById(divID); }
	if( document.all ) { return document.all[divID]; }
	if( !oDoc ) { oDoc = document; }
	if( document.layers ) {
		if( oDoc.layers[divID] ) {
			return oDoc.layers[divID];
		} else {
			for( var x = 0, y; !y && x < oDoc.layers.length; x++ ) {
				y = getRefToDiv(divID,oDoc.layers[x].document);
			}
			return y;
		}
	}
	return false;
}


function changeDisplay( elementId, setTo ) {
  var theElement;
  if( document.getElementById ) {
    //DOM
    theElement = document.getElementById( elementId );
  } else if( document.all ) {
    //Proprietary DOM
    theElement = document.all[ elementId ];
  }
  if( !theElement ) {
    /* The page has not loaded, or the browser claims to
    support document.getElementById or document.all but
    cannot actually use either */
    return;
  }
  //Reference the style ...
  if( theElement.style ) { theElement = theElement.style; }
  if( typeof( theElement.display ) == 'undefined' ) {
    //The browser does not allow us to change the display style
    //Alert something sensible (not what I have here ...)
    window.alert( 'Your browser does not support this' );
    return;
  }
  //Change the display style
  theElement.display = setTo;
}

function showDiv(divID_as_a_string) {
	var myReference = getRefToDiv(divID_as_a_string);
	
	myReference.style.display = 'block';
	
	if( !myReference ) { window.alert('Nothing works in this browser'); return; }
	if( myReference.style ) { myReference.style.visibility = 'visible'; } else {
		if( myReference.visibility ) { myReference.visibility = 'show'; } else {
			window.alert('Nothing works in this browser'); return; } }
}

function hideDiv(divID_as_a_string) {
	var myReference = getRefToDiv(divID_as_a_string);
	myReference.style.display = 'none';
	if( !myReference ) { window.alert('Nothing works in this browser'); return; }
	if( myReference.style ) { myReference.style.visibility = 'hidden'; } else {
		if( myReference.visibility ) { myReference.visibility = 'hide'; } else {
			window.alert('Nothing works in this browser'); return; } }
}


function changeDisplay(divID_as_a_string) {

	var myReference = getRefToDiv(divID_as_a_string);

    if (myReference.style.display =='none'){
    
    	showDiv(divID_as_a_string);
    	}
    else 	{
    
    	hideDiv(divID_as_a_string);
    }
}

function open_x(cod){
	j('#scroll').innerHTML = '<span id="loadingspan">Loading...</span>';
	x_open(cod);
}


window.onload= function(){
    /* pass the function the id of the top level UL */
    /* remove one, when only using one menu */
//    activateMenu('nav'); 
    activateMenu('categorias_catalogo'); 

}