/*
These functions are used to pop messages + to pop "send quote" form for qutoe confirmation
*/
/* validate quote form on get-a-quote page */
function getQuote(formID){

	//*** vars to show error tabs
	var et1 = false;
	var et2 = false;
	var et3 = 0;
	var vFail1 = 0;

//	var jetType = document.forms[formID].elements['jetType'];		//step2
//	var jetTypeDiv = document.getElementById('jetTypeDiv');

	var isMem = document.forms[formID].elements['ismember'];


	//*** Handle Step 1.
	//var e1 = validateCharterForm(formID);	//this will return vFail count from "validateCharterForm"
	//alert('errors from Step 1. = ' + e1);
	/*if(e1 > 0){
		//display step1 red tab
		et1 = true;
		vFail1 = e1;
	}*/

	//*** Handle Step 2.
	/*if(jetType.value == 'choose'){
		//jetType.style.border = '2px solid #CC0000';
		jetTypeDiv.style.border = '2px solid #CC0000';
		vFail1++;
		//display step2 red tab
		et2 = true;
	} else {
		//jetType.style.border = '';
		jetTypeDiv.style.border = '';
		et2 = false;
	}*/

	//*** Handle Step 3.
	if(isMem.checked == false){
		//visitor is NOT a member
		var firstName = document.forms[formID].elements['firstName'];
		var lastName = document.forms[formID].elements['lastName'];
		var email = document.forms[formID].elements['email'];
		var phone = document.forms[formID].elements['phone'];

		if(firstName.value == ''){
			//alert('firstName et3++');
			firstName.style.border = '2px solid #CC0000';
			vFail1++;
			et3++;
		} else {
			//alert('firstName et3--');
			firstName.style.border = '';
			et3--;
		}

		if(lastName.value == ''){
			//alert('lastName et3++');
			lastName.style.border = '2px solid #CC0000';
			vFail1++;
			et3++;
		} else {
			//alert('lastName et3--');
			lastName.style.border = '';
			et3--;
		}

		if(email.value == ''){
			//alert('email et3++');
			email.style.border = '2px solid #CC0000';
			vFail1++;
			et3++;
		} else {
			//email.style.border = '';
			//et3--;
			//validate email
			var validEmail1 = validateEmail(email.value);
			if(validEmail1 == true){
				//alert('valid regular email');
				email.style.border = '';
				et3--;
			} else {
				//alert('INvalid regular email');
				email.style.border = '2px solid #CC0000';
				vFail1++;
				et3++;
			}
		}

		if(phone.value == ''){
			phone.style.border = '2px solid #CC0000';
			vFail1++;
			et3++;
		} else {
			phone.style.border = '';
			et3--;
		}

		//alert('et3 (non member): ' + et3);

	} else {
		//visitor IS a member - probably
		var memE = document.forms[formID].elements['memberEmail'];
		var memP = document.forms[formID].elements['memberPass'];

		//Check to see if memberEmail + memberPass are filled
		if(memE.value == ''){
			memE.style.border = '2px solid #CC0000';
			vFail1++;
			et3++;
		} else {
			//validate email
			var validEmail = validateEmail(memE.value);
			if(validEmail == true){
				//alert('valid memberEmail');
				memE.style.border = '';
				et3--;
			} else {
				//alert('INvalid memberEmail');
				memE.style.border = '2px solid #CC0000';
				vFail1++;
				et3++;
			}
		}

		if(memP.value == ''){
			memP.style.border = '2px solid #CC0000';
			vFail1++;
			et3++;
		} else {
			memP.style.border = '';
			et3--;
		}

		//alert('et3 (member section): ' + et3);

		//*** Decided to do this in php by submitting the form
		/*
		if(et3 <= 0){
			alert('Verify Member email + password');
			var memberResult = testMember(memE.value, memP.value);
			alert('memberResult: ' + memberResult);

		////////
		/ *
			1. email is valid if you're here
				- use ajax to check db for existance of member (email + pass)
			2. if member DNE
				- hi-light user red
				- vFail++
				- hi-light password red too
				- vFail++
			2. if member exists
				- if password is correct --> proceed normally with rest of quote
				- else if password is INcorrect
					- hi-light red
					- vFail1++
		* ////////
		}*/

	}


	if(vFail1 > 0){	//there are errors, do not submit form

		//alert('fix errors');
		/*if(et1 == true){
			//alert('step1 errors');
			document.getElementById('step1alert').style.display = 'block';
		} else {
			document.getElementById('step1alert').style.display = 'none';
		}

		if(et2 == true){
			//alert('step2 errors');
			document.getElementById('step2alert').style.display = 'block';
		} else {
			document.getElementById('step2alert').style.display = 'none';
		}

		if(et3 > 0){
			//alert('step3 errors');
			document.getElementById('step3alert').style.display = 'block';
		} else {
			document.getElementById('step3alert').style.display = 'none';
		}*/


	} else {

		//*** 1. Loop through checkboxes with '_' to Get List of Selected Aircraft + their types (for cost calcs)
		//*** 2. Proceed to user validation

		var selected = 0;
		var selectedStr = '';
		var cbID;
		var cbIDArr;
		var cbType;
		var acType;
		var acManu;
		var acModel;
		var acSeats;
		var acPrice;
		for (var i = 0; i < document.forms[formID].elements.length; i++) {
			if (document.forms[formID].elements[i].type == 'checkbox') {
				cbID = document.forms[formID].elements[i].id;
				cbIDArr = cbID.split("_");
				//*** input id will look like:
				//selectedAircraft, table id, aircraft type, manufacturer, model, seating capacity
				//<input type="checkbox" id="selectedAircraft_178_light_CESSNA_CITATION-CJ2_6_2450" name="selectedAircraft_178" value="selectedAircraft_178" onclick="saveCheckAircraft(this.checked,'178','#fff')" style="margin:0; padding:0;">

				cbType = cbIDArr[0];
				if(cbType == 'selectedAircraft'){
					acType = cbIDArr[2];
					acManu = cbIDArr[3];
					acModel = cbIDArr[4];
					acSeats = cbIDArr[5];
					acPrice = cbIDArr[6];
					if (document.forms[formID].elements[i].checked == true) {
						selected++;
						if(selectedStr.length > 0)
							selectedStr += '||' + acType + '_' + acManu + '_' + acModel + '_' + acSeats + '_' + acPrice;
						else
							selectedStr += acType + '_' + acManu + '_' + acModel + '_' + acSeats + '_' + acPrice;
					}
				}
			}
		}

		if(selected > 0){

			if(selected <= 5){
				document.getElementById('jetTypes').value = selectedStr;
				//alert('success - submitting form');
				document.getElementById('tripSubmission').value = 'submitted';

				//*** Need to check if trip is >= 3 days if it is a return trip
				//	- we will need this hidden element '3day' to be populated to be used later in the
				//	  'getTripDetails' functino in the 'pop-quote-functions.php' file
				///////////////////////////////
				var owCheckBox = document.forms[formID].elements['oneway'];
				if(owCheckBox.checked == true){
					//trip is oneway
					document.forms[formID].elements['3day'].value = 'false';
				} else {
					//alert('trip is return');
					//check to see if > 3 days

					//$d1 = strtotime($_POST['date_depart']);
					//$d2 = strtotime($_POST['date_return']);
					//$diff = ($d2 - $d1) / (60 * 60 * 24);
					var d1 = document.forms[formID].elements['date_depart'].value;
					var d2 = document.forms[formID].elements['date_return'].value;
					var dateDiff = get_time_difference(d1,d2);
					//alert('d1: ' + d1);
					//alert('d2: ' + d2);
					//alert('dateDiff: ' + dateDiff.days);

					if(dateDiff.days >= 3){
						//set the 3 day checkbox
						//alert('trip is >= 3days');
						document.forms[formID].elements['3day'].value = 'true';
					} else {
						document.forms[formID].elements['3day'].value = 'false';
						//alert('trip is < 3days');
					}

					//var depD = "<?=$_POST['dp1']?>";
					//var retD = "<?=$_POST['dp2']?>";

				}

				//*** the 'validateUser' function will validate member/non-member & new member
				//	- it will use ajax with either the 'getmember.php' or 'setmember.php' files
				//	if isMem is set --> use getmember.php
				//	else --> use setmember.php
				//*** the 'validateUser' function will then do the following
				//	- ISMEM CHECKED
				//	[A] if valid member
				//	1. call 'distCostCalc(formID)'
				//	2. document.getElementById(formID).submit() --> will be called from
				//	[B] if invalid member
				//	1. pop message
				//	- ISMEM NOT CHECKED
				//	1. add user with temporary password
				//		- if successfully added
				//			--> call 'distCostCalc(formID)
				//		- else
				//			--> pop message
				//	2. document.getElementById(formID).submit()
				//
				/////////

				validateUser(formID,isMem.checked);
			} else {
				messagePop('Please choose no more than 5 aircraft');
			}
		} else {
			messagePop('No Aircraft Selected');
		}

	}

}

// Simple function to calculate time difference between 2 Javascript date objects
function get_time_difference(earlierDate,laterDate)
{
		var ed = new Date(earlierDate);
		var ld = new Date(laterDate);
       var nTotalDiff = ld.getTime() - ed.getTime();
       var oDiff = new Object();

       oDiff.days = Math.floor(nTotalDiff/1000/60/60/24);
       nTotalDiff -= oDiff.days*1000*60*60*24;

       oDiff.hours = Math.floor(nTotalDiff/1000/60/60);
       nTotalDiff -= oDiff.hours*1000*60*60;

       oDiff.minutes = Math.floor(nTotalDiff/1000/60);
       nTotalDiff -= oDiff.minutes*1000*60;

       oDiff.seconds = Math.floor(nTotalDiff/1000);

       return oDiff;

}
/*function get_time_difference(earlierDate,laterDate)
{
       var nTotalDiff = laterDate.getTime() - earlierDate.getTime();
       var oDiff = new Object();

       oDiff.days = Math.floor(nTotalDiff/1000/60/60/24);
       nTotalDiff -= oDiff.days*1000*60*60*24;

       oDiff.hours = Math.floor(nTotalDiff/1000/60/60);
       nTotalDiff -= oDiff.hours*1000*60*60;

       oDiff.minutes = Math.floor(nTotalDiff/1000/60);
       nTotalDiff -= oDiff.minutes*1000*60;

       oDiff.seconds = Math.floor(nTotalDiff/1000);

       return oDiff;

}*/
// Function Usage
//function use_time_difference()
//{
//	dateWhenIndiaWonFirstCricketWorldCup = new Date(1983, 6, 25, 5, 0, 0);
//	dateCurrent = new Date();
//	oDiff = get_time_difference(dateWhenIndiaWonFirstCricketWorldCup, dateCurrent);
//	alert("It has been " + oDiff.days + " days since India won it's first cricket worldcup");
//}
//use_time_difference();

function mySleep(milliseconds) {
	var start = new Date().getTime();
	while ((new Date().getTime() - start) < milliseconds){
	// Do nothing
	}
}



function validateUser(formID,memChecked){
	if(memChecked == true){
		//alert('validateUser - memChecked: true');
		var mEmail = document.forms[formID].elements['memberEmail'].value;
		var mPass = document.forms[formID].elements['memberPass'].value;
		testMember(formID,mEmail,mPass);
	} else {
		//alert('validateUser - memChecked: false');
		var u_fName = document.forms[formID].elements['firstName'].value;
		var u_lName = document.forms[formID].elements['lastName'].value;
		var u_email = document.forms[formID].elements['email'].value;
		var u_phone = document.forms[formID].elements['phone'].value;
		//addMember(formID,u_fName,u_lName,u_email,u_phone);
		testMemberNew(formID,u_email);
	}
}

//*** Final action
/*
function quoteFinalAction(formID,str){

	var submitQuoteForm = false;

	if(str == 'valid')	//valid member
	if(str == 'invalid')	//invalid member
	if(str == 'member validation error')	//error validating member
	if(str == 'success')	//successfully added new member
	if(str == 'error adding new member')	//error adding new member

	if(submitQuoteForm == true)
		document.getElementById(formID).submit();

}*/

function addMember(formID,fName,lName,email,phone){
	//alert("about to add a member");

	if (window.XMLHttpRequest) {
		// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	} else {
		// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}

	xmlhttp.onreadystatechange=function()
	{
		if (xmlhttp.readyState==4 && xmlhttp.status==200)
		{

			//document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
			//return eval("(" + xmlhttp.responseText + ")");
			//alert('addMember...xmlhttp.responseText: ' + xmlhttp.responseText);
			distCostCalc(formID,'addMember',xmlhttp.responseText);
		}
	}

	xmlhttp.open("GET","/setmember_ajax.php?fn="+fName+"&ln="+lName+"&e="+email+"&p="+phone,true);
	xmlhttp.send();
}

function addMember2(formID,quote,fName,lName,email,phone){
	//alert("about to add a member");

	if (window.XMLHttpRequest) {
		// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	} else {
		// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}

	xmlhttp.onreadystatechange=function()
	{
		if (xmlhttp.readyState==4 && xmlhttp.status==200)
		{

			//document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
			//return eval("(" + xmlhttp.responseText + ")");
			//alert('addMember...xmlhttp.responseText: ' + xmlhttp.responseText);

			//distCostCalc(formID,'addMember',xmlhttp.responseText);
			addMember2_submit(formID,quote,fName,lName,email,phone,xmlhttp.responseText);
		}
	}

	xmlhttp.open("GET","/setmember_ajax.php?fn="+fName+"&ln="+lName+"&e="+email+"&p="+phone,true);
	xmlhttp.send();
}

function addMember2_submit(formID,quote,fName,lName,email,phone,addMemberResponse){

	var splitRes = addMemberResponse.split('_');
	switch(splitRes[0]){
			case 'created':
			case 'allowed':
				//alert('generated password: ' + splitRes[1]);
				document.forms[formID].elements['qsf_pass'].value = splitRes[1];
				document.forms['trip'].elements['qsf_info'].value = document.forms['trip'].elements['quoteHolder_'+quote].value;
				document.getElementById('trip').submit();
				break;
			case 'error1':
			case 'error2':
				messagePop('There was an error creating your quote. Please try again!');
				break;
			case 'already exists':
				//*** Perhaps later on we can give the member the option to proceed without logging in
				messagePop("It seems you've used PrivateJet.com before. Check the 'I am a member' box and enter your password! (creating account)");
				break;
			default:
				messagePop('Error creating quote. Please try again!');
				break;
	}

}


function testMember(formID,memEmail,memPass)
{
	//alert("about to test member");

	if (window.XMLHttpRequest) {
		// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	} else {
		// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}

	xmlhttp.onreadystatechange=function()
	{
		if (xmlhttp.readyState==4 && xmlhttp.status==200)
		{
			//document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
			//return eval("(" + xmlhttp.responseText + ")");
			//alert('testMember...xmlhttp.responseText: ' + xmlhttp.responseText);
			distCostCalc(formID,'testMember',xmlhttp.responseText);
		}
	}

	xmlhttp.open("GET","/getmember_ajax.php?e="+memEmail+"&p="+memPass,true);
	xmlhttp.send();
}

function testMemberNew(formID,Email)
{
	//alert("about to test member");

	if (window.XMLHttpRequest) {
		// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	} else {
		// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}

	xmlhttp.onreadystatechange=function()
	{
		if (xmlhttp.readyState==4 && xmlhttp.status==200)
		{
			//document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
			//return eval("(" + xmlhttp.responseText + ")");
			//alert('testMember...xmlhttp.responseText: ' + xmlhttp.responseText);
			distCostCalc(formID,'testMemberNew',xmlhttp.responseText);
		}
	}

	xmlhttp.open("GET","/getmemberNew_ajax.php?e="+Email,true);
	xmlhttp.send();
}

function validateLogin (){
	var email = document.getElementById('cemail').value;
	var pass = document.getElementById('cpass').value;
	var errors = 0;

	if(email == ''){
		document.getElementById('emailE').style.display = 'block';
		//alert('enter a valid email');
		errors++;
	}

	if(pass == ''){
		document.getElementById('passE').style.display = 'block';
		//alert('enter your password');
		errors++;
	}

	if(errors == 0){
		//submit form
		//altLogin();return submit_haederaction("go_account");
		//altLogin();
		//return submit_headeraction("go_account");
		document.getElementById('hheader').submit();
	}
}




function ribbonSubmit(ribbonStr){
	//alert(ribbonStr);
	document.getElementById('ribbonVal').value = ribbonStr;
	document.getElementById('ribbonForm').submit();
}

function goTo() {
	var sE = null, url;
	if(document.getElementById) {
		sE = document.getElementById('filterBy');
	} else if(document.all) {
		sE = document.all['filterBy'];
	}

	if(sE && (url = sE.options[sE.selectedIndex].value)) {
		location.href = url;
	}
}

function jetTab(tab,action){
	var curOnTab = document.getElementById('chosenTab').value;
	var curOnArr = curOnTab.split('_');
	var curOn = curOnArr[1];
	var curOnDiv = 'div_' + curOn;
	var newTab = 'jet_' + tab;
	var newDiv = 'div_' + tab;
	if(action == 'mouseover'){
		if(curOnTab == newTab){
			//do nothing
		} else {
			//change tab to img 3 (darkened tab)
			document.getElementById(newTab).src = '/images/tabs/tabs-' + tab + '3.gif';
		}
	}

	if(action == 'mouseout'){
		if(curOnTab == newTab){
			//do nothing
		} else {
			//change tab to img 2 (lightened tab)
			document.getElementById(newTab).src = '/images/tabs/tabs-' + tab + '2.gif';
		}

	}

	if(action == 'click'){
		if(curOnTab == newTab){
			//do nothing
		} else {
			//change tab to img 1 (white tab)
			//change current chosenTab to (light gray tab)
			//set chosenTab.value to tab
			//alert('curOnTab: ' + curOnTab);
			//alert('curOn: ' + curOn);
			//alert('newTab:' + newTab);

			document.getElementById(newTab).src = '/images/tabs/tabs-' + tab + '1.gif';
			document.getElementById(curOnTab).src = '/images/tabs/tabs-' + curOn + '2.gif';
			document.getElementById('chosenTab').value = newTab;

			//display the appropriate div
			document.getElementById(curOnDiv).style.display = 'none';
			document.getElementById(newDiv).style.display = 'block';
		}
	}
}


function popSubmit(quote){
	//alert('popSubmit');
	var pfn = document.getElementById('pFirstName').value;
	var pln = document.getElementById('pLastName').value;
	var pem = document.getElementById('pEmail').value;
	var pph = document.getElementById('pPhone').value;
	var itemFail = 0;

	//now submit for specific quote
	var element = 'quoteHolder_' + quote;
	var quoteToSend = document.forms['quoteHolder'].elements[element].value;
	var quoteToSend2 = quoteToSend;

	if(pfn == ''){
		itemFail++;
		document.getElementById('popFirstName').style.color = "red";
	} else {
		document.getElementById('popFirstName').style.color = "#333333";
		document.forms['trip'].elements['firstName'].value = pfn;
		var pfn2 = 'contact_first_name=' + pfn;
		quoteToSend2 = quoteToSend2.replace("contact_first_name=", pfn2);
	}

	if(pln == ''){
		itemFail++;
		document.getElementById('popLastName').style.color = "red";
	} else {
		document.getElementById('popLastName').style.color = "#333333";
		document.forms['trip'].elements['lastName'].value = pln;
		var pln2 = 'contact_last_name=' + pln;
		quoteToSend2 = quoteToSend2.replace("contact_last_name=", pln2);
	}

	if(pem == ''){
		itemFail++;
		document.getElementById('popEmail').style.color = "red";
	} else {
		var validEmail = validateEmail(pem);
		if(validEmail == true){
			document.getElementById('popEmail').style.color = "#333333";
			document.forms['trip'].elements['email'].value = pem;
			var pem2 = 'contact_email=' + pem;
			quoteToSend2 = quoteToSend2.replace("contact_email=", pem2);
		} else {
			itemFail++;
			document.getElementById('popEmail').style.color = "red";
		}
	}

	if(pph == ''){
		itemFail++;
		document.getElementById('popPhone').style.color = "red";
	} else {
		document.getElementById('popPhone').style.color = "#333333";
		document.forms['trip'].elements['phone'].value = pph;
		var pph2 = 'contact_phone=' + pph;
		quoteToSend2 = quoteToSend2.replace("contact_phone=", pph2);
	}

	if(itemFail == 0){

		//Add these values to "quoteToSend" value
		//alert('quote to send: ' + quoteToSend);
		//alert('quote to send 2: ' + quoteToSend2);
		document.forms['quoteSubmissionForm'].elements['qsf_info'].value += quoteToSend2;
		document.getElementById('quoteSubmissionForm').submit();
	}


}


//Send Quote
function sendQuoteItem(quote){
	/*if(quote == 'main')
	if(quote == 'other1')
	if(quote == 'other2')
	if(quote == 'other3')
	if(quote == 'other4')*/

	//*** if quoting for a new member --> create membership & generate password --> set qsf_pass
	//*** else --> leave qsf_pass empty
	var nmv = document.forms['trip'].elements['qsf_newMember'].value;
	if(nmv == 'true'){
		//*** add new member
		var fName = document.forms['trip'].elements['firstName'].value;
		var lName = document.forms['trip'].elements['lastName'].value;
		var email = document.forms['trip'].elements['email'].value;
		var phone = document.forms['trip'].elements['phone'].value;
		//*** the addMember2 function will submit the form if everything goes smoothly
		addMember2('trip',quote,fName,lName,email,phone);
	} else {
		//*** submit form as member has already been validated
		document.forms['trip'].elements['qsf_info'].value = document.forms['trip'].elements['quoteHolder_'+quote].value;
		document.getElementById('trip').submit();
	}
}


function showHint(formID,str1,str2,jetTypes)
{
	//jetTypes looks like --> '||' + acType + '_' + acManu + '_' + acModel + '_' + acSeats + '_' + acCost
	//pass = typeof(pass) != 'undefined' ? pass : 'no password set';
	//alert('showHint');
	//Trim space from ends of string
	//var trimmed = str.replace(/^\s+|\s+$/g, '');
	str1 = str1.replace(/^\s+|\s+$/g, '');		//airport1
	str2 = str2.replace(/^\s+|\s+$/g, '');		//airport2

	//alert('str1: ' + str1 + "\nstr2: " + str2);
var xmlhttp;
if ( (str1.length==0) || (str2.length==0) )
  {
	  //alert('c1');
  //document.getElementById("txtHint").innerHTML="";
  return;
  }
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
	    //alert('c2');
    //document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
    //document.getElementById("myDiv").innerHTML = xmlhttp.responseText;
    document.getElementById("depart_coords").value = xmlhttp.responseText;
  //alert('xmlhttp.responseText: ' + xmlhttp.responseText);
    var coords = xmlhttp.responseText.split('_');
    var coords1 = coords[0].split(',');
    var coords2 = coords[1].split(',');
  //alert('lat1: ' + coords1[0] + ', lon1: ' + coords1[1]);
  //alert('lat2: ' + coords2[0] + ', lon2: ' + coords2[1]);
  //jetTypes looks like --> '||' + acType + '_' + acManu + '_' + acModel + '_' + acSeats + '_' + acCost
    getTripDetails(formID,coords1[0],coords1[1],coords2[0],coords2[1],jetTypes,str1,str2);	//lat1,lon1,lat2,lon2);
    }
  }
xmlhttp.open("GET","/pop/lat_long.php?airport1="+str1+"&airport2="+str2,true);
xmlhttp.send();
}

function distCostCalc(formID,callingFunction,callingFunctionRes){	//depart,arrive,jetType){	//lon1,lat1,lon2,lat2,jetType){
	//alert('distCostCalc: ' + formID);

	/*if (callingFunction == 'testMember') {
		alert ("callingFunction: " + callingFunction + "\ncallingFunctionRes: " + callingFunctionRes);
	} else if (callingFunction == 'addMember') {
		alert ("callingFunction: " + callingFunction + "\ncallingFunctionRes: " + callingFunctionRes);
	}*/

	var completeQuote = false;
	var popMessage = '';

	if(callingFunction == 'testMember'){
		//*** if member is valid testMember will return the following string
		// 		- valid|first_name'|last_name|email|phone
		var splitRes = callingFunctionRes.split('|');
		//alert('splitRes[0]: ' + splitRes[0]);

		switch(splitRes[0]){
			case 'valid':		//proceed
				//*** Set values to be used in Quote Generation
				document.forms['trip'].elements['validatedMemberFirstName'].value = splitRes[1];
				document.forms['trip'].elements['validatedMemberLastName'].value = splitRes[2];
				document.forms['trip'].elements['memberEmail'].value = splitRes[3];
				document.forms['trip'].elements['validatedMemberPhone'].value = splitRes[4];
				document.forms['trip'].elements['qsf_newMember'].value = 'false';
				completeQuote = true;
				popMessage = '';
				break;
			case 'invalid user + pass':
				popMessage = 'Incorrect email or password!';
				break;
			case 'not a member':
				popMessage = 'You are not a member of PrivateJet.com';
				break;
			case 'error':
				popMessage = 'There was an error processing your request. Please try again.';
				break;
			default:
				popMessage = 'Execution Error!';
		}
	} else if (callingFunction == 'testMemberNew'){		//'addMember')

		var splitRes = callingFunctionRes.split('_');
		//if(splitRes[0] == 'not a member')
		if( (splitRes[0] == 'not a member') || (splitRes[0] == 'allow') ){
			//var generatedPassword = splitres[1];
			document.forms['trip'].elements['qsf_newMember'].value = 'true';
			completeQuote = true;
			//popMessage = 'Your PrivateJet.com account has been created. Please check your email for your temporary password.';

			/*
			case 'created':		//proceed
				completeQuote = true;
				popMessage = 'Your PrivateJet.com account has been created. Please check your email for your temporary password.';
				break;
				*/

		} else {
			//switch(callingFunctionRes)
			switch(splitRes[0]){
				case 'already exists':
					popMessage = "It seems you've used PrivateJet.com before. Check the 'I am a member' box and enter your password! (verifying user)";
					break;
				case 'error':
					popMessage = 'There was an error processing your request. Please try again.';
					break;
				default:
					popMessage = 'Execution Error!';
			}
		}
	}

	if(completeQuote == true){

		//alert('completeQuote');

		var depart = document.forms[formID].elements['testinput_xml1'].value;
		var arrive = document.forms[formID].elements['testinput_xml2'].value;
		var jetTypes = document.forms[formID].elements['jetTypes'].value;		//this will have '_' instead of ' '
		//*** swapping '_' with ' ' for comparison in jetType_all array in getTripDetails function
		//jetType = jetType.split("_").join(" ");
		//jetTypes looks like --> '||' + acType + '_' + acManu + '_' + acModel + '_' + acSeats + '_' + acCost

		//var lon1, lat1, lon2, lat2;

		if( (depart != '') && (arrive != '') && (jetTypes != '') ){

			var departArr = depart.split(',');
			var depart2 = departArr[1];
			//alert('depart: ' + depart2);

			var arriveArr = arrive.split(',');
			var arrive2 = arriveArr[1];
			//alert('arrive: ' + arrive2);

			//get Lat, Long coords
			//showHint(formID,depart2,arrive2,jetType,generatedPassword);
			showHint(formID,depart2,arrive2,jetTypes);


		} else {
			//alert('fill in form');
			messagePop('Please enter departure & arrival airports');
		}


	} else {
		//alert('abortQuote');
		messagePop(popMessage);
	}
}

function getTripDetails(formID,lat1,lon1,lat2,lon2,jetTypes,airport1,airport2){

	//jetTypes looks like --> '||' + acType + '_' + acManu + '_' + acModel + '_' + acSeats + '_' + acCost
//alert('jetTypes:'+"\n"+jetTypes);

	var jetTypesArr = jetTypes.split('||');
	var typesLen = jetTypesArr.length;	//should be no more than 5
	var quotesCounter;
	//var distance = testDist(lat1,lon1,lat2,lon2);
	/*<?php
		date_default_timezone_set('ETC');
		$today = date("m-d-Y");
	?>*/
	var isMember = document.forms[formID].elements['ismember'];
	var today = new Date();
	var dd = today.getDate();
	var mm = today.getMonth()+1;
	var yyyy = today.getFullYear();
	//today.format("mm-dd-yyyy");
	today = mm+'-'+dd+'-'+yyyy;
	//alert('today: ' + today);

	var cFirstName;
	var cLastName;
	var cEmail;
	var cPhone;
	var all_quotes = [];

		/*all_quotes[0] = 'quote_date='+ today;
		all_quotes[1] = 'quote_date='+ today;
		all_quotes[2] = 'quote_date='+ today;
		all_quotes[3] = 'quote_date='+ today;
		all_quotes[4] = 'quote_date='+ today;*/
	for(quotesCounter = 0; quotesCounter < typesLen; quotesCounter++){
		all_quotes[quotesCounter] = 'quote_date=' + today;
	}

	var tripDetails = [];
	var distance = findDistance(lat1,lon1,lat2,lon2);
	var dist_mi = distance[0];
	var dist_km = distance[1];
	//alert('distance mi = ' + distance[0]);
	//alert('distance km = ' + distance[1]);

	var ow;	//oneway indicator
	var tl;	//trip length indicator
	var estOneWay = document.forms[formID].elements['oneway'];
	if(estOneWay.checked == true){
		ow = 'oneway';
		tl = 1;

		/*all_quotes[0] += '||trip_type=oneway';
		all_quotes[1] += '||trip_type=oneway';
		all_quotes[2] += '||trip_type=oneway';
		all_quotes[3] += '||trip_type=oneway';
		all_quotes[4] += '||trip_type=oneway';*/
		for(quotesCounter = 0; quotesCounter < typesLen; quotesCounter++){
			all_quotes[quotesCounter] += '||trip_type=oneway';
		}

	} else {
		ow = 'return';
		//get trip length

			var est3day = document.forms[formID].elements['3day'];
			if(est3day.value == 'true'){
				//alert('3day: ' + est3day.value + ', tl=3');
				tl = 3;
			} else {
				//alert('3day: ' + est3day.value + ', tl=1');
				tl = 1;
			}

		/*all_quotes[0] += '||trip_type=return';
		all_quotes[1] += '||trip_type=return';
		all_quotes[2] += '||trip_type=return';
		all_quotes[3] += '||trip_type=return';
		all_quotes[4] += '||trip_type=return';*/
		for(quotesCounter = 0; quotesCounter < typesLen; quotesCounter++){
			all_quotes[quotesCounter] += '||trip_type=return';
		}
	}

	var pssCnt = document.forms['trip'].elements['passengerCount'].value;
		/*all_quotes[0] += '||trip_passengers=' + pssCnt;
		all_quotes[1] += '||trip_passengers=' + pssCnt;
		all_quotes[2] += '||trip_passengers=' + pssCnt;
		all_quotes[3] += '||trip_passengers=' + pssCnt;
		all_quotes[4] += '||trip_passengers=' + pssCnt;*/
		for(quotesCounter = 0; quotesCounter < typesLen; quotesCounter++){
			all_quotes[quotesCounter] += '||trip_passengers=' + pssCnt;
		}
	var tDate = document.forms['trip'].elements['date_depart'].value;
		/*all_quotes[0] += '||trip_date=' + tDate;
		all_quotes[1] += '||trip_date=' + tDate;
		all_quotes[2] += '||trip_date=' + tDate;
		all_quotes[3] += '||trip_date=' + tDate;
		all_quotes[4] += '||trip_date=' + tDate;*/
		for(quotesCounter = 0; quotesCounter < typesLen; quotesCounter++){
			all_quotes[quotesCounter] += '||trip_date=' + tDate;
		}
	var tDateStr = '';
	var tTime = '';
		/*all_quotes[0] += '||trip_date_string=';
		all_quotes[1] += '||trip_date_string=';
		all_quotes[2] += '||trip_date_string=';
		all_quotes[3] += '||trip_date_string=';
		all_quotes[4] += '||trip_date_string=';*/
		for(quotesCounter = 0; quotesCounter < typesLen; quotesCounter++){
			all_quotes[quotesCounter] += '||trip_date_string=';
		}
		/*all_quotes[0] += '||trip_time=';
		all_quotes[1] += '||trip_time=';
		all_quotes[2] += '||trip_time=';
		all_quotes[3] += '||trip_time=';
		all_quotes[4] += '||trip_time=';*/
		for(quotesCounter = 0; quotesCounter < typesLen; quotesCounter++){
			all_quotes[quotesCounter] += '||trip_time=';
		}
	var trDate = document.forms['trip'].elements['date_return'].value;
		/*all_quotes[0] += '||trip_return_date=' + trDate;
		all_quotes[1] += '||trip_return_date=' + trDate;
		all_quotes[2] += '||trip_return_date=' + trDate;
		all_quotes[3] += '||trip_return_date=' + trDate;
		all_quotes[4] += '||trip_return_date=' + trDate;*/
		for(quotesCounter = 0; quotesCounter < typesLen; quotesCounter++){
			all_quotes[quotesCounter] += '||trip_return_date=' + trDate;
		}

		/*all_quotes[0] += '||trip_depart_from=' + airport1;
		all_quotes[1] += '||trip_depart_from=' + airport1;
		all_quotes[2] += '||trip_depart_from=' + airport1;
		all_quotes[3] += '||trip_depart_from=' + airport1;
		all_quotes[4] += '||trip_depart_from=' + airport1;*/
		for(quotesCounter = 0; quotesCounter < typesLen; quotesCounter++){
			all_quotes[quotesCounter] += '||trip_depart_from=' + airport1;
		}

		/*all_quotes[0] += '||trip_arrive_at=' + airport2;
		all_quotes[1] += '||trip_arrive_at=' + airport2;
		all_quotes[2] += '||trip_arrive_at=' + airport2;
		all_quotes[3] += '||trip_arrive_at=' + airport2;
		all_quotes[4] += '||trip_arrive_at=' + airport2;*/
		for(quotesCounter = 0; quotesCounter < typesLen; quotesCounter++){
			all_quotes[quotesCounter] += '||trip_arrive_at=' + airport2;
		}

		/*all_quotes[0] += '||trip_distance_miles=' + dist_mi;
		all_quotes[1] += '||trip_distance_miles=' + dist_mi;
		all_quotes[2] += '||trip_distance_miles=' + dist_mi;
		all_quotes[3] += '||trip_distance_miles=' + dist_mi;
		all_quotes[4] += '||trip_distance_miles=' + dist_mi;*/
		for(quotesCounter = 0; quotesCounter < typesLen; quotesCounter++){
			all_quotes[quotesCounter] += '||trip_distance_miles=' + dist_mi;
			all_quotes[quotesCounter] += '||trip_distance_kilometers=' + dist_km;
		}

if(isMember.checked == false){
	//*** Non-Member Created
	cFirstName = document.forms['trip'].elements['firstName'].value;
	cLastName = document.forms['trip'].elements['lastName'].value;
	cEmail = document.forms['trip'].elements['email'].value;
	cPhone = document.forms['trip'].elements['phone'].value;
} else {
	//*** Member validated
	cFirstName = document.forms['trip'].elements['validatedMemberFirstName'].value;
	cLastName = document.forms['trip'].elements['validatedMemberLastName'].value;
	cEmail = document.forms['trip'].elements['memberEmail'].value;
	cPhone = document.forms['trip'].elements['validatedMemberPhone'].value;
}

	//var sNotes = document.forms['trip'].elements['specialNotes'].value;



	////*** Main Calculations (Do this for each item in jetTypesArr)
	///
	//

	var jetSeating, jetSpeed, jetCost, jetCostMember, timeMins, timeMinsAlt, timeMinsUSE;
	var flightTime, flightTime2, flightCost, flightCostMember, flightTax, flightTaxMember, flightTotalMember

	var curJet, myType, myManu, myModel, mySeats, myCost;

	for(quotesCounter = 0; quotesCounter < typesLen; quotesCounter++){
		//jetTypesArr[quotesCounter] = acType + '_' + acManu + '_' + acModel + '_' + acSeats + '_' + acCost
		curJet = jetTypesArr[quotesCounter].split('_');
		myType = curJet[0];
		myManu = curJet[1];
		myModel = curJet[2];
		mySeats = curJet[3];
		myCost = curJet[4];

//alert('myType: '+myType+"\nmyManu:"+myManu+"\nmyModel:"+myModel+"\nmySeats:"+mySeats+"\nmyCost:"+myCost);
		jetSeating = mySeats;
		jetSpeed = getJetSpeed(myType);
		jetCost = getJetCost(myCost,myType,'nonmember',ow,tl);
		jetCostMember = getJetCost(myCost,myType,'member',ow,tl);

		timeMins = getTimeMins(distance[0],jetSpeed);
		timeMinsAlt = 120;
		if(timeMins < timeMinsAlt){
			timeMinsUSE = timeMinsAlt;
		} else {
			timeMinsUSE = timeMins;
		}

		flightTime = getTimeFly(timeMins);								//actual flight time
		flightTime2 = flightTime[0] + ' h ' + flightTime[1] + ' mins';
		flightCost = getCostFly(jetCost, timeMinsUSE);
		flightCostMember = getCostFly(jetCostMember, timeMinsUSE);

		if(estOneWay.checked == false){
			flightCost = flightCost*2;							//******* moved here (1)
			flightCostMember = flightCostMember*2;				//******* moved here (2)
		}

		flightTax = flightCost*(0.075);
		flightTaxMember = flightCostMember*(0.075);
		flightTotalMember = flightCostMember + flightTaxMember;

		all_quotes[quotesCounter] += '||trip_flight_time_h=' + flightTime[0];
		all_quotes[quotesCounter] += '||trip_flight_time_m=' + flightTime[1];
		all_quotes[quotesCounter] += '||payment_flight_cost=' + flightCostMember;
		all_quotes[quotesCounter] += '||payment_flight_tax=' + flightTaxMember;
		all_quotes[quotesCounter] += '||payment_due_total=' + flightTotalMember;
		all_quotes[quotesCounter] += '||jet_type=' + myType;
		all_quotes[quotesCounter] += '||jet_manufacturer=' + myManu;
		all_quotes[quotesCounter] += '||jet_model=' + myModel;
		all_quotes[quotesCounter] += '||jet_seating_capacity=' + mySeats;
		all_quotes[quotesCounter] += '||contact_first_name=' + cFirstName;
		all_quotes[quotesCounter] += '||contact_last_name=' + cLastName;
		all_quotes[quotesCounter] += '||contact_email=' + cEmail;
		all_quotes[quotesCounter] += '||contact_phone=' + cPhone;

	}

	/*
	var jetSeating = getJetMaxPass(jetType);
	var jetSpeed = getJetSpeed(jetType);					//miles per hour
	var jetCost = getJetCost(jetType,'nonmember',ow,tl);			//oneway cost
	var jetCostMember = getJetCost(jetType,'member',ow,tl);			//oneway cost member
	//alert('jetCostMember: ' + jetCostMember);

	var timeMins = getTimeMins(distance[0],jetSpeed);			//oneway flight time
	//alert('timeMins: ' + timeMins);
	//*** timeMinsAlt
	//	- This is the minimum chargable flight time (in minutes)
	//	- 2 hour minimum
	var timeMinsAlt = 120;
	//*** timeMinsUSE
	//	- This is the flight time used to calculate cost in the 'getCostFly' function
	//	- it is set to 2hours if timeMins < 2hours
	var timeMinsUSE;
	if(timeMins < timeMinsAlt){
		timeMinsUSE = timeMinsAlt;
		//alert('2 hr minimum pricing in effect');
		//*** set 2 hr min pricing alert
	} else {
		timeMinsUSE = timeMins;
	}

	//var speed = 500; //miles per hour
	//var cost = 3000; //dollars per hour
	var flightTime = getTimeFly(timeMins);
	var flightTime2 = flightTime[0] + ' h ' + flightTime[1] + ' mins';

	var flightCost = getCostFly(jetCost, timeMinsUSE);				//oneway Flight Cost
	var flightCostMember = getCostFly(jetCostMember, timeMinsUSE);		//oneway Flight Cost
	var flightTax;
	var flightTaxMember;
	var flightTotalMember;


	//
	///
	////*** End Main Calculations
	////*** Other Jet Calculations
	///
	//
	var jetType_all = ['very light', 'light', 'mid sized', 'super mid sized', 'heavy'];
	var jetSeating_all = [];
	var jetTypeOther_all = [];
	var jetSpeedOther_all = [];			//miles per hour
	var jetCostOther_all = [];			//oneway cost
	var jetCostMemberOther_all = [];		//oneway cost member
	var timeMins_all = [];				//oneway flight time
	var flightTime_all = [];
	var flightTime2_all = [];
	var flightCost_all = [];			//oneway Flight Cost
	var flightCostMember_all = [];			//oneway Flight Cost
	var flightTax_all = [];
	var flightTaxMember_all = [];
	var flightTotalMember_all = [];
	var curJetType;

	//*** handle Other Jets
	var j = 0;
	for (var i=0; i<jetType_all.length; i++) {
		curJetType = jetType_all[i];

		if(jetType != jetType_all[i]){
			jetTypeOther_all[j] = curJetType;
			jetSeating_all[j] = getJetMaxPass(curJetType);
			jetSpeedOther_all[j] = getJetSpeed(curJetType);
			jetCostOther_all[j] = getJetCost(curJetType,'nonmember',ow,tl);
			jetCostMemberOther_all[j] = getJetCost(curJetType,'member',ow,tl);
//alert('jetCostMemberOther_all['+j+']: '+jetCostMemberOther_all[j]);
			timeMins_all[j] = getTimeMins(distance[0],jetSpeedOther_all[j]);
			flightTime_all[j] = getTimeFly(timeMins_all[j]);
			flightTime2_all[j] = flightTime_all[j][0] + ' h ' + flightTime_all[j][1] + ' mins';
//alert('timeMins_all['+j+']: '+timeMins_all[j]+', timeMinsAlt: '+timeMinsAlt);
			if(timeMins_all[j] < timeMinsAlt){
				flightCost_all[j] = getCostFly(jetCostOther_all[j], timeMinsAlt);
				flightCostMember_all[j] = getCostFly(jetCostMemberOther_all[j], timeMinsAlt);
				//alert('use timeMinsAlt, jetCostOther:'+ jetCostMemberOther_all[j] + ', flightCostOther: '+ flightCostMember_all[j]);
			} else {
				//alert('use timeMins_all[j]');
				flightCost_all[j] = getCostFly(jetCostOther_all[j], timeMins_all[j]);
				flightCostMember_all[j] = getCostFly(jetCostMemberOther_all[j], timeMins_all[j]);
			}

			//*** If Trip is return, display 2*flightCost (since flightCost calculates cost for ONE WAY)
			if(estOneWay.checked){
				//do nothing
			} else {
				//double flightCost
				flightCost_all[j] = flightCost_all[j]*2;
				flightCostMember_all[j] = flightCostMember_all[j]*2;
			}

			flightTax_all[j] = flightCost_all[j]*(0.075);
			flightTaxMember_all[j] = flightCostMember_all[j]*(0.075);

			flightTotalMember_all[j] = flightCostMember_all[j] + flightTaxMember_all[j];

			flightCost_all[j] = numberFormat(flightCost_all[j],'$');
			flightCostMember_all[j] = numberFormat(flightCostMember_all[j], '$');

			j+=1;
		}
	}

	//
	///
	////*** End Other Jet Calculations


	//alert('flightTime: ' + flightTime[0] + 'h ' + flightTime[1] + 'mins');
	//alert('flightCost: ' + flightCost);

	//return dist_mi, dist_km, jetSpeed, flightTime2, flightCost
	tripDetails[0] = dist_mi;
	tripDetails[1] = dist_km;
	tripDetails[2] = jetSpeed;
	tripDetails[3] = flightTime2;
	tripDetails[4] = flightCost;

	//return tripDetails;
	//alert('dist_mi: ' + dist_mi + '\ndist_km: ' + dist_km + '\njetSpeed: ' + jetSpeed + '\nflightTime: ' + flightTime2 + '\nflightCost: ' + flightCost);
	//document.forms['tripEstimate'].elements['flightTime'].innerHTML = flightTime2;


	if(estOneWay.checked == false){
		flightCost = flightCost*2;							//******* moved here (1)
		flightCostMember = flightCostMember*2;				//******* moved here (2)
	}

	flightTax = flightCost*(0.075);
	flightTaxMember = flightCostMember*(0.075);
	flightTotalMember = flightCostMember + flightTaxMember;

	//alert('flightCostMember: ' + flightCostMember);
	//alert('flightTaxMember: ' + flightTaxMember);

	all_quotes[0] += '||trip_flight_time_h=' + flightTime[0];
	all_quotes[0] += '||trip_flight_time_m=' + flightTime[1];
	all_quotes[0] += '||payment_flight_cost=' + flightCostMember;
	all_quotes[0] += '||payment_flight_tax=' + flightTaxMember;
	all_quotes[0] += '||payment_due_total=' + flightTotalMember;
	all_quotes[0] += '||jet_type=' + jetType;
	all_quotes[0] += '||jet_seating_capacity=' + jetSeating;
	all_quotes[0] += '||contact_first_name=' + cFirstName;
	all_quotes[0] += '||contact_last_name=' + cLastName;
	all_quotes[0] += '||contact_email=' + cEmail;
	all_quotes[0] += '||contact_phone=' + cPhone;

	all_quotes[1] += '||trip_flight_time_h=' + flightTime_all[0][0];
	all_quotes[1] += '||trip_flight_time_m=' + flightTime_all[0][1];
	all_quotes[1] += '||payment_flight_cost=' + flightCostMember_all[0];
	all_quotes[1] += '||payment_flight_tax=' + flightTaxMember_all[0];
	all_quotes[1] += '||payment_due_total=' + flightTotalMember_all[0];
	all_quotes[1] += '||jet_type=' + jetTypeOther_all[0];
	all_quotes[1] += '||jet_seating_capacity=' + jetSeating_all[0];
	all_quotes[1] += '||contact_first_name=' + cFirstName;
	all_quotes[1] += '||contact_last_name=' + cLastName;
	all_quotes[1] += '||contact_email=' + cEmail;
	all_quotes[1] += '||contact_phone=' + cPhone;

	all_quotes[2] += '||trip_flight_time_h=' + flightTime_all[1][0];
	all_quotes[2] += '||trip_flight_time_m=' + flightTime_all[1][1];
	all_quotes[2] += '||payment_flight_cost=' + flightCostMember_all[1];
	all_quotes[2] += '||payment_flight_tax=' + flightTaxMember_all[1];
	all_quotes[2] += '||payment_due_total=' + flightTotalMember_all[1];
	all_quotes[2] += '||jet_type=' + jetTypeOther_all[1];
	all_quotes[2] += '||jet_seating_capacity=' + jetSeating_all[1];
	all_quotes[2] += '||contact_first_name=' + cFirstName;
	all_quotes[2] += '||contact_last_name=' + cLastName;
	all_quotes[2] += '||contact_email=' + cEmail;
	all_quotes[2] += '||contact_phone=' + cPhone;

	all_quotes[3] += '||trip_flight_time_h=' + flightTime_all[2][0];
	all_quotes[3] += '||trip_flight_time_m=' + flightTime_all[2][1];
	all_quotes[3] += '||payment_flight_cost=' + flightCostMember_all[2];
	all_quotes[3] += '||payment_flight_tax=' + flightTaxMember_all[2];
	all_quotes[3] += '||payment_due_total=' + flightTotalMember_all[2];
	all_quotes[3] += '||jet_type=' + jetTypeOther_all[2];
	all_quotes[3] += '||jet_seating_capacity=' + jetSeating_all[2];
	all_quotes[3] += '||contact_first_name=' + cFirstName;
	all_quotes[3] += '||contact_last_name=' + cLastName;
	all_quotes[3] += '||contact_email=' + cEmail;
	all_quotes[3] += '||contact_phone=' + cPhone;

	all_quotes[4] += '||trip_flight_time_h=' + flightTime_all[3][0];
	all_quotes[4] += '||trip_flight_time_m=' + flightTime_all[3][1];
	all_quotes[4] += '||payment_flight_cost=' + flightCostMember_all[3];
	all_quotes[4] += '||payment_flight_tax=' + flightTaxMember_all[3];
	all_quotes[4] += '||payment_due_total=' + flightTotalMember_all[3];
	all_quotes[4] += '||jet_type=' + jetTypeOther_all[3];
	all_quotes[4] += '||jet_seating_capacity=' + jetSeating_all[3];
	all_quotes[4] += '||contact_first_name=' + cFirstName;
	all_quotes[4] += '||contact_last_name=' + cLastName;
	all_quotes[4] += '||contact_email=' + cEmail;
	all_quotes[4] += '||contact_phone=' + cPhone;


//alert('all_quotes[0]: \n' + all_quotes[0]);

	document.getElementById('quoteHolder_main').value = all_quotes[0];
	document.getElementById('quoteHolder_other1').value = all_quotes[1];
	document.getElementById('quoteHolder_other2').value = all_quotes[2];
	document.getElementById('quoteHolder_other3').value = all_quotes[3];
	document.getElementById('quoteHolder_other4').value = all_quotes[4];
	//document.getElementById('quoteHolder_notes').value = sNotes;
*/

	for(quotesCounter = 0; quotesCounter < typesLen; quotesCounter++){
		document.getElementById('quoteHolder_'+quotesCounter).value = all_quotes[quotesCounter];
	}

	//*** Pop all potential quotes with all_quotes[0] being the main quote selected during the quoting process
	formPop(all_quotes);	//[0],all_quotes[1],all_quotes[2],all_quotes[3],all_quotes[4]);
}

