function calcPickup(selection){
	var pickuphour;
	var genericGap = 75;
	
	if(selection == 0){
		var ampmInput = 'pickupAMPM';
		var pickupHourInput = 'pickupHour';
		var pickupMinInput = 'pickupMinute';
		var timeatLocalHour = 'timeatLocalHour';
		var timeatLocalMinute = 'timeatLocalMinute';
		var thisHour = 'destinationHour';
		var thisMinute = 'destinationMinute';
		var thisAMPM = 'destinationAMPM';
	} else if(selection == 1){
		var ampmInput = 'destinationAMPM';
		var pickupHourInput = 'destinationHour';
		var pickupMinInput = 'destinationMinute';
		var timeatLocalHour = 'timeatLocalHour' + selection;
		var timeatLocalMinute = 'timeatLocalMinute' + selection;
		var thisHour = 'destinationHour'  + selection;
		var thisMinute = 'destinationMinute'  + selection;
		var thisAMPM = 'destinationAMPM'  + selection;
	} else {
		var ampmInput = 'destinationAMPM' + (selection - 1);
		var pickupHourInput = 'destinationHour' + (selection - 1);
		var pickupMinInput = 'destinationMinute' + (selection - 1);
		var timeatLocalHour = 'timeatLocalHour' + selection;
		var timeatLocalMinute = 'timeatLocalMinute' + selection;
		
		var thisHour = 'destinationHour' + selection;
		var thisMinute = 'destinationMinute' + selection;
		var thisAMPM = 'destinationAMPM' + selection;
	}
	
	/* CONVERT PICKUP TIME */
	if (document.getElementById(ampmInput).value == 'PM' && document.getElementById(pickupHourInput).value < 12)
	{
		pickuphour = (parseInt(document.getElementById(pickupHourInput).value) + 12) * 60;
	} 
	else 
	if (document.getElementById(ampmInput).value == 'AM' && document.getElementById(pickupHourInput).value == 12)
	{
		pickuphour = 0;
	} 
	else 
	{
		pickuphour = parseInt(document.getElementById(pickupHourInput).value) * 60;
	}
	
	
	
	
	pickupMinute = parseInt(document.getElementById(pickupMinInput).value);
	var pickupTotal = pickuphour + pickupMinute;
	/* SELECTED TIME AT LOCATION */
	var hourIndex = document.getElementById(timeatLocalHour).selectedIndex;
	var hourValue = document.getElementById(timeatLocalHour)[hourIndex].value;
	var minuteIndex = document.getElementById(timeatLocalMinute).selectedIndex;
	var minuteValue = document.getElementById(timeatLocalMinute)[minuteIndex].value;
	
	var timeAtHour = parseInt(hourValue) * 60;
	var timeAtMinute = parseInt(minuteValue);	

	var addedMinutes = timeAtMinute + timeAtHour + genericGap;
	var ttlMinutes = pickupTotal + addedMinutes;

	var floorHours = Math.floor(ttlMinutes / 60);
	var leftoverMinutes = ttlMinutes - (floorHours * 60);
	
	leftoverMinutes = leftoverMinutes + "";

	if (leftoverMinutes.length == 1)
	   {
	   leftoverMinutes = "0" + leftoverMinutes;
	   }

	if(floorHours > 20 || (floorHours == 20 && leftoverMinutes > 30)) {
			alert('The suggested time would be later than pickup is allowed. Please reduce your time at location.');
	}else{
		
	
			//var thisHour = 'destinationHour' + selection;
		//var thisMinute = 'destinationMinute' + selection;
		//var thisAMPM = 'destinationAMPM' + selection;
		
	if(floorHours == 12){
		var showHour = floorHours;
		var amPm = 'PM';
		var amPMSelect = 2;
	} else if(floorHours > 12) {
		var showHour = floorHours - 12;
		var amPm = 'PM';
		var amPMSelect = 2;
	} else {
		var showHour = floorHours;
		var amPm = 'AM';
		var amPMSelect = 1;
	}
	
	document.getElementById(thisAMPM).selectedIndex = amPMSelect;
	document.getElementById(thisHour).selectedIndex = showHour;
	document.getElementById(thisMinute).selectedIndex = leftoverMinutes/15+1;
	alert('Your suggested pickup time is: ' + showHour + ':' + leftoverMinutes + ' ' + amPm);
	}
	
}

function unhideBuddyInfo(input){
	var dropdown = 'addRiderType' + input;
	var buddyName = 'buddyName' + input;
	var buddyLastName = 'buddyLastName' + input;
	var buddyID = 'buddyLiftID' + input;
	var childage = 'childage' + input;
	var dropdownIndex = document.getElementById(dropdown).selectedIndex;
	var dropdownValue = document.getElementById(dropdown)[dropdownIndex].value;
	if(dropdownValue == 'Buddy') {
		document.getElementById(childage).style.display = 'none';
		document.getElementById(buddyName).style.display = 'block';
		document.getElementById(buddyID).style.display = 'block';
		document.getElementById(buddyLastName).style.display = 'block';	
		
	}else{
		if(dropdownValue == 'Child') {
		document.getElementById(childage).style.display = 'block';	
		document.getElementById(buddyName).style.display = 'none';
		document.getElementById(buddyID).style.display = 'none';
		document.getElementById(buddyLastName).style.display = 'none';		
	}else{
		document.getElementById(childage).style.display = 'none';
		document.getElementById(buddyName).style.display = 'none';
		document.getElementById(buddyID).style.display = 'none';	
		document.getElementById(buddyLastName).style.display = 'none';
	}
	}
}

