﻿// JScript File
var xHttp;
function GetXmlHttpObject()
{
var xmlHttp=null;
try
{
xmlHttp=new XMLHttpRequest();
}

catch (e)
{

try
{
xmlHttp=new  ActiveXObject("Msxml2.XMLHTTP");
}
catch(e)
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
}
return xmlHttp;
}

function AvailFlight1(Type,Flight,p)
{
xHttp=GetXmlHttpObject();
if (xHttp==null) 
{
return;
}
var  address;
if(p=="1")
{
address="../AvailFlight.aspx";
}
else
{
address="AvailFlight.aspx";
}

   var rss="";
var DestFrom,DestTo,dto,df;
if (Flight=="FH")
{
DestFrom=document.getElementById("FHDestFrom").value;
dto=document.getElementById("FHDestTo").value.split(":");
if(dto.length >1) 
{
dto=dto[0].split("(");
DestTo=dto[1].substring(0, 3);
}
else
{
DestTo=document.getElementById("FHDestTo").value;
}
}
else if (Flight=="F")
{
DestFrom=document.getElementById("FDestFrom").value;
df=document.getElementById("FDestFrom").value.split(":");
if(df.length >1) 
{
df=df[0].split("(");
DestFrom=df[0].substring(0, 3);
}
else
{
DestFrom=document.getElementById("FDestFrom").value;
}
dto=document.getElementById("FDestTo").value.split(":");
if(dto.length >1) 
{
dto=dto[0].split("(");
DestTo=dto[0].substring(0, 3);
}
else
{
DestTo=document.getElementById("FDestTo").value;
}
}
else
{
showCalender(Flight,Type,rss);
return;
}

if(DestTo=="Please Enter Arrival Airport"|| DestTo=="Please Enter Your Destination")
{
showCalender(Flight,Type,rss);
return;
}
else if (DestFrom=="Please Enter Departure Airport")
{
showCalender(Flight,Type,rss);
return;
}

if(DestFrom=='LON' ||DestFrom == 'LGW' ||DestFrom == 'NCL' || DestFrom == 'BFS' || DestFrom == 'EMA' || DestFrom == 'LPL' || DestFrom == 'LHR' || DestFrom == 'EDI' || DestFrom == 'STN' || DestFrom == 'BHX' || DestFrom == 'DSA' || DestFrom == 'BRS' || DestFrom == 'LTN' || DestFrom == 'MAN' || DestFrom == 'GLA' || DestFrom == 'LBA'|| DestFrom == 'SOU'  || DestFrom == 'EXT' || DestFrom == 'HUY') 
{
   if(DestTo == 'MLA' || DestTo == 'BUD' || DestTo == 'PAR' || DestTo == 'AMS' || DestTo == 'LIS' || DestTo == 'BER' || DestTo == 'BCN' || DestTo == 'ROM' || DestTo == 'PRG' || DestTo == 'MIL' || DestTo == 'JTR'|| DestTo == 'AYT' || DestTo == 'CHQ'|| DestTo == 'HEQ'|| DestTo == 'CFU'|| DestTo == 'ZTH' || DestTo == 'KGS' || DestTo == 'SKG' || DestTo == 'HER' || DestTo == 'KOS' || DestTo == 'RHO' || DestTo == 'JMK' || DestTo == 'DLM' || DestTo == 'BJV' || DestTo == 'IST' || DestTo == 'AGP') 
      {}
      else{
      showCalender(Flight,Type,rss);
        return;
  
  }      }
else
{
showCalender(Flight,Type,rss);
return;
}



address=address+"?Type="+Type;
address=address+"&DestFrom="+DestFrom;
address=address+"&DestTo="+DestTo;

xHttp.onreadystatechange=function()
{ 
  if (xHttp.readyState==4)
 {
 if (xHttp.status==200)
 {
 WriteDataon(xHttp.responseText,Type,Flight); 
  }
  else
  {
 
 showCalender(Flight,Type,rss);
  }
  }
};

xHttp.open("GET",address,true);
xHttp.send(null); 
}
function WriteDataon(countryNode,Type,Flight)
{ 
var rs;
var str="";
var linkimg="";
var rss=countryNode.split("|");
showCalender(Flight,Type,rss);
}




















