function addDays(strDate,iDays){
	strDate = Date.parse(strDate);
	strDate = parseInt(strDate, 10);
	strDate = strDate + iDays*(24*60*60*1000);
	strDate = new Date(strDate);
	return strDate;
}

function daychange(dayvalue)
{
 x=document.all('DepartDateMonth').value + '/'+document.all('DepartDateDay').value + '/'
	+document.all('DepartDateYear').value;
newd=new Date(x);

newd=addDays(newd,dayvalue);
document.all('ReturnDateDay').value=newd.getDate();
document.all('ReturnDateMonth').value=newd.getMonth()+1;
document.all('ReturnDateYear').value=newd.getFullYear();
}

function searchControl()
{
	
 if ( (document.form1.GoingtoID.value=='') ||(document.all.DepartDateDay.value=='') 
	   ||(document.all.DepartMonthYear.value=='')	   
	)
	{ alert (JS_searchControl_PLEASE_FIIL_FIELDS)
	  return false;
	}
	if(parseInt(form1.adult.value)+parseInt(form1.child.value)+parseInt(form1.baby.value)==0)
	{
		alert(JS_searchControl_PLEASE_SELECT_A_PASSENGER)
		return false;
	}
 return airportcontrol();		
}

function GetDepartAirports(AirportID)
{
	var apID;
	var cID,tireBulundu;
	i=0;
	apID='';
	cID='';
	tireBulundu=false;
	while (i<(AirportID.length))
	{
		if(AirportID.substring(i,i+1)=='-')
			tireBulundu=true;
		if(tireBulundu==false && AirportID.substring(i,i+1)!='-')
			cID=cID+AirportID.substring(i,i+1);
		if(tireBulundu==true && AirportID.substring(i,i+1)!='-')
			apID=apID+AirportID.substring(i,i+1);	
		i=i+1;		
	}
	if(apID=='')
	{
		document.all.TDGoingtoID.innerHTML='<select name="GoingtoID"  id="GoingtoID" onChange="javascript:airportcontrol();"  class="listbox" size=10 >' 
		+ document.all('ToAirportSelectsCID'+cID).innerHTML + '</select>';
	}
	else
	{
		document.all.TDGoingtoID.innerHTML='<select name="GoingtoID"  id="GoingtoID" onChange="javascript:airportcontrol();"  class="listbox" size=10  >' 
		+ document.all('ToAirportSelects'+apID).innerHTML + '</select>';
	}
}
function Roundtripselected()
{ 
	//document.all.radioRoundtrip.checked=true; 
	document.all.roundtripDiv.disabled=false;
	document.all.ReturnDateDay.disabled=false;
	document.all.ReturnMonthYear.disabled=false;
	document.getElementById('TabRoundtripselected').className='first centerMenuCurrent';	
	document.getElementById('TabOnewayselected').className='';	
	document.getElementById('SearchType').value='roudtrip';
}

function Onewayselected()
{
	//document.all.radioOneWay.checked=true;
	document.all.roundtripDiv.disabled=true;
	document.all.ReturnDateDay.disabled=true; 
	document.all.ReturnMonthYear.disabled=true;
	document.getElementById('TabRoundtripselected').className='first';	
	document.getElementById('TabOnewayselected').className='centerMenuCurrent';	
	document.getElementById('SearchType').value='oneway';
}

function OpenSelected()
{
	document.all.radioOpen.checked=true;
	document.all.roundtripDiv.disabled=true;
	document.all.ReturnDateDay.disabled=true; 
	document.all.ReturnMonthYear.disabled=true;
	document.getElementById('SearchType').value='open';
}

function GoBackOrNext(BackOrNextValue,BackNextListTypeValue)
{
 form1.BackOrNext.value=BackOrNextValue;
 form1.BackNextListType.value=BackNextListTypeValue;
 form1.submit();
}

FselectDepart=false;
FselectReturn=false;

/*
function flightselected(flighttype)
{
 if (flighttype=='depart') {FselectDepart=true;}
	else {FselectReturn=true;}
}





function flightselected(flighttype,ID)
{
	if (flighttype=='depart') 
	{FselectDepart=true;
	document.all('SelectedDepFQ').value=ID;
	}
	else {FselectReturn=true;document.all('SelectedRetFQ').value=ID;
	}
}*/
function flightselected(flighttype,ID)
{
	if (flighttype=='depart') 
	{
		FselectDepart=true;
		document.getElementById('SelectedDepFQ_form1').value=ID;
	}
	else 
	{
		FselectReturn=true;
		document.getElementById('SelectedRetFQ_form1').value=ID;
	}
}





function babycontrol()
{
 if (parseInt(document.all.baby.value)>parseInt(document.all.adult.value)) 
	{document.all.baby.value=document.all.adult.value;}	
}







function airportcontrol()
{
 if (parseInt(document.form1.DepartingfromID.value)==parseInt(document.form1.GoingtoID.value)) 
	{
	 alert (JS_airportcontrol_FROM_AIRPORT_AND_TO_AIRPORT_CAN_NOT_BE_EQUAL);
	 document.all.GoingtoID.value='';
	 return false;
	}
 return true;
}





function GoBackOrNext(BackOrNextValue,BackNextListTypeValue)
{
 form1.BackOrNext.value=BackOrNextValue;
 form1.BackNextListType.value=BackNextListTypeValue;
 if (BackNextListTypeValue=='depart') 
 {
	if (BackOrNextValue=='Next') 
	{
	    form1.DepartDateDay.value=form1.DepartureNextFlightDateDay.value; 
		form1.DepartDateMonth.value=form1.DepartureNextFlightDateMonth.value;
		form1.DepartDateYear.value=form1.DepartureNextFlightDateYear.value; 
	}
	else
	{
	    form1.DepartDateDay.value=form1.DepartureBackFlightDateDay.value; 
		form1.DepartDateMonth.value=form1.DepartureBackFlightDateMonth.value;
		form1.DepartDateYear.value=form1.DepartureBackFlightDateYear.value; 	
	}
 }
 else
 {
 	if (BackOrNextValue=='Next') 
	{
	    form1.ReturnDateDay.value=form1.ReturnNextFlightDateDay.value; 
		form1.ReturnDateMonth.value=form1.ReturnNextFlightDateMonth.value;
		form1.ReturnDateYear.value=form1.ReturnNextFlightDateYear.value;  
	}
	else
	{
	    form1.ReturnDateDay.value=form1.ReturnBackFlightDateDay.value; 
		form1.ReturnDateMonth.value=form1.ReturnBackFlightDateMonth.value;
		form1.ReturnDateYear.value=form1.ReturnBackFlightDateYear.value; 	
	}		
 }
 form1.submit();
}


function NextStep(SearchType,actionURL)
{
	if (!FselectDepart)
	{
		alert(JS_NextStep_DEPART_FLIGHT_NOT_SELECTED);
		return false;
	}
	if ((SearchType=='Roundtrip') && (!FselectReturn))
	{
		alert(JS_NextStep_RETURN_FLIGHT_NOT_SELECTED);
		return false;
	}
	form1.action=actionURL;
	form1.submit(); 
	return true;
}

