function validateForm40004(backFlight,IslSerch)
{
   var retStr = '';
   if(IslSerch)
   {
    if ((FO.CityDestination.value == "0") || (FO.CityDestination.value == "")) retStr += (FO.CityDestination.em1 + '\n');
   }
   else
   {
   if ((FO.Destination.value == "0") || (FO.Destination.value == "")) retStr += (FO.Destination.em1 + '\n');
   }
   if (FO.DateFrom.value == '') retStr += (FO.DateFrom.em1 + '\n');
   
   //if((backFlight && !IslSerch) || (FO.flightType1.checked && IslSerch) )
    //if((FO.flightType1.checked && FO.RadioType1.checked) || (FO.flightType3.checked && FO.RadioType2.checked))
   //{
     // if (FO.DateTo.value == '') retStr += (FO.DateTo.em1 + '\n');
   //}
   if (retStr != '')
   {
      alert(retStr);
      return false;
   }
   else if( ! checkFormDates(FO))
   {
      return false;
   }
   //enableFrmCombo();
   return true;
}



function setBackDateFrom(exitOb, backOb)
{
   if(isValidDate(exitOb.value))
   {
      backOb.value = exitOb.value;
   }
}



function Initialize()
{
   //if(typeof FO.DateFrom == "object") if( ! FO.DateFrom.value.length) FO.DateFrom.value = parseDateInToCalendarFormat(new Date());
  
     //if(FO.Destination.value != '0' && FO.Destination.value != '')
     //{
      //FO.Destination.onchange();
      //if(GLOB_exitDeparture.length)
      //{
        // FO.exitDeparture.value = GLOB_exitDeparture;
         //FO.exitDeparture.onchange();
         //if(GLOB_exitLanding.length)
         //{
           // FO.exitLanding.value = GLOB_exitLanding;
            //FO.exitLanding.onchange();
         //}
         //if(GLOB_backDeparture.length)
         //{
           // FO.backDeparture.value = GLOB_backDeparture;
            //FO.backDeparture.onchange();
            //if(GLOB_backLanding.length)
            //{
              // FO.backLanding.value = GLOB_backLanding;
            //}
         //}
      //}
      //if ((GLOB_FlightType == "n") || (GLOB_FlightType == "N"))
      //{
         
	// if(FO.Destination.options[FO.Destination.selectedIndex].oneDir == "1")
         //{
           // FO.flightType2.onmousedown();
            //FO.flightType2.checked = true;
            //FO.flightType2.onclick();
         //}
      //}
   //}
    //FO.Destination.focus();
    //FO.exitDeparture.focus();
}

function ObState(ob)
{
   if (ob.length == 2)
   {
      ob.selectedIndex = 1;
      if(typeof ob.onchange == "function") ob.onchange();
      ob.disabled = true;
   }
   else
   {
      ob.disabled = false;
      if (ob.length > 2)
      {
         if (ob.id == 'backDeparture')
         {
            xmlList = xmlFly.selectSingleNode("departures/departure[@code='"+FO.exitDeparture.options[FO.exitDeparture.selectedIndex].value+"']").selectSingleNode("landing[@code='"+FO.exitLanding.options[FO.exitLanding.selectedIndex].value+"']");
            dstn_code=xmlList.getAttribute("dstn_code");
            xmlList = xmlFlyBack.selectNodes("departures/departure");
            for(var i = 0; i < xmlList.length; i ++ )
            {
               dep_code=xmlList.item(i).getAttribute("code");
               if (dep_code == dstn_code)
               {
                  ob.selectedIndex = i + 1;
                  if(typeof ob.onchange == "function") ob.onchange();
               }
            }

         }
         if (ob.id == 'backLanding')
         {
            xmlList = xmlFly.selectSingleNode("departures/departure[@code='"+FO.exitDeparture.options[FO.exitDeparture.selectedIndex].value+"']");
            dep_code=xmlList.getAttribute("code");
            xmlList = xmlFlyBack.selectSingleNode("departures/departure[@code='"+FO.backDeparture.options[FO.backDeparture.selectedIndex].value+"']").selectNodes("landing");
            for(var i = 0; i < xmlList.length; i ++ )
            {
               dstn_code=xmlList.item(i).getAttribute("dstn_code");
               if (dstn_code == dep_code)
               {
                  ob.selectedIndex = i + 1;
                  if(typeof ob.onchange == "function") ob.onchange();
               }
            }

         }
      }

   }
}
function changeState()
{
   if(FO.exitLanding.length == 2)
   {
      FO.exitLanding.selectedIndex = 1;
      FO.exitLanding.disabled = true;
      FO.exitLanding.onchange();
      if(FO.flightType1.checked)
      {
         if(FO.backDeparture.length == 2)
         {
            FO.backDeparture.selectedIndex = 1;
            FO.backDeparture.disabled = true;
            FO.backDeparture.onchange();
         }
         if(FO.backLanding.length == 2)
         {
            FO.backLanding.selectedIndex = 1;
            FO.backLanding.disabled = true;
         }
         else
         {
            FO.backLanding.disabled = false;
         }
      }
   }
   else
   {
      FO.exitLanding.disabled = false;
      if(FO.flightType1.checked) FO.backDeparture.disabled = false;
   }
   if(FO.backLanding.length == 2)
   {
      FO.backLanding.selectedIndex = 1;
      FO.backLanding.disabled = true;
   }
   else
   {
      FO.backLanding.disabled = false;
   }
}

function displayFlightsRedio(flightType)
{
  if( ! FO.flightType1.checked)
   {
      FO.flightType1.onmousedown();
      FO.flightType1.checked = true;
      FO.flightType1.onclick();
   }
   if(FO.Destination.value != '0' && FO.Destination.value != '')
   {
    FO.flightType2.disabled = (FO.Destination.options[FO.Destination.selectedIndex].oneDir == "1") ? false : true;
      FO.flightType2.disabled = true;
      if (FO.exitDeparture.length == 2)
      {
         FO.exitDeparture.selectedIndex = 1;
         FO.exitDeparture.disabled = true;
         FO.exitDeparture.onchange();
      }
      else FO.exitDeparture.disabled = false;
      if (FO.exitLanding.length == 2)
      {
         FO.exitLanding.selectedIndex = 1;
         FO.exitLanding.disabled = true;
      }
      else FO.exitLanding.disabled = false;
   }
   else
   {
      FO.flightType2.disabled = false;
      FO.exitDeparture.disabled = false;
      FO.exitLanding.disabled = false;
   }
   FO.backDeparture.disabled = false;
   FO.backLanding.disabled = false;
}

function enableDateTo(flag)
{
   //if (flag)
   //{
      //if( ! FO.DateTo.value.length)
      //{
         //if(isValidDate(FO.DateFrom.value)) FO.DateFrom.onkeyup();
      //}
      //else
      //{
         //if( ! isValidDate(FO.DateTo.value)) FO.DateFrom.onkeyup();
      //}
   //}
   FO.DateTo.disabled = ! flag;
}

function radioTypeChange()
{
 if(FO.RadioType2.checked)
 {
  //FO.CityDestination.selectedIndex=""; 
  //FO.DateFrom.value="";
  FO.backFrom.disabled=false;
  FO.flightType3.checked=true;
  changeRadio("twoWay3","oneWay3"); 
  //FO.DateFrom.value="";
  //FO.DateTo.value="";
 }
 else
 {
  //FO.Destination.selectedIndex=""; 
  //FO.DateFrom.value="";
  FO.backFrom.disabled=false;
  FO.flightType1.checked=true;
  changeRadio("twoWay1","oneWay1");
  //FO.DateTo.value="";
 }
}


function GetCalendar(trgt)
{
var fieldDate = "";
//if(isDate(trgt))
	fieldDate = FO.DateFrom.value;
	//dateValue = window.showModalDialog("js/calendarENG.html?TheDate="+trgt.value+"",fieldDate,"dialogHeight: 215px;scroll: no; dialogWidth: 190px; dialogTop: "+event.clientY+"px; dialogLeft: "+event.clientX+"px; edge: Raised; center: Yes; help: Yes; resizable: No; status: No;");
	dateValue = window.showModalDialog("/site2/eng/js/calendarEng.html?TheDate=" + trgt.value + "", fieldDate, "dialogHeight: 215px;scroll: no; dialogWidth: 190px; dialogTop: " + event.clientY + "px; dialogLeft: " + event.clientX + "px; edge: Raised; center: Yes; help: Yes; resizable: No; status: No;");
	if (dateValue) trgt.value = dateValue;
}


