$(document).ready(function () {
    if (WrapperPage == 'singlepage') {
        addActiveClassToNavigationItem();
    }
    if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) == false) {
        RevolutionSlider.initRSfullWidth();
    }
    jQuery('.navigate-me a, #logo a').click(function (e) {
        var pageTarget = jQuery(this).attr('data-target');
        if (pageTarget === 'page') {
            window.location.replace(pageTarget);
        } else {
            if (pageTarget === "#login") {
                openLoginForm();
            } else if (pageTarget === "#register") {
                openRegisterForm();
            } else {
                jQuery.scrollTo(pageTarget, 1500, {
                    offset: -(jQuery('#home #menu').height() + 100), axis: 'y'
                });
            }
        }
        if (jQuery(window).width() <= 767) {
            if ($('.navbar-collapse').hasClass('in')) {
                $('.navbar-collapse').removeClass('in');
                e.stopPropagation();
            } else {
                $('.navbar-collapse').addClass('in');
                $('.navbar-collapse').collapse();
            }
        }
    });
    if (jQuery(window).width() > 767 && $('.bhoechie-tab-menu').length > 0) {
        jQuery('.category-navigation.bhoechie-tab-menu').jScrollPane({autoReinitialise: true});
    }
    if (jQuery('.content-scroll-pane').length > 0) {
        jQuery('.bhoechie-tab-content.active .content-scroll-pane').jScrollPane({autoReinitialise: true});
    }
    jQuery(".bhoechie-tab-menu a").click(function (e) {
        e.preventDefault();
        jQuery(this).siblings('a.active').removeClass("active");
        jQuery(this).addClass("active");
        var index = $(this).index();
        jQuery(".bhoechie-tab .bhoechie-tab-content").removeClass("active");
        jQuery(".bhoechie-tab .bhoechie-tab-content").eq(index).addClass("active");
        if (jQuery(window).width() <= 767) {
            jQuery(".category-navigation").slideUp();
        }

        if (jQuery(window).width() > 767) {
            jQuery('.bhoechie-tab-content.active .content-scroll-pane').jScrollPane({autoReinitialise: true});
        }

    });
    addjqueryValidatorFunction();
    LoginSpecificNavigation();
});
function LoginSpecificNavigation() {
    $.ajax({
        url: baseUrl + 'onlineorder/checklogin',
        type: 'POST',
        dataType: 'json',
        success: function (output) {
            if (output.status) {
                $('#navigationShowLogin').removeAttr('style');
                $('#navigationShowLogin').css({'display': 'none'});
                $('#navigationShowRegister').removeAttr('style');
                $('#navigationShowRegister').css({'display': 'none'});
                $('#reviewBoxOpener').length > 0 ? $('#reviewBoxOpener').removeAttr('style').css({'display': 'block'}).click() : '';
                $('#reviewLoginOpener').length > 0 ? $('#reviewLoginOpener').removeAttr('style').css({'display': 'none'}) : '';
                if (jQuery(window).width() <= 767) {
                    $('#navigationShowAccount').removeAttr('style');
                    $('#navigationShowAccount').css({'display': 'block'});
                    $('#navigationShowLogout').removeAttr('style');
                    $('#navigationShowLogout').css({'display': 'block'});
                } else {
                    $('#navigationShowAccount').removeAttr('style');
                    $('#navigationShowAccount').css({'display': 'inline-block'});
                    $('#navigationShowLogout').removeAttr('style');
                    $('#navigationShowLogout').css({'display': 'inline-block'});
                }

            } else {
                $('#navigationShowAccount').removeAttr('style');
                $('#navigationShowAccount').css({'display': 'none'});
                $('#navigationShowLogout').removeAttr('style');
                $('#navigationShowLogout').css({'display': 'none'});
                $('#reviewBoxOpener').length > 0 ? $('#reviewBoxOpener').removeAttr('style').css({'display': 'none'}) : '';
                $('#reviewLoginOpener').length > 0 ? $('#reviewLoginOpener').removeAttr('style').css({'display': 'block'}) : '';
                if (jQuery(window).width() <= 767) {
                    $('#navigationShowLogin').removeAttr('style');
                    $('#navigationShowLogin').css({'display': 'block'});
                    $('#navigationShowRegister').removeAttr('style');
                    $('#navigationShowRegister').css({'display': 'block'});
                } else {
                    $('#navigationShowLogin').removeAttr('style');
                    $('#navigationShowLogin').css({'display': 'inline-block'});
                    $('#navigationShowRegister').removeAttr('style');
                    $('#navigationShowRegister').css({'display': 'inline-block'});
                }

            }

            if (output.isRestaaurantOpened || output.preorder == 'yes') {
                $('.click-to-add.disable-add-to-cart').length > 0 ? $('.click-to-add').removeClass('disable-add-to-cart') : ''
                $('#processPreorder').length > 0 ? $('#processPreorder').removeAttr('style').css({'display': 'none'}) : '';
                $('#processingPreorder').length > 0 ? $('#processingPreorder').removeAttr('style').css({'display': 'block'}) : '';
            } else {
                $('#processingPreorder').length > 0 ? $('#processingPreorder').removeAttr('style').css({'display': 'none'}) : '';
                $('#processPreorder').length > 0 ? $('#processPreorder').removeAttr('style').css({'display': 'block'}) : '';
                $('.click-to-add').length > 0 ? $('.click-to-add').addClass('disable-add-to-cart') : '';
            }
        }
    });
}
function closeColorbox() {
    $.colorbox.close();
}
function openLoginForm() {
    $.colorbox({inline: true, scrolling: false, href: "#loginFormPopup", width: "550px", maxWidth: "95%", open: true, closeButton: false, transition: 'elastic', speed: '5000'});
}
function openDeliveryPostcodeForm(trigeredFrom) {
    trigeredFrom == 'checkout' ? $('#PostcodeFormPopupTriggeredFrom').val('checkout') : $('#PostcodeFormPopupTriggeredFrom').val('menu');
    $.colorbox({inline: true, scrolling: false, href: "#PostcodeFormPopup", width: "550px", maxWidth: "95%", open: true, closeButton: false, transition: 'elastic', speed: '5000'});
}
function openRegisterForm() {
    $.colorbox({inline: true, scrolling: false, href: "#RegisterFormPopup", maxWidth: "95%", open: true, closeButton: false});
}

function  switchingToRegiterForm() {
    closeColorbox();
    window.setTimeout(function () {
        openRegisterForm();
    }, 500);
}
function  switchingToLoginForm() {
    closeColorbox();
    window.setTimeout(function () {
        openLoginForm();
    }, 500);
}
function openForgetPasswordForm() {
    $.colorbox.close();
    window.setTimeout(function () {
        $.colorbox({inline: true, scrolling: false, href: "#ForgetPasswordForm", width: "550px", maxWidth: "95%", open: true, closeButton: false});
    }, 500);
}
function showTermsCondition() {
    $.colorbox.close();
    window.setTimeout(function () {
        jQuery('#termsConditionPage').modal('show');
        jQuery('#termsConditionPage .modal-body').jScrollPane({autoReinitialise: true});
    }, 500);

}
function openAlergyPopUp() {
    $.colorbox({inline: true, scrolling: false, href: "#AlergyPopup", width: "550px", maxWidth: "95%", open: true, closeButton: false, transition: 'elastic', speed: '5000'});
}

/*====================================================
 Arow Navigation function 
 ======================================================*/
function navigateMeTo(myscrollTo, myoffsets) {
    jQuery.scrollTo(myscrollTo, 1500, {
        offset: -(jQuery(myoffsets).height() + 100), axis: 'y'
    });

}
function errorPlacement(error, element) {
    var placement = $(element).data('error');
    if (placement) {
        $(placement).append(error)
    } else {
        error.insertAfter(element);
    }
}
function openMenuCategory() {
    jQuery(".category-navigation").slideToggle();
}
/*===========================================
 //Cutom Alert Popup system 
 =============================================*/
var ALERT_TITLE = "Oops!";
var ALERT_BUTTON_TEXT = "Ok";
if (document.getElementById) {
    window.alert = function (txt) {
        createCustomAlert(txt);
    }
}
function createCustomAlert(txt) {
    d = document;
    if (d.getElementById("modalContainer"))
        return;

    mObj = d.getElementsByTagName("body")[0].appendChild(d.createElement("div"));
    mObj.id = "modalContainer";
    mObj.style.height = d.documentElement.scrollHeight + "px";
    alertObj = mObj.appendChild(d.createElement("div"));
    alertObj.id = "alertBox";
    alertObj.style.top = '30%';
    alertObj.style.left = (d.documentElement.scrollWidth - alertObj.offsetWidth) / 2 + "px";
    alertObj.style.visiblity = "visible";
    h1 = alertObj.appendChild(d.createElement("h1"));
    h1.appendChild(d.createTextNode(ALERT_TITLE));
    msg = alertObj.appendChild(d.createElement("p"));
    msg.innerHTML = txt;
    btn = alertObj.appendChild(d.createElement("a"));
    btn.id = "closeBtn";
    btn.appendChild(d.createTextNode(ALERT_BUTTON_TEXT));
    btn.href = "#";
    btn.focus();
    btn.onclick = function () {
        removeCustomAlert();
        return false;
    }
    alertObj.style.display = "block";
}
function removeCustomAlert() {
    document.getElementsByTagName("body")[0].removeChild(document.getElementById("modalContainer"));
}
function ful() {
    alert('Alert this pages');
}
function addjqueryValidatorFunction() {
    jQuery.validator.addMethod("lettersonly", function (value, element) {
        return this.optional(element) || /^[a-z\s]+$/i.test(value);
    }, "Only alphabetical characters");
    jQuery.validator.addMethod('phone', function (value, element) {
        return this.optional(element) || value.length > 9 &&
                value.match(/^(((\+44)? ?(\(0\))? ?)|(0))( ?[0-9]{3,4}){3}$/);
    }, 'Please specify a valid phone number');
    jQuery.validator.addMethod("postcodeUK", function (value, element) {
        return this.optional(element) || /^[A-Z]{1,2}[0-9]{1,2} ?[0-9][A-Z]{2}$/i.test(value);
    }, "Please specify a valid Postcode");

    $.validator.addMethod("loginRegex", function (value, element) {
        return this.optional(element) || /^[A-Za-z][a-z0-9\-\s]+$/i.test(value);
    }, "Username must contain only letters, numbers, or dashes.");

    $.validator.addMethod("email", function (value, element) {
        return this.optional(element) || /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(value);
    }, "Please specify valid email addresss");
}
function addActiveClassToNavigationItem() {
    var lastId,
            topMenu = $("#menu"),
            topMenuHeight = topMenu.outerHeight() + 200,
            menuItems = topMenu.find("a"),
            scrollItems = menuItems.map(function () {
                var item = $($(this).attr("data-target"));
                if (item.length) {
                    return item;
                }
            });

    $(window).scroll(function () {
        var fromTop = $(this).scrollTop() + topMenuHeight;
        var cur = scrollItems.map(function () {
            if ($(this).offset().top < fromTop)
                return this;
        });
        cur = cur[cur.length - 1];
        var id = cur && cur.length ? cur[0].id : "";
        if (lastId !== id) {
            lastId = id;
            menuItems
                    .parent().removeClass("active")
                    .end().filter("[data-target='#" + id + "']").parent().addClass("active");
        }
    });
}

/*====================================
 * Online Order
 =====================================*/
function ShowHideDealSet(clickedSet, SetContent) {
    $('#' + clickedSet).toggle('slow');
}

function calculateDealSetInfo(cat, deal, set, menu, form, maxAllowed, menusel) {
    var setItemCounterLoc = '#' + form + ' #setItemCounter_' + cat + '_' + deal + '_' + set + '_' + menusel;
    var checkbox = '#' + form + ' #dealSetItemsCheckbox_' + cat + '_' + deal + '_' + set + '_' + menu + '_' + menusel;
    var dealSetItemsLoc = '#' + form + ' #dealSetItems_' + cat + '_' + deal + '_' + menusel;
    var dealInvidualSetItemsLoc = '#' + form + ' #displayIndividualSetItems_' + cat + '_' + deal + '_' + set + '_' + menusel;
    var dealSetItems = $(dealSetItemsLoc).val();
    var setItemCounter = Number($(setItemCounterLoc).val());
    var title = $(checkbox).val();
    var dealInvidualSetItemsLocValue = $(dealInvidualSetItemsLoc + ' .individual-set-items-val').val();
    if ($(checkbox).is(':checked')) {
        if (Number(setItemCounter) >= Number(maxAllowed)) {
            $(checkbox).attr('checked', false);
            alert('Please select any ' + maxAllowed + ' items from this set');
        } else {
            setItemCounter += 1;
            dealSetItems += ',' + title;
            dealInvidualSetItemsLocValue += ',' + title;
        }
    } else {
        setItemCounter -= 1;
        dealSetItems = dealSetItems.replace(',' + title, '');
        dealInvidualSetItemsLocValue = dealInvidualSetItemsLocValue.replace(',' + title, '');
    }
    $(dealSetItemsLoc).val(dealSetItems);
    $(setItemCounterLoc).val(setItemCounter);
    $(dealInvidualSetItemsLoc + ' .individual-set-items-val').val(dealInvidualSetItemsLocValue);
    if ($.trim(dealInvidualSetItemsLocValue)) {
        $(dealInvidualSetItemsLoc + ' .individual-set-items').text(dealInvidualSetItemsLocValue.substr(1));
    } else {
        $(dealInvidualSetItemsLoc + ' .individual-set-items').text('No Items Yet');
    }
    setItemCounter = Number($(setItemCounterLoc).val());
    if (setItemCounter === Number(maxAllowed)) {
        ShowHideDealSet('dealSet_' + deal + '_' + set + '_' + menusel, 'deal-set-toggle');
    }

}
function  showExtra(extra) {
    var extra_arr = extra.split('_');
    var formType = extra_arr[0]
    if (formType == 'dealForm') {
        showDealString(extra_arr[1], extra_arr[2])
    }
    $('#' + extra + ' .extra').slideToggle('slow');
    jQuery('.bhoechie-tab-content.active .content-scroll-pane').jScrollPane({autoReinitialise: true});

}
function showDealString(cat, deal, menusel) {
    var dealItems = $('#dealSetItems_' + cat + '_' + deal + '_' + menusel).val();
    var dealToppings = $('#dealToppingsString_' + cat + '_' + deal + '_' + menusel).val();
    if ($.trim(dealItems) || $.trim(dealToppings)) {
        $('#dealStringDisplay_' + deal + '_' + menusel).show();
        if ($.trim(dealToppings)) {
            $('#dealToppingsDisplayLi_' + deal + '_' + menusel).show();
            $('#dealToppingsDisplay_' + deal + '_' + menusel).text(dealToppings.substr(1));
        } else {
            $('#dealToppingsDisplayLi_' + deal + '_' + menusel).hide();
        }
        if ($.trim(dealItems)) {
            $('#dealItemsDisplayLi_' + deal + '_' + menusel).show();
            $('#dealItemsDisplay_' + deal + '_' + menusel).text(dealItems.substr(1));
        } else {
            $('#dealItemsDisplayLi_' + deal + '_' + menusel).hide();
        }
    } else {
        $('#dealStringDisplay_' + deal + '_' + menusel).hide();
        $('#dealItemsDisplay_' + deal + '_' + menusel).text('');
        $('#dealToppingsDisplay_' + deal + '_' + menusel).text('');
    }
}

function calculateToppingsInfo(cat, menu, sel, topping, form, maxToppings, freeToppings, price, top_cat) {
    var title = '';
    var toppingPrice = 0;
    var toppingsString = '';
    if ($.trim(sel) == false || $.trim(sel) == null) {
        var checkbox = '#' + form + ' #topping_' + cat + '_' + menu + '_' + topping;
        var toppingsStringLoc = '#' + form + ' #toppingsString_' + cat + '_' + menu;
        var toppingPriceLoc = '#' + form + ' #toppingPrice_' + cat + '_' + menu + '_' + topping;
        var visiblePriceLoc = '#' + form + ' #visiblePriceFor_' + cat + '_' + menu;
        var hiddenPriceLoc = '#' + form + ' #hiddenPriceFor_' + cat + '_' + menu;
        var menuToppingsCounterLoc = '#' + form + ' #menuToppingsCounter_' + cat + '_' + menu;
        var menuToppingsCounter = Number($(menuToppingsCounterLoc).val());
        var menuToppingsPriceTotalLoc = '#' + form + ' #menuToppingsPriceTotal_' + cat + '_' + menu;
        var maximumCategoryTopping = '#' + form + ' #maximumCategoryTopping_' + top_cat + '_' + menu;
        var maximumCategoryToppingVal = Number($(maximumCategoryTopping).val());
        var maxmumCategoryToppingCounter = '#' + form + ' #maxmumCategoryToppingCounter_' + top_cat + '_' + menu;
        var maxmumCategoryToppingCounterVal = Number($(maxmumCategoryToppingCounter).val());
        title = $(checkbox).val();
        toppingPrice = $(toppingPriceLoc).val();
        toppingsString = $(toppingsStringLoc).val();
        if ($(checkbox).is(':checked')) {
            if (Number(maxToppings) > 0 && menuToppingsCounter >= Number(maxToppings)) {
                $(checkbox).attr('checked', false);
                alert('Please select any ' + maxToppings + ' toppings');
            } else {
                if (Number(maxmumCategoryToppingCounterVal) >= Number(maximumCategoryToppingVal)) {
                    $(checkbox).attr('checked', false);
                    alert('you can not exceed ' + Number(maximumCategoryToppingVal) + ' toppings from this category');
                    if ($('#collapseToppingCategory_' + top_cat + '_' + menu).length > 0) {
                        $('#collapseToppingCategory_' + top_cat + '_' + menu).click();
                    }
                } else {
                    maxmumCategoryToppingCounterVal += 1;
                    $(maxmumCategoryToppingCounter).val(maxmumCategoryToppingCounterVal);
                    if (Number(maxmumCategoryToppingCounterVal) >= Number(maximumCategoryToppingVal)) {
                        if ($('#collapseToppingCategory_' + top_cat + '_' + menu).length > 0) {
                            $('#collapseToppingCategory_' + top_cat + '_' + menu).click();
                        }
                    }
                    menuToppingsCounter += 1;
                    var toppingsPriceTotal;
                    if (freeToppings < menuToppingsCounter) {
                        toppingsPriceTotal = $(menuToppingsPriceTotalLoc).val();
                        toppingsPriceTotal = parseFloat(toppingsPriceTotal) + parseFloat(toppingPrice);
                        $(menuToppingsPriceTotalLoc).val(toppingsPriceTotal);
                    } else {
                        toppingsPriceTotal = 0;
                        $(menuToppingsPriceTotalLoc).val(toppingsPriceTotal);
                    }
                    toppingsString += ',' + title;
                }
            }
        } else {
            maxmumCategoryToppingCounterVal -= 1;
            $(maxmumCategoryToppingCounter).val(maxmumCategoryToppingCounterVal);
            menuToppingsCounter -= 1;
            var toppingsPriceTotal;
            if (freeToppings < menuToppingsCounter) {
                toppingsPriceTotal = $(menuToppingsPriceTotalLoc).val();
                toppingsPriceTotal = parseFloat(toppingsPriceTotal) - parseFloat(toppingPrice);
                $(menuToppingsPriceTotalLoc).val(toppingsPriceTotal);
            } else {
                toppingsPriceTotal = 0;
                $(menuToppingsPriceTotalLoc).val(toppingsPriceTotal);
            }
            toppingsString = toppingsString.replace(',' + title, '');
        }
        var EndToppingsPriceTotal = Number($(menuToppingsPriceTotalLoc).val());
        var menu_price = parseFloat(0);
        if (EndToppingsPriceTotal > 0) {
            menu_price = parseFloat(price) + parseFloat(EndToppingsPriceTotal);
        } else {
            menu_price = parseFloat(price);
        }
        $(menuToppingsCounterLoc).val(menuToppingsCounter);
        $(visiblePriceLoc).text(menu_price.toFixed(2));
        $(hiddenPriceLoc).val(menu_price.toFixed(2));
        $(toppingsStringLoc).val(toppingsString);
    } else {
        var checkbox = '#' + form + ' #topping_' + cat + '_' + menu + '_' + sel + '_' + topping;
        var toppingsStringLoc = '#' + form + ' #toppingsString_' + cat + '_' + menu + '_' + sel;
        var toppingPriceLoc = '#' + form + ' #toppingPrice_' + cat + '_' + menu + '_' + sel + '_' + topping;
        var visiblePriceLoc = '#' + form + ' #visiblePriceFor_' + cat + '_' + menu + '_' + sel;
        var hiddenPriceLoc = '#' + form + ' #hiddenPriceFor_' + cat + '_' + menu + '_' + sel;
        var selectionToppingsPriceTotalLoc = '#' + form + ' #selectionToppingsPriceTotal_' + cat + '_' + menu + '_' + sel;
        var selectionToppingsCounterLoc = '#' + form + ' #selectionToppingsCounter_' + cat + '_' + menu + '_' + sel;
        var selectionToppingsCounter = Number($(selectionToppingsCounterLoc).val());
        var maximumCategoryTopping = '#' + form + ' #maximumCategoryTopping_' + top_cat + '_' + menu + '_' + sel;
        var maximumCategoryToppingVal = Number($(maximumCategoryTopping).val());
        var maxmumCategoryToppingCounter = '#' + form + ' #maxmumCategoryToppingCounter_' + top_cat + '_' + menu + '_' + sel;
        var maxmumCategoryToppingCounterVal = Number($(maxmumCategoryToppingCounter).val());
        title = $(checkbox).val();
        toppingPrice = $(toppingPriceLoc).val();
        toppingsString = $(toppingsStringLoc).val();
        if ($(checkbox).is(':checked')) {
            if (Number(maxToppings) > 0 && selectionToppingsCounter >= Number(maxToppings)) {
                $(checkbox).attr('checked', false);
                alert('Please select any ' + maxToppings + ' toppings');
            } else {
                if (Number(maxmumCategoryToppingCounterVal) >= Number(maximumCategoryToppingVal)) {
                    $(checkbox).attr('checked', false);
                    alert('you can not exceed ' + Number(maximumCategoryToppingVal) + ' toppings from this category');
                    if ($('#collapseToppingCategory_' + top_cat + '_' + menu + '_' + sel).length > 0) {
                        $('#collapseToppingCategory_' + top_cat + '_' + menu + '_' + sel).click();
                    }
                } else {
                    maxmumCategoryToppingCounterVal += 1;
                    $(maxmumCategoryToppingCounter).val(maxmumCategoryToppingCounterVal);
                    if (Number(maxmumCategoryToppingCounterVal) >= Number(maximumCategoryToppingVal)) {
                        if ($('#collapseToppingCategory_' + top_cat + '_' + menu + '_' + sel).length > 0) {
                            $('#collapseToppingCategory_' + top_cat + '_' + menu + '_' + sel).click();
                        }
                    }
                    selectionToppingsCounter += 1;
                    var toppingsPriceTotal;
                    if (freeToppings < selectionToppingsCounter) {
                        toppingsPriceTotal = $(selectionToppingsPriceTotalLoc).val();
                        toppingsPriceTotal = parseFloat(toppingsPriceTotal) + parseFloat(toppingPrice);
                        $(selectionToppingsPriceTotalLoc).val(toppingsPriceTotal);
                    } else {
                        toppingsPriceTotal = 0;
                        $(selectionToppingsPriceTotalLoc).val(toppingsPriceTotal);
                    }
                    toppingsString += ',' + title;
                }
            }
        } else {
            maxmumCategoryToppingCounterVal -= 1;
            $(maxmumCategoryToppingCounter).val(maxmumCategoryToppingCounterVal);
            selectionToppingsCounter -= 1;
            var toppingsPriceTotal;
            if (freeToppings < selectionToppingsCounter) {
                toppingsPriceTotal = $(selectionToppingsPriceTotalLoc).val();
                toppingsPriceTotal = parseFloat(toppingsPriceTotal) - parseFloat(toppingPrice);
                $(selectionToppingsPriceTotalLoc).val(toppingsPriceTotal);
            } else {
                toppingsPriceTotal = 0;
                $(selectionToppingsPriceTotalLoc).val(toppingsPriceTotal);
            }
            toppingsString = toppingsString.replace(',' + title, '');
        }
        var EndToppingsPriceTotal = Number($(selectionToppingsPriceTotalLoc).val());
        var selection_price = parseFloat(0);
        if (EndToppingsPriceTotal > 0) {
            selection_price = parseFloat(price) + parseFloat(EndToppingsPriceTotal);
        } else {
            selection_price = parseFloat(price);
        }
        $(selectionToppingsCounterLoc).val(selectionToppingsCounter);
        $(visiblePriceLoc).text(selection_price.toFixed(2));
        $(hiddenPriceLoc).val(selection_price.toFixed(2));
        $(toppingsStringLoc).val(toppingsString);
    }
}



function submitTocart(itemForm, is_special, menusel) {
    var itemFormArr = itemForm.split('_');
    var itemFormName = itemFormArr['0'];
    if (itemFormName !== 'dealForm_' && is_special !== 'yes') {
        submit(itemForm);
    } else {
        var cat = itemFormArr[1];
        var deal = itemFormArr[2];
        var setQuantity = $('#DealSetQuantity_' + deal + '_' + menusel).val();
        // setQuantity = setQuantity >= 1 ? setQuantity - 1 : 0;
        // alert(setQuantity);
        if (setQuantity > 0) {
            var setIds = $('#DealSetIds_' + deal + '_' + menusel).val();
            var setIdsArr = setIds.split('_');
            var setItemCounterVal = 0;
            var setTitleForLoc = '#' + itemForm + ' #setTitleFor_' + cat + '_' + deal + '_' + menusel;
            var setItemEmtyId = 'no';
            for (var i = 0; i < setQuantity; i++) {
                setItemCounterVal = $('#' + itemForm + ' #setItemCounter_' + cat + '_' + deal + '_' + setIdsArr[i] + '_' + menusel).val();
                if (setItemCounterVal == 0) {
                    setItemEmtyId = setIdsArr[i];
                    break;
                }
            }
            if (setItemEmtyId != 'no') {
                var setTitle = $(setTitleForLoc + '_' + setItemEmtyId).text();
                alert('please select items from ' + setTitle);
                return false;
            } else {
                submit(itemForm);
            }
        } else {
            submit(itemForm);
        }
    }
}
function subtractQty(qtyField) {
    if (document.getElementById(qtyField).value - 1 < 1)
        return;
    else
        document.getElementById(qtyField).value--;
}

function subtractQty1() {
    if (document.getElementById("qty1").value - 1 < 0)
        return;
    else
        document.getElementById("qty1").value--;
}

function subtractQty2() {
    if (document.getElementById("qty2").value - 1 < 0)
        return;
    else
        document.getElementById("qty2").value--;
}

function subtractQty3() {
    if (document.getElementById("qty3").value - 1 < 0)
        return;
    else
        document.getElementById("qty3").value--;
}

function subtractQty4() {
    if (document.getElementById("qty4").value - 1 < 0)
        return;
    else
        document.getElementById("qty4").value--;
}

