 jQuery(document).ready(function(){
 	var url_base='/';
 	var language='ro';
 	
 jQuery("#to_1,#from_1,#to_2,#from_2,#to_3,#from_3").autocomplete(url_base + 'media/php/autocomplete.php', {
        minChars: 2,
        width: 280,
        max: 20,
   
   
   
      	 selectFirst:true,
      	 formatMatch:true,
        delay: 0,
        cacheLength: 20000,
        delay: 0,
        extraParams: {
            'lang': language
        },
        scroll: false,
        scrollHeight: 130,
        matchContains: true,
        parse: function(data){
            return jQuery.map(eval(data), function(row){
                if (row) {
                    return {
                        data: row,
                        value: row.kod + '|' + row.name,
                        result: row.kod
                    }
                    
                }
                
            });
        },
        formatItem: function(item){
            if (item.depend) {
                return '<span class="depend_city"> ->' + item.name + ', ' + item.country + ' - ' + item.airport + " (" + item.kod + ")</span>";
            }
            else {
                return item.name + ', ' + item.country + ' - ' + item.airport + " (" + item.kod + ")";
            }
            
            
        }
    }).result(function(event, data){
        if (data) {
            var id = jQuery(this).attr('id');
           // eval(id + '_filled=1;');
            if(id=='External_FlightFareSearch_From'){
            	jQuery('#flight_from_code').val(data.kod);
            }
            if(id=='External_FlightFareSearch_To'){
            	jQuery('#flight_to_code').val(data.kod);
            }
        }
        
    });
    });
    
    
    function make_search(){
   		// alert(jQuery('#flightSearchForm').attr('target'));
    	jQuery('#flightSearchForm').attr('action','http://fullvola.demo.pakla.pl/betaSearch');
    		//alert(jQuery('#flightSearchForm').attr('target'));
    jQuery('#flightSearchForm').submit();
    	return false;
    }