FLYG.ready(function(){

	if (document.getElementById('last_minute_flights')){

		FLYG.LastMinuteBox=function(id,depHeader,defaultDep,defaultType){
			this.id=id;
			this.dep=new FLYG.FormControls.SelectBox(id+'_dep',depHeader);
			this.type=defaultType ? new FLYG.FormControls.SelectBox(id+'_type') : false;
			if (this.dep.control[0].options.length==1) defaultDep=this.dep.control[0].options[0].value;
			this.current=[defaultDep,defaultType||''];
			};

		FLYG.LastMinuteBox.prototype.update=function(){
			this.dep.rename();
			var data=[this.dep.getValue(), this.type ? this.type.getValue() : ''];
			if (this.current) FLYG.$(this.id+'_'+this.current[0]+'_'+this.current[1]).hide();
			FLYG.$(this.id+'_'+data[0]+'_'+data[1]).show();
			this.current=data;
			};
		
		var lmf=new FLYG.LastMinuteBox('last_minute_flights','From','GLA','ow');
		lmf.dep.setValue(lmf.current[0]);
		lmf.type.setValue(lmf.current[1]);
		FLYG.$(lmf.dep.id, lmf.type.id).change(function(){ lmf.update() });
		
		}
	
	});