﻿// JScript File
var ExtensionNights=null;
var MinimumStay=null;
var SelectedOptionalServices="";
var Details=null;
var PackageName=null;
var AirClassDesc=null;


    function PackageAvailability(MinimumStays)
    {
        try
        {
            ExtensionNight=document.getElementById("ExtensionNights").value;
           
            ExtensionNights=ExtensionNight
            MinimumStay=MinimumStays
            Details=PAXDetail + "\\" + MinimumStay + "\\"+ ExtensionNight;
 		    setNull();
 		    setNullCopy();
             document.getElementById("ContentDisplayArea").innerHTML=Loading();
            
             AgentPageStatus=false;
            Flyaways.Engine.Webservice.PackageMenuWebService.PackageAvailabilityWindow(ArrivalDate, DestinationCityID,OriginID, AirClassCode1,Details,onPackageAvailabilityComplete,onStartupTimeout,onStartupError);
            }
            catch(e)
            {
                alert(e.description);
            }
         
    }

     //CallBack Function When Server Method 'PackageAvailabilityWindow' Completes.
     function onPackageAvailabilityComplete(result) 
     {
		try
		{
		   //document.write(result);
		    setNull();
		    setNullCopy();
		   document.getElementById("ContentDisplayArea").innerHTML=result;
        }
        catch(e)
        {
            alert(e.description);
        }
    }
    
    
    // This function invoke if User change the Date from the Availability Page
    function MPackageAvailability()
    {
        try
        {
			 
              ArrivalDate=document.aspnetForm.ArrivalDates.value;
			 // alert(ArrivalDate);
               gArrivalDate=ArrivalDate
              PAX=PAXDetail.split("^");
              PAXDetail=PAXDetail.replace(PAX[PAX.length-1],ArrivalDate);
               
              Details=PAXDetail + "\\" + MinimumStay + "\\"+ ExtensionNights;
               document.getElementById("ContentDisplayArea").innerHTML=Loading();
               
             Flyaways.Engine.Webservice.PackageMenuWebService.PackageAvailabilityWindow(ArrivalDate, DestinationCityID,OriginID, AirClassCode1,Details,onPackageAvailabilityComplete,onStartupTimeout,onStartupError);
           
        }
        catch(e)
        {
            alert(e.description);
        }
         
    }
    
    
   // This function invoke if User change the Air Class from the Availability Page
    function M1PackageAvailability(AirClassCode)
    {
        try
        {
              AirClassCode1=AirClassCode
              Details=PAXDetail + "\\" + MinimumStay + "\\"+ ExtensionNights;
              document.getElementById("ContentDisplayArea").innerHTML=Loading();
               
             Flyaways.Engine.Webservice.PackageMenuWebService.PackageAvailabilityWindow(ArrivalDate, DestinationCityID,OriginID, AirClassCode1,Details,onPackageAvailabilityComplete,onStartupTimeout,onStartupError);
           
        }
        catch(e)
        {
            alert(e.description);
        }
         
    }
    
    
    // This function invoke if User change the Extension from the Availability Page
    function M2PackageAvailability(Extn)
    {
        try
        {
            if(Extn!="")
            {
               ExtensionNights=Extn
              Details=PAXDetail + "\\" + MinimumStay + "\\"+ ExtensionNights;
              document.getElementById("ContentDisplayArea").innerHTML=Loading();
              Flyaways.Engine.Webservice.PackageMenuWebService.PackageAvailabilityWindow(ArrivalDate, DestinationCityID,OriginID, AirClassCode1,Details,onPackageAvailabilityComplete,onStartupTimeout,onStartupError);
           }
        }
        catch(e)
        {
            alert(e.description);
        }
         
    }
    
    
    function AvlPriceDetail(PkgName, PkgPrice, PAXDetail, Currency,SupplRate,ExtCharges,ExtNight,ID)
    {
        try
        {
         
          //   alert(PkgName + "\n" + PkgPrice + "\n" + PAXDetail+ "\n" + SupplRate+ "\n" + ExtCharges)
            // return false;
           //  Showing the Destination Field
            DisplayID=ID
             showhide(0,'ctl00_DestinationCity');
            setValueCopy();
            Flyaways.Engine.Webservice.PackageMenuWebService.PkgAvailablityPriceDetail(PkgName, PkgPrice, PAXDetail, Currency,SupplRate,ExtCharges,ExtNight,onAvlPriceDetailComplete,onStartupTimeout,onStartupError);
        }
        catch(e)
        {
            alert(e.description);
        }
    }
    
     //CallBack Function When Server Method 'inclusion' Completes.
     function onAvlPriceDetailComplete(result) 
     {
		try
		{
 		    document.getElementById("PackageOptionsCopy").innerHTML=result;
		
        }
        catch(e)
        {
            alert(e.description);
        }
    }
    
    
    function PkgOptSrv(PkgMasterID, ArrivalDate, CurrencyID, Duration,ID,Status,AirClass,PkgName)
    {
        try
        {
         if(AgencyStatus==false)
         {
             alert("While the information can be viewed by all, bookings can only be made by \nIndian Airlines Booking Offices or approved Indian Airlines agents.\nPlease login to continue...");
             AgentLogin(ID);
             return false;
         }
            AirClassDesc=AirClass;
            PackageName=PkgName
 
         
          //   alert(PkgMasterID + "\n" + ArrivalDate + "\n" + CurrencyID+ "\n" + Duration+ "\n" + ID)
            // return false;
             //  Showing the Destination Field
            DisplayID=ID
           // showhide(0,'ctl00_DestinationCity');
            setNull();
            setValue();
            PkgStatus=Status;
             //alert(PkgMasterID + ","  +ArrivalDate+ "," + CurrencyID+ "," + Duration+ "," + ID+ "," + Status+ "," + AirClass+ "," + PkgName);
            Flyaways.Engine.Webservice.PackageMenuWebService.AvlOptionalService(PkgMasterID, ArrivalDate, CurrencyID, Duration,PAXDetail,Status,onPkgOptSrvComplete,onStartupTimeout,onStartupError);
        }
        catch(e)
        {
            alert(e.description);
        }
    }
    
     //CallBack Function When Server Method 'AvlOptionalService' Completes.
     function onPkgOptSrvComplete(result) 
     {
		try
		{
		    //document.write(result);
 		    document.getElementById("PackageOptions").innerHTML=result;
        }
        catch(e)
        {
            alert(e.description);
        }
     }
    
    
    function SelectedServices(Status,PAXDetail,PkgMasterID)
    {
        var c_value="";
        var obj=document.aspnetForm.OptionalSelectedServices
        if(obj.length>2)
        {
            for (var i=0; i < obj.length; i++)
            { 
                  if (obj[i].checked)
                  {
                      c_value = c_value + obj[i].value + ",";
                  }
            }
         }
       else
          {
          if(obj.checked)
          {
             c_value=obj.value+",";
           }
         }
        SelectedOptionalServices=c_value;
       
       Flyaways.Engine.Webservice.PackageMenuWebService.AvlBookingForm(Status,PAXDetail,PkgMasterID,onBookingFormComplete,onStartupTimeout,onStartupError);
     }
     
      //CallBack Function When Server Method 'AvlBookingForm' Completes.
     function onBookingFormComplete(result) 
     {
		try
		{
		    //document.write(result);
 		    document.getElementById("PackageOptions").innerHTML=result;
        }
        catch(e)
        {
            alert(e.description);
        }
     }
  
     
    function TotalPayable(PkgMasterID)
    {     
		try
		{
		   Details=PAXDetail + "\\" + MinimumStay + "\\"+ ExtensionNights;
		  // alert(Details);
		    //document.write(result);
       Flyaways.Engine.Webservice.PackageMenuWebService.TotalPayables(Details,SelectedOptionalServices,AirClassDesc,PkgMasterID,PackageName,ExtendedNights,ExtCompNight,onTotalPayableComplete,onStartupTimeout,onStartupError);
        }
        catch(e)
        {
            alert(e.description);
        }
     }
 
     
      //CallBack Function When Server Method 'TotalPayable' Completes.
     function onTotalPayableComplete(result) 
     {
		try
		{
		    //document.write(result);
		    setNull();
		    setNullCopy();
  		    document.getElementById("ContentDisplayArea").innerHTML=result;
        }
        catch(e)
        {
            alert(e.description);
        }
     }

 
    function ExtensionWindow(PkgName, MinStay, ArrivalDate, Extension, CitiesCovered,ID,PkgMasterID,CurrencyID,Status,AirClass)
    {     
		try
		{
         if(AgencyStatus==false)
         {
             alert("While the information can be viewed by all, bookings can only be made by \nIndian Airlines Booking Offices or approved Indian Airlines agents.\nPlease login to continue...");
             AgentLogin(ID);
             return false;
         }
		//  alert(PkgName + "," + MinStay+ "," +ArrivalDate+ "," + Extension+ "," + CitiesCovered + "," + ID+ "," + PkgMasterID+ "," + CurrencyID+ "," + Status+ "," + AirClass);
	        PkgStatus=Status;
		//return false;    
		    DisplayID=ID
		    MinimumStay=parseInt(MinStay)-parseInt(Extension);
 		    setValue();
       Flyaways.Engine.Webservice.PackageMenuWebService.ExtensionWindow(PkgName, MinStay, ArrivalDate, Extension, CitiesCovered,ID,PkgMasterID,CurrencyID,Status,AirClass,onExtensionWindowComplete,onStartupTimeout,onStartupError);
        }
        catch(e)
        {
            alert(e.description);
        }
     }
     
      //CallBack Function When Server Method 'ExtensionWindow' Completes.
     function onExtensionWindowComplete(result) 
     {
		try
		{
		    //document.write(result);
   		    document.getElementById("PackageOptions").innerHTML=result;
        }
        catch(e)
        {
            alert(e.description);
        }
     }