function LoadUpdateBaggage(TotalCostPerBag,NumberOfSectors,CostPerExtraKG,DisplayCostPerExtraKG,CurrencySymbol,dp,KgIncrementBy,NumPax,SelectedBag,SelectedWeight,MaxWeightPerBag,MaxExcessWeightPerPerson, MaxBagsPerPerson,FreeWeightPerPerson,BagsText,LoadOrUpdate)
    {
        var WeightUnit = " kg";
        //var BagsText = "hold bags";
        var MaxWeightPerPerson = MaxExcessWeightPerPerson + FreeWeightPerPerson;
        var selctedWeightAvailable = false;
        
        //retrieve numeric values from selectedValues       
        var SelectedBagSplit = String(SelectedBag).split("|");
        var selectedWeightSplit = String(SelectedWeight).split("|");
        
        var SelectedBagNum = parseInt(SelectedBagSplit[0]);
        var SelectedWeightNum = parseInt(selectedWeightSplit[0]);

       
        if(LoadOrUpdate == "L")
        {
            //populate the bags dropdown
            var bagsSelect = document.getElementById("cbobagChg_quantity");
            var maxNumBags = parseInt(NumPax * MaxBagsPerPerson);
            
            //clear options
            for(i = bagsSelect.options.length-1 ;i>=0;i=i-1)
            {
                bagsSelect.remove(i);
            }

            for(i=0;i<=maxNumBags;i++)
            {
                //price is cost per bag for all sectors * num bags
                var price = ((i-SelectedBagNum) * TotalCostPerBag)
                var displayPrice
                if(price==0)
                {
                    displayPrice = "";
                }
                else
                {
                    var sign = price < 0 ? "-":"+";
                    displayPrice = "  " + sign + CurrencySymbol + (price > 0 ? String(price.toFixed(dp)) : String(price.toFixed(dp)).substring(1));
                }
                //value = <bag num>
                bagsSelect.options[i] = new Option(i + " " + BagsText + " " + displayPrice,i);//display,value,selected
                
                //IE does not support constructor with selected parameter - so select option here
                bagsSelect.options[i].selected=i==SelectedBagNum;
                
            }
        }
        
        //populate the excess weight dropdown
        var weightSelect = document.getElementById("cbobagChg_weight");
        
        //max weight
        var absoluteMaxWeight = parseInt(NumPax * MaxWeightPerPerson);
        var maxExcessWeightBags =  parseInt(SelectedBagNum * MaxWeightPerBag);    
        
        var maxExcessWeight = absoluteMaxWeight < maxExcessWeightBags ? absoluteMaxWeight : maxExcessWeightBags;
        
        //min weight
        var freeWeightEntitlement = parseInt(NumPax * FreeWeightPerPerson);
        
        var minExcessWeight = freeWeightEntitlement < maxExcessWeightBags  ? freeWeightEntitlement:maxExcessWeightBags;
        
        //clear options
        for(i = weightSelect.options.length-1 ;i>=0;i=i-1)
        {
            weightSelect.remove(i);
        }
        
        var optionCounter = 0;
        for(i=minExcessWeight; i<=maxExcessWeight; i+=KgIncrementBy)
        {
            //show relative price
            var price;
            var displayWeight;
            if(i==SelectedWeightNum)
            {
                //if option == selected weight then price for excess weight is zero
                price=0;
                selctedWeightAvailable = true;
            }
            else
            {
                var excessWeightOption;
                if(i < freeWeightEntitlement)
                {
                    if(SelectedWeightNum < i || SelectedWeightNum <= freeWeightEntitlement)
                    {
                        //selected weight is less than option or less than/eaqual to free weight and option is less than free weight so excess weight will cost nothing for this option
                        excessWeightOption = 0;
                    }
                    else
                    {
                        //option is less than free weight but greater than selected weight, so price is based on difference between free weight and selected weight
                        excessWeightOption = freeWeightEntitlement - SelectedWeightNum;
                    }
                }
                else
                {
                    if(SelectedWeightNum < freeWeightEntitlement)
                    {
                        //if option is greater than free weight and selected weight is less than free weight, then price is based on difference between option and free weight
                        excessWeightOption = i - freeWeightEntitlement;
                    }
                    else
                    {
                        //if option is greater than free weight and selected weight is more than or equal to free weight, then price is based on difference between option and selected weight
                        excessWeightOption = i - SelectedWeightNum;
                    }
                }
                
                price = (excessWeightOption * DisplayCostPerExtraKG) * NumberOfSectors;

            }
            
            displayWeight = ((i-freeWeightEntitlement)<0?0:(i-freeWeightEntitlement)) + WeightUnit;
            
            var actualPrice = ((i-freeWeightEntitlement) * CostPerExtraKG) * NumberOfSectors;
            actualPrice = actualPrice < 0 ? 0 : actualPrice;
            var actualDisplayPrice = ((i-freeWeightEntitlement) * DisplayCostPerExtraKG) * NumberOfSectors;
            actualDisplayPrice = actualDisplayPrice < 0 ? 0 : actualDisplayPrice;
            
            var displayPrice = price > 0 ? " +" + CurrencySymbol + price.toFixed(dp) : (price == 0? "": " -" + CurrencySymbol + String(price.toFixed(dp)).substring(1));
            //value = <total weight>|<actual price>|<excess weight>|<relative price>
            var val = i + "|" + actualPrice + "|" + ((i-freeWeightEntitlement)<0?0:(i-freeWeightEntitlement)) + "|" + actualDisplayPrice;

            var optionLabel = displayWeight + displayPrice;
            weightSelect.options[optionCounter] = new Option(optionLabel,val);//display,value,selected
            
            //IE does not support constructor with selected parameter - so select option here
            weightSelect.options[optionCounter].selected = i==SelectedWeightNum;
            
            optionCounter++;
            
        }
        if(!selctedWeightAvailable)
        {
            var selectedExcessWeight =  (SelectedWeightNum-freeWeightEntitlement)<0?0:(SelectedWeightNum-freeWeightEntitlement);
            var maxExcessWeightOption = (maxExcessWeight - freeWeightEntitlement)<0?0:(maxExcessWeight - freeWeightEntitlement);
            if(maxExcessWeight < freeWeightEntitlement && maxExcessWeightOption != selectedExcessWeight)
            {
                var errorText = errorMSG['ExcessWeightMaxWeightWarning'];
                errorText = errorText.replace("%DATA1%",maxExcessWeight + WeightUnit);
                errorText = errorText.replace("%DATA2%",freeWeightEntitlement + WeightUnit);
                alert(errorText);
            }
            else if (maxExcessWeightOption < selectedExcessWeight)
            {
                var errorText = errorMSG['ExcessWeightSelectedWeightUnavailableWarning'];
                errorText = errorText.replace("%DATA1%",maxExcessWeight + WeightUnit);
                alert(errorText); 
            }
        }
    }
    
    
    function LoadUpdateBaggageChangeProcess(TotalCostPerBag,NumberOfSectors,CostPerExtraKG,DisplayCostPerExtraKG,CurrencySymbol,dp,KgIncrementBy,NumPax,SelectedBag,SelectedWeight,MaxWeightPerBag,MaxExcessWeightPerPerson, MaxBagsPerPerson,FreeWeightPerPerson,BagsText,LoadOrUpdate, ConfirmedNumberBags, ConfirmedWeight)
    {
        var WeightUnit = " kg";
        //var BagsText = "hold bags";
        var MaxWeightPerPerson = MaxExcessWeightPerPerson + FreeWeightPerPerson;
        var selctedWeightAvailable = false;
        
        //retrieve numeric values from selectedValues       
        var SelectedBagSplit = String(SelectedBag).split("|");
        var selectedWeightSplit = String(SelectedWeight).split("|");
        
        var SelectedBagNum = parseInt(SelectedBagSplit[0]);
        var SelectedWeightNum = parseInt(selectedWeightSplit[0]);

       
        if(LoadOrUpdate == "L")
        {
            //populate the bags dropdown
            var bagsSelect = document.getElementById("cbobagChg_quantity");
            var maxNumBags = parseInt(NumPax * MaxBagsPerPerson);
            var optionCounterB = 0;
            
            //clear options
            for(i = bagsSelect.options.length-1 ;i>=0;i=i-1)
            {
                bagsSelect.remove(i);
            }
    
            for(i=ConfirmedNumberBags;i<=maxNumBags;i++)
            {
                //price is cost per bag for all sectors * num bags
                var price = ((i-SelectedBagNum) * TotalCostPerBag)
                var displayPrice
                if(price==0)
                {
                    displayPrice = "";
                }
                else
                {
                    var sign = price < 0 ? "-":"+";
                    displayPrice = "  " + sign + CurrencySymbol + (price > 0 ? String(price.toFixed(dp)) : String(price.toFixed(dp)).substring(1));
                }
                //value = <bag num>
                bagsSelect.options[optionCounterB] = new Option(i + " " + BagsText + " " + displayPrice,i);//display,value,selected
                
                //IE does not support constructor with selected parameter - so select option here
                bagsSelect.options[optionCounterB].selected=i==SelectedBagNum;
                optionCounterB ++;
            }
        }
        
        //populate the excess weight dropdown
        var weightSelect = document.getElementById("cbobagChg_weight");
        
        //max weight
        var absoluteMaxWeight = parseInt(NumPax * MaxWeightPerPerson);
        var maxExcessWeightBags =  parseInt(SelectedBagNum * MaxWeightPerBag);    
        
        var maxExcessWeight = absoluteMaxWeight < maxExcessWeightBags ? absoluteMaxWeight : maxExcessWeightBags;
        
        //min weight
        var freeWeightEntitlement = parseInt(NumPax * FreeWeightPerPerson);
        
        var minExcessWeight = freeWeightEntitlement < maxExcessWeightBags  ? freeWeightEntitlement:maxExcessWeightBags;
        
        minExcessWeight = minExcessWeight < ConfirmedWeight ? ConfirmedWeight:minExcessWeight;
        
        //clear options
        for(i = weightSelect.options.length-1 ;i>=0;i=i-1)
        {
            weightSelect.remove(i);
        }
        
        var optionCounter = 0;
        
        for(i=minExcessWeight; i<=maxExcessWeight; i+=KgIncrementBy)
        {
            //show relative price
            var price;
            var displayWeight;
            if(i==SelectedWeightNum)
            {
                //if option == selected weight then price for excess weight is zero
                price=0;
                selctedWeightAvailable = true;
            }
            else
            {
                var excessWeightOption;
                if(i < freeWeightEntitlement)
                {
                    if(SelectedWeightNum < i || SelectedWeightNum <= freeWeightEntitlement)
                    {
                        //selected weight is less than option or less than/eaqual to free weight and option is less than free weight so excess weight will cost nothing for this option
                        excessWeightOption = 0;
                    }
                    else
                    {
                        //option is less than free weight but greater than selected weight, so price is based on difference between free weight and selected weight
                        excessWeightOption = freeWeightEntitlement - SelectedWeightNum;
                    }
                }
                else
                {
                    if(SelectedWeightNum < freeWeightEntitlement)
                    {
                        //if option is greater than free weight and selected weight is less than free weight, then price is based on difference between option and free weight
                        excessWeightOption = i - freeWeightEntitlement;
                    }
                    else
                    {
                        //if option is greater than free weight and selected weight is more than or equal to free weight, then price is based on difference between option and selected weight
                        excessWeightOption = i - SelectedWeightNum;
                    }
                }
                
                price = (excessWeightOption * DisplayCostPerExtraKG) * NumberOfSectors;

            }
            
            displayWeight = ((i-freeWeightEntitlement)<0?0:(i-freeWeightEntitlement)) + WeightUnit;
            
            var actualPrice = ((i-freeWeightEntitlement) * CostPerExtraKG) * NumberOfSectors;
            actualPrice = actualPrice < 0 ? 0 : actualPrice;
            var actualDisplayPrice = ((i-freeWeightEntitlement) * DisplayCostPerExtraKG) * NumberOfSectors;
            actualDisplayPrice = actualDisplayPrice < 0 ? 0 : actualDisplayPrice;
            
            var displayPrice = price > 0 ? " +" + CurrencySymbol + price.toFixed(dp) : (price == 0? "": " -" + CurrencySymbol + String(price.toFixed(dp)).substring(1));
            //value = <total weight>|<actual price>|<excess weight>|<relative price>
            var val = i + "|" + actualPrice + "|" + ((i-freeWeightEntitlement)<0?0:(i-freeWeightEntitlement)) + "|" + actualDisplayPrice;

            var optionLabel = displayWeight + displayPrice;
            weightSelect.options[optionCounter] = new Option(optionLabel,val);//display,value,selected
            
            //IE does not support constructor with selected parameter - so select option here
            weightSelect.options[optionCounter].selected = i==SelectedWeightNum;
            
            optionCounter++;
            
        }
        if(!selctedWeightAvailable)
        {
            var selectedExcessWeight =  (SelectedWeightNum-freeWeightEntitlement)<0?0:(SelectedWeightNum-freeWeightEntitlement);
            var maxExcessWeightOption = (maxExcessWeight - freeWeightEntitlement)<0?0:(maxExcessWeight - freeWeightEntitlement);
            if(maxExcessWeight < freeWeightEntitlement && maxExcessWeightOption != selectedExcessWeight)
            {
                var errorText = errorMSG['ExcessWeightMaxWeightWarning'];
                errorText = errorText.replace("%DATA1%",maxExcessWeight + WeightUnit);
                errorText = errorText.replace("%DATA2%",freeWeightEntitlement + WeightUnit);
                alert(errorText);
            }
            else if (maxExcessWeightOption < selectedExcessWeight)
            {
                var errorText = errorMSG['ExcessWeightSelectedWeightUnavailableWarning'];
                errorText = errorText.replace("%DATA1%",maxExcessWeight + WeightUnit);
                alert(errorText); 
            }
        }
    }