/* toggleDisabled(oForm, bDisabled, sElement1 [, sElementn ...]) */

var isIE = (document.all);
var isGecko = navigator.userAgent.indexOf('Gecko') > -1;
var isSafari = navigator.userAgent.indexOf('Safari') > -1
		|| navigator.userAgent.indexOf('AppleWebKit') > -1;
var isOpera = navigator.userAgent.indexOf('Opera') > -1;

function toggleChecked(oElement) {
	oForm = oElement.form;
	oElement = oForm.elements[oElement.name];
	if (oElement.length) {
		bChecked = oElement[0].checked;
		for (i = 1; i < oElement.length; i++)
			oElement[i].checked = bChecked;
	}
}


function toggleIndeterminate(oElement) {
	oForm = oElement.form;
	oElement = oForm.elements[oElement.name];
	if (oElement.length) {
		bIndeterminate = false;
		bChecked = true;
		nChecked = 0;
		for (i = 1; i < oElement.length; i++)
			if (oElement[i].checked)
				nChecked++;
		if (nChecked < oElement.length - 1) {
			if (nChecked)
				bIndeterminate = true;
			else {
				bIndeterminate = false;
				bChecked = false;
			}
		} else {
			bIndeterminate = false;
		}
		oElement[0].indeterminate = bIndeterminate;
		oElement[0].checked = bChecked;
	}
}

function ListFindNoCase(list, value) {
	var returnValue = -1;
	var i = 0;
	var delimiter = ',';
	var _tempArray = new Array();
	if (ListFindNoCase.arguments.length == 3)
		delimiter = ListFindNoCase.arguments[2];
	list = list.toLowerCase();
	value = value.toLowerCase();
	_tempArray = list.split(delimiter);
	for (i = 0; i < _tempArray.length; i++) {
		if (_tempArray[i] == value) {
			returnValue = i;
			break;
		}
	}
	return returnValue;
};

function toggleDisabled(oForm, bDisabled) {
	if (toggleDisabled.arguments.length < 3)
		return;
	for ( var i = 2; i < toggleDisabled.arguments.length; i++) {
		element = oForm.elements[toggleDisabled.arguments[i]];
		if (element) {
			if (typeof element.length != 'undefined' && element.length > 0
					&& typeof element[0].type != 'undefined'
					&& ListFindNoCase('checkbox,radio', element[0].type) != -1) {
				for ( var j = 0; j < element.length; j++)
					element[j].disabled = bDisabled;
			} else {
				element.disabled = bDisabled;
				if (ListFindNoCase('input,textarea,select', element.tagName) != -1) {
					if (ListFindNoCase('checkbox,radio,button,submit,reset',
							element.type) == -1) {
						switch (element.type.toLowerCase()) {
						case 'text':
						case 'password': {
							if (!element.enabledClass && !element.disabled)
								element.enabledClass = 'inputText';
							if (!element.disabledClass && element.disabled)
								element.disabledClass = 'disabledText';
							break;
						}
						case 'textarea': {
							if (!element.enabledClass && !element.disabled)
								element.enabledClass = 'inputTextarea';
							if (!element.disabledClass && element.disabled)
								element.disabledClass = 'disabledTextarea';
							break;
						}
						default: {
							if (!element.enabledClass && !element.disabled)
								element.enabledClass = element.className;
							if (!element.disabledClass && element.disabled)
								element.disabledClass = element.className;
							break;
						}
						}
						element.className = (bDisabled) ? element.disabledClass
								: element.enabledClass;
						if (element.type.toLowerCase() == 'file'
								&& element.reset)
							element.reset();
					}
					if (element.type.toLowerCase() == 'select-one') {
						if (bDisabled) {
							if (element.selectedIndex != -1)
								element.defaultSelected = element.selectedIndex;
							element.selectedIndex = -1;
						} else {
							if (typeof element.defaultSelected != 'undefined')
								element.selectedIndex = element.defaultSelected;
							element.defaultSelected = element.selectedIndex;
						}
					}
				}
			}
		}
	}
	// if(!bDisabled &&
	// ListFindNoCase('text,password,textarea,checkbox,radio,select-one,select-multiple,submit,reset,button',
	// form.elements[toggleDisabled.arguments[2]].type) != -1)
	// form.elements[toggleDisabled.arguments[2]].focus();
}

/* toggle_displayed.js */

var toggledDisplay = new Object();

function toggleDisplayed(bDisplayed) {
	if (!document.getElementById || toggleDisplayed.arguments.length < 2)
		return;
	var displayed = new Object();
	displayed['true'] = '';
	displayed['false'] = 'none';
	for ( var i = 1; i < toggleDisplayed.arguments.length; i++) {
		oDisplay = document.getElementById(toggleDisplayed.arguments[i]);
		if (oDisplay) {
			oDisplay.style.display = displayed[bDisplayed];
			if (typeof toggledDisplay[toggleDisplayed.arguments[i]] != 'undefined')
				toggledDisplay[toggleDisplayed.arguments[i]] = !bDisplayed;
		}
	}
}

function toggleTabs(oTab) {
	if (!Element.hasClassName(oTab, 'selected')) {
		var oTabs = $A(oTab.parentNode.getElementsByTagName(oTab.tagName));
		oTabs.each( function(oTab) {
			Element.removeClassName(oTab, 'selected');
			oDiv = $(oTab.getAttribute('for'));
			if (oDiv)
				oDiv.style.display = 'none';
		});
		Element.addClassName(oTab, 'selected');
		oDiv = $(oTab.getAttribute('for'));
		if (oDiv)
			oDiv.style.display = 'block';
	}
}

/* newWindow.js */

function newWindow(href, target, width, height) {
	var returnValue = false;
	var features = (arguments.length == 4) ? 'scrollbars,status,width=' + width
			+ ',height=' + height : ((arguments[4]) ? arguments[4] + ',width='
			+ width + ',height=' + height : 'width=' + width + ',height='
			+ height);
	if (window.screen) {
		var pxLeft = ((screen.availWidth - width - 10) * .5);
		var pxTop = ((screen.availHeight - height - 30) * .5);
		features += ',left=' + pxLeft + ',top=' + pxTop + ',x=' + pxLeft
				+ ',y=' + pxTop;
	}
	if (!window.open)
		returnValue = true;
	else {
		self[target + 'Win'] = window.open(href, target, features);
		if (self[target + 'Win'].focus)
			self[target + 'Win'].focus();
	}
	return returnValue;
}

function validateLogin(oForm) {
	var returnValue = true;
	var errorMessage = 'The following errors must be corrected before you may login:';
	var oFocusField = null;
	if (!oForm.username.value) {
		errorMessage += '\n - Username must not be blank';
		if (!oFocusField)
			oFocusField = oForm.username;
		returnValue = false;
	}
	if (!oForm.password.value) {
		errorMessage += '\n - Password must not be blank';
		if (!oFocusField)
			oFocusField = oForm.password;
		returnValue = false;
	}
	if (!returnValue) {
		alert(errorMessage);
		oFocusField.focus();
	}
	return returnValue;
}

function cancelClick(e) {
	if (!e)
		var e = window.event;
	e.cancelBubble = true;
	if (e.stopPropagation)
		e.stopPropagation();
}

function initCategories() {
	if (!document.getElementById)
		return;
	var oUL = null;
	var oCategories = null;
	var i = '';
	var oChildUL = null;
	if (arguments.length > 1)
		oUL = arguments[1];
	else
		oUL = document.getElementById('tree');
	if (oUL) {
		oCategories = oUL.getElementsByTagName('LI');
		for (i = 0; i < oCategories.length; i++) {
			oChildUL = oCategories[i].getElementsByTagName('UL');
			if (oChildUL && oChildUL.length) {
				oChildUL = oChildUL[0];
				if (oCategories[i].className.indexOf('selected') == -1)
					oCategories[i].className = 'collapsed';
				else
					initCategories(arguments[0], oChildUL);
			}
			oCategories[i].onclick = function(e) {
				if (!e)
					var e = window.event;
				if (e.srcElement)
					e = e.srcElement;
				var oUL = e.getElementsByTagName('UL');
				if (oUL && oUL.length) {
					if (e.className.toLowerCase().indexOf('collapsed') != -1)
						e.className = e.className.replace('collapsed',
								'expanded');
					else if (e.className.toLowerCase().indexOf('expanded') != -1)
						e.className = e.className.replace('expanded',
								'collapsed');
					else
						e.className += ' collapsed';
				}
				cancelClick();
			};
		}
	}
}

if (typeof HTMLElement != 'undefined'
		&& typeof HTMLElement.prototype.__defineGetter__ != 'undefined') {
	// HTMLElement.prototype.__defineGetter__('innerText',
	// function()
	// {
	// var tmp = this.innerHTML.replace(//gi, '\n');
	// return tmp.replace(/]+>/g, '');
	// }
	// );
	HTMLElement.prototype.__defineSetter__('innerText', function(txtStr) {
		var parsedText = document.createTextNode(txtStr);
		this.innerHTML = '';
		this.appendChild(parsedText);
	});
}

document.getElementsByAttributeValue = function(elements, attribute, value) {
	var returnValue = [];
	var i = 0;
	if (!elements)
		elements = document.all ? document.all : document
				.getElementsByTagName('*');
	for (i = 0; i < elements.length; i++) {
		if (elements[i].getAttribute(attribute)
				&& elements[i].getAttribute(attribute) == value)
			returnValue[returnValue.length] = elements[i];
	}
	return returnValue;
}

//
// getPageScroll()
// Returns array with x,y page scroll values.
// Core code from - quirksmode.org
//
function getPageScroll() {

	var xScroll = 0;
	var yScroll = 0;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop) { // Explorer
		// 6
		// Strict
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
	}

	arrayPageScroll = new Array(xScroll, yScroll)
	return arrayPageScroll;
}

//
// getPageSize()
// Returns array with page width, height and window width, height
// Core code from - quirksmode.org
// Edit for Firefox by pHaez
//
function getPageSize() {

	var xScroll, yScroll;

	if (window.innerHeight && window.scrollMaxY) {
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight) { // all
		// but
		// Explorer
		// Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla
		// and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}

	var windowWidth, windowHeight;
	if (self.innerHeight) { // all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement
			&& document.documentElement.clientHeight) { // Explorer 6 Strict
		// Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}

	// for small pages with total height less then height of the viewport
	if (yScroll < windowHeight) {
		pageHeight = windowHeight;
	} else {
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if (xScroll < windowWidth) {
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}

	arrayPageSize = new Array(pageWidth, pageHeight, windowWidth, windowHeight)
	return arrayPageSize;
}

function stripUnits(value) {
	return parseInt(value, 10);
}

function getNode(id) {
	return document.getElementById(id);
}

function getElementComputedStyle(object, property) {
	if (document.defaultView && document.defaultView.getComputedStyle)
		return document.defaultView.getComputedStyle(object, null)
				.getPropertyValue(property);
	else {
		if (object.currentStyle)
			return object.currentStyle[property];
		else
			return null;
	}
}

function getElementComputedHeight(object) {
	var nHeight = getElementComputedStyle(object, 'height');
	if (nHeight != null) {
		if (nHeight == 'auto') {
			if (object.offsetHeight)
				nHeight = object.offsetHeight;
		}
		nHeight = parseInt(nHeight, 10);
	}
	return nHeight;
}

function getElementComputedWidth(object) {
	var nWidth = getElementComputedStyle(object, 'width');
	if (nWidth != null) {
		if (nWidth.indexOf('px') != -1)
			nWidth = nWidth.substring(0, nWidth.indexOf('px'));
		if (nWidth == 'auto') {
			if (object.offsetWidth)
				nWidth = object.offsetWidth;
		}
	}
	return nWidth;
}

function getElementOffsetY(object) {
	var nOffset = 0;
	if (object.offsetTop != null) {
		nOffset += object.offsetTop;
		while (object.offsetParent) {
			nOffset += object.offsetParent.offsetTop;
			object = object.offsetParent;
		}
	}
	return nOffset;
}

function getElementMouseCoordinate(evt, object) {
	var difX = -1;
	if (!evt)
		var evt = window.event;
	if (evt.offsetX)
		difX = evt.offsetX;
	else {
		if (object.offsetX != null) {
			var nOffsetX = object.offsetX;
			difX = evt.layerX - nOffsetX;
		} else {
			if (evt.layerX) {
				var nOffsetX = getElementOffsetX(object);
				difX = evt.layerX - nOffsetX;
				object.offsetX = nOffsetX;
			}
		}
	}
	return difX;
}

function getElementOffsetX(object) {
	return handleElementOffsetX(object, true);
}

function getPageElementOffsetX(object) {
	return handleElementOffsetX(object, false);
}

function handleElementOffsetX(object, bPage) {
	var nOffsetX = 0;
	if (object.offsetLeft != null) {
		nOffsetX += object.offsetLeft;
		var _31 = 0;
		while (object.offsetParent) {
			if (bPage
					&& getElementComputedStyle(object.offsetParent, 'position') == 'absolute') {
				return nOffsetX;
			} else {
				nOffsetX += object.offsetParent.offsetLeft;
				object = object.offsetParent;
			}
		}
	}
	return nOffsetX;
}

function getNodeTop(id) {
	var oNode = document.getElementById(id);
	var nTop = oNode.style.top ? (oNode.offsetTop - stripUnits(oNode.style.top))
			: oNode.offsetTop;
	return nTop;
}

function getNodeLeft(id) {
	var oNode = document.getElementById(id);
	var nLeft = oNode.style.top ? (oNode.offsetLeft - stripUnits(oNode.style.left))
			: oNode.offsetLeft;
	return nLeft;
}

function moveNode(object, y) {
	if (typeof object == 'string')
		object = getNode(object);
	if (object.style.top)
		object.style.top = stripUnits(object.style.top) + y + 'px';
	else
		object.style.top = (y) + 'px';
}

function getElementHeightMidpoint(object, _50) {
	var nHeight = getElementComputedHeight(object);
	if (nHeight == null)
		return null;
	else {
		var temp = '' + nHeight;
		if (temp.indexOf('px') != -1)
			nHeight = temp.substring(0, nHeight.indexOf('px'));
	}
	return nHeight / 2;
}

function sentenceList(list, concatenator) {
	var returnValue = list;
	var delimiter = ',';
	var _tempArray = new Array();
	if (sentenceList.arguments.length == 3)
		delimiter = sentenceList.arguments[2];
	_tempArray = list.split(delimiter);
	if (_tempArray.length)
		returnValue = _tempArray[0];
	for ( var i = 1; i < _tempArray.length - 1; i++)
		returnValue += ', ' + _tempArray[i];
	if (_tempArray.length > 2)
		returnValue += ',';
	if (_tempArray.length > 1)
		returnValue += ' ' + concatenator + ' '
				+ _tempArray[_tempArray.length - 1];
	return returnValue;
};

function removeOptions(oElement) {
	oElement.options.length = 0;
}

function removeOption(oElement, index) {
	for ( var i = index + 1; i < oElement.options.length; i++)
		oElement.options[i - 1] = new Option(oElement.options[i].text,
				oElement.options[i].value);
	oElement.options.length = oElement.options.length - 1;
}

function addOptions(oElement, labels, values, selectedValue) {
	for ( var i = 0; i < values.length; i++) {
		if (labels[i] || values[i]) {
			oElement.options[oElement.options.length] = new Option(labels[i],
					values[i]);
			if (selectedValue
					&& values[i].toLowerCase() == selectedValue.toLowerCase())
				oElement.options[oElement.options.length - 1].selected = true;
		}
	}
}

function addOption(oElement, label, value, selected) {
	for ( var i = oElement.options.length - 1; i > 0; i--)
		oElement.options[i + 1] = new Option(oElement.options[i].text,
				oElement.options[i].value);
	oElement.options[0] = new Option(label, value);
	oElement.options[0].selected = selected;
}

/*
 * if(window.addEventListener) window.addEventListener('load', initCategories,
 * false); // gecko, safari, konqueror and standard else
 * if(document.addEventListener) document.addEventListener('load',
 * initCategories, false); // opera 7 else if(window.attachEvent) { // win/ie
 * window.attachEvent('onload', initCategories); } else { // mac/ie5 if(typeof
 * window.onload == 'function') { var existing = onload; window.onload =
 * function() { existing(); initCategories(); } } else { window.onload =
 * function() { initCategories(); } } }
 */

function addError(oElement, sError) {
	var oError = (oElement.parentNode.firstChild.tagName.toLowerCase() == 'p') ? oElement.parentNode.firstChild
			: null;
	if (!oError) {
		oError = document.createElement('P');
		oError.className = 'error';
		oElement.parentNode
				.insertBefore(oError, oElement.parentNode.firstChild);
	}
	oError.innerHTML = sError;
	if (!Element.hasClassName(oElement.parentNode, 'error'))
		Element.addClassName(oElement.parentNode, 'error');
}

function removeError(oElement) {
	var oError = (oElement.parentNode.firstChild.tagName.toLowerCase() == 'p') ? oElement.parentNode.firstChild
			: null;
	if (oError) {
		oError.removeNode(true);
		Element.removeClassName(oElement.parentNode, 'error');
	}
}

function initDownload(file_path) {
	document
			.write('<iframe height="0" width="0" src="' + file_path + '"></iframe>');
}

function toggleTripOptions(option) {
	var optionPanel;
	var execPanel;
	for (i = 1; i < 8; i++) {
		if (document.getElementById("searchPanel_" + i) && document.getElementById("execPanel_" + i)){
			optionPanel = document.getElementById("searchPanel_" + i);
			execPanel = document.getElementById("execPanel_" + i);
			optionPanel.style.display = "none";
			execPanel.style.display = "none";
		}
	}
	optionPanel = document.getElementById("searchPanel_" + option);
	optionPanel.style.display = "block";

	execPanel = document.getElementById("execPanel_" + option);
	execPanel.style.display = "block";

}

function toggleDetailPanel(id, count) {
	jQuery.noConflict();
	jQuery(document).ready( function() {
		for (i = 1; i <= count; i++) {
			jQuery("#panel_detail_" + i).hide();
			jQuery("#panel_img_" + i).attr( {
				src :"images/down.png",
				title :"Expand",
				alt :"Expand"
			});
			jQuery("#panel_title_" + i).addClass("hilight");

		}

		jQuery("#panel_detail_" + id).show();
		jQuery("#panel_img_" + id).attr( {
			src :"images/forward.png",
			title :"Collapse",
			alt :"Collapse"
		});
		jQuery("#panel_title_" + id).removeClass("hilight");
	});

}

function toggleOrderedTrips() {
	jQuery.noConflict();
	jQuery(document).ready( function() {
		jQuery("#search_trips").hide();
		jQuery("#ordered_trips").show();
	});

}

function toggleSearchTrips() {
	jQuery.noConflict();
	jQuery(document).ready( function() {
		jQuery("#ordered_trips").hide();
		jQuery("#search_trips").show();
	});
}

function toggleTripInformation(id, count) {
	jQuery.noConflict();
	jQuery(document).ready( function() {
		for (i = 1; i <= count; i++) {
			jQuery("#trip_information_" + i).hide();
			jQuery("#btn_trip_" + i).html("&or;");
		}

		jQuery("#trip_information_" + id).show("slow");
		jQuery("#btn_trip_" + id).html("&and;");
	});
}

function load_passenger_profile(query_string, passenger_id) {
	// alert("trip_infomation.php?" + query_string + passenger_id);
	if(passenger_id == "")
	{
			return;
	}
	xajax_loadPassengerProfile(passenger_id);
	//window.location = "trip_information.php?" + query_string + passenger_id;
}

function load_pickup_profile(query_string, location_id) {
	// alert("trip_infomation.php?" + query_string + passenger_id);
	document.getElementById('pickup_location_save_later').checked = false;
	jQuery('#from_profile_name_loc').hide();

	if(location_id == "")
	{
			return;
	}
	xajax_loadPickupProfile(location_id);
	//window.location = "trip_information.php?" + query_string + location_id;
}

function load_pickup_airport_profile(provider_id, location_id) {
	// alert("trip_infomation.php?" + query_string + passenger_id);

	if(location_id == "")
	{
			return;
	}
	xajax_loadPickupAirportProfile(provider_id, location_id);
	//window.location = "trip_information.php?" + query_string + location_id;
}

function load_dest_profile(query_string, location_id) {
	// alert("trip_infomation.php?" + query_string + passenger_id);

	document.getElementById('dest_location_save_later').checked = false;
	jQuery('#to_profile_name_loc').hide();
	if(location_id == "")
	{
			return;
	}
	xajax_loadDestProfile(location_id);
	//window.location = "trip_information.php?" + query_string + location_id;
}

function load_dest_airport_profile(query_string, location_id) {
	// alert("trip_infomation.php?" + query_string + passenger_id);
	// alert("trip_infomation.php?" + query_string + passenger_id);
	if(location_id == "")
	{
			return;
	}
	xajax_loadDestAirportProfile(location_id);
	//window.location = "trip_information.php?" + query_string + location_id;
}

function lookup(inputString, tblName, fieldName, inputID, suggestionID, dataID) {
	jQuery.noConflict();
	if(inputString.length == 0) {
		// Hide the suggestion box.
		jQuery('#' + suggestionID).hide();
	} else {
		jQuery.post("rpc.php", {queryString: ""+inputString+"", table: tblName, field: fieldName, divID:inputID, outputID:suggestionID }, function(data){
			if(data.length >0) {
				jQuery('#' + suggestionID).show();
				jQuery('#' + dataID ).html(data);
			}
		});
	}
} // lookup

function fill(thisValue, inputID, suggestionID) {
	jQuery.noConflict();
	jQuery("#" + inputID ).val(thisValue);
	setTimeout("jQuery('#" + suggestionID + " ').hide();", 200);
}


function lookup_airport_pickup(inputString) {

	jQuery.noConflict();
	if(inputString.length == 0) {
		// Hide the suggestion box.
		jQuery('#output_airport_pickup').hide();
	} else {
		jQuery.post("rpc_airport_pickup.php", {queryString: ""+inputString+""}, function(data){
			if(data.length >0) {
				jQuery('#output_airport_pickup').show();
				jQuery('#data_airport_pickup').html(data);
			}
		});
	}
} // lookup

function lookup_airport_pickup_aaa(inputString) {

	jQuery.noConflict();
	if(inputString.length == 0) {
		// Hide the suggestion box.
		jQuery('#output_airport_pickup_aaa').hide();
	} else {
		jQuery.post("rpc_airport_pickup_aaa.php", {queryString: ""+inputString+""}, function(data){
			if(data.length >0) {
				jQuery('#output_airport_pickup_aaa').show();
				jQuery('#data_airport_pickup_aaa').html(data);
			}
		});
	}
} // lookup

function lookup_airport_pickup2(inputString) {

	jQuery.noConflict();
	if(inputString.length == 0) {
		// Hide the suggestion box.
		jQuery('#output_airport_pickup2').hide();
	} else {
		jQuery.post("rpc_airport_pickup2.php", {queryString: ""+inputString+""}, function(data){
			if(data.length >0) {
				jQuery('#output_airport_pickup2').show();
				jQuery('#data_airport_pickup2').html(data);
			}
		});
	}
} // lookup

function fill_airport_pickup(thisValue) {
	jQuery.noConflict();
	jQuery('#from_airport').val(thisValue);
	setTimeout("jQuery('#output_airport_pickup').hide();", 200);
}

function fill_airport_pickup_aaa(thisValue) {
	jQuery.noConflict();
	jQuery('#from_airport_AAA').val(thisValue);
	setTimeout("jQuery('#output_airport_pickup_aaa').hide();", 200);
}


function fill_airport_pickup2(thisValue) {
	jQuery.noConflict();
	var str= thisValue;
	var item = str.split(",");
	jQuery('#faa_name').val(item[0]);


	jQuery('#airport_name').val(trim(item[1]));

	jQuery('#city').val(trim(item[2]));
	jQuery('#state').val(trim(item[3]));

	//setTimeout("jQuery('#output_airport_pickup').hide();", 200);
	setTimeout("jQuery('#output_airport_pickup2').hide();", 200);
}

function lookup_airport_dropoff(inputString) {

	jQuery.noConflict();
	if(inputString.length == 0) {
		// Hide the suggestion box.
		jQuery('#output_airport_dropoff').hide();
	} else {
		jQuery.post("rpc_airport_dropoff.php", {queryString: ""+inputString+""}, function(data){
			if(data.length >0) {
				jQuery('#output_airport_dropoff').show();
				jQuery('#data_airport_dropoff').html(data);
			}
		});
	}
} // lookup

function fill_airport_dropoff(thisValue) {
	jQuery.noConflict();
	jQuery('#to_airport').val(thisValue);
	setTimeout("jQuery('#output_airport_dropoff').hide();", 200);
}

function lookup_airport_dropoff_aaa(inputString) {

	jQuery.noConflict();
	if(inputString.length == 0) {
		// Hide the suggestion box.
		jQuery('#output_airport_dropoff_aaa').hide();
	} else {
		jQuery.post("rpc_airport_dropoff_aaa.php", {queryString: ""+inputString+""}, function(data){
			if(data.length >0) {
				jQuery('#output_airport_dropoff_aaa').show();
				jQuery('#data_airport_dropoff_aaa').html(data);
			}
		});
	}
} // lookup

function fill_airport_dropoff_aaa(thisValue) {
	jQuery.noConflict();
	jQuery('#to_airport_AAA').val(thisValue);
	setTimeout("jQuery('#output_airport_dropoff_aaa').hide();", 200);
}



function showFilterValue()
{

	var low_rate = jQuery('#rateA').val();
	var high_rate = jQuery('#rateB').val();
	var low_price = jQuery('#priceA').val();
	var high_price = jQuery('#priceB').val();
	var vehicle_type = jQuery('#vehicleA').val();


	location.href = "results.php?filter=1&low_rate=" + low_rate + "&high_rate=" + high_rate + "&low_price=" + low_price + "&high_price=" + high_price + "&vehicle_type=" + vehicle_type;
	//alert("results.php?filter=1&low_rate=" + low_rate + "&high_rate=" + high_rate + "&low_price=" + low_price + "&high_price=" + high_price);

}

function sortBy(value)
{
	location.href = "results.php?sort=" + value;

}

function sortBy_PreBuildTrips(value)
{
	location.href = "result_trips.php?sort=" + value;
}

function doSortBy()
{
	var sort = jQuery('#dropdown_sort').val();
	location.href = "results.php?sort=" + sort;

}

function doSortBy_PreBuildTrips()
{
	var sort = jQuery('#dropdown_sort').val();
	location.href = "result_trips.php?sort=" + sort;

}
/*
function showLocationView(value)
{
	if(value == 0){
		location.href = "my_locations.php";
	}
	else
	{
		location.href = "my_airports.php";
	}
}
*/
//Removes leading whitespaces
function LTrim( value ) {

	var re = /\s*((\S+\s*)*)/;
	return value.replace(re, "$1");

}

// Removes ending whitespaces
function RTrim( value ) {

	var re = /((\s*\S+)*)\s*/;
	return value.replace(re, "$1");

}

// Removes leading and ending whitespaces
function trim( value ) {

	return LTrim(RTrim(value));

}


