var xmlHttp;
var classs;
function Offer(ww,destto)
{
classs=ww;
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
var url="newclass.aspx";
url=url+"?class="+ww+"&destto="+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)
{ 

//document.getElementById("displayRulesDiv").style.visibility='hidden';
var rs;
var str="";
var linkimg="";
var rss=countryNode.split("^|");
if(rss.length-1>0)
	{
	str="<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
	//str=str + "<tr><td colspan=6>&nbsp;</td></tr>"
	str=str + "<tr class=\"big_orange_font\"><td>Dest From</td><td>Flight Type</td><td>Airline</td><td align='center'>Total Amount<br>Incl. Taxes</br></td><td>Baggage</td><td>Travel Between</td><td></td></tr>"
	for(i=0;i<rss.length-1;i++)
		{
		
					var field;
					var j;
					var img;
					field=rss[i].split("|");
					var flightType;
									
			        if(field[9].substr(0,6).toUpperCase()=="DIRECT".toUpperCase())
			        {
				        flightType="Non Stop";
			        }
			        else
			        {
				        flightType="One Stop";
			        }
		             
					  if(field[5].toUpperCase()=="BA")
					  {
						   img="please"
					  }
					  else
					  {
						img="book_now"  
					  }
					  
					  
						if(i%2==0)
			            {
						 str=str + "<tr height=25 bgcolor=\"#FFFFFF\"  class=site ><td>" + field[0]+"("+field[1]+")</td><td>" +flightType+ "</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>"+field[13]+"</td><td>" + field[11]+ "</td><td></td><td><a href=\"SearchOffer.aspx?Airline="+field[5]+"&DestFrom="+field[1]+"&DestTo="+field[3]+"&class="+classs+"\" id=\""+classs+i+"\"  class=\"greybox\"><img  src=\"pics/"+ img +".jpg\" border=\"0\" ></a></td></tr>"
						}
			            else
			             {
							str=str + "<tr height=25 bgcolor=\"#F9F9F9\"  class=site ><td>" + field[0]+"("+field[1]+")</td><td>" + flightType + "</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>"+field[13]+"</td><td>" + field[11]+ "</td><td></td><td><a href=\"SearchOffer.aspx?Airline="+field[5]+"&DestFrom="+field[1]+"&DestTo="+field[3]+"&class="+classs+"\" id=\""+classs+i+"\"  class=\"greybox\"><img  src=\"pics/" + img + ".jpg\" border=\"0\"></a></td></tr>"       
		                 }
		   }
	        str=str+"</table>";	
	        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 displayRules1(evt,text1,td_id)
	{
	       // getMouseXY(evt);
       var arr=text1;

           MM_openBrWindow("Rules.aspx?val="+arr,"","width=500,height=210")

}
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 preurlcheck(purl)
{
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
var url="preurl.aspx";
url=url+"?purl="+purl;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);

}


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.")
}

function HomeOffers()
{
	 xmlHttp=GetXmlHttpObject();
        if (xmlHttp==null)
          {
          alert ("Your browser does not support AJAX!");
          return;
          } 
        var url="flightofferind.aspx";
	    xmlHttp.onreadystatechange=stateServer11; 
        xmlHttp.open("GET",url,true);
        xmlHttp.send(null);
}

function stateServer11() 
{ 

	if(xmlHttp.readyState == 4)
	{
		if(xmlHttp.status == 200)
		{		
		document.getElementById("offerresult").innerHTML=xmlHttp.responseText;		
		}
		else
		{
			alert("There was a problem retrieving data from the server." );
		}
	}
}

