var isIE = false;
var req;
var TempDiv;
var TempIfr;
var TempFieldname;
var TempHiddenfieldname;
var full = false;

/**
* CVH: building index Array
*/
var indexArray = new Array();

function init(startDiv, startIfr, zielDiv, zielIfr)
	{
	aus(startDiv, startIfr);
	document.getElementById(startDiv).setAttribute("autocomplete","off");
	aus(zielDiv, zielIfr);
	document.getElementById(zielDiv).setAttribute("autocomplete","off");
	}

function aus(what, iFR)
	{
	document.getElementById(what).style.display = "none";
	if(isIE == true)
		{
		document.getElementById(iFR).style.display = "none";
		var DivRef 				= document.getElementById(what);
		var IfrRef 				= document.getElementById(iFR);
		IfrRef.style.width 		= DivRef.offsetWidth;
		IfrRef.style.height 	=  DivRef.offsetHeight;
		IfrRef.style.top 		= DivRef.style.top;
		IfrRef.style.left 		= DivRef.style.left;
		IfrRef.style.zIndex 	= DivRef.style.zIndex - 1;
		IfrRef.style.display 	= DivRef.style.display;
		}
	}

function an(what, iFR)
	{
	document.getElementById(what).style.display = "";
	if(isIE == true)
		{
		var DivRef 				= document.getElementById(what);
		var IfrRef 				= document.getElementById(iFR);
		DivRef.style.display 	= "block";
		IfrRef.style.width 		= DivRef.offsetWidth;
		TEMPheight				= DivRef.offsetHeight - 3;
		IfrRef.style.height 	= TEMPheight;
		IfrRef.style.top 		= DivRef.style.top;
		IfrRef.style.left 		= DivRef.style.left;
		IfrRef.style.zIndex 	= DivRef.style.zIndex - 1;
		IfrRef.style.display 	= "block";
		}
	}

function div_display(where, what)
	{
	document.getElementById(where).innerHTML = what;
	if(isIE == true)
		{
		var DivRef 				= document.getElementById(TempDiv);
   		var IfrRef 				= document.getElementById(TempIfr);
		DivRef.style.display 	= "block";
		IfrRef.style.width 		= DivRef.offsetWidth;
		TEMPheight				= DivRef.offsetHeight - 3;
		IfrRef.style.height 	= TEMPheight;
		IfrRef.style.top 		= DivRef.style.top;
		IfrRef.style.left 		= DivRef.style.left;
		IfrRef.style.zIndex 	= DivRef.style.zIndex - 1;
		}
	}


function keylistener(what, TempDiv, TempIfr, TempFieldname, TempHiddenfieldname, TMPmultiairport, form_name)
	{
	l = 0;
	t_field = what;
	aktDiv = TempDiv
	aktIfr = TempIfr
	fieldname = TempFieldname
	hiddenfieldname = TempHiddenfieldname
	multiairport = TMPmultiairport;
	f_name = form_name;

	if (navigator.userAgent.indexOf("Safari") > 0)
		{
		document.getElementById(what).removeEventListener("keyup",nav,false);
		document.getElementById(what).addEventListener("keyup",nav,false);
		document.getElementById(what).removeEventListener("keydown",nav_safari_dummy,false);
		document.getElementById(what).addEventListener("keydown",nav_safari_dummy,false);
		document.getElementById(what).removeEventListener("keypress",nav_safari_dummy,false);
		document.getElementById(what).addEventListener("keypress",nav_safari_dummy,false);
		}
	else if (navigator.product == "Gecko")
		{
		document.getElementById(what).removeEventListener("keyup",nav,false);
		document.getElementById(what).addEventListener("keyup",nav,false);
		document.getElementById(what).removeEventListener("keydown",nav_safari_dummy,false);
		document.getElementById(what).addEventListener("keydown",nav_safari_dummy,false);
		document.getElementById(what).removeEventListener("keypress",nav_safari_dummy,false);
		document.getElementById(what).addEventListener("keypress",nav_safari_dummy,false);
		}
	else
		{
		document.getElementById(what).detachEvent('onkeyup',nav);
		document.getElementById(what).attachEvent('onkeyup',nav);
		document.getElementById(what).detachEvent('onkeydown',nav_safari_dummy);
		document.getElementById(what).attachEvent('onkeydown',nav_safari_dummy);
		document.getElementById(what).detachEvent('onkeypress',nav_safari_dummy);
		document.getElementById(what).attachEvent('onkeypress',nav_safari_dummy);
		}
	}


var oldAP=-1;
var maxAP=0;
var startAP=0;
var APs=Array();

function HilightAirport(newAP)
{
   var el;
   var value="";

   el=document.getElementById(oldAP);
   if (el) { el.className = 'lc3'; }

   el=document.getElementById(newAP);
   if (el) { el.className = 'lc3_Hover'; }

   oldAP=newAP;
}


function nav_safari_dummy(event)
{
  if (event.keyCode == 13)
  {
  	if (event.stopPropagation) event.stopPropagation();
  	if (event.preventDefault) event.preventDefault();
  	return false;
  }
  return true;
}


function nav(event)
	{
	if (event.keyCode == 38 || event.keyCode == 40 || event.keyCode == 27 || event.keyCode == 9 || event.keyCode == 13)
		{
		if (event.keyCode == 38)
			{
			if(oldAP > startAP)
				{
				HilightAirport(oldAP-1);
				}
			}
		if (event.keyCode == 40)
			{
			if(oldAP < maxAP)
				{
				HilightAirport(oldAP+1);
				}
			}
		if (event.keyCode == 27)
			{
			  // bei ESC
			  aus('start3lc','start3lc_i');
			  aus('ziel3lc','ziel3lc_i');
			}
		if (event.keyCode == 9)
			{
			// bei Tabulator (TAB)
			/*
			if(t_field == "start_text")
				{
				//airline_short(document.forms[f_name].start_text.value, f_name);
				document.forms[f_name].ziel_text.focus();
				document.forms[f_name].m_over_von.value = '0';
				document.forms[f_name].m_over_nach.value = '0';
				}
			if(t_field == "ziel_text")
				{
				//airline_short(document.forms[f_name].ziel_text.value, f_name);
				document.forms[f_name].DVON.focus();
				document.forms[f_name].m_over_von.value = '0';
				document.forms[f_name].m_over_nach.value = '0';
				}
			*/
			}
		if (event.keyCode == 13)
			{
			// bei ENTER
			if(t_field == "start_text")
				{
				  if (oldAP>-1)
				  {
				    changeField(APs[oldAP], 'start3lc', 'start3lc_i',  'start_text', 'VON');
				  }else
				  {
				    document.forms[f_name].ziel_text.focus();
				    document.forms[f_name].m_over_von.value = '0';
				    document.forms[f_name].m_over_nach.value = '0';
                          }
				}
			if(t_field == "ziel_text")
				{
				if (oldAP>-1)
				  {
				    changeField(APs[oldAP], 'ziel3lc', 'ziel3lc_i',  'ziel_text', 'NACH');
				  }else
				  {
				    document.forms[f_name].DVON.focus();
				    document.forms[f_name].m_over_von.value = '0';
				    document.forms[f_name].m_over_nach.value = '0';
				  }
				}
			if(t_field == "h_start_text")
				{
				if (oldAP>-1)
				  {
				    changeFieldHotel(APs[oldAP], 'start3lc_h', 'start3lc_i_h',  'start_text', 'VON');
				  }else
				  {
					document.forms[f_name].DVON.focus();
					document.forms[f_name].m_over_von.value = '0';
				  }
				}
			if(t_field == "m_start_text")
				{
				if (oldAP>-1)
				  {
				    changeField(APs[oldAP], 'start3lc_m', 'start3lc_i_m',  'start_text', 'VON');
				  }else
				  {
					document.forms[f_name].DVON.focus();
					document.forms[f_name].m_over_von.value = '0';
				  }
				}
			if(t_field == "p_start_text")
				{
				if (oldAP>-1)
				  {
				    changeField(APs[oldAP], 'start3lc_p', 'start3lc_i_p',  'start_text', 'VON');
				  }else
				  {
					document.forms[f_name].DVON.focus();
					document.forms[f_name].m_over_von.value = '0';
				  }
				}
				if (event.stopPropagation) event.stopPropagation();
				if (event.preventDefault) event.preventDefault();
			}
		}
		else
		{
		if(t_field == "start_text")
			{
			airline_code(document.forms[f_name].start_text.value, aktDiv, aktIfr, fieldname, hiddenfieldname, multiairport);
			}
		if(t_field == "ziel_text")
			{
			airline_code(document.forms[f_name].ziel_text.value, aktDiv, aktIfr, fieldname, hiddenfieldname, multiairport);
			}
		if(t_field == "h_start_text")
			{
			airline_code(document.forms[f_name].start_text.value, aktDiv, aktIfr, fieldname, hiddenfieldname, multiairport);
			}
		if(t_field == "m_start_text")
			{
			airline_code(document.forms[f_name].start_text.value, aktDiv, aktIfr, fieldname, hiddenfieldname, multiairport);
			}
		if(t_field == "p_start_text")
			{
			airline_code(document.forms[f_name].start_text.value, aktDiv, aktIfr, fieldname, hiddenfieldname, multiairport);
			}
		if(t_field == "p_ziel_text")
			{
			airline_code(document.forms[f_name].ziel_text.value, aktDiv, aktIfr, fieldname, hiddenfieldname, multiairport);
			}
		}
		return false;
	}

function airline_code(letter, aktDiv, aktIfr, fieldname, hiddenfieldname, multiairport)
	{
	set = "";
	TempDiv 				= aktDiv;
	TempIfr 				= aktIfr;
	TempFieldname 			= fieldname;
	TempHiddenfieldname 	= hiddenfieldname;
	if(f_name == 'hotels')
		{
		xmlSource = '3lc_hotels.php';
		}
		else
		{
		xmlSource = '3lc.php';
		}
	if(letter.length == 3)
		{
		aus(aktDiv, aktIfr);
		letter = escape(letter);
		initVar = true;
		indexArray=new Array();
		load3lc('../../inc/' + xmlSource + '?param=' + letter + '&multi=' + multiairport);
		}
	if(letter.length > 3)
		{
		if(initVar == false)
			{
			letter = escape(letter);
			initVar = true;
			load3lc('../../inc/' + xmlSource + '?param=' + letter + '&multi=' + multiairport);
			}
		var letter_comp = letter.toLowerCase();
		aus(aktDiv, aktIfr);
		if (req.readyState == 4)
			{
			if (req.status == 200)
				{
				buildAirports(letter_comp, TempDiv, TempIfr, TempFieldname, TempHiddenfieldname);
				}
			}
		}
	if(letter.length < 3)
		{
		aus(aktDiv, aktIfr);
		initVar = false;
		}
	}

function load3lc(evt)
	{
    try
		{
        loadXMLDoc(evt);
        }
    catch(e)
		{
        var msg = (typeof e == "string") ? e : ((e.message) ? e.message : "Unknown Error");
        alert("Unable to get XML data:\n" + msg);
        return;
        }
	}

function loadXMLDoc(url)
	{
    if (window.XMLHttpRequest)
		{
        req = new XMLHttpRequest();
        req.onreadystatechange = processReqChange;
        req.open("GET", url, true);
        req.send(null);
		}
		else if (window.ActiveXObject)
		{
       	isIE = true;
        req = new ActiveXObject("Microsoft.XMLHTTP");
        if (req)
			{
            req.onreadystatechange = processReqChange;
            req.open("GET", url, true);
            req.send();
        	}
    	}
	}

function processReqChange()
	{
    if (req.readyState == 4)
		{
        if (req.status == 200)
			{
            buildAirports("", TempDiv, TempIfr, TempFieldname, TempHiddenfieldname, formname);
         	}
			else
			{
            alert("There was a problem retrieving the XML data:\n" + req.statusText);
         	}
    	}
	}

function getElementTextNS(prefix, local, parentElem, index)
	{
    var result = "";
    if (prefix && isIE)
		{
        result = parentElem.getElementsByTagName(prefix + ":" + local)[index];
    	}
		else
		{
        result = parentElem.getElementsByTagName(local)[index];
    	}
    if (result)
		{
        if (result.childNodes.length > 1)
			{
            return result.childNodes[1].nodeValue;
        	}
			else
			{
			// IE WHITE-SPACE BUG-FIX
            return result.firstChild.nodeValue;
        	}
    	}
		else
		{
        return "n/a";
    	}
	}

function changeFieldHotel(what, aktDiv, aktIfr, fieldname, hiddenfieldname) {
	if(aktDiv == "start3lc_h") 	{
		document.forms[this.formname].start_text.value 		= indexArray[what][1] + ((indexArray[what][0]!="N/A")?", "+ indexArray[what][2]:"") + ", " + indexArray[what][3];
		document.forms[this.formname].VON.value 			= indexArray[what][0];
		aus(aktDiv, aktIfr);
	}
}

function buildAirports(what, aktDiv, aktIfr, fieldname, hiddenfieldname)
	{
	if(f_name == 'hotels')
		{

				APs=new Array();
				divid=startAP=2000;
				var hitcount=0;
				var lines = new Array();
				var tmp_land="";
				var i=0;
				var showmaxhits=25;
				
				function checkbyDistrict(what,tmpA) {
					if (what == tmpA[2].substring(0, what.length).toLowerCase()) {
						return true;
					}
					return false;					
				}
				function checkHotelMatch(what,tmpA,i,divid,hitcount,tmp_land) {
					var stmp="";
					if (what == tmpA[1].substring(0, what.length).toLowerCase()) { // no match on district or country: || what == tmpA[2].substring(0, what.length).toLowerCase()  ||	what == tmpA[3].substring(0, what.length).toLowerCase()
						// Hit by real name or district
						if(tmp_land != tmpA[3]) {
							stmp="<div class=\"item_land\">" +tmpA[3]  + "</div>";
							tmp_land=tmpA[3];
						}
						stmp+="<div id=\"" + divid + "\" class=\"lc3\" onMouseOver=\"this.className = 'lc3_Hover';\" onMouseOut=\"this.className = 'lc3';\" onClick=\"changeFieldHotel(\'" + i + "\', \'" + aktDiv + "\', \'" + aktIfr + "\', \'" + fieldname + "\', \'" + hiddenfieldname + "\');\">" + tmpA[1] +  ((tmpA[2]=="N/A" || tmpA[2]=="" )?"":", " +tmpA[2])  + "</div>";
						return stmp;
					} else {
						for (var aic=0; aic<tmpA[4].length;aic++) {
							if (what == tmpA[4][aic].substring(0, what.length).toLowerCase()) {
								if(tmp_land != tmpA[3]) {
									stmp="<div class=\"item_land\">" +tmpA[3]  + "</div>";
									tmp_land=tmpA[3];
								}
								stmp+="<div id=\"" + divid + "\" class=\"lc3\" onMouseOver=\"this.className = 'lc3_Hover';\" onMouseOut=\"this.className = 'lc3';\" onClick=\"changeFieldHotel(\'" + i + "\', \'" + aktDiv + "\', \'" + aktIfr + "\', \'" + fieldname + "\', \'" + hiddenfieldname + "\');\">" + tmpA[1] + " (" + tmpA[4][aic] +")"  + ((tmpA[2]=="N/A" || tmpA[2]=="" )?"":", " +tmpA[2]) + "</div>";
								return stmp;
					 		}
					 	}
					}
					return false;
				}

		 		// First-call Index building
		 		if (indexArray.length<1) {
		 			// parse XML once and build indexArray
					i=0;
					$A(req.responseXML.getElementsByTagName("i")).each(
		 				function(item) {
							var done=false;
							var children=item.firstChild.nodeValue.split("|");
		 					var tmpA = new Array(
				 					children[0], // id
				 					children[1], // name
				 					children[2], // district
				 					children[4] // land
									
									//item.getElementsByTagName("id")[0].firstChild.nodeValue,        // id
				 					//item.getElementsByTagName("n")[0].firstChild.nodeValue,  // city
				 					//item.getElementsByTagName("dt")[0].firstChild.nodeValue,  // district
				 					//item.getElementsByTagName("l")[0].firstChild.nodeValue,      // land
				 					//item.getElementsByTagName("c")[0].firstChild.nodeValue
				 					);
							var OaltN = children[3]; // altnames //item.getElementsByTagName("an")[0].firstChild.nodeValue;
							var tmpAltN = new Array();
							if( OaltN ) {
								tmpAltN=OaltN.split(";");
							}
							tmpA.push(tmpAltN);
							var stmp="";
							if(stmp=checkHotelMatch(what,tmpA,i,divid,hitcount,tmp_land)) {
								if (hitcount < showmaxhits) 
										lines.push(stmp);
								APs[divid]=i;
								divid++;
								hitcount++;
							}
							tmp_land=tmpA[3];
							indexArray.push(tmpA);
							i++;
		 				}
		 			);

		 		} else {
			 		// Actual Search functionality now done over Array instead of xml
			 		var select = "";
			 		var tmp_land = "";
					var success=false;
					what = what.toLowerCase() ;
					i=0;
					indexArray.each(function(tmpA){
								var stmp="";
								if(stmp=checkHotelMatch(what,tmpA,i,divid,hitcount,tmp_land)) {
									if (hitcount<showmaxhits)
	 									lines.push(stmp);
									APs[divid]=i;
									divid++;
									hitcount++;
									tmp_land=tmpA[3];
								}
								i++;
							});
				}
				if (hitcount>=showmaxhits) {
					lines.push("<div class=\"lc3\">...</div>");
					lines.push("<div class=\"lc3\">und "+(hitcount-showmaxhits) +" weitere</div>");
				}
		 		if (lines.length>0)  {
					div_display(aktDiv, lines.join("\n"));
					an(aktDiv, aktIfr);
					HilightAirport(startAP);
				} else  {
					aus(aktDiv, aktIfr);
				}
				maxAP=divid-1;

		}
		else
		{
		var select = "";
	//	alert(what+" "+aktDiv+" "+aktIfr);
		var divid;
		APs=new Array();

		switch (aktDiv)
		{
			case 'start3lc': divid=startAP=0; break;
			case 'ziel3lc': divid=startAP=1000; break;
			case 'start3lc_h': divid=startAP=2000; break;
			case 'start3lc_m': divid=startAP=3000; break;
			case 'start3lc_p': divid=startAP=4000; break;
		}

		if(what == "")
			{
			var full = false;
			var tmp_land = "";
			var items = req.responseXML.getElementsByTagName("item");
			dl = items.length;
			for (var i = 0; i < items.length; i++)
				{
				LC_city 		= getElementTextNS("", "airport", items[i], 0);
				LC_airportname 	= getElementTextNS("", "portname", items[i], 0);
				LC_id			= getElementTextNS("", "id", items[i], 0);
				LC_land		= getElementTextNS("", "land", items[i], 0);
				LC_code		= getElementTextNS("", "code", items[i], 0);
				if(LC_airportname != "N/A")
					{
					LC_airportname_3lc = " - " + LC_airportname;
					LC_airportname = " - " + LC_airportname + " (" + LC_code + ")";
					}
					else
					{
					LC_airportname = " (" + LC_code + ")";
					LC_airportname_3lc = "";
					}
				if(LC_id != "DOUBLE")
					{
					if(LC_id != "SHORT")
						{
						if(LC_land != tmp_land)
							{
							select = select + "<div class=\"item_land\">" + LC_land + "</div>";
							tmp_land = LC_land;
							}
						full = true;
						APs[divid]=i;
						select = select + "<div id=\"" + divid + "\" class=\"lc3\" onMouseOver=\"this.className = 'lc3_Hover';\" onMouseOut=\"this.className = 'lc3';\" onClick=\"changeField(\'" + i + "\', \'" + aktDiv + "\', \'" + aktIfr + "\',  \'" + fieldname + "\', \'" + hiddenfieldname + "\');\">" + LC_city + LC_airportname + "</div>";
						divid++;
						}
					}
				if( LC_id == "SHORT")
					{
					full = true;
					APs[divid]=i;
					select = select + "<div id=\"" + divid + "\" class=\"lc3\" onMouseOver=\"this.className = 'lc3_Hover';\" onMouseOut=\"this.className = 'lc3';\" onClick=\"changeField(\'" + i + "\', \'" + aktDiv + "\', \'" + aktIfr + "\',  \'" + fieldname + "\', \'" + hiddenfieldname + "\');\"><b>" + LC_code + "</b> - " + LC_city + LC_airportname_3lc + "</div>";
					divid++;
					if(items.length > 1)
						{
						select = select + "<hr size=\"1\" noshade>";
						}
					}
				}
			if(full == true)
				{
				div_display(aktDiv, select);
				an(aktDiv, aktIfr);
				HilightAirport(startAP);
				}
				else
				{
				 buildAirports("", TempDiv, TempIfr, TempFieldname, TempHiddenfieldname, formname);aus(aktDiv, aktIfr);
				}
			}
			else
			{
			var full = false;
			var tmp_land = "";
			var select = "";
			var items = req.responseXML.getElementsByTagName("item");
			dl = items.length;
			for (var i = 0; i < items.length; i++)
				{
				LC_city 			= getElementTextNS("", "airport", items[i], 0);
				LC_id				= getElementTextNS("", "id", items[i], 0);
				LC_land				= getElementTextNS("", "land", items[i], 0);
				LC_airportname 		= getElementTextNS("", "portname", items[i], 0);
				LC_code				= getElementTextNS("", "code", items[i], 0);
				if(LC_airportname != "N/A")
					{
					LC_airportname = " - " + LC_airportname + " (" + LC_code + ")";
					}
					else
					{
					LC_airportname = " (" + LC_code + ")";
					LC_airportname_3lc = "";
					}
				CompA				= LC_city + LC_airportname;
				CompA				= CompA.substring(0, what.length);
				CompA				= CompA.toLowerCase();
				CompB				= what;
				if(CompA == CompB && LC_id != "SHORT")
					{
					if(LC_id != "SHORT")
						{
						if(LC_land != tmp_land)
							{
							select = select + "<div class=\"item_land\">" + LC_land + "</div>";
							tmp_land = LC_land;
							}
						full = true;
						APs[divid]=i;
						select = select + "<div id=\"" + divid + "\" class=\"lc3\" onMouseOver=\"this.className = 'lc3_Hover';\" onMouseOut=\"this.className = 'lc3';\" onClick=\"changeField(\'" + i + "\', \'" + aktDiv + "\', \'" + aktIfr + "\', \'" + fieldname + "\', \'" + hiddenfieldname + "\');\">" + LC_city + " " + LC_airportname + "</div>";
						divid++;
						}
					}
				}
			if(full == true)
				{
				div_display(aktDiv, select);
				an(aktDiv, aktIfr);
				HilightAirport(startAP);
				}
				else
				{
				aus(aktDiv, aktIfr);
				}
			}
			maxAP=divid-1;
			}
		}

function changeField(what, aktDiv, aktIfr, fieldname, hiddenfieldname)
	{
	var set = "click";
	aus(aktDiv, aktIfr);
	//alert("CF: "+what+", "	+aktDiv+", "+aktIfr+", "+", "+fieldname+", "+hiddenfieldname);
	oldAP=-1;
	var items = req.responseXML.getElementsByTagName("item");
	var port3lc = getElementTextNS("", "portname", items[what], 0);
	if(port3lc == "N/A") {port3lc = "";} else {port3lc = " - " + port3lc;}
	if(aktDiv == "start3lc" || aktDiv == "start3lc_m" || aktDiv == "start3lc_h" || aktDiv == "start3lc_p")
		{
		document.forms[this.formname].start_text.value 		= getElementTextNS("", "airport", items[what], 0) + port3lc;
		document.forms[this.formname].VON.value 			= getElementTextNS("", "code", items[what], 0);
		}
	if(aktDiv == "ziel3lc" || aktDiv == "ziel3lc_m" || aktDiv == "ziel3lc_h" || aktDiv == "ziel3lc_p")
		{
		document.forms[this.formname].ziel_text.value 		= getElementTextNS("", "airport", items[what], 0) + port3lc;
		document.forms[this.formname].NACH.value 			= getElementTextNS("", "code", items[what], 0);
		}
	}

// ***************************************************************************************** //

function airline_short(letter, f_name)
	{
	if(f_name == 'flug')
		{
		if(document.forms[f_name].m_over_von.value == '0' && aktDiv == 'start3lc')
			{
			if(letter.length >= 3)
				{
				letter = escape(letter);
				initVar = true;
				short_load3lc('../../inc/3lc.php?param=' + letter + '&multi=' + multiairport);
				}
			}
		if(document.forms[f_name].m_over_nach.value == '0' && aktDiv == 'ziel3lc')
			{
			if(letter.length >= 3)
				{
				letter = escape(letter);
				initVar = true;
				short_load3lc('../../inc/3lc.php?param=' + letter + '&multi=' + multiairport);
				}
			}
		}
	if(f_name == 'hotels')
		{
		/*
		if(document.forms[f_name].m_over_von.value == '0' && aktDiv == 'start3lc_h')
			{
			if(letter.length >= 3)
				{
				letter = escape(letter);
				initVar = true;
				short_load3lc('../../inc/3lc.php?param=' + letter + '&multi=' + multiairport);
				}
			}
		*/
		}
	if(f_name == 'mietwagen')
		{
		if(document.forms[f_name].m_over_von.value == '0' && aktDiv == 'start3lc_m')
			{
			if(letter.length >= 3)
				{
				letter = escape(letter);
				initVar = true;
				short_load3lc('../../inc/3lc.php?param=' + letter + '&multi=' + multiairport);
				}
			}
		}
	if(f_name == 'preisarchiv')
		{
		if(document.forms[f_name].m_over_von.value == '0' && aktDiv == 'start3lc_p')
			{
			if(letter.length >= 3)
				{
				letter = escape(letter);
				initVar = true;
				short_load3lc('../../inc/3lc.php?param=' + letter + '&multi=' + multiairport);
				}
			}
		if(document.forms[f_name].m_over_nach.value == '0' && aktDiv == 'ziel3lc_p')
			{
			if(letter.length >= 3)
				{
				letter = escape(letter);
				initVar = true;
				short_load3lc('../../inc/3lc.php?param=' + letter + '&multi=' + multiairport);
				}
			}
		}
	}

function short_load3lc(evt)
	{
    try
		{
        short_loadXMLDoc(evt);
        }
    catch(e)
		{
        var msg = (typeof e == "string") ? e : ((e.message) ? e.message : "Unknown Error");
        alert("Unable to get XML data:\n" + msg);
        return;
        }
	}

function short_loadXMLDoc(url)
	{
    if (window.XMLHttpRequest)
		{
        req = new XMLHttpRequest();
        req.onreadystatechange = short_processReqChange;
        req.open("GET", url, true);
        req.send(null);
		}
		else if (window.ActiveXObject)
		{
       	isIE = true;
        req = new ActiveXObject("Microsoft.XMLHTTP");
        if (req)
			{
            req.onreadystatechange = short_processReqChange;
            req.open("GET", url, true);
            req.send();
        	}
    	}
	}

function short_processReqChange()
	{
    if (req.readyState == 4)
		{
        if (req.status == 200)
			{
            short_buildAirports("", TempDiv, TempIfr, TempFieldname, TempHiddenfieldname);
         	}
			else
			{
            alert("There was a problem retrieving the XML data:\n" + req.statusText);
         	}
    	}
	}

function short_buildAirports(what, aktDiv, aktIfr, fieldname, hiddenfieldname)
	{
	var select = "";
	if(what == "")
		{
		var items = req.responseXML.getElementsByTagName("item");
		LC_city 		= getElementTextNS("", "airport", items[0], 0);
		LC_airportname 	= getElementTextNS("", "portname", items[0], 0);
		LC_id			= getElementTextNS("", "id", items[0], 0);
		LC_land			= getElementTextNS("", "land", items[0], 0);
		LC_code			= getElementTextNS("", "code", items[0], 0);
		if(getElementTextNS("", "portname", items[0], 0) != "N/A")
			{
			portn = ' - ' + getElementTextNS("", "portname", items[0], 0);

			}
			else
			{
			portn = '';
			}
		if(aktDiv == "start3lc" || aktDiv == "start3lc_m" || aktDiv == "start3lc_h" || aktDiv == "start3lc_p")
			{
			document.forms[this.formname].start_text.value 		= getElementTextNS("", "airport", items[0], 0) + portn;
			document.forms[this.formname].VON.value 			= getElementTextNS("", "code", items[0], 0);
			aus(aktDiv, aktIfr);
			}
		if(aktDiv == "ziel3lc" || aktDiv == "ziel3lc_m" || aktDiv == "ziel3lc_h" || aktDiv == "ziel3lc_p")
			{
			document.forms[this.formname].ziel_text.value 	= getElementTextNS("", "airport", items[0], 0) + portn;
			document.forms[this.formname].NACH.value 		= getElementTextNS("", "code", items[0], 0);
			aus(aktDiv, aktIfr);
			}
		}
	}
