Kibero.addProduct = function( id,fid) {
    var oid = id+(fid ? '-'+fid : '')
    new Request({
        url: 'ajax.index.php?comp=goods&act=order&task=add',
        async: false,
        onRequest: function() {Kibero.stateLoading(true)},
        onSuccess: function( responseText) {
            if( Kibero.checkResponseError( responseText, true)) return
            responseText = Kibero.trim(responseText)
            $('order-count').set('html','в корзине товаров: '+responseText)
            if( confirm( 'Спасибо, товар успешно добавлен в корзину!'
                +'\n\nтоваров в корзине: '+responseText
                +'\nПерейти в корзину и к оформлению заказа?'
                +'\n\n"ОК" - перейти\n"Отмена" (или ESC) - остаться' 
            )) document.location.href = $('base_tag').href+'index.php?comp=goods&act=order'
        },
        onFailure: function() {Kibero.error( Kibero.error_default+Kibero.try_again)},
        onComplete: function() {Kibero.stateLoading(false)}
    }).send('&id='+id+'&fid='+fid+'&min_count='+$('min_count'+oid).value+'&count='+$('count'+oid).value)
}
Kibero.orderRecount = function() {
    Kibero.getForm().set('send', {
        url: 'ajax.index.php',
        async: false,
        onRequest: function() {Kibero.stateLoading(true)},
        onSuccess: function( responseText) {
            if( Kibero.checkResponseError( responseText, true)) return
            var resp = responseText.split('@total_count@')
            $('basket').set('html', resp[0])
            $('order-count').set('html', 'в корзине товаров: '+(resp[1] ? resp[1] : 0))
        },
        onFailure: function() {Kibero.error( Kibero.error_default+Kibero.try_again)},
        onComplete: function() {Kibero.stateLoading(false)}
    }).send()
    
}
Kibero.payer_type = function() {
    var value = Kibero.getForm().payer_type[0].checked ? '1' : '0'
    new Request({
        url: 'ajax.index.php?comp=goods&act=order&task=payer_type',
        async: false,
        onRequest: function() {Kibero.stateLoading(true)},
        onSuccess: function( responseText) {
            if( Kibero.checkResponseError( responseText, true)) return
            eval( responseText)
        },
        onFailure: function() {Kibero.error( Kibero.error_default+Kibero.try_again)},
        onComplete: function() {Kibero.stateLoading(false)}
    }).send('value='+value)
}
Kibero.orderSubmit = function() {
    if( !Kibero.configValidator.validate()) return
    Kibero.getForm().set( 'target', '_self');
    Kibero.submitform( 'save')
}
Kibero.orderCustomSubmit = function() {
    if( !Kibero.configValidator.validate()) return
    Kibero.stateLoading(true)
    Kibero.getForm().set( 'action', 'ajax.index.php');
    Kibero.submitform( 'save')
}
