//var coupon_print = 0;

function checkAddressChange() {

    if ($("#store_register_address_street").val() != org_address_street ||
        $("#store_register_address_code").val() != org_address_code ||
        $("#store_register_address_city").val() != org_address_city ||
        $("#store_register_address_state").val() != org_address_state) {

        $("#mapRefreshButton").removeAttr("disabled");
    } else {
        $("#mapRefreshButton").attr("disabled", "true");
    }

}


function warnUser(msg) {
    alert(msg);
}

function infoUser(msg) {
    //alert(msg);
}

function couponHighlight(coupon_box, mode) {
    //$(coupon_box).
}

function couponPrint(win_url, win_name) {
    var win_w = 700;
    var win_h = 500;
    newWindow(win_url, win_name, win_w, win_h);
}

function couponSend(win_url, win_name) {
    var win_w = 700;
    var win_h = 400;
    newWindow(win_url, win_name, win_w, win_h);
}

function couponFeedback(win_url, win_name) {
    var win_w = 630;
    var win_h = 450;
    newWindow(win_url, win_name, win_w, win_h);
}

function newWindow(win_url, win_name, win_w, win_h, full) {
    if (win_w > screen.width) {
        win_w = screen.width;
        win_h = screen.height;
    }
    pos_l = (screen.width - win_w) /2;
    pos_t = (screen.height - win_h) /2;
    if (full == true) {
        var new_window = open(win_url,'','scrollbars=yes,resizable=yes,toolbar=1,location=1,status=1,menubar=1,left=' + pos_l + ',top = ' + pos_t + ',width=' + win_w + ',height=' + win_h);
    } else {
        var new_window = open(win_url,'','scrollbars=yes,resizable=yes,left=' + pos_l + ',top = ' + pos_t + ',width=' + win_w + ',height=' + win_h);
    }

    new_window.focus();

}

function printCoupon(mode) {
    if (mode == 1) {
        $("#coupon_print_footer").hide();
        $("#coupon_print_details").show();
  //      coupon_print = 1;
        print();
    } else {
   //     if (coupon_print == 1) {
   //         coupon_print = 0;
   //     } else {
        setTimeout('showPrintButtons()', 1000);
  //      }
    }
}


function showPrintButtons() {
    $("#coupon_print_footer").show();
    $("#coupon_print_details").hide();
}


function filterStores() {
    var typed = $("#search_store_name").val();
    var regexp = new RegExp(typed, "i");
    var store_list_filtered = new Array();
    for ( var i in store_list ) {
        if (store_list[i].match(regexp)) {
            //alert(store_list[i]);
            store_list_filtered[i] = store_list[i];
        }
    }
    $("#search_store_select").removeOption(/./);
    $("#search_store_select").addOption(store_list_filtered, false);
}

function showMap(show) {
    if (show == 1) {
        $("#map_div").show();
        $("#show_map").hide();
        var map_url = $("#map_url").text();
        if (map_url.length > 0) {
            $("#map_url").text('');
            $("#map_img").attr('src', map_url);
        }
    } else {
        $("#map_div").hide();
        $("#show_map").show();
    }
}

function showShareIcons(coupon_id) {
    $("#share_box_" + coupon_id).show("fast");
}

function hideShareIcons(coupon_id) {
    $("#share_box_" + coupon_id).hide("slow");
}