$(document).ready(function(){	
	var tmp = new Array();      
	var tmp2 = new Array();     
	var param = new Array();
	var get = location.search;  
	if(get != '') {
		tmp = (get.substr(1)).split('&');  
		for(var i=0; i < tmp.length; i++) {
			tmp2 = tmp[i].split('=');      
			param[tmp2[0]] = tmp2[1];       
		}
		$("input._locDep").val = '';
		$("input._locArr").val = '';
		$("input[name='FlightSearchForm.departureLocation.0.CODE']").val = '';
		$("input[name='FlightSearchForm.arrivalLocation.0.CODE']").val = '';
		
		for (var key in param) {
			if(key == 'cityDepN')
				//$("input._locDep").attr('value',decodeURI(param[key]));
				$("input._locDep").attr('value',decodeURIComponent(param[key]).replace("+"," "));
			if(key == 'cityArrN')
				//$("input._locArr").attr('value',decodeURI(param[key]));
				$("input._locArr").attr('value',decodeURIComponent(param[key]).replace("+"," "));
			if(key == 'cityDepC')
				$("input[name='FlightSearchForm.departureLocation.0.CODE']").attr('value',param[key]);
			if(key == 'cityArrC')
				$("input[name='FlightSearchForm.arrivalLocation.0.CODE']").attr('value',param[key]);
			if(key == 'DateStr')
				$('input#dateStr_0').attr('value',param[key]);
			if(key == 'retDateStr')
				$('input#returnDateStr').attr('value',param[key]);
			if(key == 'searchMode')
				$("input[value="+param[key]+"]").attr('checked','checked');
			if(key == 'adultsType')
				$("option[value="+param[key]+"]").attr('selected','selected');
			if(key == 'adultsCount')
				$("select[name='FlightSearchForm.adultsCount'] option[value="+param[key]+"]").attr('selected','selected');	
			if(key == 'children')
				$("select[name='FlightSearchForm.children'] option[value="+param[key]+"]").attr('selected','selected');
			if(key == 'infants')
				$("select[name='FlightSearchForm.infants'] option[value="+param[key]+"]").attr('selected','selected');
				$('button.submitbutton').click();
			//validateSearchForm();
			var go = function(){
				//$('button.submitbutton').click();
			}			
			
		}
	}
});
