//Variables que indican si el usuario quiere ir a vullanar fijando el origen o el destino
var urlVullAnar = "";
var origen = false;
function getUtms(){
	var x = findObj('index');
	x.TCallFrame("/", 75);
}
				
function mostrarInfoOrigen(idioma,descripcion,origenx,origeny,mensaje,mensaje2)
{
urlVullAnar = "/vullanar/"+idioma+"/vullanar.jsp";
	      if (confirm(mensaje))
         {
         	document.location=urlVullAnar + "?equipamentonsoc1="+descripcion + "&origenx="+origenx+"&origeny="+origeny;
         }
   		else {
   			origen = true;
   			urlVullAnar += "?equipamentonsoc1="+mensaje2;
   			getUtms();
   		}   
}

function mostrarInfoDestino(idioma,descripcion,destix,destiy,mensaje,mensaje2)
{
urlVullAnar = "/vullanar/"+idioma+"/vullanar.jsp";
	
	      if (confirm(mensaje))
         {
         	document.location=urlVullAnar + "?equipamentonvullanar1="+descripcion + "&destix="+destix+"&destiy="+destiy;
         }
   		 else {
   		 	origen = false;
   		 	urlVullAnar += "?equipamentonvullanar1="+mensaje2;
 			getUtms();
   		 	}   
}

function getPuntMapa(x,y) {
if (origen) 
urlVullAnar +="&origenx="+x+"&origeny="+y;
else
urlVullAnar +="&destix="+x+"&destiy="+y;
document.location=urlVullAnar;
}

      	function findObj(n, d) 
        {
          var p,i,x;  
          if(!d) d=document; 
          if( (p=n.indexOf("?")) > 0 && parent.frames.length) 
          {
	        	d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);
        	}
          if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
          for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=findObj(n,d.layers[i].document);
          if(!x && document.getElementById) x=document.getElementById(n); 
          return x;
        }
        
 function index_DoFSCommand(command, args) {
	// Gestionar todos los mensajes de FSCommand de una película Flash
	var indexObj = isInternetExplorer ? document.all.index : document.index;
 
 	var xmlDoc
	
	if(isInternetExplorer){
		xmlDoc = new ActiveXObject("Msxml2.DOMDocument.3.0"); 
		xmlDoc.async = false;
	}
	else if (document.implementation && document.implementation.createDocument) {
	   xmlDoc=document.implementation.createDocument("ns", "root", null);
	   //add the loadXML() method to the Document class
           //var parser = new DOMParser();
           //xmlDoc = parser.parseFromString(args,"text/xml");
	     		Document.prototype.loadXML = function(strXML) {
        
    		//create a DOMParser
    		var objDOMParser = new DOMParser();
        	
    		//create new document from string
    		var objDoc = objDOMParser.parseFromString(strXML, "text/xml");
		
			//make sure to remove all nodes from the document
			while (this.hasChildNodes())
				this.removeChild(this.lastChild);

			//add the nodes from the new document
			for (var i=0; i < objDoc.childNodes.length; i++) {
            
			  //import the node
  			  var objImportedNode = this.importNode(objDoc.childNodes[i], true);
            
			  //append the child to the current document
			  this.appendChild(objImportedNode);
        
			} //End: for
	  } //End: function
	}
	else
	{
	alert('Your browser cannot handle this script');
	}
	xmlDoc.loadXML(args);	
	if(command=="refrescaLineasBus") {
		var x = findObj('lineasBus');
		var lin = xmlDoc.getElementsByTagName("LINIA");
		var out = "<table width=100% border=0 cellspacing=0 cellpadding=0>";
		if (args != ""){
			for (i=0; i < lin.length; i++)
			{
				var codi = lin.item(i).getAttribute("NOM");
				var op = lin.item(i).getAttribute("OP");
				if ((i%3) ==0){
					out +="</tr><tr height=15>"
				}
				out += "<td><a href=javascript:abrirVentanaBus('/"+idioma+"/barcelona/moute/planols/infolinia.jsp?codi_linia=" + codi +"&codi_operador="+op+"') class=txtgrisosc_gral><img src=/img/icon_adelante.gif width=7 height=7 border=0> " + codi+"</a></td>";
			}
		}
		out+="</table>"
		x.innerHTML = out;
	} else if(command=="refrescaLineasMetro") {
		var y = findObj('lineasMetro');
		var z = findObj('lineasAltres');
		var linMetro = xmlDoc.getElementsByTagName("LINIA");
		out = "";
		outz = "";
		if (args != ""){
		for (i=0; i < linMetro.length; i++)
		{
				var codi = linMetro.item(i).getAttribute("NOM");
				var op = linMetro.item(i).getAttribute("OP");
				if ('001' == op)
					out += "<a href=\"javascript:abrirVentanaMetro('/"+idioma+"/barcelona/moute/planols/infolinia.jsp?codi_linia="+codi+"&codi_operador="+op+"')\"><img src=\"/onsoc/img/"+op+codi+".gif\" border=0></a>&nbsp;";
				else
					outz += "<a href=\"/"+idioma+"/barcelona/moute/planols/infolinia.jsp?codi_linia="+codi+"&codi_operador="+op+"\" target=\"_blank\"><img src=\"/onsoc/img/"+op+codi+".gif\" border=0></a>&nbsp;";
		}
		}
		y.innerHTML = out;
		z.innerHTML = outz;
	}
	else {
	alert ("command desconocido");
	}
}
