	function Browser(){
	  this.dom = document.getElementById?1:0;
	  this.ie4 = (document.all && !this.dom)?1:0;
	  this.ns4 = (document.layers && !this.dom)?1:0;
	  this.ns6 = (this.dom && !document.all)?1:0;
	  this.ie5 = (this.dom && document.all)?1:0;
	  this.ok = this.dom || this.ie4 || this.ie5;
	  this.platform = navigator.platform;
	}
	var browser = new Browser();	


	var xmlLoadXML=false,idoutConXML = null;		

	var xmlDXML,xmlhXML;

	var prefixes = ["MSXML2", "Microsoft", "MSXML", "MSXML3"];
	var prefixIE = ""

	var pagNoXML = "";

	strNIE = navigator.appName
	if(strNIE.toUpperCase().indexOf("MICROSOFT")!=-1){
		strNIE="<script language='javascript'>"
	    strNIE+= "for(var i=0;i<prefixes.length;i++)"
	    strNIE+="try {"
		strNIE+="xmlDXML = new ActiveXObject(prefixes[i] + '.XMLDOM');"
		strNIE+="prefixIE = prefixes[i];"
		strNIE+="break;"
	 	strNIE+="} catch (e) {"
	  	strNIE+="}"
	  	strNIE+="</script>"
	  	document.write(strNIE);
	 }

	function iXML(pagina, pagNoXMLtmp){																												
		
		if(xmlLoadXML)return		
		clearTimeout(idoutConXML);				
	 	if(!gDomXML()){
			document.location.href=pagNoXMLtmp;
		}else{													
			if(xmlLoadXML)return
			xmlLoadXML = true;																		
			idoutConXML = setTimeout("connectionTimeOut()",10000);																							
			xmlhXML.open("GET",pagina);
			xmlhXML.send(null);
			window.location.replace('#arriba')
		}		
	}

	function gDomXML(){
		if (document.implementation && document.implementation.createDocument){
			xmlhXML=new XMLHttpRequest();
			xmlhXML.onload=gestionaXML;

			xmlDXML=document.implementation.createDocument("","root",null);
			Document.prototype.loadXML = function(strXML) {    //generamos una emulacion del loadxml
	        this.readyState=1;
	        var objDOMP=new DOMParser();
	        var objDoc = objDOMP.parseFromString(strXML,"text/xml");
	        while(this.hasChildNodes())
	            this.removeChild(this.lastChild);
	        for (var i=0;i<objDoc.childNodes.length;i++) {
	            var objNode=this.importNode(objDoc.childNodes[i],true);
	            this.appendChild(objNode);
	        }
	        if (!objDoc.documentElement || objDoc.documentElement.tagName=="parsererror")
	        	this.parseError=1;
	        else
	        	this.parseError=0;

	        this.readyState=4;
		   }
		   return true
		}
		else
			if (window.ActiveXObject && prefixIE!=""){
				xmlDXML = new ActiveXObject(prefixIE + ".XMLDOM");
				xmlhXML = new ActiveXObject(prefixIE + ".XmlHttp");
		        xmlhXML.onreadystatechange=tmpXML;
		        return true
	 		}	
	    return false	
	}

	function gestionaXML(){										
		var divCONTENIDO = new div ("divcontenido", "")
		clearTimeout(idoutConXML);	 		 			 			 					
 		divCONTENIDO.escribeDiv(xmlhXML.responseText); 		 		
 		xmlLoadXML = false; 	 					
	}

	function tmpXML(){
		if (xmlhXML.readyState==4) gestionaXML();
	}					

	function connectionTimeOut(){
		clearTimeout(idoutConXML);				
		document.location.href=pagNoXML;
		xmlLoadXML=false;			
	}		
	
	function div(nombre, imgRef){

		if (browser.ns4){
	    	var tmpLayer = new Layer(127);
	  	}
	 	if (browser.dom || browser.ie4){
			var tmpLayer = browser.dom?document.getElementById(nombre):document.all(nombre);
	  	}   	 	
	 	this.containerLayer = tmpLayer;	   
	  	this.escribeDiv = escribeDiv;
	}
	
	function escribeDiv(str){
		if (browser.ie4)
			this.containerLayer.innerHTML = str;
		else
			if (browser.dom)
				this.containerLayer.innerHTML = str;
			else
				if(browser.ns4){
					this.containerLayer.document.open();
					this.containerLayer.document.write(str);
					this.containerLayer.document.close();
				}
	}
	
	
	function generaXML(formName, nivel){		
		var formu = document.forms[formName]										
		if(formu.xml.value == "1"){
			var str = ""
			for(i=0;i<formu.length;i++){
	switch(formu[i].type){
					case "text":				
						str += "&" + formu.elements[i].name + "=" + formu.elements[i].value
						break;
					case "password":				
						str += "&" + formu.elements[i].name + "=" + formu.elements[i].value
						break;
					case "radio":		
						if(formu.elements[i].checked)		
							str += "&" + formu.elements[i].name + "=" + formu.elements[i].value
						break;
					case "select-one":
						str += "&" + formu.elements[i].name + "=" + formu.elements[i].options[formu.elements[i].selectedIndex].value
						break;
					case "select-multiple":					
						selOpt = ""
						for(j=0;j<formu.elements[i].options.length;j++){
							if(formu.elements[i].options[j].selected)
								selOpt += formu.elements[i].options[j].value + ", "
						}
						if(selOpt != "")
							str += "&" + formu.elements[i].name + "=" + selOpt;
						break;
					case "hidden":					
						str += "&" + formu.elements[i].name + "=" + formu.elements[i].value					
						break;
					case "textarea":					
						str += "&" + formu.elements[i].name + "=" + formu.elements[i].value					
						break;
				}
			}										
																
			iXML(nivel + str + "&xml=1", "home.php?nivel=" + nivel + str);	
			//alert(nivel + str)
		}else
			formu.submit();
	}


