﻿function goToNext(selectedPricableUnitID) 
{
	if((document.getElementById("hdSearchOption")!= null)&&(document.getElementById("hdOutboundStartIndex")!= null)&&(document.getElementById("hdOutboundEndIndex")!= null)&&(document.getElementById("hdInboundStartIndex")!= null)&&(document.getElementById("hdInboundEndIndex")!= null))
	{
		switch((document.getElementById("hdSearchOption")).value)
		{
			case "1":
			{
				var OutboundStartIndex = Number((document.getElementById("hdOutboundStartIndex")).value);
				var OutboundEndIndex = Number((document.getElementById("hdOutboundEndIndex")).value);
				var InboundStartIndex = Number((document.getElementById("hdInboundStartIndex")).value);
				var InboundEndIndex = Number((document.getElementById("hdInboundEndIndex")).value); 
				
				var selectedOutboundPriceIndex = -3;
				var selectedInboundPriceIndex = -4;
				var lbolStatus = false;
				var outboundRadioBtn; 
				var selectedRadioOutboundBtnIndex = -1;
				var selectedInboundRadioBtnIndex = -1;
				for( var i = OutboundStartIndex; i <= OutboundEndIndex;i++)
				{
					outboundRadioBtn = document.getElementById("radioBtnOutbound" + i);
					if ((outboundRadioBtn != null) && (outboundRadioBtn.checked) && (outboundRadioBtn.value == selectedPricableUnitID))
					{
						selectedOutboundPriceIndex = outboundRadioBtn.value;
						selectedRadioOutboundBtnIndex = "radioBtnOutbound" + i;
						break;
					}
				}
				
				var inboundRadioBtn;
				for( var i = InboundStartIndex; i <= InboundEndIndex ; i++)
				{
					inboundRadioBtn = document.getElementById("radioBtnInbound" + i);
					if ((inboundRadioBtn != null) && (inboundRadioBtn.checked) && (inboundRadioBtn.value == selectedPricableUnitID))
					{
						selectedInboundPriceIndex = inboundRadioBtn.value;
						selectedInboundRadioBtnIndex = "radioBtnInbound" + i;
						break;
					}
				}
				
				// alert("selectedOutboundPriceIndex:" + selectedOutboundPriceIndex + " selectedInboundPriceIndex:" + selectedInboundPriceIndex);
				
			    // alert("GQ_Availability.aspx?OutboundPriceUnitId=" + selectedOutboundPriceIndex +"&InboundPriceUnitId=" + selectedInboundPriceIndex +"&OutboundIndex=" + outboundRadioBtn.title + "&InboundIndex=" + inboundRadioBtn.title + "&outboundRadioBtn=" + selectedRadioOutboundBtnIndex + "&inboundRadioBtn=" + selectedInboundRadioBtnIndex+"&hotelrooom="+document.getElementById('hdHotelRoom').value);
				// debugger;
			    
			    if(selectedOutboundPriceIndex == selectedInboundPriceIndex)
				{
				    window.location = "GQAvailability.aspx?PriceUnitId=" + selectedOutboundPriceIndex + "&OutboundIndex=" + outboundRadioBtn.title + "&InboundIndex=" + inboundRadioBtn.title + "&outboundRadioBtn=" + selectedRadioOutboundBtnIndex + "&inboundRadioBtn=" + selectedInboundRadioBtnIndex;
				    return;
				}
				else
				{
				    if((InboundStartIndex == -1)&&(InboundEndIndex == -1)&&(selectedOutboundPriceIndex != -3))
					{
					    window.location = "GQAvailability.aspx?PriceUnitId=" + selectedOutboundPriceIndex + "&OutboundIndex=" + outboundRadioBtn.title + "&InboundIndex=-1&outboundRadioBtn=" + selectedRadioOutboundBtnIndex + "&inboundRadioBtn=-1";
					    return;
					}
					else
					{
					    alert("Please Select the Correct Flight");
					}
				}

				break;
			}
		}
	}
	else
	{
		alert("Please wait till the page fully loads. Thank you.");
	}
}



function OnPageLoad()
{
	var OutboundIndex = document.getElementById("outboundSelected");
	var OutboundValues = null;
	if(OutboundIndex != null)
	{
		OutboundValues = OutboundIndex.value.split(',');
	}
	
	var InboundIndex = document.getElementById("inboundSelected");
	var InboundValue = "";
	if(InboundIndex != null)
	{
		InboundValue = InboundIndex.value;
	}
	
	if(OutboundValues != null)
	{
		var OutboundValue;
	
		for( var i = 0; i <= OutboundValues.length;i++)
		{
			OutboundValue = OutboundValues[i];
			if((OutboundValue != null)&&(document.getElementById(OutboundValue) != null))
			{
				document.getElementById(OutboundValue).checked = true;
			}
		}
	}
	
	if((InboundValue != "")&&(document.getElementById(InboundValue) != null))
	{
		document.getElementById(InboundValue).checked = true;
	}
}
