<!--

var contextPath = "ehungry";
//var contextPath = "order";
var scriptsPath = "scripts";
var servletPath = "newacct";
var servletManagerPath = "manager"; 

function buildPath() {
    return "/" + contextPath + "/" + servletPath;
}

function buildManagerPath() {
    return "/" + contextPath + "/" + servletManagerPath;
}

function addOptionPopup() {
    if(optionwin) optionwin.close();
    var optionwin = window.open(buildPath() + "?form=options&type=new&aw=1","optionWin","width=390,height=400,scrollbars=yes,toolbar=no,location=no,resizable=yes");
    optionwin.focus();
}

function editOptionPopup(optionID) {
    if(optionwin) optionwin.close();
    var optionwin = window.open(buildPath() + "?form=options&type=edit&aw=1&oid=" + optionID,"optionWin","width=390,height=400,scrollbars=yes,toolbar=no,location=no,resizable=yes");
    optionwin.focus();
}

function addToppingPopup() {
    if(toppingwin) toppingwin.close();
    var toppingwin = window.open(buildPath() + "?form=toppings&type=new&aw=1","toppingWin","width=340,height=400,scrollbars=yes,toolbar=no,location=no,resizable=yes");
    toppingwin.focus();
}

function editToppingPopup(toppingID) {
    if(toppingwin) toppingwin.close();
    var toppingwin = window.open(buildPath() + "?form=toppings&type=edit&aw=1&tid=" + toppingID,"toppingWin","width=340,height=400,scrollbars=yes,toolbar=no,location=no,resizable=yes");
    toppingwin.focus();
}

function addExtraPopup() {
    if(extrawin) extrawin.close();
    var extrawin = window.open(buildPath() + "?form=extras&type=new&aw=1","extraWin","width=340,height=400,scrollbars=yes,toolbar=no,location=no,resizable=yes");
    extrawin.focus();
}

function editExtraPopup(extraID) {
    if(extrawin) extrawin.close();
    var extrawin = window.open(buildPath() + "?form=extras&type=edit&aw=1&eid=" + extraID,"extraWin","width=340,height=400,scrollbars=yes,toolbar=no,location=no,resizable=yes");
    extrawin.focus();
}

function addLocationOptionPopup(locationID) {
    if(optionwin) optionwin.close();
    var optionwin = window.open(buildManagerPath() + "?form=locationoptions&type=new&lid=" + locationID + "&aw=1","optionWin","width=390,height=400,scrollbars=yes,toolbar=no,location=no,resizable=yes");
    optionwin.focus();
}

function editLocationOptionPopup(locationID, optionID) {
    if(optionwin) optionwin.close();
    var optionwin = window.open(buildManagerPath() + "?form=locationoptions&type=edit&lid=" + locationID + "&aw=1&oid=" + optionID,"optionWin","width=390,height=400,scrollbars=yes,toolbar=no,location=no,resizable=yes");
    optionwin.focus();
}

function addLocationToppingPopup(locationID) {
    if(toppingwin) toppingwin.close();
    var toppingwin = window.open(buildManagerPath() + "?form=locationtoppings&type=new&lid=" + locationID + "&aw=1","toppingWin","width=340,height=400,scrollbars=yes,toolbar=no,location=no,resizable=yes");
    toppingwin.focus();
}

function editLocationToppingPopup(locationID, toppingID) {
    if(toppingwin) toppingwin.close();
    var toppingwin = window.open(buildManagerPath() + "?form=locationtoppings&type=edit&lid=" + locationID + "&aw=1&tid=" + toppingID,"toppingWin","width=340,height=400,scrollbars=yes,toolbar=no,location=no,resizable=yes");
    toppingwin.focus();
}

function addLocationExtraPopup(locationID) {
    if(extrawin) extrawin.close();
    var extrawin = window.open(buildManagerPath() + "?form=locationextras&type=new&lid=" + locationID + "&aw=1","extraWin","width=340,height=400,scrollbars=yes,toolbar=no,location=no,resizable=yes");
    extrawin.focus();
}

function editLocationExtraPopup(locationID, extraID) {
    if(extrawin) extrawin.close();
    var extrawin = window.open(buildManagerPath() + "?form=locationextras&type=edit&aw=1&lid=" + locationID + "&eid=" + extraID,"extraWin","width=340,height=400,scrollbars=yes,toolbar=no,location=no,resizable=yes");
    extrawin.focus();
}

function addLocationCategoryPopup(locationID) {
    if(catwin) catwin.close();
    var catwin = window.open(buildManagerPath() + "?form=locationcategories&type=new&lid=" + locationID + "&aw=1","catWin","width=340,height=400,scrollbars=yes,toolbar=no,location=no,resizable=yes");
    catwin.focus();
}

function editLocationCategoryPopup(locationID, catID) {
    if(catwin) catwin.close();
    var catwin = window.open(buildManagerPath() + "?form=locationcategories&type=edit&aw=1&lid=" + locationID + "&cid=" + catID,"catWin","width=340,height=400,scrollbars=yes,toolbar=no,location=no,resizable=yes");
    catwin.focus();
}


function checkDefaultOption(fieldToCheck) {
    if(fieldToCheck && fieldToCheck.value=="") {
        alert("Option must have a name to be selected as the default");
        return false;
    }
}

function forceCategorySelection(thisForm) {
    if(thisForm) {
        var numCats = thisForm.category.length;
        var c=document.getElementsByName('category');
        for(var i=0,a;a=c[i];i++) {
            if(a.checked) return true;
        }
        alert("You must place this menu item into at least one category before saving");
        return false;
    }
}

function confirmDeleteItem() {
    if(confirm("Deleting a menu item is a permanent action. Once deleted, it cannot be retrieved.  Are you sure you wish to do this?")) {
        return true;
    } else {
        return false;
    }
}

function confirmCategoryItem() {
    if(confirm("Deleting a category is a permanent action. Once deleted, it cannot be retrieved.  Are you sure you wish to do this?")) {
        return true;
    } else {
        return false;
    }
}

function confirmDelete(what) {
    if(confirm("Deleting a" + what + " is a permanent action. Once deleted, it cannot be retrieved.  Are you sure you wish to do this?")) {
        return true;
    } else {
        return false;
    }
}

var newWindow = null;
    function openWindow(url, name)
    {
      if (!newWindow || newWindow.closed) {
            newWindow = window.open(url, name, 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=yes,width=480,height=350');
            newWindowURL = url;
      } else {
            if (newWindowURL != url) {
                newWindow.location.href = url;
                newWindowURL = url;
            }
      }
      newWindow.focus();
    }

    function cancelAcctConfirm(thisField) {
        if(thisField.checked == true) {
            if(confirm("By checking this box, you are asking for your account to be cancelled.  Are you sure you want to do this?")) {
                alert("You have indicated that you DO wish for your account to be cancelled.  You will receive an e-mail notification notifying you of your selection as soon as this cancellation request has been processed.");
                return true;
            } else {
                return false;
            }
        }
        return true;
    }


function addStoreOptionPopup() {
    if(optionwin) optionwin.close();
    var optionwin = window.open(buildPath() + "?form=storeoptions&type=new&aw=1","optionWin","width=390,height=400,scrollbars=yes,toolbar=no,location=no,resizable=yes");
    optionwin.focus();
}

function editStoreOptionPopup(optionID) {
    if(optionwin) optionwin.close();
    var optionwin = window.open(buildPath() + "?form=storeoptions&type=edit&aw=1&oid=" + optionID,"optionWin","width=390,height=400,scrollbars=yes,toolbar=no,location=no,resizable=yes");
    optionwin.focus();
}

function addStoreToppingPopup() {
    if(toppingwin) toppingwin.close();
    var toppingwin = window.open(buildPath() + "?form=storetoppings&type=new&aw=1","toppingWin","width=340,height=400,scrollbars=yes,toolbar=no,location=no,resizable=yes");
    toppingwin.focus();
}

function editStoreToppingPopup(toppingID) {
    if(toppingwin) toppingwin.close();
    var toppingwin = window.open(buildPath() + "?form=storetoppings&type=edit&aw=1&tid=" + toppingID,"toppingWin","width=340,height=400,scrollbars=yes,toolbar=no,location=no,resizable=yes");
    toppingwin.focus();
}

function addStoreExtraPopup() {
    if(extrawin) extrawin.close();
    var extrawin = window.open(buildPath() + "?form=storeextras&type=new&aw=1","extraWin","width=340,height=400,scrollbars=yes,toolbar=no,location=no,resizable=yes");
    extrawin.focus();
}

function editStoreExtraPopup(extraID) {
    if(extrawin) extrawin.close();
    var extrawin = window.open(buildPath() + "?form=storeextras&type=edit&aw=1&eid=" + extraID,"extraWin","width=340,height=400,scrollbars=yes,toolbar=no,location=no,resizable=yes");
    extrawin.focus();
}

function verifySuspendedCustomer() {
    if(confirm("Please note that you should ONLY suspend a customer for a serious violation of policy, such as failing to pay for or show up for an order.  Frivolous use of this tool to suspend customers without cause can result in your restaurant account being cancelled.\n\nAre you sure you want to suspend this customer?")) {
        return true;
    }
    return false;
}

function verifyPaymentGatewayForm(f) {
    var a = document.getElementById("realtime~credit~processing");
    var b = document.getElementById("payment~gateway~provider");
    var c = document.getElementById("payment~gateway~login");
    var d = document.getElementById("payment~gateway~password");
    if(a && b && c && d) {
        if(a.checked == true) {
            if(b.selectedIndex == 0) {
                alert("You must select a payment gateway provider from the drop-down list");
                return false;
            }
            if(TrimAll(c.value) == "" || TrimAll(d.value) == "") {
                alert("Payment Gateway login and password/transaction key are required if enabling real time credit card processing.");
                return false;
            }
        } else {
            c.value = "";
            d.value = "";
            b.selectedIndex = 0;
        }
    }
    return true;
}

function validateGatewayChoice(thisCheckbox) {
    if(thisCheckbox.checked == true) {
        if(confirm("By checking this box, you are indicating that you want real time credit card processing for your online restaurant.\n\nFor this to work, you must provide a valid payment gateway login and password/transaction key below.\n\nYou must already have an active account with one of the payment gateway providers listed below.  For assistance in obtaining such an account, see our support forum for help.\n\Do you wish to proceed?")) {
            return true;
        }
    } else {
        if(confirm("By deselecting this box, you are indicating that you do NOT wish to process credit card payment in real time.  Credit card numbers, if accepted by your restaurant, will be forwarded to you rather than processed on our server.  Do you wish to proceed?")) {
            var a = document.getElementById("payment~gateway~login");
            var b = document.getElementById("payment~gateway~password");
            if(a && b) {
                a.value = "";
                b.value = "";
            }
            return true;
        }
    }
    return false;
}

//-->