function shopReportShowDailyReport(button, report)
{
    if (!shopReportShowDailyReport.form) {
        var today = new Date();
        var date = today.getDate() + "/" + (today.getMonth() + 1) + "/" + today.getFullYear();
        var formHtml = "<label>Report for Date:</label><input type='text' value='" + date + "' id='txtDailyOrderDate' onclick='ApOnCalendar.pop(this);'>" +
        "<input type='button' value='Show' onclick='shopReportShowDailyReportByDate($(\"txtDailyOrderDate\").value);'><input type='button' value='Cancel' onclick='shopReportCancelDailyOrderByDate();'>";
        shopReportShowDailyReport.form = new shopReportForm(formHtml);
    }
    shopReportShowDailyReport.report = report;
    var form = shopReportShowDailyReport.form;
    form.show(button.getAbsPosition());
}

function shopReportShowDailyReportByDate(date)
{
    shopReportShowDailyReport.form.hide();
    //bring up report
    var date = /^(([0]?[1-9]{1})|(1[0-9]{1})|(2[0-9]{1})|(3[01]{1}))\/(([0]?[1-9])|(1[012]))\/(20[0-9]{2})$/(date);
    var uriDate = "/" + date[9] + "-" + date[6] + "-" + date[1] + "/";
    var report = shopReportShowDailyReport.report;
    if (report == "labels") {
        var uri = "/shop_report/daily_labels" + uriDate;
    } else if (report == "products") {
        var uri = "/shop_report/daily_products" + uriDate;
    }
    window.open(uri);
}

function shopReportCancelDailyOrderByDate(date)
{
    shopReportShowDailyReport.form.hide();
}

/**
 * Form like object
 */
function shopReportForm(html)
{
    this.div = document.body.appendDiv("shopReportForm");
    this.div.innerHTML = html;
    this.hide();
}

shopReportForm.prototype.show = function(position)
{
    this.div.style.display = "block";
    this.div.setPosition(position.x, position.y);
}

shopReportForm.prototype.hide = function()
{
    this.div.style.display = "none";
}

