function startswf(v1,v2,v3,v4){
	document.flymask.flytofrom.options[0].selected=true;
	document.flymask.flytoto.options[0].selected=true;
	document.flymask.flybackfrom.options[0].selected=true;
	document.flymask.flybackto.options[0].selected=true;
	var defaulttofrom=v1;
		for (i=0;i<document.flymask.flytofrom.length;i++){
			if (document.flymask.flytofrom.options[i].value==defaulttofrom){
				document.flymask.flytofrom.options[i].selected=true;
		}
	}
	var defaulttoto=v2;
		for (i=0;i<document.flymask.flytoto.length;i++){
			if (document.flymask.flytoto.options[i].value==defaulttoto){
				document.flymask.flytoto.options[i].selected=true;
		}
	}
	var defaultbackfrom=v3;
		for (i=0;i<document.flymask.flybackfrom.length;i++){
			if (document.flymask.flybackfrom.options[i].value==defaultbackfrom){
				document.flymask.flybackfrom.options[i].selected=true;
		}
	}
	var defaultbackto=v4;
		for (i=0;i<document.flymask.flybackto.length;i++){
			if (document.flymask.flybackto.options[i].value==defaultbackto){
				document.flymask.flybackto.options[i].selected=true;
			}
	}
}


function startairport(v1,v2,v3,v4,action,strecke){
	var defaulttofrom=v1;
	if (document.flymask.flytofrom.selectedIndex==0){
		for (i=0;i<document.flymask.flytofrom.length;i++){
			if (document.flymask.flytofrom.options[i].value==defaulttofrom){
				document.flymask.flytofrom.options[i].selected=true;
			}
		}
	}
	var defaulttoto=v2;
	if (document.flymask.flytoto.selectedIndex==0){
		for (i=0;i<document.flymask.flytoto.length;i++){
			if (document.flymask.flytoto.options[i].value==defaulttoto){
				document.flymask.flytoto.options[i].selected=true;
			}
		}
	}
	if (strecke==1){
	var defaultbackfrom=v3;
	if (document.flymask.flybackfrom.selectedIndex==0){
		for (i=0;i<document.flymask.flybackfrom.length;i++){
			if (document.flymask.flybackfrom.options[i].value==defaultbackfrom){
				document.flymask.flybackfrom.options[i].selected=true;
			}
		}
	}
	}
	if (strecke==1){
	var defaultbackto=v4;
	if (document.flymask.flybackto.selectedIndex==0){
		for (i=0;i<document.flymask.flybackto.length;i++){
			if (document.flymask.flybackto.options[i].value==defaultbackto){
				document.flymask.flybackto.options[i].selected=true;
			}
		}
	}
	}
	changeoption('idflytofrom','idflytoto');
	if (action==1){
		var defaulttofrom=v1;
		for (i=0;i<document.flymask.flytofrom.length;i++){
			if (document.flymask.flytofrom.options[i].value==defaulttofrom){
				document.flymask.flytofrom.options[i].selected=true;
			}
		}
	var defaulttoto=v2;
		for (i=0;i<document.flymask.flytoto.length;i++){
			if (document.flymask.flytoto.options[i].value==defaulttoto){
				document.flymask.flytoto.options[i].selected=true;
			}
		}
	if (strecke==1){
	var defaultbackfrom=v3;
		for (i=0;i<document.flymask.flybackfrom.length;i++){
			if (document.flymask.flybackfrom.options[i].value==defaultbackfrom){
				document.flymask.flybackfrom.options[i].selected=true;
			}
		}
	}
	if (strecke==1){
	var defaultbackto=v4;
		for (i=0;i<document.flymask.flybackto.length;i++){
			if (document.flymask.flybackto.options[i].value==defaultbackto){
				document.flymask.flybackto.options[i].selected=true;
			}
		}
	}
}
	if (strecke==1){
	changeoption('idflytoto','idflybackfrom');
	changeflybackfrom2('idflybackto');
	}
document.flymask.flytofrom.blur();
document.flymask.flytoto.blur();
if (strecke==1){
document.flymask.flybackfrom.blur();
document.flymask.flybackto.blur();
}
}

function changeoption(elementid,targetid){
	if (elementid=="idflytofrom"){
		document.getElementById(targetid).length=0;
		document.getElementById(targetid).options[0]=new Option ('','',false,false);
		var codehin=document.flymask.flytofrom.options[document.flymask.flytofrom.selectedIndex].value;
		var k=1;
		for (var i = 0; i < route.length;i++){
			var values=route[i].split('#');
			if (values[0]==codehin){
				document.getElementById(targetid).options[k]=new Option (airportname[values[1]],values[1],false,false);
				k++;
				var testvalue=values[2];
			}
		}
	}
	if (elementid=="idflytoto"){
		document.getElementById(targetid).length=0;
		document.getElementById(targetid).options[0]=new Option ('','',false,false);
		var codehin=document.flymask.flytofrom.options[document.flymask.flytofrom.selectedIndex].value;
		var k=1;
		for (var i = 0; i < route.length;i++){
			var values=route[i].split('#');
			if (values[1]==codehin){
				var testroute=values[2];
				break;
			}
		}

		var k=1;
		for (var i = 0; i < route.length;i++){
			var values=route[i].split('#');
			if (values[0]==codehin){
				document.getElementById(targetid).options[k]=new Option (airportname[values[1]],values[1],false,false);
				k++;
				var testvalue=values[2];
			}
		}
		
		var codezur=document.flymask.flytoto.options[document.flymask.flytoto.selectedIndex].value;
		document.flymask.flybackfrom.focus();
		for (var i = 0; i < document.flymask.flybackfrom.length;i++){
			if (document.flymask.flybackfrom.options[i].value==codezur){
				document.flymask.flybackfrom.options[i].selected=true;
				document.flymask.flybackfrom.selectedIndex=i;
			}
		}
		changeflybackfrom2('idflybackto');
	}
}

function changeflybackfrom2(targetid){
	document.getElementById(targetid).length=0;
	document.getElementById(targetid).options[0]=new Option ('....','',false,false);
	var codehin=document.flymask.flybackfrom.options[document.flymask.flybackfrom.selectedIndex].value;
	var k=1;
	for (var i = 0; i < route.length;i++){
	var values=route[i].split('#');
		if (values[0]==codehin){
			document.getElementById(targetid).options[k]=new Option (airportname[values[1]],values[1],false,false);
			k++;
		}
	}
		var codezur=document.flymask.flytofrom.options[document.flymask.flytofrom.selectedIndex].value;
		for (var i = 0; i < document.flymask.flybackto.length;i++){
		if (document.flymask.flybackto.options[i].value==codezur){
			document.flymask.flybackto.options[i].selected=true;
		}
	}
}