function setOptsTBus()
{
	document.getElementById('tbus').options[0].text='Buscando opciones...';
//	var a= document.getElementById('cSentido').options[document.getElementById('cSentido').selectedIndex].value;
	var a= document.getElementById('cSentido').value;
	var b= document.getElementById('tbus').options[document.getElementById('tbus').selectedIndex].value;

	if(a=='D')
	{
		document.getElementById('tbus').options[1].text='Seleccionar entre todos los orígenes';
		document.getElementById('tbus').options[2].text='Escribir el orígen';
		if(b == 0)
		{
			document.getElementById('p3').src='imagenes/blank.gif';
		}
		else if(b == 1)
			{
				document.getElementById('p3').src='imagenes/seleccionar_origen.gif';
			}
			else
				{
					document.getElementById('p3').src='imagenes/buscar_origen.gif';
				}
			}
			else if (a=='O')
				{
					document.getElementById('tbus').options[1].text='Seleccionar entre todos los destinos';
					document.getElementById('tbus').options[2].text='Escribir el destino';
					if(b == 0)
					{
						document.getElementById('p3').src='imagenes/blank.gif';
					}
					else if(b == 1)
						{
							document.getElementById('p3').src='imagenes/seleccionar_destino.gif';
						}
						else
							{
								document.getElementById('p3').src='imagenes/buscar_destino.gif';
							}
						}
						document.getElementById('tbus').options[0].text='';
					}
					function capaBlock(id)
					{
						if (document.layers) document.layers[''+id+''].display = "block"
						else if (document.all) document.all[''+id+''].style.display = "block"
							else if (document.getElementById) document.getElementById(''+id+'').style.display = "block"
							}

							function capaNone(id)
							{
								if (document.layers) document.layers[''+id+''].display = "none"
								else if (document.all) document.all[''+id+''].style.display = "none"
									else if (document.getElementById) document.getElementById(''+id+'').style.display = "none"
									}

									function testBus(index)
									{
										if(index>0)
										{
											var a= document.getElementById('tbus');
											var b= document.getElementById('cSentido').value;
//											var b= document.getElementById('cSentido').options[document.getElementById('cSentido').selectedIndex].value;

											if(a.options[index].value>0)
											{
												if(a.options[index].value == 1)
												{
													capaNone('tbus2');
													capaBlock('tbus1');
													if(b == 'D')
													{
														document.getElementById('p3').src='imagenes/seleccionar_origen.gif';
													}
													else
														{
															document.getElementById('p3').src='imagenes/seleccionar_destino.gif';
														}
													}
													else if(a.options[index].value == 2)
														{
															capaNone('tbus1');
															capaBlock('tbus2');
															if(b == 'D')
															{
																document.getElementById('p3').src='imagenes/buscar_origen.gif';
															}
															else
																{
																	document.getElementById('p3').src='imagenes/buscar_destino.gif';
																}
															}
														}
														else
															{
																document.getElementById('p3').src='imagenes/blank.gif';
															}

														}
														else
															{
																document.getElementById('p3').src='imagenes/blank.gif';
															}

														}

														function nuevoAjax()
														{
															var xmlhttp=false;
															try
															{
																xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
															}
															catch(e)
															{
																try
																{
																	xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
																}
																catch(E) { xmlhttp=false; }
															}
															if (!xmlhttp && typeof XMLHttpRequest!='undefined') { xmlhttp=new XMLHttpRequest(); }
															return xmlhttp;
														}

														function loadObj(act,selt)
														{
															var valor=document.getElementById("cSentido").value;
															var valorBack = valor;
															if(valor == '')
															{
																combo=document.getElementById("objetivo");
																combo.length=0;
																var nuevaOpcion=document.createElement("option"); nuevaOpcion.value=0; nuevaOpcion.innerHTML="Seleccione Sentido...";
																combo.appendChild(nuevaOpcion);	combo.disabled=true;
															}
															else
																{
																	ajax=nuevoAjax();
																	ajax.open("GET", "../gen_combo.php?valor="+valorBack+'&act='+act,true);
																	ajax.onreadystatechange=function()
																	{
																		if (ajax.readyState==1)
																		{
																			combo=document.getElementById("objetivo");
																			combo.length=0;
																			var txtOpt = valorBack == 'D'?'Buscando orígenes...':'Buscando destinos...';
																			var nuevaOpcion=document.createElement("option"); nuevaOpcion.value=0; nuevaOpcion.innerHTML=txtOpt;
																			combo.appendChild(nuevaOpcion);
																			combo.disabled=false;
																		}
																		if (ajax.readyState==4)
																		{
																			if(ajax.responseXML.documentElement==null)
																			{
																				var  doc = new ActiveXObject("Msxml2.DOMDocument.3.0");
																				doc.async = false;
																				doc.loadXML(ajax.responseText);
																			}
																			else
																				{
																					var doc=ajax.responseXML;
																				}

																				var texto, valor, selected, nuevaOpcion;
																				var opts=doc.getElementsByTagName('opcion');

																				if(opts.length>0)
																				{
																					combo.length=0;
																					var nuevaOpcion=document.createElement("option"); nuevaOpcion.value=0;

																					if(valorBack ==  'D')
																					{
																						nuevaOpcion.innerHTML="Seleccione orígen";
																					}
																					else
																						{
																							nuevaOpcion.innerHTML="Seleccione destino";
																						}

																						combo.appendChild(nuevaOpcion);

																						for (i = 0; i < opts.length; i++)
																						{
																							var opt= opts[i];
																							texto = opt.getElementsByTagName('texto')[0].firstChild.data;
																							valor = opt.getElementsByTagName('id')[0].firstChild.data;
																							nuevaOpcion=document.createElement("option");
																							nuevaOpcion.value=valor;
																							nuevaOpcion.innerHTML=texto;
																							if(selt == valor)
																							{
																								nuevaOpcion.selected=true;
																							}
																							combo.appendChild(nuevaOpcion);
																						}
																					}
																					else
																						{
																							combo.length=0;
																							var nuevaOpcion=document.createElement("option"); nuevaOpcion.value=0; nuevaOpcion.innerHTML="-Sin Resultados-";
																							combo.appendChild(nuevaOpcion);
																						}
																					}
																				}
																				ajax.send(null);
																			}
																		}


																		function loadSuggest(act,selt)
																		{
//																		var valor=document.getElementById("cSentido").options[document.getElementById("cSentido").selectedIndex].value;
																			var valor=document.getElementById("cSentido").value;
																			var valorBack = valor;

																			var let=document.getElementById("let").value;

																			if(let == '')
																			{
																				return true;
																			}
																			else
																				{
																					capaBlock('searchResults');
																					ajax=nuevoAjax();
																					ajax.open("GET", "../gen_suggest.php?valor="+valorBack+'&act='+act+'&let='+let,true);
																					ajax.onreadystatechange=function()
																					{

																						if (ajax.readyState==4 && ajax.status == 200)
																						{
																							var response = ajax.responseText;
																							document.getElementById("searchResults").innerHTML =  response;

																						}
																					}
																					ajax.send(null);
																				}
																				return true;
																			}
