// *************************************************************************
// SETTINGS
// *************************************************************************
var price_widget_file = '/price_widget/price_widget.php';
var price_widget_submit_file = '/price_widget/price_widget_submit.php';
// *************************************************************************
var widget_index = 0;

function setCookie(c_name, value, expiredays) {
    var exdate = new Date();
    exdate.setDate(exdate.getDate() + expiredays);
    document.cookie = c_name + "=" + escape(value) +
    ((expiredays == null) ? "": ";expires=" + 
        exdate.toGMTString()) + ";path=/";
}

function initPriceWidget(article_id, base_price) {
    document.write('<div id="price_widget_' + widget_index + '" class="price_widget"></div>');
    var this_widget_index = widget_index;

    $.getScript(price_widget_file + '?article_id=' + article_id + '&widget_id=' + this_widget_index + '&base_price=' + base_price);

    widget_index += 1;
}

function submitPrice(widget_id, article_id, base_price) {
    var user_appraisal = $('#price_' + widget_id).val();
    if (user_appraisal == '' || isNaN(user_appraisal)) {
        alert('Please enter a number');
    }
    else {
        $.getScript(price_widget_submit_file + '?article_id=' + article_id + '&widget_id=' + widget_id + '&user_appraisal=' + user_appraisal + '&base_price=' + base_price);
    }
}
