/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

function openpopup(url)
{
    window.open(url, 'coupon', 'status=0,toolbar=1,location=0,menubar=1,directories=0,resizable=1,scrollbars=1,height=500,width=700');
}

function loginToPrintCoupon(http_tmp, coupon_guid) {
    // drop a 30-day cookie with the coupon's guid on the user's machine
    var date = new Date();
    date.setTime(date.getTime()+(30*24*60*60*1000));
    var expires = '; expires=' + date.toGMTString();
    document.cookie = 'glickin_coupon_request' + '=' + coupon_guid + expires + '; path=/';

    // let them know why they've been redirected, and what to do next
    alert('You must be a registered user in order to print coupons. Please press "OK" to go to the registration page.');

    // and forward them to the registration page
    document.location = http_tmp + 'account/register.php';
}

function printCoupon(url, user, coupon) {
    // post the user to make sure they really want to delete this comment
    $.post(url,{
        'user_id': user,
        'coupon_id': coupon
    });
    //return true;
    window.print();
}