
Contact = new Class( {
    trimite: function() {
        var formular = $( 'formContact' );
        var updateCnt = $( 'cntFormContact' );
        var buton = $( 'btTrimiteFormContact' );
        formular.set( 'send', {
            evalScripts: true,
            onRequest: function() {
                formular.setStyle( 'opacity', 0.5 );
            },
            onComplete: function() {
                if ( updateCnt ) {
                    var txt = this.response.text;
                    $( updateCnt ).set( 'html', txt );
                    if ( ( txt.indexOf('<!--succes-->') != -1 ) && ( buton ) ) {
                        buton.setStyle( 'display', 'none' );
                        $( 'cntFooter' ).removeClass( 'footer_oferta' );
                        //$( 'cntFooter' ).addClass( 'footer_toate' );
                        $( 'cntFooter' ).set( 'id', 'cntFooterToate' );
                    }
                    else {
                        var calDataInceput = new Calendar( { RezervareDataInceput: 'Y-m-d' }, {} );
                        var calDataSfarsit = new Calendar( { RezervareDataSfarsit: 'Y-m-d' }, {} );
                    }
                }
                formular.setStyle( 'opacity', 1 );
            }
        } );

        formular.send();
    }
} );

Cautare = new Class( {
    cautaOrase: function() {
        var taraId = $( 'StatiuneTaraId' ).options[ $( 'StatiuneTaraId' ).selectedIndex ].value;
        var myRequest = new Request( {
            url: baseUrl + 'Oferte/gasesteStatiuni',
            data: 'taraId=' + taraId,
            update: 'header',
            onComplete: function() {
                var txt = this.response.text;
                $( 'cntStatiuneId' ).set( 'html', txt );
                $( 'StatiuneId' ).addEvent( 'change', function() {
                    var statiuneId = $( 'StatiuneId' ).options[ $( 'StatiuneId' ).selectedIndex ].value;
                    var myRequest = new Request( {
                        url: baseUrl + 'Oferte/gasesteMijloace',
                        data: 'statiuneId=' + statiuneId,
                        onComplete: function() {
                            var txt = this.response.text;
                            $( 'cntMijlocTransportId' ).set( 'html', txt );
                        }
                    } );
                    myRequest.send();
                } );
            }
        } );
        myRequest.send();
    }/*,
    cautaMijloace: function() {
//         alert( 'ceva' );
        var statiuneId = $( 'StatiuneId' ).options[ $( 'StatiuneId' ).selectedIndex ].value;
        var myRequest = new Request( {
            url: baseUrl + 'Oferte/gasesteMijloace',
            data: 'statiuneId=' + statiuneId,
            onComplete: function() {
                var txt = this.response.text;
                $( 'cntMijlocTransportId' ).set( 'html', txt );
            }
        } );
        myRequest.send();
    }*/
} );

Newsletter = new Class( {
    aboneaza: function() {
        $( 'formNewsletter' ).set( 'send', {
            onComplete: function() {
                var txt = this.response.text;
                MochaUI.responseWindow = function() {
                    new MochaUI.Window( {
                        id: 'mywindow',
                        title: '',
                        loadMethod: 'html',
                        content: txt,
                        width: 300,
                        height: 100
                    } );
                };
                MochaUI.responseWindow();
            }
        } );
        $( 'formNewsletter' ).send();
    }
} );
