function goToPay()
{
    window.location = 'http://'+url+'/oneclick/1/cart.htm';
}

function savePaymentSystemToSession(payment_system)
{
    $.post(
        window.location.protocol+"//"+url+"/index.php",
        { 
            s:      "ajax",
            ajax:   "ecommertc",  
            func:   "savePaymentSystemToSession",
            payment_system:     payment_system
        }
    );
}

function checkSum(id)
{ 
    var amount = floatval(0);
    var sum = floatval(0); 
    var item_id = 0;
    var mult_1 = floatval(0);
    var mult_2 = floatval(0);
    var new_all_am = floatval(0);
    var item_count = 0;
    //var tmp = 0;
    var item_count_n = 0;
    
    $('span[title="allamount"]').each
    (
        function(id)
        {
            item_id = (this.id).replace(/all_amount_/, "");
            item_count = parseInt( $('#num_'+item_id).val());
            
            $.post(
                window.location.protocol+"//"+url+"/index.php",
                { 
                    s:      "ajax",
                    ajax:   "ecommertc",  
                    func:   "updateProductsCountInCart",
                    product_id:   item_id,
                    count: item_count
                }
            );
            
            //alert(item_count);
            new_all_am =  floatval( ( $('#amount_'+item_id).html() ) * ( $('#num_'+item_id).val() ) );
            sum = floatval( $('#all_amount_'+item_id).html(new_all_am) );
            amount = amount + new_all_am;
            
            //tmp = ( $('#tmp_count_'+item_id).html(new_all_am) );
            item_count_n = item_count_n + item_count;
            //alert(item_count_n);
            
            if ( ($('#num_'+item_id).val() )  == '0')
            {
               $('#num_'+item_id).parent().parent().parent().remove();
            }
        }
    );
    
    $('#amount').html(amount);
    $('span.amount').html(amount);
    $('span.it_count').html(item_count_n);
}


/*
function checkSum(id)
{
    var quantityField = $('#num_'+id);
    var price = floatval($('#amount_'+id).html());
    var quantity = parseInt(quantityField.val());
    
    if (!quantity)
    {
        quantity = 1;
    }
    if (quantity < 0)
    {
        quantity = 1;
    }
    quantityField.val(quantity);
    
    $('#all_amount_'+id).html(floatval(quantity * price));
    
    var amount = floatval(0);
    
    $('span').each
    (
        function(i)
        {
            if( this.title == 'allamount' )
            {
                var sum = 0;
                sum = floatval( $('#'+this.id).html() );
                amount = amount+sum;
            }
        }
    );
    
    $('#amount').html(amount);
}
*/


function subByPaySys()
{
    $('#prodedit').append('<input type="hidden" name="bypaysys" value="1" />');
    $('#prodedit').submit();
}


function checkAuthorization()
{
    $.post(
        window.location.protocol+"//"+url+"/index.php",
        { 
            s:      "ajax",
            ajax:   "login",  
            func:   "loginAjax",
            login:   $("#login").val(),
            password: $("#password").val()
        },
        function (data)
        {
            if  (data == 1)
            {
                //$("#payment_system_local").attr("disabled", "");
                $(':radio').attr("disabled", "");
                $("#div_login_form").hide();
                $("div.ico_arrow_here").hide();
                $("#smb_div").click(function() {
                    $('#payment_form').submit();
                });
                //$("div.buttonRightSectionDetailed").click('payment_form.submit()');
                //onClick="payment_form.submit()"
            }
            else
            {
                $("#div_login_error").html(translates["wrong_login_passw"]);
            }
        }
    );
}

function resetCountVal(prod_id)
{
    $('#num_'+prod_id).val('0'); 
}

