var tiempo = 0;
startList = function() {
if (document.all&&document.getElementById) {
navRoot = document.getElementById("nav");
for (i=0; i<navRoot.childNodes.length; i++) {
node = navRoot.childNodes[i];
clearTimeout(tiempo);
node.style.display == "none";
if (node.nodeName=="LI") {
node.onmouseover=function() {


this.className+=" over";
  }
  node.onmouseout=function() {
  this.className=this.className.replace(" over", "");
   }
   }
  }
 }
}
window.onload=startList;

function TrimLeft( str ) {
	var resultStr = "";
	var i = len = 0;
	// Return immediately if an invalid value was passed in
	if (str+"" == "undefined" || str == null) 
	return null;
	// Make sure the argument is a string
	str += "";
	if (str.length == 0) 
		resultStr = "";
		else { 
		// Loop through string starting at the beginning as long as there
		// are spaces.
		// len = str.length - 1;
		len = str.length;
		
		while ((i <= len) && (str.charAt(i) == " "))
		i++;
		// When the loop is done, we're sitting at the first non-space char,
		// so return that char plus the remaining chars of the string.
		resultStr = str.substring(i, len);
	}
	return resultStr;
}
function TrimRight( str ) {
	var resultStr = "";
	var i = 0;
	// Return immediately if an invalid value was passed in
	if (str+"" == "undefined" || str == null) 
		return null;
		// Make sure the argument is a string
	str += "";
	
	if (str.length == 0) 
		resultStr = "";
		else {
		// Loop through string starting at the end as long as there
		// are spaces.
		i = str.length - 1;
		while ((i >= 0) && (str.charAt(i) == " "))
		i--;
		
		// When the loop is done, we're sitting at the last non-space char,
		// so return that char plus all previous chars of the string.
		resultStr = str.substring(0, i + 1);
	}
	
	return resultStr; 
}

function Trim( str ) {
	var resultStr = "";
	
	resultStr = TrimLeft(str);
	resultStr = TrimRight(resultStr);
	
	return resultStr;
}

function valNewTemp() {
 var	retorno = '';
 with(document.forms[0]) {
		if (Trim(rotulo.value) == "")  {
		  retorno = false;
		  alert('Debe asignar un rótulo a la opción');
		  
		}
		if (Trim(idMenu.options[idMenu.selectedIndex].value) == "" && retorno != false) {
		  retorno = false;
		  alert('Por favor, asigne a que elemento de menú va asociado');
		  
		}
		
		if (retorno != false) {
			retorno = true;
		}
	 
   }
	return retorno;
}

//modificar un parametro de una clase
function noBlock(n) {
	x = 0;
	switch(n) {
		case 1: x = 2; break;
		case 2: x = 3; break;
		case 3: x = 5; break;
		case 5: x = 4; break;
	}
	if 	(x > 1) {

		document.getElementById("nav"+x).style.display = "none"
	}
		
}

function apBlock(n) {
	noBlock(n);
	x = 0;
	
	switch(n) {
		case 1: x = 2; break;
		case 2: x = 3; break;
		case 3: x = 5; break;
		case 5: x = 4; break;
	}
	if 	(x > 1) {
		
		document.getElementById("nav"+x).style.display = "block";

	}

}

function siBlock(n) {
	segundos= 1.1;
	hayCapa = false;
	clearTimeout(tiempo);

	 /*for (i=1;i<6;i++) {
      if (n != i) {
		  if (document.getElementById("nav"+i).style.display == "block") {
			  hayCapa = true;
		  }

	 }
	} */
		

			tiempo = setTimeout("apBlock("+n+")", segundos*1000);
			
	
}


function CreaXHR()
{
  var ref = false;

  try { // Procedimiento para crear un objeto
   // XMLHttpRequest compatible entre distintos
   ref = new ActiveXObject('Msxml2.XMLHTTP');
  } catch (e1) { // navegadores Web
   try {
     ref = 
        new ActiveXObject('Microsoft.XMLHTTP');
     }  catch (e2) {
     objXML = false;
   }
  }

  if (!ref && (typeof XMLHttpRequest != 'undefined' || window.XMLHttpRequest))  ref = new XMLHttpRequest();  

  return ref;
 }
  
function CargaRep()  {
 num = document.getElementById('orden').value;
 divListado = document.getElementById("error");
 ajax = CreaXHR();
 ajax.open("GET", "/pruebas/gestion/existe.asp?n="+num);
 ajax.onreadystatechange = function() {
		  if (ajax.readyState == 4) {
			   divListado.innerHTML = ajax.responseText;
			   document.forms[0].submit = false;
		  }
   }
  ajax.send(null);
} 
