if ( typeof( NicoTyres ) == 'undefined' ) {
    NicoTyres = new Object();
}
NicoTyres.cosCumparaturi = new Object();
NicoTyres.cosCumparaturi.adauga = function( id ) {
    var windowSize = window.getSize();
    $( 'wrapper_cos' ).style.top = ( windowSize.vScroll + 200 ) + 'px';
    new Ajax.Updater( 'raspuns_cos',
                      NicoTyres.baseUrl + 'cos_de_cumparaturi/adauga/',
                      { asynchronous:   true,
                        method:         'post',
                        parameters:     'cantitate=' + $( 'anv_' + id ).value + '&id=' + id + '&stoc=' + $( 'anv_stoc' ).value + '&mod=' + mod,
                        onSuccess:      function() {
                                            NicoTyres.cosCumparaturi.actualizeaza();
                                            $( 'wrapper_cos' ).show();
                                        } } );
}
NicoTyres.cosCumparaturi.sterge = function( id ) {
    if ( confirm( 'Confirmaţi ştergerea acestor produse din coşul de cumpărături?' ) ) {
        new Ajax.Request( NicoTyres.baseUrl + 'cos_de_cumparaturi/sterge/',
                          { asynchronous:   true,
                            method:         'post',
                            parameters:     'id=' + id,
                            onSuccess:      function( t ) {
                                                NicoTyres.cosCumparaturi.actualizeaza();
                                            } } );
    }
}
NicoTyres.cosCumparaturi.actualizeaza = function() {
    new Ajax.Updater( 'cos_de_cumparaturi',
                      NicoTyres.baseUrl + 'cos_de_cumparaturi/',
                      {
                        method:         'post',
                        asynchronous:   true,
                        parameters:     '&mod=' + mod
                      }
                    );
}

NicoTyres.FormularComanda = new Object();

NicoTyres.FormularComanda.trimite = function( formId ) {
    new Ajax.Updater( 'container_formular_comanda',
                      NicoTyres.baseUrl + 'anvelope/trimite_comanda/',
                      { asynchronous:   true,
                        post:           'post',
                        evalScripts:    true,
                        parameters:     Form.serialize( formId ) } );
}

NicoTyres.FormularComandaOnline = new Object();

NicoTyres.FormularComandaOnline.trimite = function() {
    new Ajax.Request( NicoTyres.baseUrl + 'anvelope/trimite_comanda_facuta_online',
                        {
                            aysnchronous: false,
                            post: 'post'
                        }
    );
}

NicoTyres.FormularComandaCompanie = new Object();

NicoTyres.FormularComandaCompanie.trimite = function() {
    new Ajax.Updater( 'container_formular_comanda',
                        NicoTyres.baseUrl + 'pentru_companii/trimiteComanda',
                        {
                            aysnchronous: true,
                            post: 'post',
                            parameters: Form.serialize( 'formular_comanda' ) }
    );
}

NicoTyres.FormularComanda.afiseaza = function() {
    Effect.toggle( 'container_formular_comanda', 'appear' );
}