function calculateLRT1()
{
	var varOp1 = document.getElementById('lrt1-origin');
	var firstSelect = varOp1.options[varOp1.selectedIndex].text;
	var varOp2 = document.getElementById('lrt1-destination');
	var secondSelect = varOp2.options[varOp2.selectedIndex].text;
	var varOp3 = document.getElementById('lrt1-tickettype');
	var ticketType = varOp3.options[varOp3.selectedIndex].value;

console.log(ticketType);
if(ticketType == "sj")
	{
		if( (firstSelect == "Balintawak" || firstSelect == "Roosevelt") || (secondSelect == "Balintawak" || secondSelect == "Roosevelt") )
		{
			var e1 = document.getElementById('lrt1-origin');
			op1 = e1.options[e1.selectedIndex].value;
			var e2 = document.getElementById('lrt1-destination');
			op2 = e2.options[e2.selectedIndex].value;
			op1 = parseInt(op1);
			op2 = parseInt(op2);
			result = op1 - op2;
			result = Math.abs(result);

			if((result <= 7) && (result >= 1))
			{
				document.getElementById('lrt1-sum').innerHTML = "Php. 15";
			}
			else if((result <= 19) && (result >= 8))
			{
				document.getElementById('lrt1-sum').innerHTML = "Php. 20";
			}
			else if(result <= 0)
			{
				document.getElementById('lrt1-sum').innerHTML = "Php. 0. Tip: You cannot select the same origin and destination.";
			}
			else
			{
				console.log("Error:" + result);
				document.getElementById('lrt2-sum').innerHTML = "Invalid input. Please try again.";
			}
		}
		else
		{
			var e1 = document.getElementById('lrt1-origin');
			op1 = e1.options[e1.selectedIndex].value;
			var e2 = document.getElementById('lrt1-destination');
			op2 = e2.options[e2.selectedIndex].value;
			op1 = parseInt(op1);
			op2 = parseInt(op2);
			result = op1 - op2;
			result = Math.abs(result);

			if((result <= 4) && (result >= 1))
			{
				document.getElementById('lrt1-sum').innerHTML = "Php. 12";
			}
			else if((result <= 17) && (result >= 5))
			{
				document.getElementById('lrt1-sum').innerHTML = "Php. 15";
			}
			else if(result <= 0)
			{
				document.getElementById('lrt1-sum').innerHTML = "Php. 0. Tip: You cannot select the same origin and destination.";
			}
			else
			{
				console.log("Error:" + result);
				document.getElementById('lrt2-sum').innerHTML = "Invalid input. Please try again.";
			}
		}
	}
else
	{
		if( (firstSelect == "Balintawak" || firstSelect == "Roosevelt") || (secondSelect == "Balintawak" || secondSelect == "Roosevelt") )
		{
			var e1 = document.getElementById('lrt1-origin');
			op1 = e1.options[e1.selectedIndex].value;
			var e2 = document.getElementById('lrt1-destination');
			op2 = e2.options[e2.selectedIndex].value;
			op1 = parseInt(op1);
			op2 = parseInt(op2);
			result = op1 - op2;
			result = Math.abs(result);

			if((result <= 2) && (result >= 1))
			{
				document.getElementById('lrt1-sum').innerHTML = "Php. 13";
			}
			else if((result <= 4) && (result >= 3))
			{
				document.getElementById('lrt1-sum').innerHTML = "Php. 14";
			}
			else if((result <= 7) && (result >= 5))
			{
				document.getElementById('lrt1-sum').innerHTML = "Php. 15";
			}
			else if((result <= 10) && (result >= 8))
			{
				document.getElementById('lrt1-sum').innerHTML = "Php. 16";
			}
			else if((result <= 13) && (result >= 11))
			{
				document.getElementById('lrt1-sum').innerHTML = "Php. 17";
			}
			else if((result <= 16) && (result >= 14))
			{
				document.getElementById('lrt1-sum').innerHTML = "Php. 18";
			}
			else if((result <= 18) && (result >= 17))
			{
				document.getElementById('lrt1-sum').innerHTML = "Php. 19";
			}
			else if(result >= 19)
			{
				document.getElementById('lrt1-sum').innerHTML = "Php. 20";
			}
			else if(result <= 0)
			{
				document.getElementById('lrt1-sum').innerHTML = "Php. 0. Tip: You cannot select the same origin and destination.";
			}
			else
			{
				console.log("Error:" + result);
				document.getElementById('lrt2-sum').innerHTML = "Invalid input. Please try again.";
			}
		}
		else
		{
			var e1 = document.getElementById('lrt1-origin');
			op1 = e1.options[e1.selectedIndex].value;
			var e2 = document.getElementById('lrt1-destination');
			op2 = e2.options[e2.selectedIndex].value;
			op1 = parseInt(op1);
			op2 = parseInt(op2);
			result = op1 - op2;
			result = Math.abs(result);

			if((result <= 4) && (result >= 1))
			{
				document.getElementById('lrt1-sum').innerHTML = "Php. 12";
			}
			else if((result <= 8) && (result >= 5))
			{
				document.getElementById('lrt1-sum').innerHTML = "Php. 13";
			}
			else if((result <= 12) && (result >= 9))
			{
				document.getElementById('lrt1-sum').innerHTML = "Php. 14";
			}
			else if((result >= 13))
			{
				document.getElementById('lrt1-sum').innerHTML = "Php. 15";
			}
			else if(result <= 0)
			{
				document.getElementById('lrt1-sum').innerHTML = "Php. 0. Tip: You cannot select the same origin and destination.";
			}
			else
			{
				console.log("Error:" + result);
				document.getElementById('lrt2-sum').innerHTML = "Invalid input. Please try again.";
			}
		}
	}
}
function calculateLRT2()
{
	var e1 = document.getElementById('lrt2-origin');
	op1 = e1.options[e1.selectedIndex].value;
	var e2 = document.getElementById('lrt2-destination');
	op2 = e2.options[e2.selectedIndex].value;
	op1 = parseInt(op1);
	op2 = parseInt(op2);
	result = op1 - op2;
	result = Math.abs(result);

	if((result <= 3) && (result >= 1))
	{
		document.getElementById('lrt2-sum').innerHTML = "Php. 12";
	}
	else if((result <= 6) && (result >= 4))
	{
		document.getElementById('lrt2-sum').innerHTML = "Php. 13";
	}
	else if((result <=9) && (result >= 7))
	{
		document.getElementById('lrt2-sum').innerHTML = "Php. 14";
	}
	else if(result >= 6)
	{
		document.getElementById('lrt2-sum').innerHTML = "Php. 15";
	}
				else if(result <= 0)
			{
				document.getElementById('lrt2-sum').innerHTML = "Php. 0. Tip: You cannot select the same origin and destination.";
			}
	else
	{
		console.log("Error:" + result);
		document.getElementById('lrt2-sum').innerHTML = "Invalid input. Please try again.";
	}
}

function calculateMRT3()
{
	var e1 = document.getElementById('mrt3-origin');
	op1 = e1.options[e1.selectedIndex].value;
	var e2 = document.getElementById('mrt3-destination');
	op2 = e2.options[e2.selectedIndex].value;
	op1 = parseInt(op1);
	op2 = parseInt(op2);
	result = op1 - op2;
	result = Math.abs(result);

	if((result <= 2) && (result >= 1))
	{
		document.getElementById('mrt3-sum').innerHTML = "Php. 10";
	}
	else if((result <= 4) && (result >= 3))
	{
		document.getElementById('mrt3-sum').innerHTML = "Php. 11";
	}
	else if((result <=7) && (result >= 5))
	{
		document.getElementById('mrt3-sum').innerHTML = "Php. 12";
	}
	else if((result <= 10) && (result >= 8))
	{
		document.getElementById('mrt3-sum').innerHTML = "Php. 14";
	}
	else if(result >= 11)
	{
		document.getElementById('mrt3-sum').innerHTML = "Php. 15";
	}
				else if(result <= 0)
			{
				document.getElementById('mrt3-sum').innerHTML = "Php. 0. Tip: You cannot select the same origin and destination.";
			}
	else
	{
		console.log("Error:" + result);
		document.getElementById('mrt3-sum').innerHTML = "Invalid input. Please try again.";
	}
}

function calculatePNR()
{
	var e1 = document.getElementById('pnr-origin');
	op1 = e1.options[e1.selectedIndex].value;
	var e2 = document.getElementById('pnr-destination');
	op2 = e2.options[e2.selectedIndex].value;
	op1 = parseInt(op1);
	op2 = parseInt(op2);
	result = op1 - op2;
	result = Math.abs(result);

	if((result <= 10) && (result >= 1))
	{
		document.getElementById('pnr-sum').innerHTML = "Php. 10";
	}
	else if((result <= 14) && (result >= 11))
	{
		document.getElementById('pnr-sum').innerHTML = "Php. 15";
	}
	else if((result == 16))
	{
		document.getElementById('pnr-sum').innerHTML = "Php. 20";
	}
	else if((result <= 18) && (result >= 17))
	{
		document.getElementById('pnr-sum').innerHTML = "Php. 25";
	}
	else if((result <= 22) && (result >= 19))
	{
		document.getElementById('pnr-sum').innerHTML = "Php. 30";
	}
	else if(result >= 23)
	{
		document.getElementById('pnr-sum').innerHTML = "Php. 35";
	}
				else if(result <= 0)
			{
				document.getElementById('pnr-sum').innerHTML = "Php. 0. Tip: You cannot select the same origin and destination.";
			}
	else
	{
		console.log("Error:" + result);
		document.getElementById('pnr-sum').innerHTML = "Invalid input. Please try again.";
	}
}

$("#lrt1-origin").change(calculateLRT1);
$("#lrt1-destination").change(calculateLRT1);
$("#lrt1-tickettype").change(calculateLRT1);
$("#lrt1-origin").change(calculateLRT2);
$("#lrt2-destination").change(calculateLRT2);
$("#mrt3-origin").change(calculateMRT3);
$("#mrt3-destination").change(calculateMRT3);
$("#pnr-origin").change(calculatePNR);
$("#pnr-destination").change(calculatePNR);