/* --------------------------------------------------------------- */
// Search page - Oneway Trip tab
//
// var author = Remi Palard;
// author.email = remi.palard@gmail.com;
//
/* --------------------------------------------------------------- */

function onewaySubmit() { 	
	var f = document.forms['onewayTravel'];	 
	
	if ($('onewayunaccompaniedWarning').style.display != 'none')
		return;
		
	if ($('onewaymaxWarning').style.display != 'none')
		return;
	
	if (!isPosted){
		var params = $H({"idd":"4.1.1", "trip_type":f.currentTripTab.value});
		pingSurfaid(params);
		isPosted = true;

		// Patch the airport control fields since they may be not synchronized with their visual pairs. 
		["from", "to"].each(function(direction) {
			var name = "city1" + direction.capitalize() + "Oneway";
			var field = $(name);
			if(field.value.length > 2) {
				$(name + "Code").value = field.value.substr(0, 3).toUpperCase();
			}
		});

		f.submit();
	}
	
	// Close city popup
	if (WindowCityPopup != '') WindowCityPopup.close();	
}
