function choiceOfGoods(action, product_type, product_id, price, currency, quantity_id) {
    var req = new JsHttpRequest();
    req.onreadystatechange = function() {
        if (req.readyState == 4) {
            if(req.responseText!='') document.getElementById('purch_div').innerHTML = req.responseText;
        }
    }
    
    var host = location.protocol+'//'+location.hostname+'/'+'lib/request/';
    req.open(null, host+'choice_of_goods.php', true);
    
    if(action=='add') {
        var quantity = document.getElementById(quantity_id).value;
        req.send({action:action, product_type:product_type, product_id:product_id, price:price, currency:currency, quantity:quantity});
    } else {
        req.send({action:action, product_type:product_type, product_id:product_id});
    }
}

function formAdressList() {
    var tmp = '';
    var ha_list = '';
    
    var hidden_adress = document.getElementById('hidden_email_adress').value;
    if(hidden_adress!='') {
        var hidden_adress_array = hidden_adress.split(',');
        for(var i=0;i<hidden_adress_array.length;i++){
            if(hidden_adress_array[i]!='') {
                tmp = tmp+'<input type="checkbox" checked="checked" name="adress[]" value="'+hidden_adress_array[i]+'"> '+hidden_adress_array[i]+'<br />';
                ha_list = ha_list+','+hidden_adress_array[i];
            }
            
        }
    }
    var adress = document.getElementById('email_adress').value; 
    if(adress!='') {
        var adress_array = adress.split(',');
        for(var i=0;i<adress_array.length;i++) {
            if(adress_array[i]!='') {
                tmp = tmp+'<input type="checkbox" checked="checked" name="adress[]" value="'+adress_array[i]+'"> '+adress_array[i]+'<br />';
                ha_list = ha_list+','+adress_array[i];
            }
        }
    }
    document.getElementById('hidden_email_adress').value = ha_list.substring(1);
    document.getElementById('adress_list').innerHTML = tmp;
    document.getElementById('adress_list').style.display = 'block';
    document.getElementById('email_adress').value = '';
}
