/*
'   ----------------------------------------------------------------------------------
'   © Copyright 2006, Radixx Solutions International
'   All Rights Reserved
'   Any unauthorized review, use, disclosure or distribution is prohibited.
'
'   Desc:   This class contains the functions for the Web Services
'
'   Revision History -
'   Date        Init    Description
'   --------    ----    --------------
'   14Nov2007	VHP		Inital code that is compatible with IE and FireFox
'   ----------------------------------------------------------------------------------
*/

MyMonthArray = new Array(0,31,28,31,30,31,30,31,31,30,31,30,31);

function GetNumberOfDaysForMonthYear(month, year) 
{
	//alert("GetNumberOfDaysForMonthYear.");
	var e;
	try
	{
		if (typeof month == "undefined" || typeof year == "undefined" ) {
			month = this.getMonth();
		}
		if (((0 == (year%4)) && ( (0 != (year%100)) || (0 == (year%400)))) && month == 2) {
			return 29;
		} else {
			return MyMonthArray[month];
		}
	}
	catch(e)
	{
		alert("Error in GetNumberOfDaysForMonthYear Error = "+ e.description);
		return "";
	}
}

function writeOptions_MonthYear(intValue)
{
	//alert("writeOptions_MonthYear.");
	var e;
	try
	{
		var theMonth;
		var monthCounter;
		var theDate = new Date();
		var currentMonth=theDate.getMonth();
		var currentYear=theDate.getFullYear();
		var monthYear;
		var monYear_val;
		   
		//alert("currentMonth - currentYear" + currentMonth + " " + currentYear);
		for (monthCounter = 0; monthCounter < 16; monthCounter++)
		{
				theDate.setDate(1);
				theDate.setMonth(currentMonth);
				theMonth = theDate.toString();
				theMonth = theMonth.substr(4,3);
				monYear = theMonth + " " + currentYear;
				if (((+currentMonth)+1) <=9)
				{
					currentMonth = '0' + currentMonth;
					monYear_val = '0' + ((+currentMonth)+1) + ' ' + currentYear;
				}
				else
			{
					monYear_val = ((+currentMonth)+1) + ' ' + currentYear;
			}
				document.write('<OPTION value="' + monYear_val + '">' + monYear);
				document.write('</option>');
				currentMonth = (+currentMonth) + 1;
				if (currentMonth == 12)
				{
					currentMonth = 0;
					currentYear =(+currentYear) +  1;

				}
		}

		theDate = new Date();
		var currentDay=theDate.getDate();
		currentMonth=theDate.getMonth();
		currentMonth=currentMonth+1;
		currentYear=theDate.getFullYear();
		   
		if ( intValue == 1 )
		{
				//alert("CreateDepDayList " + currentDay + " intMonth : " + currentMonth + " intYearValue : " + currentYear );
				CreateDepDayList(currentDay,new Number(currentMonth),currentYear);
		}
		if ( intValue == 2 )
		{
				//alert("CreateDepDayList " + currentDay + " intMonth : " + currentMonth + " intYearValue : " + currentYear );
				CreateRetDayList(currentDay,new Number(currentMonth),currentYear);
		}   
	}
	catch(e)
	{
		alert("Error in writeOptions_MonthYear Error = "+ e.description);
		return "";
	}
}

function SelectDep_MonthYear(strSelectedVal)
{
	//alert("SelectDep_MonthYear strSelectedVal : " + strSelectedVal);
	var e;
	try
	{
		for (i=0; i < document.forms[0].ctlAvailCriteria_cboDepMon.options.length; i++) 
		{
			//alert("SelectDep_MonthYear : " + document.forms[0].ctlAvailCriteria_cboDepMon.options[i].value );
			if( document.forms[0].ctlAvailCriteria_cboDepMon.options[i].value == strSelectedVal) {
				document.forms[0].ctlAvailCriteria_cboDepMon.options[i].selected = "selected";
				//alert("SelectDep_MonthYear selected : " + strSelectedVal);
			}
		}	
	}
	catch(e)
	{
		alert("Error in SelectDep_MonthYear Error = "+ e.description);
		return false;
	}	
}

function SelectRet_MonthYear(strSelectedVal)
{
	//alert("SelectRet_MonthYear strSelectedVal : " + strSelectedVal);
	var e;
	try
	{
		for (i=0; i < document.forms[0].ctlAvailCriteria_cboRetMon.options.length; i++) 
		{
			//alert("SelectRet_MonthYear : " + document.forms[0].ctlAvailCriteria_cboRetMon.options[i].value );
			if( document.forms[0].ctlAvailCriteria_cboRetMon.options[i].value == strSelectedVal) {
				document.forms[0].ctlAvailCriteria_cboRetMon.options[i].selected = "selected";
				//alert("SelectRet_MonthYear selected : " + strSelectedVal);
			}
		}	
	}
	catch(e)
	{
		alert("Error in SelectRet_MonthYear Error = "+ e.description);
		return false;
	}	
}

function Radixx_window_onload()
{
	//alert("Radixx_window_onload : ");
	var e;
	try
	{
		var theForm = document.forms[0];
		var nowDate = new Date();
		var mMonth;

		var depday_param = gup( 'depday' );
		var depmon_param = gup( 'depmon' );
		var depyear_param = gup( 'depyear' );
		var retday_param = gup( 'retday' );
		var retmon_param = gup( 'retmon' );
		var retyear_param = gup( 'retyear' );

		Form_Init();
			
		//alert("Setting today's date.");
		if ( depday_param == '' || depmon_param == '' || depyear_param == '' )
			{
					theForm.ctlAvailCriteria_cboDepDay.options[nowDate.getDate() - 1].selected = true;
			}
		if ( retday_param == '' || retmon_param == '' || retyear_param == '' )
			{
					theForm.ctlAvailCriteria_cboRetDay.options[nowDate.getDate() - 1].selected = true;
			}   
		
		
		//document.forms[0].elements["ctlAvailCriteria_cboOrigin"].value = "";
		//window.open('flightsmumdel.htm','mywindow','width=400,height=330,menubar=no,status=no,directories=no,location=no,toolbar=no,titlebar=no,scrollbars=no');
	}
	catch(e)
	{
		alert("Error in Radixx_window_onload Error = "+ e.description);
		return false;
	}	
}

function gup( name )
{  
	//alert("gup : ");
	var e;
	try
	{
		name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");  
		var regexS = "[\\?&]"+name+"=([^&#]*)";  
		var regex = new RegExp( regexS );  
		var results = regex.exec( window.location.href );  
		if( results == null )    
			return "";  
		else    
		return results[1];
	}
	catch(e)
	{
		alert("Error in gup Error = "+ e.description);
		return "";
	}
}

function Form_Init()
{		
	//alert("Form_Init : ");
	var origin_param = gup( 'origin' );
	var dest_param = gup( 'dest' );
	var triptype_param = gup( 'triptype' );
	var adults_param = gup( 'adults' );
	var Children_param = gup( 'Children' );
	var infants_param = gup( 'infants' );
	var depday_param = gup( 'depday' );
	var depmon_param = gup( 'depmon' );
	var depyear_param = gup( 'depyear' );
	var retday_param = gup( 'retday' );
	var retmon_param = gup( 'retmon' );
	var retyear_param = gup( 'retyear' );
	
	try
	{		
		if (origin_param != '' && dest_param != '' )
		{
			origin_param = origin_param.replace("+","");
			dest_param = dest_param.replace("+","");
			//alert("Form_Init origin_param,dest_param : " + origin_param + " " + dest_param);
			
			SetOriginSelected(origin_param);
			
			doDestinations();

			SetDestinationSelected(dest_param);
			
		}
		else
		{
				doDestinations();
		}
		
		if (triptype_param != '' )
		{
			//alert("Form_Init triptype: " + triptype_param);
			if (triptype_param == 'rRoundTrip' )
			{
				document.forms[0].ctlAvailCriteria_rRoundTrip.checked = true;
				document.forms[0].ctlAvailCriteria_rOneWay.checked = false;
				showRT();
			}
			else
			{
				document.forms[0].ctlAvailCriteria_rRoundTrip.checked = false;
				document.forms[0].ctlAvailCriteria_rOneWay.checked = true;
				hideRT();
			}	
		}

		//alert("Form_Init adults_param: " + adults_param);
		if (adults_param != '' )
		{
			window.document.forms[0].ctlAvailCriteria_cboAdults.value= adults_param;
		}

		//alert("Form_Init Children_param: " + Children_param);
		if (Children_param != '' )
		{
			window.document.forms[0].ctlAvailCriteria_cboChild.value= Children_param;
		}

		//alert("Form_Init infants_param: " + infants_param);
		if (infants_param != '' )
		{			
			getInfants();
			window.document.forms[0].ctlAvailCriteria_cboInfants.value= infants_param;
		}

		//alert("Form_Init dep date : " + depday_param + " " + depmon_param + " " + depyear_param);
		if ( depday_param != '' && depmon_param != '' && depyear_param != '' )
		{
				CreateDepDayList(depday_param,new Number(depmon_param),depyear_param);
				SelectDep_MonthYear(depmon_param + " " + depyear_param);
		}
		
		//alert("Form_Init dep date : " + retday_param + " " + retmon_param + " " + retyear_param);
		if ( retday_param != '' && retmon_param != '' && retyear_param != '' )
		{
				
				CreateRetDayList(retday_param,new Number(retmon_param),retyear_param);
				SelectRet_MonthYear(retmon_param + " " + retyear_param);
				setReturnCalendarDate();
		}   
		setCalendarDates();
			
	}
	catch(e)
	{
		alert("Error in Form_Init Error = "+ e.description);
		return false;
	}		
}

function SetOriginSelected(strSelectedVal) 
{
	//alert("SetOriginSelected : " + strSelectedVal );
	var e;
	try
	{
		for (i=0; i < document.forms[0].ctlAvailCriteria_cboOrigin.options.length; i++) {
			if( document.forms[0].ctlAvailCriteria_cboOrigin.options[i].value == strSelectedVal) {
				document.forms[0].ctlAvailCriteria_cboOrigin.options[i].selected = "selected";
				//alert("SetOriginSelected selected : " + strSelectedVal);
			}
		}
	}
	catch(e)
	{
		alert("Error in SetOriginSelected Error = "+ e.description);
		return false;
	}	
}

function SetDestinationSelected(strSelectedVal) 
{
	//alert("SetOriginSelected : " + strSelectedVal);
	var e;
	try
	{
		for (i=0; i < document.forms[0].ctlAvailCriteria_cboDest.options.length; i++) 
		{
			if( document.forms[0].ctlAvailCriteria_cboDest.options[i].value == strSelectedVal) {
				document.forms[0].ctlAvailCriteria_cboDest.options[i].selected = "selected";
				//alert("SetOriginSelected  selected: " + strSelectedVal);
			}
		}
	}
	catch(e)
	{
		alert("Error in SetDestinationSelected Error = "+ e.description);
		return false;
	}	
}

function CreateDepDayList(intDayValue,intMonth,intYearValue)
{
	//alert("CreateDepDayList.");
	var e;
	try
	{
		while (document.forms[0].ctlAvailCriteria_cboDepDay.options.length > 0)
		{
			var deleteIndex=document.forms[0].ctlAvailCriteria_cboDepDay.options.length-1;
			document.forms[0].ctlAvailCriteria_cboDepDay.options[deleteIndex]=null;
		}

		var intDaysInMonthYear = GetNumberOfDaysForMonthYear(intMonth,intYearValue);
		//alert("CreateDepDayList selected intDayValue : " + intDayValue + " intMonth : " + intMonth + " intYearValue : " + intYearValue + " intDaysInMonthYear : " +intDaysInMonthYear );
		for (j=1; j <= intDaysInMonthYear; j++) 
		{
					var myOption=new Option();
					var insertIndex;
					var strName;
					var strVal;
					if (j <=9)
					{
						strVal = '0' + j;
						strName = '0' + j;
					}
					else
					{
						strVal = j;
						strName = j;
					}
					myOption.text=strName;
					myOption.value=strVal;
					
					//alert("CreateDepDayList before IF.");
					if (document.forms[0].ctlAvailCriteria_cboDepDay.selectedIndex > 0)
						insertIndex=document.forms[0].ctlAvailCriteria_cboDepDay.selectedIndex;
					else
						insertIndex=document.forms[0].ctlAvailCriteria_cboDepDay.options.length;

					//alert("CreateDepDayList after IF insertIndex = " + insertIndex);
					document.forms[0].ctlAvailCriteria_cboDepDay.options[insertIndex]=myOption;						
		}	
		if (intDayValue <=9)
		{
			intDayValue = '0' + intDayValue;
		}
		//alert("CreateDepDayList intDayValue : " + intDayValue);
		for (I=0; I < document.forms[0].ctlAvailCriteria_cboDepDay.options.length; I++)
		{
			if( document.forms[0].ctlAvailCriteria_cboDepDay.options[I].value == intDayValue) {
			document.forms[0].ctlAvailCriteria_cboDepDay.options[I].selected = "selected";
			//alert("CreateDepDayList selected : " + intDayValue);
			}
		}
		return true;
	}
	catch(e)
	{
		alert("Error in function CreateDepDayList. Error = " + e.description);
		return false;
	}
}

function CreateRetDayList(intDayValue,intMonth,intYearValue)
{
	//alert("CreateRetDayList.");
	var e;
	try
	{
		while (document.forms[0].ctlAvailCriteria_cboRetDay.options.length > 0)
		{
			var deleteIndex=document.forms[0].ctlAvailCriteria_cboRetDay.options.length-1;
			document.forms[0].ctlAvailCriteria_cboRetDay.options[deleteIndex]=null;
		}

		var intDaysInMonthYear = GetNumberOfDaysForMonthYear(intMonth,intYearValue);
		//alert("CreateRetDayList selected intDayValue : " + intDayValue + " intMonth : " + intMonth + " intYearValue : " + intYearValue + " intDaysInMonthYear : " +intDaysInMonthYear );
		for (j=1; j <= intDaysInMonthYear; j++) 
		{
					var myOption=new Option();
					var insertIndex;
					var strName;
					var strVal;
					if (j <=9)
					{
						strVal = '0' + j;
						strName = '0' + j;
					}
					else
					{
						strVal = j;
						strName = j;
					}
					myOption.text=strName;
					myOption.value=strVal;
					
					//alert("CreateRetDayList before IF.");
					if (document.forms[0].ctlAvailCriteria_cboRetDay.selectedIndex > 0)
						insertIndex=document.forms[0].ctlAvailCriteria_cboRetDay.selectedIndex;
					else
						insertIndex=document.forms[0].ctlAvailCriteria_cboRetDay.options.length;

					//alert("CreateRetDayList after IF insertIndex = " + insertIndex);
					document.forms[0].ctlAvailCriteria_cboRetDay.options[insertIndex]=myOption;						
		}	
		if (intDayValue <=9)
		{
			intDayValue = '0' + intDayValue;
		}
		//alert("CreateRetDayList intDayValue : " + intDayValue);
		for (I=0; I < document.forms[0].ctlAvailCriteria_cboRetDay.options.length; I++)
		{
			if( document.forms[0].ctlAvailCriteria_cboRetDay.options[I].value == intDayValue) {
			document.forms[0].ctlAvailCriteria_cboRetDay.options[I].selected = "selected";
			//alert("CreateRetDayList select : " + intDayValue);
			}
		}
		return true;
	}
	catch(e)
	{
		alert("Error in function CreateRetDayList. Error = " + e.description);
		return false;
	}
}

function ClearDestinationList()
{
	//alert("ClearDestinationList Begin ");
	var e;
	try
	{
		var nlength = document.forms[0].ctlAvailCriteria_cboDest.options.length;
		//alert("ClearDestinationList nlength = " + nlength);

		while (document.forms[0].ctlAvailCriteria_cboDest.options.length > 0)
		{
			var deleteIndex=document.forms[0].ctlAvailCriteria_cboDest.options.length-1;
			document.forms[0].ctlAvailCriteria_cboDest.options[deleteIndex]=null;
		}
		return true;
	}
	catch(e)
	{
		alert("Error in function ClearDestinationList. Error = " + e.description );
		return false;
	}
}

function CreateOptionInDestinationList(strVal,strName,blnIsSelected)
{
	//alert("CreateOptionInDestinationList return value = " + sResult);
	var e;
	try
	{		
		var myOption=new Option();
		var insertIndex;
		myOption.text=strName;
		myOption.value=strVal;
		//alert("CreateOptionInDestinationList before IF.");
		if (document.forms[0].ctlAvailCriteria_cboDest.selectedIndex > 0)
			insertIndex=document.forms[0].ctlAvailCriteria_cboDest.selectedIndex;
		else
			insertIndex=document.forms[0].ctlAvailCriteria_cboDest.options.length;

		//alert("CreateOptionInDestinationList after IF.");
		document.forms[0].ctlAvailCriteria_cboDest.options[insertIndex]=myOption;	
		
	}
	catch(e)
	{
		alert("Error in function CreateOptionInDestinationList. Error = " + e.description);
		return false;
	}
}

function doDestinations()
{
	//alert("doDestinations ");
	var e;
	try
	{	
		var strOriginCityCode = document.forms[0].ctlAvailCriteria_cboOrigin.value;
		
		//alert("doDestinations : " + strOriginCityCode);
		
		if ( strOriginCityCode == '' )
		{
			return;
		}
		
		ClearDestinationList();
		
		for (j=0; j < origin_array.length; j++) 
		{
			if (strOriginCityCode == origin_array[j])
			{
				CreateOptionInDestinationList(destination_array[j],destination_cities_array[j],false);
			}
		}
	}
	catch(e)
	{
		alert("Error in function doDestinations. Error = " + e.description);
		return false;
	}
}

function showRT()
{
	//alert("showRT ");
	var e;
	try
	{
		document.forms[0].ctlAvailCriteria_cboRetDay.style.visibility = 'visible';
		document.forms[0].ctlAvailCriteria_cboRetMon.style.visibility = 'visible';
		document.forms[0].cal_trigger_return.style.visibility = 'visible';
	}
	catch(e)
	{
		alert("Error in function showRT. Error = " + e.description);
		return false;
	}
}
function hideRT()
{
	//alert("hideRT ");
	var e;
	try
	{
		document.forms[0].ctlAvailCriteria_cboRetDay.style.visibility = 'hidden';
		document.forms[0].ctlAvailCriteria_cboRetMon.style.visibility = 'hidden';
		document.forms[0].cal_trigger_return.style.visibility = 'hidden';
	}
	catch(e)
	{
		alert("Error in function hideRT. Error = " + e.description);
		return false;
	}
}
function changeday()
{
	//alert("changeday ");
	var e;
	try
	{
		//window.document.forms[0].ctlAvailCriteria_cboRetDay.value = window.document.forms[0].ctlAvailCriteria_cboDepDay.value;
		//window.document.forms[0].ctlAvailCriteria_cboRetMon.value = window.document.forms[0].ctlAvailCriteria_cboDepMon.value;
		setCalendarDates();
	}
	catch(e)
	{
		alert("Error in function changeday. Error = " + e.description);
		return false;
	}		
}

function changeMonthYear(intValue)
{
	//alert("changeMonthYear : " + intValue);
	var e;
	try
	{
		var mdepmonyear=window.document.forms[0].ctlAvailCriteria_cboDepMon.value.split(" ");	
		var mretmonyear=window.document.forms[0].ctlAvailCriteria_cboRetMon.value.split(" ");
		document.forms[0].outDate.value=mdepmonyear[1] + '/' + mdepmonyear[0] + '/' + window.document.forms[0].ctlAvailCriteria_cboDepDay.value ;
		document.forms[0].retDate.value=mretmonyear[1] + '/' + mretmonyear[0] + '/' + window.document.forms[0].ctlAvailCriteria_cboRetDay.value ;

		if ( intValue == 1 )
		{
				//alert("changeMonthYear : " + window.document.forms[0].ctlAvailCriteria_cboDepMon.value);
				CreateDepDayList(new Number(document.forms[0].ctlAvailCriteria_cboDepDay.value),new Number(mdepmonyear[0]),mdepmonyear[1]);
		}
		if ( intValue == 2 )
		{
				//alert("changeMonthYear : " + window.document.forms[0].ctlAvailCriteria_cboRetMon.value);
				CreateRetDayList(new Number(document.forms[0].ctlAvailCriteria_cboRetDay.value),new Number(mretmonyear[0]),mretmonyear[1]);
				setReturnCalendarDate();
		}   	
		setCalendarDates();
	}
	catch(e)
	{
		alert("Error in function changeMonthYear. Error = " + e.description);
		return false;
	}
}

//we have to set the calendar date when we change the departure date through the list
function setCalendarDates()
{
	//alert("setCalendarDates ");
	var e;
	try
	{
		var mdepmonyear=document.forms[0].ctlAvailCriteria_cboDepMon.value.split(" ");	
		var mretmonyear=window.document.forms[0].ctlAvailCriteria_cboRetMon.value.split(" ");
		document.forms[0].outDate.value=mdepmonyear[1] + '/' + mdepmonyear[0] + '/' + window.document.forms[0].ctlAvailCriteria_cboDepDay.value ;
		document.forms[0].retDate.value=mretmonyear[1] + '/' + mretmonyear[0] + '/' + window.document.forms[0].ctlAvailCriteria_cboRetDay.value ;
	}
	catch(e)
	{
		alert("Error in function setCalendarDates. Error = " + e.description);
		return false;
	}
}
function setReturnCalendarDate()
{
	//alert("setReturnCalendarDate ");
	var e;
	try
	{
		var mretmonyear=window.document.forms[0].ctlAvailCriteria_cboRetMon.value.split(" ");
		document.forms[0].retDate.value=mretmonyear[1] + '/' + mretmonyear[0] + '/' + window.document.forms[0].ctlAvailCriteria_cboRetDay.value ;
	}
	catch(e)
	{
		alert("Error in function setReturnCalendarDate. Error = " + e.description);
		return false;
	}
}
function getInfants()
{
	//alert("getInfants ");
	var e;
	try
	{
		while (document.forms[0].ctlAvailCriteria_cboInfants.options.length > 0)
		{
			var deleteIndex=document.forms[0].ctlAvailCriteria_cboInfants.options.length-1;
			document.forms[0].ctlAvailCriteria_cboInfants.options[deleteIndex]=null;
		}
		
		var seladult = document.forms[0].ctlAvailCriteria_cboAdults.value;
		for (i=0;i<=seladult;i++)
		{
			var myOption=new Option();
			var insertIndex;
			myOption.text=i;
			myOption.value=i;
			if (document.forms[0].ctlAvailCriteria_cboInfants.selectedIndex > 0)
				insertIndex=document.forms[0].ctlAvailCriteria_cboInfants.selectedIndex;
			else
				insertIndex=document.forms[0].ctlAvailCriteria_cboInfants.options.length;

			document.forms[0].ctlAvailCriteria_cboInfants.options[insertIndex]=myOption;
		}
	}
	catch(e)
	{
		alert("Error in function getInfants. Error = " + e.description);
		return false;
	}
}
function set_form_date_fields_mmyyyy_Outbound(oMonYrDdl, oDayDdl, date) 
{
	//alert("set_form_date_fields_mmyyyy_Outbound ");
	var e;
	try 
	{
		if ((oMonYrDdl == undefined) || (oDayDdl == undefined) || (date == undefined)) return;
		if ((oMonYrDdl == "") || (oDayDdl == "") || (date == "")) return;
		var arrDate=date.split("/",3);
		if (arrDate.length <=0) return;
		//alert("set_form_date_fields_mmyyyy_Outbound arrDate = " + arrDate);
		//alert("set_form_date_fields_mmyyyy_Outbound oDayDdl.length = " + oDayDdl.length);
		//alert("set_form_date_fields_mmyyyy_Outbound date = " + date);
		
		CreateDepDayList(new Number(arrDate[2]),new Number(arrDate[1]),arrDate[0]);		
		SelectDep_MonthYear(arrDate[1] + " " + arrDate[0]);	
		changeday();
	} 
	catch(e)
	{
		alert("Error in function set_form_date_fields_mmyyyy_Outbound. Error = " + e.description);
		return false;
	}
}
function set_form_date_fields_mmyyyy_Return(oMonYrDdl, oDayDdl, date) 
{
	//alert("set_form_date_fields_mmyyyy_Return ");
	var e;
	try 
	{
		if ((oMonYrDdl == undefined) || (oDayDdl == undefined) || (date == undefined)) return;
		if ((oMonYrDdl == "") || (oDayDdl == "") || (date == "")) return;
		var arrDate=date.split("/",3);
		if (arrDate.length <=0) return;
		//alert("set_form_date_fields_mmyyyy_Return arrDate = " + arrDate);
		//alert("set_form_date_fields_mmyyyy_Return oDayDdl.length = " + oDayDdl.length);
		//alert("set_form_date_fields_mmyyyy_Return date = " + date);
		
		CreateRetDayList(new Number(arrDate[2]),new Number(arrDate[1]),arrDate[0]);	
		SelectRet_MonthYear(arrDate[1] + " " + arrDate[0]);					
	} 
	catch(e)
	{
		alert("Error in function set_form_date_fields_mmyyyy_Return. Error = " + e.description);
		return false;
	}
}
function checkForm()
{
	//alert("checkForm ");
	var e;
	try 
	{
		if (window.document.forms[0].ctlAvailCriteria_cboOrigin.value == "") 
		{	
			alert("Please enter valid From Airports");
			window.document.forms[0].ctlAvailCriteria_cboOrigin.selectedIndex=0;
			return false;
		}
		if (window.document.forms[0].ctlAvailCriteria_cboDest.value == "") 
		{	
			alert("Please enter valid To Airports");
			window.document.forms[0].ctlAvailCriteria_cboDest.selectedIndex=0;
			return false;
		}
		var mdepmonyear=window.document.forms[0].ctlAvailCriteria_cboDepMon.value.split(" ");
		var mretmonyear=window.document.forms[0].ctlAvailCriteria_cboRetMon.value.split(" ");
		var mDepDate = new Date(mdepmonyear[1],mdepmonyear[0]-1,window.document.forms[0].ctlAvailCriteria_cboDepDay.value);
		var mRetDate = new Date(mretmonyear[1],mretmonyear[0]-1,window.document.forms[0].ctlAvailCriteria_cboRetDay.value);

		var nowDate = new Date();
		nowDate.setHours(0,0,0,0);
		//alert("checkForm nowDate :" + nowDate + " mDepDate " + mDepDate);
		if (mDepDate < nowDate)
		{
			alert("Departure Date must be greater than today.");
			return false;
		}
		
		if (document.forms[0].ctlAvailCriteria_rRoundTrip.checked && mRetDate < mDepDate)
		{
			alert("Return Date must be greater than Departure Date.");
			return false;
		}
		var totalAdults = (+window.document.forms[0].ctlAvailCriteria_cboAdults.value); 
		var totalChild = (+window.document.forms[0].ctlAvailCriteria_cboChild.value) ;
		totalPax = totalAdults+totalChild;
		
		//alert("totalPax " + totalPax);
		if (totalPax < 1 )
		{
			alert("Please select at least 1 passenger.");
			return false;
		}	
		if (totalPax > 9 )
		{
			alert("Maximum Passengers per booking is 9. Please call our 24x7 All India Call Centre at (city code) 39008888 to make the booking.");
			return false;
		}
	} 
	catch(e)
	{
		alert("Error in function checkForm. Error = " + e.description);
		return false;
	}
}
function submitForm()
{
	var mdepmonyear=document.forms[0].ctlAvailCriteria_cboDepMon.value.split(" ");
	var mretmonyear=document.forms[0].ctlAvailCriteria_cboRetMon.value.split(" ");
	var mtriptype;
	if (document.forms[0].ctlAvailCriteria_rRoundTrip.checked)
	{
		mtriptype=document.forms[0].ctlAvailCriteria_rRoundTrip.value
	}
	else if (document.forms[0].ctlAvailCriteria_rOneWay.checked)
	{
		mtriptype = document.forms[0].ctlAvailCriteria_rOneWay.value;
	}

	var strURL_UAT = "http://uat.radixx.com/AirDeccan/avail.aspx?"
	
	var strURL_PRODUCTION = "http://airdeccan.booksecure.net/avail.aspx?"
	
	document.forms[0].action=strURL_PRODUCTION +"triptype=" + mtriptype + "&origin=" + document.forms[0].ctlAvailCriteria_cboOrigin.value 
	+ "&dest=" + document.forms[0].ctlAvailCriteria_cboDest.value 
	+ "&depday=" + document.forms[0].ctlAvailCriteria_cboDepDay.value 
	+ "&depmon=" + mdepmonyear[0] + "&depyear=" + mdepmonyear[1] + "&retday=" + document.forms[0].ctlAvailCriteria_cboRetDay.value 
	+ "&retmon=" + mretmonyear[0] + "&retyear=" + mretmonyear[1] + "&adults=" + document.forms[0].ctlAvailCriteria_cboAdults.value 
	+ "&Children=" + document.forms[0].ctlAvailCriteria_cboChild.value + "&infants=" 
	+ document.forms[0].ctlAvailCriteria_cboInfants.value + "&subfaretype=1" + "&subwebfaretype=1"
	
	document.forms[0].submit();	
}
function submitLowestFareForm()
{
	var mdepmonyear=document.forms[0].ctlAvailCriteria_cboDepMon.value.split(" ");
	var mretmonyear=document.forms[0].ctlAvailCriteria_cboRetMon.value.split(" ");
	var mtriptype;
	if (document.forms[0].ctlAvailCriteria_rRoundTrip.checked)
	{
		mtriptype=document.forms[0].ctlAvailCriteria_rRoundTrip.value
	}
	else if (document.forms[0].ctlAvailCriteria_rOneWay.checked)
	{
		mtriptype = document.forms[0].ctlAvailCriteria_rOneWay.value;
	}

	var strURL_UAT = "http://uat.radixx.com/AirDeccan/WebShopper.aspx?"
	var strURL_PRODUCTION = "http://airdeccan.booksecure.net/WebShopper.aspx?"

	document.forms[0].action=strURL_PRODUCTION +"triptype=" + mtriptype + "&origin=" + document.forms[0].ctlAvailCriteria_cboOrigin.value 
	+ "&dest=" + document.forms[0].ctlAvailCriteria_cboDest.value 
	+ "&depday=" + document.forms[0].ctlAvailCriteria_cboDepDay.value 
	+ "&depmon=" + mdepmonyear[0] + "&depyear=" + mdepmonyear[1] + "&retday=" + document.forms[0].ctlAvailCriteria_cboRetDay.value 
	+ "&retmon=" + mretmonyear[0] + "&retyear=" + mretmonyear[1] + "&adults=" + document.forms[0].ctlAvailCriteria_cboAdults.value 
	+ "&Children=" + document.forms[0].ctlAvailCriteria_cboChild.value + "&infants=" 
	+ document.forms[0].ctlAvailCriteria_cboInfants.value + "&subfaretype=1" + "&subwebfaretype=1"
	
	document.forms[0].submit();	
}
function OpenCreditNoteMessage()
{
	alert("The online facility will be restored shortly.");
}
