/* Java Utiles */

function loadXML(xmlFile, cbFun){
	var xdoc;
	if(window.ActiveXObject && /Win/.test(navigator.userAgent)){
		
		xdoc = new ActiveXObject("Microsoft.XMLDOM");
		
		xdoc.async = false;
		xdoc.load(xmlFile);
		
		cbFun(xdoc);
		
		return true;
		
	}else if(document.implementation && document.implementation.createDocument){
		
		xdoc = document.implementation.createDocument("", "", null);
		xdoc.load(xmlFile);
		
		xdoc.onload = function(){
			cbFun(xdoc);
      	}
		
		return true;
	}else{
		return false;
	}
}
function regresaDatos(xdoc){
	var nodo = xdoc.getElementsByTagName('cuerpo')[0].getElementsByTagName('menu');
	var innerSec = "";
	var rer = "";
	setTD = document.getElementById('dMenu');
	erUL = document.createElement('ul');
	erUL.setAttribute("align", "center");
	erUL.setAttribute("id", "navega");
	for(var i = 0; i < nodo.length; i++){
		liCreate = document.createElement('li');
		erUL.appendChild(liCreate);
		
		if(nodo[i].attributes.getNamedItem("ref").value != ''){
			ref = "javascript:openWindow('" + nodo[i].attributes.getNamedItem("ref").value + "')";	
		}else{
			ref = "#";
		}
		
		aCreate = document.createElement('a');
		aCreate.setAttribute("href", ref);
		aCreate.style.width = nodo[i].attributes.getNamedItem("textWidth").value;
		var titleAtrib = nodo[i].attributes.getNamedItem("titulo").value;
		if(titleAtrib != ''){
			aCreate.innerHTML = titleAtrib;
		}else{
			aCreate.innerHTML = nodo[i].getElementsByTagName('imagen')[0].firstChild.nodeValue;
		}
		liCreate.appendChild(aCreate);
		
		seUL = document.createElement('ul');
		/*seUL.style.top = 'auto';
		seUL.style.left = 'auto';*/
		var widthOfItem =  nodo[i].attributes.getNamedItem("textWidth").value;
		liCreate.appendChild(seUL);
		for(var s = 0; s < nodo[i].getElementsByTagName('sub').length; s++){
			var nodeText = nodo[i].getElementsByTagName('sub')[s].firstChild.nodeValue;
			var attRef = nodo[i].getElementsByTagName('sub')[s].attributes.getNamedItem("ref").value;
			sLiCreate = document.createElement('li');
			seUL.appendChild(sLiCreate);
			
			if(attRef != ''){
				ref = "javascript:openWindow('" + attRef + "')";	
			}else{
				ref = "#";
			}
			
			seACreate = document.createElement('a');
			seACreate.setAttribute("href", ref);
			seACreate.style.width = widthOfItem;
			seACreate.innerHTML = nodeText;
			sLiCreate.appendChild(seACreate);
		}

	}
	setTD.appendChild(erUL);
}

function openWindow(strURL){
	location = strURL;
}

var state = 0;
function setNewUrl(URLStr, newSkin, wHeight){
	if(state != 0){
		setNewSkin('whit', wHeight);
	}
	
	if(newSkin == 1){
		if(state != 1){
			setNewSkin('green', wHeight);
		}
	}
	
	window.frames['info'].location = URLStr;
}
function setNewSkin(color, wHeight){
	var tabla = document.getElementsByTagName('table');
	var td = tabla[0].getElementsByTagName('td');
	/*for(var i = 0; i < td.length; i++){
		alert("No."+ (i+1) + ", " + td[i].innerHTML);
	}*/
	if(wHeight == 0){
		var myHeight = 510;
	}else{
		var myHeight = wHeight;
	}
	
	
	if(color == 'whit'){
		tabla[1].bgColor = "#FFFFFF";
		td[0].innerHTML = "<img src=\"image/pantilla_blanca/corner_03.jpg\">";
		td[1].style.background = "url('image/pantilla_blanca/line_top.jpg')";
		td[2].innerHTML = "<img src=\"image/pantilla_blanca/corner_05.jpg\">";
		td[3].style.background = "url('image/pantilla_blanca/line_left.jpg')";
		td[5].getElementsByTagName('img')[0].setAttribute("src", "image/logo.jpg");
		td[9].style.background = "url('image/pantilla_blanca/line_rigth.jpg')";
		td[10].innerHTML = "<img src=\"image/pantilla_blanca/corner_09.jpg\">";
		td[11].style.background = "url('image/pantilla_blanca/line_buttom.jpg')";
		td[12].innerHTML = "<img src=\"image/pantilla_blanca/corner_08.jpg\">";
		state = 0;
		var w = window.frames['info'].document.body.offsetWidth;
		//window.frames['info'].resizeTo(w, 510);
		document.getElementById('contenido').height = myHeight;
	}
	if(color == 'whit'){
		tabla[1].bgColor = "#FFFFFF";
		td[0].innerHTML = "<img src=\"image/productos/ezq_left_top.jpg\">";
		td[1].style.background = "url('image/productos/line_top.jpg')";
		td[2].innerHTML = "<img src=\"image/productos/ezq_right_top.jpg\">";
		td[3].style.background = "url('image/productos/line_left.jpg')";
		td[5].getElementsByTagName('img')[0].setAttribute("src", "image/logo_green.jpg");
		td[9].style.background = "url('image/productos/line_right.jpg')";
		td[10].innerHTML = "<img src=\"image/productos/ezq_left_bottom.jpg\">";
		td[11].style.background = "url('image/productos/line_bottom.jpg')";
		td[12].innerHTML = "<img src=\"image/productos/ezq_right_bottom.jpg\">";
		var w = window.frames['info'].document.body.offsetWidth;
		document.getElementById('contenido').height = myHeight;
		//alert(window.frames['info'].window.resizeTo(w, 950));
		state = 1;
	}
}
/* Funcion para Cambiar el Evento hover por over en
   la hoja de estilos por medio de onMouseOver y
   onMouseOut */
startList = function() {
	if (document.all && document.getElementById) {
		navRoot = document.getElementById("navega");
		for (i=0; i < navRoot.childNodes.length; i++) {			
			node = navRoot.childNodes[i];
			if (node.nodeName == "LI") {
				node.onmouseover = function() {					
					this.className += " over";
				}
				node.onmouseout = function() {
					this.className = this.className.replace(" over", "");
				}
			}
		}
 	}
}