var $j = jQuery.noConflict(), DepartureStationId = "";
$j(document).ready(function () {
	var a = $j("#ajaxBaseUrl").val(); $j.ajax({ type: "GET", cache: false, url: a + "/rail/GetDepartureStationsForPartial?callback=ProcessDepartureStations", data: { pid: 2 }, crossDomain: true, dataType: "jsonp" }); $j.ajax({ type: "GET", cache: false, url: a + "/rail/GetOfferEndDateForPartial?callback=ProcessOfferEndDate", data: { pid: 2 }, crossDomain: true, dataType: "jsonp" }); $j("#departStation").change(function () {
		var b = $j("#isCoachStation") ? $j("#isCoachStation").val() : "False", c = $j(this).find("option:selected").val();
		DepartureStationId = c; $j("#destinationStation").removeAttr("disabled"); $j("select#destinationStation option").remove(); DisableTicketTypes(); $j.ajax({ type: "GET", cache: false, url: a + "/rail/GetDestinationStationsForPartial?callback=ProcessDestinationStations", data: { sid: c, ics: b }, crossDomain: true, dataType: "jsonp" })
	}); $j("#destinationStation").change(function () {
		var b = $j(this).find("option:selected").val(), c = $j("#packageDetailsId").val(); $j("#TicketId").removeAttr("disabled"); $j("select#TicketId option").remove();
		$j.ajax({ type: "GET", cache: false, url: a + "/rail/GetTicketTypesForPartial?callback=ProcessTicketTypes", data: { sid: b, pid: c, did: DepartureStationId }, crossDomain: true, dataType: "jsonp" })
	}); $j("#fastTrackForm").submit(function () {
		$j("div#errorMsg").remove(); var b = []; if ($j("#departStation").attr("selectedIndex") == 0) { var a; b.push("Please choose a Departure Station") } $j("#destinationStation").attr("selectedIndex") == 0 && b.push("Please choose a Destination Station"); $j("#TicketId").attr("selectedIndex") == 0 && b.push("Please choose a Ticket type");
		$j("#ftRooms").find("option:selected").html() == "1" && $j("#ftAdults1").find("option:selected").html() == "1" && $j("#ftChildren1").find("option:selected").html() == "0" && b.push("Unfortunately we do not issue tickets for rail bookings where there is just one person travelling."); for (var e = $j("#ftRooms").find("option:selected").html(), d = 0, d = 1; d <= parseInt(e); d++) if ($j("#ftChildren" + d).find("option:selected").html() != "0") for (var g = $j("#ftChildren" + d).find("option:selected").html(), f = 0, f = 1; f <= parseInt(g); f++) $j("#ftChildAges_" +
d + "_" + f).attr("selectedIndex") == 0 && (a = "Please choose the age of child " + f + " in room " + d + ".", b.push(a)); if (b.length > 0) { a = ""; a += '<div id="errorMsg" class="hide">'; a += "<ul>"; for (i = 0; i < b.length; i++) a += "<li>" + b[i] + "</li>"; a += "</ul>"; a += "</div>"; $j("#step1Row").before(a); $j("div#errorMsg").fadeIn("slow"); return false } return true
	})
});
function ProcessDestinationStations(a) {
	if (document.getElementById("destinationStation")) {
		var b = 0, c = $j("#companyCode").val(), e = true; if (a.length == 0) DisableDestinationStation(); else {
			c.toUpperCase() == "IN049" ? $j("#destinationStation").append("<option value=''>Destination</option>") : $j("#destinationStation").append("<option value=''>Select destination</option>"); for (b = 0; a.length > b; b++) e = true, c.toUpperCase() == "IN049" && (e = VisitLondonDestinationStations(a[b].Name)), e && $j("#destinationStation").append("<option value='" +
a[b].Code + "'>" + a[b].Name + "</option>")
		}
	}
} function ProcessTicketTypes(a) { if (document.getElementById("TicketId")) { var b = 0; if (a.length == 0) DisableTicketTypes(); else { $j("#TicketId").append("<option value=''>Select ticket type</option>"); for (b = 0; a.length > b; b++) $j("#TicketId").append("<option value='" + a[b].Id + "'>" + a[b].Name + "</option>") } } }
function ProcessDepartureStations(a) { if (document.getElementById("departStation")) { var b = 0; if (a.length == 0) $j("#departStation").append("<option value=''>No Stations Available</option>"); else { $j("#departStation").append("<option value=''>Select departure station</option>"); for (b = 0; a.length > b; b++) $j("#departStation").append("<option value='" + a[b].Code + "'>" + a[b].Name + "</option>") } } } function ProcessOfferEndDate(a) { RemoveInvalidAvailabilityDates(a != "" ? new Date(a) : new Date) }
function DisableTicketTypes() { $j("select#TicketId option").remove(); $j("#TicketId").append("<option value=''>Select ticket type</option>"); $j("#TicketId").attr("disabled", "disabled") } function DisableDestinationStation() { $j("select#destinationStation option").remove(); $j("#destinationStation").append("<option value=''>Select destination</option>"); $j("#destinationStation").attr("disabled", "disabled") }
function VisitLondonDepartureStations() { $j("#departStation") && $j("#departStation")[0].length > 0 && $j("#departStation option").each(function () { $j(this).text().toLowerCase() == "london" && $j(this).remove() }) } function VisitLondonDestinationStations(a) { return a.toLowerCase() == "london" ? true : false };
