﻿// JScript File

    //Function creating Shopping Page from PKGCOMP Control
    // Function name BuildPkgMaster()
    
    var gArrivalDate="";
    var ArrivalDate="";
    var DestinationCityID="";
    var OriginID="";
    var AirClassCode1="";
    var PAXDetail="";
    var DisplayID="";
    
    function BuildPkgMaster(dateField,AirClassCode)
    {
        try
        {
            ExtensionNights=null;
            MinimumStay=null;
            SelectedOptionalServices="";
            Details=null;
            PackageName=null;
            AirClassDesc=null;
            gArrivalDate="";
            ArrivalDate="";
            DestinationCityID="";
            OriginID="";
            AirClassCode1="";
            PAXDetail="";
            DisplayID="";
            ExtPName;
            ExtMinStay;
            ExtArrivalDate;
            ExtExtension;
            ExtCitiesCovered;
            ExtPkgMasterID;
            ExtCurrencyID;
            ExtStatus;
            ExtAirClass;
            ExtPMasterID;
            ExtDuration;
            ExtPkgRatesID;
            ExtWithinCXL="FALSE";
            ExtCompNight;
            ExtendedNights="";
            IC=false;
            IA=false;
            TicketFormat=null;
            Ticket="";
            MCO="";
            PkgStatus=false;
            AgentPageStatus=true;

            AirClassCode1=AirClassCode
            //ArrivalDate=eval("document.getElementById('"+dateField+"').value");
            
             // - - updated on Nov 20.08var now = new Date();
              ArrivalDate= document.getElementById(dateField).value;

             gArrivalDate=ArrivalDate
           
             // - - updated on Nov 20.08
             OriginID=eval("document.getElementById('Origin_ID').value");
			 
            // OriginID=document.getElementById("Origin_ID").value
            //  var AirClassCode="y"

           //  var RoomType= document.getElementById("RoomType").value
          
             // - - updated on Nov 20.08
              var RoomType= document.aspnetForm.roomType.value
                
            var Adult="";
            var Child="";
            var Infant="";
             
            for(var i=1;i<=parseInt(RoomType);i++)
            {
                 if(i>=2) Adult+=",";
                   Adult += eval("document.aspnetForm.Adult"+i+".value")
                 
                 if(i>=2) Child+=",";
                 Child += eval("document.aspnetForm.Child"+i+".value")
                 
                 if(i>=2) Infant+=",";
                 Infant +=  eval("document.aspnetForm.Infant"+i+".value")
            }

             PAXDetail=RoomType + "^" + Adult + "^" + Child + "^" + Infant+ "^" + ArrivalDate;
           
             //  Hiding the Destination Field
             showhide(0,'ctl00_DestinationCity');
             showhide(0,'HomePage');
             showhide(1,'ContentDisplayArea');
             document.getElementById("ContentDisplayArea").innerHTML=Loading();
             
               // - - updated on Nov 20.08
              DestinationCityID=document.aspnetForm.DestinationCityID.value

        //   alert("gArrivalDate-" +gArrivalDate + "\nDestinationCityID-" + DestinationCityID + "\nOriginID-" + OriginID + "\nAirClassCode-" + AirClassCode + "\nPAXDetail-" + PAXDetail)
            
             Flyaways.Engine.Webservice.PackageMenuWebService.PkgMaster(gArrivalDate, DestinationCityID,OriginID, AirClassCode,PAXDetail,onBuildPkgMasterComplete,onStartupTimeout,onStartupError);
        }
        catch(e)
        {
            alert(e.description);
        }
    }
    
     //CallBack Function When Server Method 'DestinationList' Completes.
     function onBuildPkgMasterComplete(result) 
     {
		try
		{
		//document.write(result);
 			document.getElementById("ContentDisplayArea").innerHTML=result;
        }
        catch(e)
        {
            alert(e.description);
        }
    }
 
    function ReBuildPkg()
   {
    if(ArrivalDate!="")
     {
     document.getElementById("ContentDisplayArea").innerHTML=Loading();
     Flyaways.Engine.Webservice.PackageMenuWebService.PkgMaster(ArrivalDate, DestinationCityID,OriginID, AirClassCode1,PAXDetail,onBuildPkgMasterComplete,onStartupTimeout,onStartupError);
     }
   }
   
    //CallBack Function When Server Method 'DestinationList' doesn't get the webservice..
    function onStartupTimeout(result) 
    {
        alert("Timed out");
    }
    
    //Called when server method 'DestinationList' gets some error
     function onStartupError(result) 
    {
       alert("OnError - Exception");
       PrintDebugMessage(result.get_message());
       PrintDebugMessage(result.get_stackTrace());
    }
    
   function PkgDetail(PKGMasterID, ID)
    {
        try
        {
         DisplayID=ID;
               //  Showing the Destination Field
             showhide(0,'ctl00_DestinationCity');
            setValue();
            Flyaways.Engine.Webservice.PackageMenuWebService.PkgDetail(PKGMasterID,onPkgDetailComplete,onStartupTimeout,onStartupError);
        }
        catch(e)
        {
            alert(e.description);
        }
    }
    
     //CallBack Function When Server Method 'inclusion' Completes.
     function onPkgDetailComplete(result) 
     {
		try
		{
 		    document.getElementById("PackageOptions").innerHTML=result;
		
        }
        catch(e)
        {
            alert(e.description);
        }
    }
    
       
   function PriceDetail(PkgName, PkgPrice, PAXDetail, Currency,SupplRate,ID)
    {
        try
        {
         
            // alert(PkgName + "\n" + PkgPrice + "\n" + PAXDetail+ "\n" + SupplRate)
            // return false;
           //  Showing the Destination Field
            DisplayID=ID
             showhide(0,'ctl00_DestinationCity');
            setValue();
            Flyaways.Engine.Webservice.PackageMenuWebService.PkgPriceDetail(PkgName, PkgPrice, PAXDetail, Currency,SupplRate,onPriceDetailComplete,onStartupTimeout,onStartupError);
        }
        catch(e)
        {
            alert(e.description);
        }
    }
    
     //CallBack Function When Server Method 'inclusion' Completes.
     function onPriceDetailComplete(result) 
     {
		try
		{
 		    document.getElementById("PackageOptions").innerHTML=result;
		
        }
        catch(e)
        {
            alert(e.description);
        }
    }
    
    

    function inclusion(PKGMasterID,ID)
    {
        try
        {
        DisplayID=ID
               //  Showing the Destination Field
             showhide(0,'ctl00_DestinationCity');
            setValue();
            Flyaways.Engine.Webservice.PackageMenuWebService.PkgInclusion(PKGMasterID,gArrivalDate,oninclusionComplete,onStartupTimeout,onStartupError);
        }
        catch(e)
        {
            alert(e.description);
        }
    }
    
     //CallBack Function When Server Method 'inclusion' Completes.
     function oninclusionComplete(result) 
     {
		try
		{
 		    document.getElementById("PackageOptions").innerHTML=result;
		
        }
        catch(e)
        {
            alert(e.description);
        }
    }
    
    function daywise(PkgRatesID,ID)
    {
        try
        {
         DisplayID=ID
            //  Showing the Destination Field
            showhide(0,'ctl00_DestinationCity');
            setValue();
            Flyaways.Engine.Webservice.PackageMenuWebService.PkgDayWise(PkgRatesID,ondaywiseComplete,onStartupTimeout,onStartupError);
        }
        catch(e)
        {
            alert(e.description);
        }
    }
    
     //CallBack Function When Server Method 'daywise' Completes.
     function ondaywiseComplete(result) 
     {
		try
		{
		  
  		    document.getElementById("PackageOptions").innerHTML=result;
		
        }
        catch(e)
        {
            alert(e.description);
        }
    }
    
    function cxlfee(PKGMasterID,CurrencyIn,PAXDetail,ID)
    {
        try
        {
        
          DisplayID=ID
            //  Showing the Destination Field
            showhide(0,'ctl00_DestinationCity');
            setValue();
            Flyaways.Engine.Webservice.PackageMenuWebService.PkgCXLFee(PKGMasterID,gArrivalDate,CurrencyIn,PAXDetail,oncxlfeeComplete,onStartupTimeout,onStartupError);
        }
        catch(e)
        {
            alert(e.description);
        }
    }
    
     //CallBack Function When Server Method 'cxlfee' Completes.
     function oncxlfeeComplete(result) 
     {
		try
		{
		    //document.write(result);
  		 document.getElementById("PackageOptions").innerHTML=result;
		
        }
        catch(e)
        {
            alert(e.description);
        }
    }
    
   function extrate(PKGMasterID,PKGRatesID,CurrencyIn,PAXDetail,ID)
    {
        try
        {
           DisplayID=ID
            //  Showing the Destination Field
            showhide(0,'ctl00_DestinationCity');
            setValue();
            Flyaways.Engine.Webservice.PackageMenuWebService.PkgEXTRate(PKGMasterID,PKGRatesID,CurrencyIn,PAXDetail,onextrateComplete,onStartupTimeout,onStartupError);
        }
        catch(e)
        {
            alert(e.description);
        }
    }
    
     //CallBack Function When Server Method 'cxlfee' Completes.
     function onextrateComplete(result) 
     {
		try
		{
        
  		    document.getElementById("PackageOptions").innerHTML=result;
		
        }
        catch(e)
        {
            alert(e.description);
        }
    }
    
     function SuppRate(PKGMasterID,CurrencyIn,PAXDetail,ID,Duration)
    {
        try
        {
         DisplayID=ID
             //alert(PKGMasterID + "\n" + CurrencyIn + "\n" + PAXDetail + "\n" + Duration);
            //  Showing the Destination Field
            showhide(0,'ctl00_DestinationCity');
            setValue();
            Flyaways.Engine.Webservice.PackageMenuWebService.PkgSuppRate(PKGMasterID,gArrivalDate,CurrencyIn,PAXDetail,Duration,onSuppRateComplete,onStartupTimeout,onStartupError);
        }
        catch(e)
        {
            alert(e.description);
        }
    }
    
     //CallBack Function When Server Method 'SuppRate' Completes.
     function onSuppRateComplete(result) 
     {
		try
		{
		    //document.write(result);
		   
  		    document.getElementById("PackageOptions").innerHTML=result;
		
        }
        catch(e)
        {
            alert(e.description);
        }
    }
    
     function Optional(PKGMasterID,CurrencyIn,PAXDetail,ID,Duration)
    {
        try
        {
         DisplayID=ID
            //  Showing the Destination Field
            showhide(0,'ctl00_DestinationCity');
            setValue();
            Flyaways.Engine.Webservice.PackageMenuWebService.PkgOptional(PKGMasterID,gArrivalDate,CurrencyIn,PAXDetail,Duration,onOptionalComplete,onStartupTimeout,onStartupError);
        }
        catch(e)
        {
            alert(e.description);
        }
    }
    
     //CallBack Function When Server Method 'SuppRate' Completes.
     function onOptionalComplete(result) 
     {
		try
		{
		  //  document.write(result);
  		    document.getElementById("PackageOptions").innerHTML=result;
		
        }
        catch(e)
        {
            alert(e.description);
        }
    }

    // This function show the Non-Itinerary Based packages
    function BookPackage(WithinCxl,PkgCounter, PkgName, PkgTotalPrice, PkgTAC, PriceDetailLink, ArrivalDate,PerDayExtension,PkgRatesID,DaysPAXStay,ID)
    {
     
     
      DisplayID=ID
        if(WithinCxl=="True")
        {
	        if(document.all)
	        {
		        var conf1=makeMsgBox("Dear Agent,\n\nYou are making this booking within the cancellation period. Once Confirmed/Confirmed on Time Limit, cancellation will be charged if booking is cancelled. Do you want to continue?");
		        if(conf1!=6)
		        {
			        return;
		        }
	        }
	        else
	        {
		        var conf1=confirm("Dear Agent,\n\nYou are making this booking within the cancellation period. Once Confirmed/Confirmed on Time Limit, cancellation will be charged if booking is cancelled. Do you want to continue?");
		        if(conf1==false)
		        {
			        return;
		        }
	        }
        }
        
        // alert(WithinCxl+"\n"+PkgCounter+"\n"+PkgName+"\n"+PkgTotalPrice +"\n"+ PkgTAC +"\n"+ PriceDetailLink +"\n"+ArrivalDate +"\n"+PerDayExtension+"\n"+ PkgRatesID +"\n"+DaysPAXStay);
        // return false;
          showhide(0,'ctl00_DestinationCity');
        setValue();
      Flyaways.Engine.Webservice.PackageMenuWebService.PkgExtWindow(PkgCounter, PkgName, PkgTotalPrice, PkgTAC, PriceDetailLink, ArrivalDate,DaysPAXStay,PerDayExtension,PkgRatesID,onBookPackageComplete,onStartupTimeout,onStartupError);
    }
    
 

 //CallBack Function When Server Method 'BookPackage' Completes.
     function onBookPackageComplete(result) 
     {
		try
		{
		    //document.write(result);
  		    document.getElementById("PackageOptions").innerHTML=result;
		
        }
        catch(e)
        {
            alert(e.description);
        }
    }
    
    
    function setNull()
    {
        showhide(0,'PackageOptions');
        document.getElementById("PackageOptions").innerHTML="";
        document.getElementById("PackageOptionsContainer").style.height="0px";
        document.getElementById("PackageOptionsContainer").style.width="0px";
        document.getElementById("PackageOptionsContainer").style.left="0px";
        document.getElementById("PackageOptionsContainer").style.top="0px";
        document.getElementById("PackageOptionsContainer").style.display="";
        if(!document.all) 
        {
            // show scrollbars for netscape
        //    ScrollNS();
        }
        
        if(document.all) 
        {
            // show scrollbars for IE
       //     scrollIE();
        }
    }
    
    function setValue()
    {
        setValueContainer();
        showhide(1,'PackageOptions');
        document.getElementById("PackageOptions").innerHTML=Loading();
         
     // body.style.overflow:hidden;
        
      // alert(parseInt(eval("document.getElementById('"+DisplayID+"')").offsetLeft) + "\n" + parseInt(eval("document.getElementById('"+DisplayID+"')").offsetTop));
    //    alert((eval("document.getElementById('"+DisplayID+"')").clientX) + "//" + mouseX + "//" + screen.width + "\n" + parseInt(eval("document.getElementById('"+DisplayID+"')").clientY)+ "//" + mouseY+ "//" + screen.height  );
        
        // get the clicked position
        var ObjW=(parseInt(eval("document.getElementById('"+DisplayID+"')").offsetLeft)+600);//-(parseInt(mouseX));
        var ObjH=(parseInt(eval("document.getElementById('"+DisplayID+"')").offsetTop)+150);//-(parseInt(mouseY));
         
      //  alert(ObjH);
        document.getElementById("PackageOptions").style.left= (parseInt(ObjW) / 2) + "px";//parseInt(screen.height)/parseInt(4)+"px"
        document.getElementById("PackageOptions").style.top= parseInt(ObjH) + "px";//parseInt(screen.width)/parseInt(6)+"px";
        document.getElementById("PackageOptions").style.position="absolute";
        document.getElementById("PackageOptions").style.width="800px";
		document.getElementById("PackageOptions").style.height="700px";

    }
    
    function setValueContainer()
    {
        document.getElementById("PackageOptionsContainer").style.height=parseInt(screen.width)*10;
        document.getElementById("PackageOptionsContainer").style.width=screen.width;
        document.getElementById("PackageOptionsContainer").style.backgroundColor="#f5f5f5";
        document.getElementById("PackageOptionsContainer").style.left="0px";
        document.getElementById("PackageOptionsContainer").style.top="0px";
        document.getElementById("PackageOptionsContainer").style.display="";
        document.getElementById("PackageOptionsContainer").style.position="absolute";
       document.getElementById("PackageOptionsContainer").style.filter="alpha(opacity=80)";
  document.getElementById("PackageOptionsContainer").style.opacity=".8";

    }
    
     function setValueCopy()
    {
        setValueContainer();
        showhide(1,'PackageOptionsCopy');
        var ObjW=(parseInt(eval("document.getElementById('"+DisplayID+"')").offsetLeft)+600);//-(parseInt(mouseX));
        var ObjH=(parseInt(eval("document.getElementById('"+DisplayID+"')").offsetTop)+150);//-(parseInt(mouseY));

        document.getElementById("PackageOptionsCopy").innerHTML=Loading();
        document.getElementById("PackageOptionsCopy").style.left= (parseInt(ObjW) / 2) + "px";//parseInt(screen.height)/parseInt(4)+"px"
        document.getElementById("PackageOptionsCopy").style.top= parseInt(ObjH) + "px";//parseInt(screen.width)/parseInt(6)+"px";
        document.getElementById("PackageOptionsCopy").style.position="absolute";
        document.getElementById("PackageOptionsCopy").style.width="800px";
		 document.getElementById("PackageOptions").style.height="700px";

    }
    
    function setNullCopy()
    {
        var PackageOptions=document.getElementById("PackageOptions").innerHTML;
             
        showhide(0,'PackageOptionsCopy');
        if(PackageOptions=="")
        {
            document.getElementById("PackageOptionsContainer").style.height="0px";
            document.getElementById("PackageOptionsContainer").style.width="0px";
            document.getElementById("PackageOptionsContainer").style.left="0px";
            document.getElementById("PackageOptionsContainer").style.top="0px";
            document.getElementById("PackageOptionsContainer").style.display="";
        }
    }
    
    
    
