﻿var xmlHttp
var classs;
var num;
var num2="";
var url
var str="";
function Offer(ww,destto,num)
{
classs=ww;
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
  
   url="airlineclass.aspx";
   url=url+"?ClsType="+ww+"&Airline="+destto;



xmlHttp.onreadystatechange=stateServer1;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}

function stateServer1() 
{ 
	if(xmlHttp.readyState == 4)
	{
		if(xmlHttp.status == 200)
		{		
		WriteData1(xmlHttp.responseText);
		}
		else
		{
			alert("There was a problem retrieving data from the server." );
		}
		$(document).ready(function(){
			$("a.greybox").click(function(){
			   GB_show(this.id,this.href,300,550);
			  return false;
			});
		  });
	}
	
}

function WriteData1(countryNode)
{ 
var rs;
var linkimg="";
var field1="";
var field2="";
var arrVal=new Array(2);
var field3,flttype,img;
var rss=countryNode.split("^|");
if(rss.length-1>0)
	{
	str="<form id='flight_search'><table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
	str=str + "<input type='hidden' name='val1' id='val1'>"
	str=str + "<input type='hidden' name='val2' id='val2'>"
	str=str + "<input type='hidden' name='val3' id='val3'>"
	str=str + "<tr><td colspan=8>&nbsp;</td></tr>"
	if(num2==1)
	str=str + "<tr class=\"boldNEW1\" bgcolor=#F7B030 height=25><td>&nbsp;&nbsp;&nbsp;&nbsp;Dest From</td><td>Dest To</td><td align=center>Flight<br>Type</td><td>Class Type</td><td>Total Amt<br>Incl. Taxes</td><td align=center>Baggage <br>Allowance</td><td>Travel Between</td><td>&nbsp;</td></tr>"
	else
	str=str + "<tr class=\"big_orange_font\"><td style='padding-left:5px;'>Dest From</td><td>Dest To</td><td align=center>Flight<br>Type</td><td align='center'>Airline</td><td >Total Amt<br>Incl. Taxes</br></td><td align=center>Baggage <br> Allowance</td><td>Travel Between</td><td></td></tr>"
	            for (var i = 0; i < rss.length-1; i++)
                {
					
                        field=rss[i].split("|");
						
						flttype=field[9];
						
						if(flttype.toUpperCase()=="INDIRECT")
						{
							flttype="One Stop";
						}
						else if(flttype.toUpperCase()=="DIRECT")
						{
							flttype="Non Stop";
						}
						else
						{
							flttype=field[9];
						}
					if(field[5].toUpperCase()=="BA")
					  {
						   img="please"
					  }
					  else
					  {
						img="book_now"  
					  }
					str=str + "<tr height=25 bgcolor=\"#F9F9F9\" class=offerP_text><td style='padding-left:5px;'>" + field[0]+"</td><td>"+ field[2] +"</td><td>"+flttype+"</td><td><img src=\"http://myvacations.co.uk/airlogo/"+field[5]+".gif\"></td><td align='center'>fr&nbsp;<strong>&pound;"  +field[10] + "</strong></td><td align=center>"+field[13]+"</td><td>" + field[11]+ "</td><td><a href=\"SearchOffer.aspx?Airline="+field[5]+"&DestFrom="+field[1]+"&DestTo="+field[3]+"&class="+classs+"\" id=\""+classs+i+"\"  class=\"greybox\"><img name='" +field[1]+ "-" + field[3]+"-" + field[5]+"'src=\"pics/"+img+".jpg\" border=\"0\"></a></td></tr>"
				}
	str=str+"<tr><td colSpan=8>&nbsp;</td></tr>"
	str=str+"<tr><td colSpan=8 id=\"sheet\" class=usa>&nbsp;</td></tr>"
	str=str+"</table></form>";
	document.getElementById("result").innerHTML=str;
	}
	else
	{
		str="<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td colSpan=6>&nbsp;</td><tr><td colSpan=6>&nbsp;</td></tr><tr><td colspan=6 align=center class=bluebignew>There Is No Offer Found In " + classs + " Class</td></tr><tr><td colSpan=6>&nbsp;</td><tr><td colSpan=6>&nbsp;</td></tr></table>"
		document.getElementById("result").innerHTML=str;
	}
}

function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}


function changePicture(num)
	{
	
		if(num==0)
			{
				document.getElementById("eco").setAttribute("src","pics/economy1.jpg"); 
				document.getElementById("bus").setAttribute("src","pics/business.jpg"); 
				document.getElementById("fir").setAttribute("src","pics/first.jpg"); 
				
				
			}
			if(num==1)
			{
				
				document.getElementById("eco").setAttribute("src","pics/economy.jpg"); 
				document.getElementById("bus").setAttribute("src","pics/business1.jpg"); 
				document.getElementById("fir").setAttribute("src","pics/first.jpg"); 

				
			}
			if(num==2)
			{
				document.getElementById("eco").setAttribute("src","pics/economy.jpg"); 
				document.getElementById("bus").setAttribute("src","pics/business.jpg"); 
				document.getElementById("fir").setAttribute("src","pics/first1.jpg");
							
			}
				
	} 
function dis(sheet)
	{
document.getElementById("sheet").innerHTML=""
document.getElementById("sheet").innerHTML=sheet;
	}
function outMouse()
	{
document.getElementById("sheet").innerHTML=""
	}


function setFromTo(fromDest,toDest)
	{
		
	 }

function writevalues(destfrom,destto,countryNode)
	{
		
	       var flttype;
		   var m=true;
	        var rv;
	        var rss1=countryNode.split("^|");
             for(rv=0;rv<rss1.length-1;rv++)
            {
	            var img,field1;
	            var j;
	            field1=rss1[rv].split("|");
	            if(field1[0]==destfrom && field1[2]==destto)
                    {
					flttype=field1[9]
                    flttype=flttype.replace(/^\s*|\s*$/g,'');

						if(flttype=="InDirect" || flttype=="Indirect" || flttype=="indirect")
						{
							flttype="One Stop";
						}
						else if(flttype=="Direct" || flttype=="direct")
						{
							flttype="Non Stop";
						}
						else
						{
							flttype=field1[9];
						}
					if(field[5].toUpperCase()=="BA")
					  {
						   img="please"
					  }
					  else
					  {
						img="book_now"  
					  }
                        if(m==true)
                        {
                         //str=str + "<tr><td colspan=6 align='left' class='font12px'>" +field1[0]+ "-" + field1[2]+ "</td></tr>";
                         str=str + "<tr height=25 bgcolor=\"#F9F9F9\" class=offerP_text><td style='padding-left:5px;'>" + field1[0]+"</td><td>"+ field1[2] +"</td><td>"+flttype+"</td><td><img src=\"http://myvacations.co.uk/airlogo/"+field1[5]+".gif\"></td><td align='center'>fr&nbsp;<strong>&pound;"  +field1[10] + "</strong></td><td align=center>"+field[13]+"</td><td>" + field1[11]+ "</td><td><a href=\"#\"><img name='" +field1[1]+ "-" + field1[3]+"-" + field1[5]+"'src=\"pics/"+img+".jpg\" border=\"0\" onClick=\"setFromTo(\'"+field[1]+"\',\'"+field[3]+"\');showAlert();\"></a></td></tr>"
                         m=false;
                        }
                         else
                          {
                          str=str + "<tr height=25 bgcolor=\"#F9F9F9\" class=offerP_text><td style='padding-left:5px;'>" + field1[0]+"</td><td>"+ field1[2] +"</td><td c>"+flttype+"</td><td><img src=\"http://myvacations.co.uk/airlogo/"+field1[5]+".gif\"></td><td align='center'>fr&nbsp;<strong>&pound;" +field1[10] + "</strong></td><td align=center>"+field[13]+".</td><td>" + field1[11]+ "</td><td><a href=\"#\"><img name='" +field1[1]+ "-" + field1[3]+"-" + field1[5]+"'src=\"pics/"+img+".jpg\" border=\"0\" onClick=\"setFromTo(\'"+field[1]+"\',\'"+field[3]+"\');showAlert();\"></a></td></tr>"
                          }
                    }
            }
	}


function Dest_ft(name)
{
var ts=name.split("-");
document.getElementById("val1").value=ts[0];
document.getElementById("val2").value=ts[1];
document.getElementById("val3").value=ts[2];
parent.frames['Flight_search1'].window.location.reload();
}



function displayRules1(evt,text1,td_id)
	{
	       // getMouseXY(evt);
       var arr=text1;

            MM_openBrWindow("Rules.aspx?val="+arr,"","width=500,height=210")

	}
	
	function changePicture1(num)
	{
		
		if(num==0)
			{
				document.getElementById("eco").setAttribute("src","http://www.myairindia.co.uk/images/eco1.gif"); 
				document.getElementById("bus").setAttribute("src","http://www.myairindia.co.uk/images/bus.gif"); 
				document.getElementById("fir").setAttribute("src","http://www.myairindia.co.uk/images/fir.gif"); 
				
				
			}
			if(num==1)
			{
				
				document.getElementById("eco").setAttribute("src","http://www.myairindia.co.uk/images/eco.gif"); 
				document.getElementById("bus").setAttribute("src","http://www.myairindia.co.uk/images/bus1.gif"); 
				document.getElementById("fir").setAttribute("src","http://www.myairindia.co.uk/images/fir.gif"); 

				
			}
			if(num==2)
			{
				document.getElementById("eco").setAttribute("src","http://www.myairindia.co.uk/images/eco.gif"); 
				document.getElementById("bus").setAttribute("src","http://www.myairindia.co.uk/images/bus.gif"); 
				document.getElementById("fir").setAttribute("src","http://www.myairindia.co.uk/images/fir1.gif");
							
			}
			
	}

function changePicture1KING(num)
	{
		
		if(num==0)
			{
				document.getElementById("eco").setAttribute("src","images/eco1KING.gif"); 
				document.getElementById("bus").setAttribute("src","images/busKING.gif"); 
				document.getElementById("fir").setAttribute("src","images/firKING.gif"); 
				
				
			}
			if(num==1)
			{
				
				document.getElementById("eco").setAttribute("src","images/ecoKING.gif"); 
				document.getElementById("bus").setAttribute("src","images/bus1KING.gif"); 
				document.getElementById("fir").setAttribute("src","images/firKING.gif"); 

				
			}
			if(num==2)
			{
				document.getElementById("eco").setAttribute("src","images/ecoKING.gif"); 
				document.getElementById("bus").setAttribute("src","images/busKING.gif"); 
				document.getElementById("fir").setAttribute("src","images/fir1KING.gif");
							
			}
			
	}
var testdest="";
function writevalues2(destfrom,destto,countryNode)
	{
	        var m=true;
	        var rv;
	        var rss1=countryNode.split("^|");
             for(rv=0;rv<rss1.length-1;rv++)
            {
	            var field1;
	            var j;
	            field1=rss1[rv].split("|");
	            if(field1[0]==destfrom && field1[2]==destto)
                    {
                        if(m==true)
                        {
						 //str=str + "<tr><td colspan=6 align='left' class='bold1'>" +field1[0]+ "-" + field1[2]+"</td></tr>";
                         str=str + "<tr height=25 bgcolor=\"#F4C673\" class=side1><td>" + field1[0]+"</td><td>"+ field1[2] +"</td><td>" + field1[9]+ "</td><td>" + field1[6]+ "</td><td align='center'><strong>&pound;&nbsp;"  + field1[10] + "</strong></td><td>" + field1[11]+ "</td><td><a href=\"#\"><img name='" +field1[1]+ "-" + field1[3]+"-" +field1[6]+"' src=\"pics/book_now.jpg\" border=\"0\"  ></a></td></tr>"
                         m=false;
                        }
                         else
                          {
                          str=str + "<tr height=25 bgcolor=\"#F4C673\" class=side1><td>" + field1[0]+"</td><td>"+ field1[2] +"</td><td>" + field1[9]+ "</td><td>" + field1[6]+ "</td><td align='center'><strong>&pound;&nbsp;"  + field1[10] + "</strong></td><td>" + field1[11]+ "</td><td><a href=\"#\"><img name='" +field1[1]+ "-" + field1[3]+"-" +field1[6]+"' src=\"pics/book_now.jpg\" border=\"0\"  ></a></td></tr>"
                          }
                    }
            }
	}




function changecls(num)
{
	
	try
	{
		if(num==1)
		{
		parent.frames['Flight_search1'].document.FlightSearch.classRequestB.checked=true;
		parent.frames['Flight_search1'].document.FlightSearch.classTypeRequest.value="BUS";
		parent.frames['Flight_search1'].document.FlightSearch.flcls.value="BUS";
		 
		//document.getElementById("flcls").value="BUS";
		}
		else if(num==2)
		{
		parent.frames['Flight_search1'].document.FlightSearch.classRequestF.checked=true;
		parent.frames['Flight_search1'].document.FlightSearch.classTypeRequest.value="FIRST";
		parent.frames['Flight_search1'].document.FlightSearch.flcls.value="FIRST";
		//document.getElementById("flcls").value="FIRST";
		}
		else if(num==0)
		{
		parent.frames['Flight_search1'].document.FlightSearch.classRequestE.checked=true;
		parent.frames['Flight_search1'].document.FlightSearch.flcls.value="ECO";
		parent.frames['Flight_search1'].document.FlightSearch.classTypeRequest.value="ECO";
		//document.getElementById("flcls").value="ECO";
		}
		else
		{
		parent.frames['Flight_search1'].document.FlightSearch.classRequestE.checked=true;
		parent.frames['Flight_search1'].document.FlightSearch.flcls.value="ECO";
		parent.frames['Flight_search1'].document.FlightSearch.classTypeRequest.value="ECO";
		}
		//parent.frames['Flight_search1'].window.location.reload();
	}
	catch(err){}
}


function setFromTo(from,to,Airline)
{
	
var fromlen=parent.frames['Flight_search1'].document.FlightSearch.FDestFrom.length;
var tolen=parent.frames['Flight_search1'].document.FlightSearch.FDestTo.length;
var Air=parent.frames['Flight_search1'].document.FlightSearch.FAirLine.length;
	var i;
	
		if (Air>0)
	{
	     for(i=0;i<Air-1;i++)
	        {
            if(parent.frames['Flight_search1'].document.FlightSearch.FAirLine.options[i].value==Airline)
                {
	                  parent.frames['Flight_search1'].document.FlightSearch.FAirLine.options[i].selected=true;
		       }
	        }
	}

	if (fromlen>0)
	{
	     for(i=0;i<fromlen-1;i++)
	        {
	            if(parent.frames['Flight_search1'].document.FlightSearch.FDestFrom.options[i].value==from)
	                {
	                  parent.frames['Flight_search1'].document.FlightSearch.FDestFrom.options[i].selected=true;
					 
	                }
	        }
	}
	
	if (tolen>0)
	{
	     for(i=0;i<tolen-1;i++)
	        {
	            if(parent.frames['Flight_search1'].document.FlightSearch.FDestTo.options[i].value==to)
	                {
	                  parent.frames['Flight_search1'].document.FlightSearch.FDestTo.options[i].selected=true;
					             }
	        }
	}

}

function showAlert()
{
	alert("Please select Departure and Return Date according to your journey from search engine and then click on \"show flights\" button.")
}
