  var xmlhttp = null
	var numRows = 0
	var currentService = null
	var currentElement = null
	var currentTrip = null
	var trip1 = ""
	var trip2 = ""
	var tripLink = ""
	
	var origin = ""
	var originId = ""
	var originCoordX = ""
	var originCoordY = ""
	var originCoordName = ""

	var dest = ""
	var destId = ""
	var destCoordX = ""
	var destCoordY = ""
	var destCoordName = ""
	
	var selectedTrips = new Array();
	
	function loadLocationXMLDoc(e,element,service,trip) {		
		if (element.value.length >= 4) {
			if (element.value != '' && e.keyCode != 38 && e.keyCode != 40 && e.keyCode != 13) {
				currentService = service
				currentElement = element
        currentTrip = trip
				
				xmlhttp=null
				xmlhttp = (window.XMLHttpRequest)? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP") ;
				if (xmlhttp!=null) {
					xmlhttp.onreadystatechange=onLocationResponse					
					xmlhttp.open("GET","custom/getJourneyPlannerData.aspx?searchString=" + escape(element.value) + "&service=" + service + "",true)
					xmlhttp.send(null)
				} else {
					alert("Your browser does not support XMLHTTP.")
				}
			}
		} else {
			hideLocations(true)
		}
	}
	
	function loadTripXMLDoc(url) {							
		xmlhttp=null
		xmlhttp = (window.XMLHttpRequest)? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP") ;
		if (xmlhttp!=null) {
			xmlhttp.onreadystatechange=onTripResponse					
			xmlhttp.open("GET",url,true)
			xmlhttp.send(null)
		} else {
			alert("Your browser does not support XMLHTTP.")
		}
	}
	
	function checkReadyState() {
		if (xmlhttp != null) {
			if (xmlhttp.readyState == 4) {
				// if "OK"
				if (xmlhttp.status == 200) {
					return true
				} else {
					return false
				}
			} else {
				return false
			}
		} else {
			return false
		}
	}

	function onLocationResponse() {	
		var loaded = checkReadyState()
		
	  if (loaded) {
		  var response = xmlhttp.responseXML.documentElement;

			if (response != null) {
				if (currentElement != null) {
				  var output = '<table width="100%" cellpadding="2" cellspacing="0" border="0">'

					var arr = new Array();
					arr = response.getElementsByTagName("*");
          
          var i
					for (i = 0; i < arr.length; i++) {
					  var tagName = response.getElementsByTagName("*").item(i).nodeName;

            locations = response.getElementsByTagName("*").item(i).attributes

						output += '<tr>'

						try {
						  output += '<td style="text-align:left; cursor:pointer;" valign="top" onclick="javascript:selectLocation(\'' + i + '\')" id="td_' + i + '" onmouseover="rowOver(' + i + ')">' + locations.getNamedItem("name").nodeValue + ''
							
						  if (currentElement.name == "txtOrigin" + currentTrip) {
						    output += '<span id="origin' + i + '_' + currentTrip + '" style="display:none;">' + locations.getNamedItem("name").nodeValue + '</span>'
						    output += '<span id="spanOriginCoordX' + i + '_' + currentTrip + '" style="display:none;">' + locations.getNamedItem("x").nodeValue + '</span>'
						    output += '<span id="spanOriginCoordY' + i + '_' + currentTrip + '" style="display:none;">' + locations.getNamedItem("y").nodeValue + '</span>'
						    output += '<span id="spanOriginCoordName' + i + '_' + currentTrip + '" style="display:none;">' + locations.getNamedItem("name").nodeValue + '</span>'
						    output += '<span id="spanOriginId' + i + '_' + currentTrip + '" style="display:none;">' + locations.getNamedItem("id").nodeValue + '</span>'
							}

						  if (currentElement.name == "txtDestination" + currentTrip) {
						    output += '<span id="dest' + i + '_' + currentTrip + '" style="display:none;">' + locations.getNamedItem("name").nodeValue + '</span>'
						    output += '<span id="spanDestCoordX' + i + '_' + currentTrip + '" style="display:none;">' + locations.getNamedItem("x").nodeValue + '</span>'
						    output += '<span id="spanDestCoordY' + i + '_' + currentTrip + '" style="display:none;">' + locations.getNamedItem("y").nodeValue + '</span>'
						    output += '<span id="spanDestCoordName' + i + '_' + currentTrip + '" style="display:none;">' + locations.getNamedItem("name").nodeValue + '</span>'
						    output += '<span id="spanDestId' + i + '_' + currentTrip + '" style="display:none;">' + locations.getNamedItem("id").nodeValue + '</span>'
							}

						  output += '</td>'

						}
						catch (er) {
						  output += '<td> </td>'
						}

						output += '</tr>'

					}
					
					numRows = i

					output += '</table>'
				
					xmlhttp=null

					var elmPos = getElementPosition(currentElement)
					
					document.getElementById('xmldiv').style.left = elmPos.left + 'px'
					document.getElementById('xmldiv').style.top = (elmPos.top + 25) + 'px'
					document.getElementById('xmldiv').style.visibility = "visible"
					document.getElementById('xmldiv').innerHTML = output
					
					return false;
					
					rowOver(0)
				}
			}
	  }
	}
	
	function onTripResponse() {
		var loaded = checkReadyState()
		
	  if (loaded) {
	  	var response = xmlhttp.responseXML.documentElement;

	  	if (response != null) {
	  	  var trip = response.getElementsByTagName("Trip")
	  	  var t

	  	  var originTime = ""
	  	  var originName = ""
	  	  var destinationTime = ""
	  	  var destinationName = ""
	  	  var tripInfo = ""

	  	  var legInfo = ""
	  	  var legInfo2 = ""
	  	  var legInfo3 = ""
	  	  var backgroundColor = ""
	  	  var checked = ""

	  	  if (trip.length > 0) {
	  	    var output = '<table width="100%" cellpadding="0" cellspacing="0" border="0">'
	  	    output += '	<tr>'
	  	    output += '		<td colspan="4"><img src="custom/design/blank1x1.gif" alt="" style="border:0px; height:5px; width:1px;"></td>'
	  	    output += '	</tr>'
	  	    output += '	<tr>'
	  	    output += '		<td style="width:25px;" valign="top"></td>'

					if (currentTrip.indexOf("_1") > -1) {
	  	      output += '		<td colspan="3"><b>Vælg ønskede udrejse:</b></td>'
	  	    } else if (currentTrip.indexOf("_2") > -1) {
	  	      output += '		<td colspan="3"><b>Vælg ønskede hjemrejse:</b></td>'
	  	    }

	  	    output += '	</tr>'
	  	    output += '	<tr>'
	  	    output += '		<td colspan="4"><img src="custom/design/blank1x1.gif" alt="" style="border:0px; height:10px; width:1px;"></td>'
	  	    output += '	</tr>'
	  	    output += '	<tr>'
	  	    output += '		<td style="width:25px;" valign="top"></td>'
	  	    output += '		<td style="width:100px;"><b>Kl.:</b></td>'
	  	    output += '		<td style="width:250px;"><b>Start/Stop:</b></td>'
	  	    output += '		<td><b>Transportform:</b></td>'
	  	    output += '	</tr>'
	  	    output += '	<tr>'
	  	    output += '		<td colspan="4"><img src="custom/design/blank1x1.gif" alt="" style="border:0px; height:10px; width:1px;"></td>'
	  	    output += '	</tr>'
	  	    output += '</table>'

	  	    output += '<table width="100%" cellpadding="0" cellspacing="0" border="0">'
	  	    output += '	<tr>'
	  	    output += '		<td colspan="2">'

	  	    for (t = 0; t < trip.length; t++) {
	  	      var leg = trip[t].getElementsByTagName("Leg")
	  	      var l

	  	      for (l = 0; l < leg.length; l++) {
	  	        var lega = leg[l].attributes
	  	        var origin = leg[l].getElementsByTagName("Origin")
	  	        var destination = leg[l].getElementsByTagName("Destination")
	  	        var origina = origin[0].attributes
	  	        var destinationa = destination[0].attributes

	  	        try {
	  	          if (l == 0) {
	  	            originTime = origina.getNamedItem("time").nodeValue
	  	            originName = origina.getNamedItem("name").nodeValue
	  	          }

	  	          if (l == eval(leg.length - 1)) {
	  	            destinationTime = destinationa.getNamedItem("time").nodeValue
	  	            destinationName = destinationa.getNamedItem("name").nodeValue
	  	          }

	  	          if (t == 0) {
	  	            checked = 'checked="checked"'
	  	          } else {
	  	            checked = ""
	  	          }

	  	          legInfo2 += lega.getNamedItem("name").nodeValue + ", "
								
								tripLink = 'http://www.rejseplanen.dk/bin/query.exe/mn?SBHF=2&ZBHF=2&SADR=1&ZADR=1&S=' + escape(originName) + '&Z=' + escape(destinationName) + '&D=' + document.getElementById("txtDate" + currentTrip).value + '&T=' + document.getElementById("txtTime" + currentTrip).value + '&SALL=0&ZALL=0timesel=arrive&start=yes'

	  	          tripInfo = '<table width="375" cellpadding="0" cellspacing="0" border="0">'
	  	          tripInfo += '	<tr>'
	  	          tripInfo += '		<td rowspan="2" style="width:25px;" valign="top"><input type="radio" id="check' + t + '_' + currentTrip + '" value="' + t + '" onclick="javascript:selectTrip(\'' + t + '\',\'' + originTime + '\',\'' + originName + '\',\'' + destinationTime + '\',\'' + destinationName + '\',\'' + legInfo2 + '\',\'' + tripLink + '\',\'' + currentTrip + '\');" ' + checked + '></td>'
	  	          tripInfo += '		<td style="width:30px;" valign="top">Afg.</td>'
	  	          tripInfo += '		<td style="width:70px;" valign="top">' + originTime + '</td>'
	  	          tripInfo += '		<td style="width:250px;"valign="top">' + originName + '</td>'
	  	          tripInfo += '	</tr>'
	  	          tripInfo += '	<tr>'
	  	          tripInfo += '		<td style="width:30px;" valign="top">Ank.</td>'
	  	          tripInfo += '		<td style="width:70px;" valign="top">' + destinationTime + '</td>'
	  	          tripInfo += '		<td style="width:250px;" valign="top">' + destinationName + '</td>'
	  	          tripInfo += '	</tr>'
	  	          tripInfo += '</table>'

	  	        }
	  	        catch (er) {

	  	        }
	  	      }

	  	      legInfo2 = ""

	  	      for (l = 0; l < leg.length; l++) {
	  	        var lega = leg[l].attributes
	  	        var origin = leg[l].getElementsByTagName("Origin")
	  	        var destination = leg[l].getElementsByTagName("Destination")
	  	        var origina = origin[0].attributes
	  	        var destinationa = destination[0].attributes
	  	        var legType = lega.getNamedItem("type").nodeValue.toLowerCase()
	  	        var legTypeImage = ""
	  	        var legTypeConnector = ""

	  	        try {

	  	          switch (legType) {
	  	            case "bus":
	  	              legTypeImage = "ntRejseplanenTypeBus.gif"
	  	              break;
	  	            case "exb":
	  	              legTypeImage = "ntRejseplanenTypeBus.gif"
	  	              break;
	  	            case "nb":
	  	              legTypeImage = "ntRejseplanenTypeBus.gif"
	  	              break;
	  	            case "tb":
	  	              legTypeImage = "ntRejseplanenTypeBus.gif"
	  	              break;
	  	            case "ic":
	  	              legTypeImage = "ntRejseplanenTypeTrain.gif"
	  	              break;
	  	            case "lyn":
	  	              legTypeImage = "ntRejseplanenTypeTrain.gif"
	  	              break;
	  	            case "reg":
	  	              legTypeImage = "ntRejseplanenTypeTrain.gif"
	  	              break;
	  	            case "s":
	  	              legTypeImage = "ntRejseplanenTypeTrain.gif"
	  	              break;
	  	            case "tog":
	  	              legTypeImage = "ntRejseplanenTypeTrain.gif"
	  	              break;
	  	            case "walk":
	  	              legTypeImage = "ntRejseplanenTypeWalk.gif"
	  	              break;
	  	            default:
	  	              legTypeImage = "ntRejseplanenTypeBus.gif"
	  	              break;
	  	          }

	  	          if (l < eval(leg.length - 1)) {
	  	            legTypeConnector = '<div class="spanLegTypeConnector"><img src="custom/design/ntRejseplanenConnector.gif" style="border:0px; vertical-align:middle;" alt="" title=""></div>'
	  	          } else {
	  	            legTypeConnector = ''
	  	          }

	  	          legInfo += '<div class="spanLegType"><img src="custom/design/' + legTypeImage + '" style="border:0px; vertical-align:middle;" alt="" title="">&nbsp;' + lega.getNamedItem("name").nodeValue + '</div>' + legTypeConnector
	  	          legInfo3 += lega.getNamedItem("name").nodeValue + ", "
	  	        }
	  	        catch (er) {
	  	        }
	  	      }

	  	      if (t == 0) {
	  	        backgroundColor = 'style="background-color:#eeeeee;"'
	  	      } else {
	  	        backgroundColor = ''
	  	      }

	  	      output += '			<table id="legTable' + t + '_' + currentTrip + '" name="legTable' + t + '_' + currentTrip + '" width="100%" cellpadding="0" cellspacing="0" border="0" ' + backgroundColor + '>'
	  	      output += '				<tr>'
	  	      output += '					<td colspan="2"><img src="custom/design/blank1x1.gif" alt="" style="border:0px; height:5px; width:1px;"></td>'
	  	      output += '				</tr>'
	  	      output += '				<tr>'
	  	      output += '					<td style="width:375px;" valign="top">' + tripInfo + '</td>'
	  	      output += '					<td valign="top">' + legInfo + '</td>'
	  	      output += '				</tr>'
	  	      output += '				<tr>'
	  	      output += '					<td colspan="2"><img src="custom/design/blank1x1.gif" alt="" style="border:0px; height:5px; width:1px;"></td>'
	  	      output += '				</tr>'
	  	      output += '			</table>'
	  	      output += '			<table width="100%" cellpadding="0" cellspacing="0" border="0">'
	  	      output += '				<tr>'
	  	      output += '					<td colspan="2"><img src="custom/design/blank1x1.gif" alt="" style="border:0px; height:5px; width:1px;"></td>'
	  	      output += '				</tr>'
	  	      output += '				<tr>'
	  	      output += '					<td colspan="2" style="height:1px; border-bottom: 1px solid #9f9f9f;"><img src="custom/design/blank1x1.gif" alt="" style="border:0px; height:1px; width:1px;"></td>'
	  	      output += '				</tr>'
	  	      output += '				<tr>'
	  	      output += '					<td colspan="2"><img src="custom/design/blank1x1.gif" alt="" style="border:0px; height:5px; width:1px;"></td>'
	  	      output += '				</tr>'
	  	      output += '			</table>'
						
						output += '<input type="hidden" id="hiddenDate' + t + '_' + currentTrip + '" value="' + document.getElementById("txtDate" + currentTrip).value + '">'
						
						output += '<input type="hidden" id="hiddenOriginTime' + t + '_' + currentTrip + '" value="' + originTime + '">'
						output += '<input type="hidden" id="hiddenOriginName' + t + '_' + currentTrip + '" value="' + originName + '">'
						
						output += '<input type="hidden" id="hiddenDestinationTime' + t + '_' + currentTrip + '" value="' + destinationTime + '">'
						output += '<input type="hidden" id="hiddenDestinationName' + t + '_' + currentTrip + '" value="' + destinationName + '">'
						
						output += '<input type="hidden" id="hiddenLegInfo' + t + '_' + currentTrip + '" value="' + legInfo3 + '">'
						output += '<input type="hidden" id="hiddenTripLink' + t + '_' + currentTrip + '" value="' + tripLink + '">'

	  	      legInfo = ""
						legInfo3 = ""
						
						//if (t == 0) {
						//	selectTrip("0", originTime, originName, destinationTime, destinationName, legInfo3, tripLink, currentTrip)
						//}
	  	    }

	  	    output += '		</td>'
	  	    output += '	</tr>'
	  	    output += '	<tr>'
	  	    output += '	  <td style="width:614px;" align="right"><a href="' + tripLink + '" target="_blank">Klik her for yderligere oplysninger</a></td>'
	  	    output += '		<td style="width:10px;">&nbsp;</td>'
	  	    output += '	</tr>'
	  	    output += '	<tr>'
	  	    output += '		<td colspan="2"><img src="custom/design/blank1x1.gif" alt="" style="border:0px; height:10px; width:1px;"></td>'
	  	    output += '	</tr>'
	  	    output += '</table>'

	  	    xmlhttp = null

	  	    document.getElementById('div' + currentTrip).style.visibility = "visible"
	  	    document.getElementById('div' + currentTrip).innerHTML = output

	  	  } else {
	  	    var output = '<table width="100%" cellpadding="0" cellspacing="0" border="0">'
	  	    output += '	<tr>'
	  	    output += '		<td><img src="custom/design/blank1x1.gif" alt="" style="border:0px; height:10px; width:1px;"></td>'
	  	    output += '	</tr>'
	  	    output += '	<tr>'
	  	    output += '		<td style="padding-left:25px;"><b>Din søgning gav desværre ingen resultater.</b></td>'
	  	    output += '	</tr>'
	  	    output += '	<tr>'
	  	    output += '		<td><img src="custom/design/blank1x1.gif" alt="" style="border:0px; height:10px; width:1px;"></td>'
	  	    output += '	</tr>'
	  	    output += '</table>'

	  	    document.getElementById('div' + currentTrip).style.visibility = "visible"
	  	    document.getElementById('div' + currentTrip).innerHTML = output
	  	  }
      }
	  }
	}

	var prevRow = 0 

	function rowOver(rowId) {
		if (document.getElementById("td_" + prevRow)) {
			document.getElementById("td_" + prevRow).style.backgroundColor = "#ffffff";
			document.getElementById("td_" + prevRow).style.color = "#000000";
		}
		if (document.getElementById("td_" + rowId)) {
			document.getElementById("td_" + rowId).style.backgroundColor = "#0b3f7b";
			document.getElementById("td_" + rowId).style.color = "#ffffff";
		}
		prevRow = rowId
	}
	
	function scrollSelection(e) {
		var tempRow = 0
		var divHeight = 135
		
		if (e.keyCode == 40) {
			if (prevRow >= numRows - 1) {
				tempRow = numRows - 1
			} else {
				tempRow = prevRow + 1
				if ((tempRow * 18) > divHeight + xmldiv.scrollTop) {
				  xmldiv.scrollTop = (tempRow * 18) - divHeight
				}
			}
			rowOver(tempRow)
		} else if (e.keyCode == 38) {
			if (prevRow > 0) {
				tempRow = prevRow - 1

				if ((tempRow * 18) < xmldiv.scrollTop) {
				  xmldiv.scrollTop = (tempRow * 18)
				}
			}
			rowOver(tempRow)
		} else if (e.keyCode == 13) {
			selectLocation(prevRow)
			return false;
		}
	}
	
	function updateSelection() {		
	  if (document.getElementById("txtOrigin" + currentTrip) && document.getElementById("txtDestination" + currentTrip)) {			
	    if (document.getElementById("txtOrigin" + currentTrip).value != "" && document.getElementById("txtDestination" + currentTrip).value != "") {
				selectLocation(prevRow)
				return false;
			}
		}
	}

	function selectTrip(element, originTime, originName, destinationTime, destinationName, legTypes, tripLink, currentTrip) {							
		for (i=0; i < document.formJourneyPlanner.elements.length; i++) {
			if (document.formJourneyPlanner[i].id.indexOf(currentTrip) > -1) {
				if (document.formJourneyPlanner.elements[i].type == "radio" && document.formJourneyPlanner[i].id == "check" + element + '_' + currentTrip) { 
					document.formJourneyPlanner.elements[i].checked = true;					
				} else {
					document.formJourneyPlanner.elements[i].checked = false;
				}
			}
		}
		
		var pageElements = document.getElementsByTagName("*");
		
		for (var i=0, max = pageElements.length; i < max; i++) {			
			if (pageElements[i].id.indexOf(currentTrip) > -1) {				
				if (pageElements[i].id == "legTable" + element + '_' + currentTrip) {
					pageElements[i].style.backgroundColor = "#eeeeee"
				} else {
					pageElements[i].style.backgroundColor = ""
				}
			}
		}
	}
	
	function createTripList() {
		var element = ""
		var tripList = ""
		var tripNum = ""
		var prevTripNum = ""
		
		for (i=0; i < document.formJourneyPlanner.elements.length; i++) {
			if (document.formJourneyPlanner.elements[i].type == "radio" && document.formJourneyPlanner[i].checked == true) {
				element = document.formJourneyPlanner.elements[i].id.replace("check","") 
			
				tripNum = element.substring(2)
				tripNum = tripNum.replace("Trip","")
				tripNum = tripNum.replace("_1","")
				tripNum = tripNum.replace("_2","")
				
				if (element.indexOf("_1") > -1) {
					tripList += 'Du har valgt følgende udrejse for Rejse ' + tripNum + ' (tryk på link for flere detaljer):\n'
				} else if (element.indexOf("_2") > -1) {
					tripList += 'Du har valgt følgende hjemrejse for Rejse ' + tripNum + ' (tryk på link for flere detaljer):\n'
				}
				
        tripList += "---------------------------------\n"
        tripList += "Dato: " + document.getElementById('hiddenDate' + element).value + "\n"
        tripList += "Afg.: " + document.getElementById('hiddenOriginTime' + element).value + "\n"
        tripList += "Ank.: " + document.getElementById('hiddenDestinationTime' + element).value + "\n"
        tripList += "Start: " + document.getElementById('hiddenOriginName' + element).value + "\n"
        tripList += "Stop: " + document.getElementById('hiddenDestinationName' + element).value + "\n"
        tripList += "Transportformer: " + document.getElementById('hiddenLegInfo' + element).value + "\n"
				tripList += "Link til Rejseplanen: " + document.getElementById('hiddenTripLink' + element).value + "\n"
				
				tripList += "\n"
			}
		}
		
		if (document.getElementById("rejse")) {
			document.getElementById("rejse").value = tripList
		}
	}
	
	function selectLocation(id) {
		if (document.getElementById("origin" + id + "_" + currentTrip)) {
			if (document.getElementById("hiddenOriginCoordName" + currentTrip)) {
				document.getElementById("hiddenOriginCoordName" + currentTrip).value = document.getElementById("origin" + id + "_" + currentTrip).innerHTML
			}
			
			if (document.getElementById("hiddenOriginId" + currentTrip)) {
				if (document.getElementById("spanOriginId" + id + "_" + currentTrip)) {
					document.getElementById("hiddenOriginId" + currentTrip).value = document.getElementById("spanOriginId" + id + "_" + currentTrip).innerHTML
				} else {
					document.getElementById("hiddenOriginId" + currentTrip).value = ""
				}
			}
			
			if (document.getElementById("hiddenOriginX" + currentTrip)) {
				document.getElementById("hiddenOriginX" + currentTrip).value = document.getElementById("spanOriginCoordX" + id + "_" + currentTrip).innerHTML
			}
			
			if (document.getElementById("hiddenOriginY" + currentTrip)) {
				document.getElementById("hiddenOriginY" + currentTrip).value = document.getElementById("spanOriginCoordY" + id + "_" + currentTrip).innerHTML
			}
			
			document.getElementById(currentElement.name).value = document.getElementById("hiddenOriginCoordName" + currentTrip).value
		}
		
		if (document.getElementById("dest" + id + "_" + currentTrip)) {
			if (document.getElementById("hiddenDestinationCoordName" + currentTrip)) {
				document.getElementById("hiddenDestinationCoordName" + currentTrip).value = document.getElementById("dest" + id + "_" + currentTrip).innerHTML
			}
			
			if (document.getElementById("hiddenDestinationId" + currentTrip)) {
				if (document.getElementById("spanDestId" + id + "_" + currentTrip)) {
					document.getElementById("hiddenDestinationId" + currentTrip).value = document.getElementById("spanDestId" + id + "_" + currentTrip).innerHTML
				} else {
					document.getElementById("hiddenDestinationId" + currentTrip).value = ""
				}
			}
			
			if (document.getElementById("hiddenDestinationX" + currentTrip)) {
				document.getElementById("hiddenDestinationX" + currentTrip).value = document.getElementById("spanDestCoordX" + id + "_" + currentTrip).innerHTML
			}
			
			if (document.getElementById("hiddenDestinationY" + currentTrip)) {
				document.getElementById("hiddenDestinationY" + currentTrip).value = document.getElementById("spanDestCoordY" + id + "_" + currentTrip).innerHTML
			}
			
			document.getElementById(currentElement.name).value = document.getElementById("hiddenDestinationCoordName" + currentTrip).value
		}
	
		var selectedDate = ""
		if (document.getElementById("txtDate" + currentTrip) && document.getElementById("txtDate" + currentTrip).value != "") {
		  selectedDate = document.getElementById("txtDate" + currentTrip).value
			selectedDate = selectedDate.replace(/-/gi,".");
		}
		
		var selectedTime = ""
		if (document.getElementById("txtTime" + currentTrip) && document.getElementById("txtTime" + currentTrip).value != "") {
		  selectedTime = document.getElementById("txtTime" + currentTrip).value
		}
		
		if (document.getElementById("hiddenOriginCoordName" + currentTrip).value != "" && document.getElementById("hiddenDestinationCoordName" + currentTrip).value != "") {			
			//alert('custom/getJourneyPlannerData.aspx?originId=' + document.getElementById("hiddenOriginId" + currentTrip).value + '&originCoordX=' + document.getElementById("hiddenOriginX" + currentTrip).value + '&originCoordY=' + document.getElementById("hiddenOriginY" + currentTrip).value + '&originCoordName=' + document.getElementById("hiddenOriginCoordName" + currentTrip).value + '&destId=' + document.getElementById("hiddenDestinationId" + currentTrip).value +'&destCoordX=' + document.getElementById("hiddenDestinationX" + currentTrip).value + '&destCoordY=' + document.getElementById("hiddenDestinationY" + currentTrip).value + '&destCoordName=' + document.getElementById("hiddenDestinationCoordName" + currentTrip).value + '&date=' + selectedDate + '&time=' + selectedTime + '&service=trip')
			
			loadTripXMLDoc('custom/getJourneyPlannerData.aspx?originId=' + document.getElementById("hiddenOriginId" + currentTrip).value + '&originCoordX=' + document.getElementById("hiddenOriginX" + currentTrip).value + '&originCoordY=' + document.getElementById("hiddenOriginY" + currentTrip).value + '&originCoordName=' + document.getElementById("hiddenOriginCoordName" + currentTrip).value + '&destId=' + document.getElementById("hiddenDestinationId" + currentTrip).value +'&destCoordX=' + document.getElementById("hiddenDestinationX" + currentTrip).value + '&destCoordY=' + document.getElementById("hiddenDestinationY" + currentTrip).value + '&destCoordName=' + document.getElementById("hiddenDestinationCoordName" + currentTrip).value + '&date=' + selectedDate + '&time=' + selectedTime + '&service=trip')
			
		}
		
		document.getElementById('xmldiv').style.visibility = "hidden"
	}
	
	var sTi
	function hideLocations(force) {
		sTi = setTimeout("hideLocations2(" + force + ")", 200)
	}

	function hideLocations2(force) {
		if (force) {
		  if (document.getElementById('xmldiv')) {
		    document.getElementById('xmldiv').style.visibility = "hidden"
			}
		}
	}
	
	function getElementPosition(obj) {
		var curleft = curtop = 0;
		
		if (obj.offsetParent) {
			do {
				curleft += obj.offsetLeft;
				curtop += obj.offsetTop;
			} while (obj = obj.offsetParent);
		}
		
		//return [curleft,curtop];
		return { left: curleft, top: curtop }
	}
	
	
	
	
	
	
	
	/*
	function selectLocation2(id) {		
		if (currentElement.name == "txtOrigin" + currentTrip) {			
		
			if (document.getElementById("hiddenOriginCoordName" + currentTrip)) {
				document.getElementById("hiddenOriginCoordName" + currentTrip).value = document.getElementById("origin" + id + "_" + currentTrip).innerHTML
			}
			
			if (document.getElementById("hiddenOriginCoordName" + currentTrip).value != "") {
				origin = document.getElementById("hiddenOriginCoordName" + currentTrip).value
			} else {
				origin = document.getElementById("origin" + id + "_" + currentTrip).innerHTML
			}
		
		//if (document.getElementById("origin" + id + "_" + currentTrip)) {
			//origin = document.getElementById("origin" + id + "_" + currentTrip).innerHTML

			if (document.getElementById("spanOriginId" + id + "_" + currentTrip)) {
			  originId = document.getElementById("spanOriginId" + id + "_" + currentTrip).innerHTML
			} else {
			  originId = ""
			}
      
			originCoordX = document.getElementById("spanOriginCoordX" + id + "_" + currentTrip).innerHTML
			originCoordY = document.getElementById("spanOriginCoordY" + id + "_" + currentTrip).innerHTML
			originCoordName = document.getElementById("spanOriginCoordName" + id + "_" + currentTrip).innerHTML			
			
			document.getElementById(currentElement.name).value = origin
		}

	  if (currentElement.name == "txtDestination" + currentTrip) {
			if (document.getElementById("hiddenDestinationCoordName" + currentTrip)) {
				document.getElementById("hiddenDestinationCoordName" + currentTrip).value = document.getElementById("dest" + id + "_" + currentTrip).innerHTML
			}
			
			if (document.getElementById("hiddenDestinationCoordName" + currentTrip).value != "") {
				dest = document.getElementById("hiddenDestinationCoordName" + currentTrip).value
			} else {
				dest = document.getElementById("dest" + id + "_" + currentTrip).innerHTML
			}
			
		//if (document.getElementById("dest" + id + "_" + currentTrip))	{
		  //dest = document.getElementById("dest" + id + "_" + currentTrip).innerHTML

		  if (document.getElementById("spanDestId" + id + "_" + currentTrip)) {
		    destId = document.getElementById("spanDestId" + id + "_" + currentTrip).innerHTML
		  } else {
        destId = ""
		  }

			destCoordX = document.getElementById("spanDestCoordX" + id + "_" + currentTrip).innerHTML
			destCoordY = document.getElementById("spanDestCoordY" + id + "_" + currentTrip).innerHTML
			destCoordName = document.getElementById("spanDestCoordName" + id + "_" + currentTrip).innerHTML
			
			document.getElementById(currentElement.name).value = dest
		}
		
		var selectedDate = ""
		if (document.getElementById("txtDate" + currentTrip) && document.getElementById("txtDate" + currentTrip).value != "") {
		  selectedDate = document.getElementById("txtDate" + currentTrip).value
			selectedDate = selectedDate.replace(/-/gi,".");
		}
		
		var selectedTime = ""
		if (document.getElementById("txtTime" + currentTrip) && document.getElementById("txtTime" + currentTrip).value != "") {
		  selectedTime = document.getElementById("txtTime" + currentTrip).value
		}	
				
    if (document.getElementById("txtOrigin" + currentTrip).value != "" && document.getElementById("txtDestination" + currentTrip).value != "") {			
			alert('custom/getJourneyPlannerData.aspx?originId=' + originId + '&originCoordX=' + originCoordX + '&originCoordY=' + originCoordY + '&originCoordName=' + originCoordName + '&destId=' + destId +'&destCoordX=' + destCoordX + '&destCoordY=' + destCoordY + '&destCoordName=' + destCoordName + '&date=' + selectedDate + '&time=' + selectedTime + '&service=trip')
			
			loadTripXMLDoc('custom/getJourneyPlannerData.aspx?originId=' + originId + '&originCoordX=' + originCoordX + '&originCoordY=' + originCoordY + '&originCoordName=' + originCoordName + '&destId=' + destId +'&destCoordX=' + destCoordX + '&destCoordY=' + destCoordY + '&destCoordName=' + destCoordName + '&date=' + selectedDate + '&time=' + selectedTime + '&service=trip')
			
		}

	  document.getElementById('xmldiv').style.visibility = "hidden"
	}
	*/
	

  //-->
