/* Mootools scripts */
window.addEvent('domready', function() {
    var nlFormEl = document.id( 'newsletter-form' );
    var sendLink = document.id( document.body ).getElements( '.article_horizontal_list .article.newsletter a.send-link' );
    var nlInput = document.id( document.body ).getElements( '.article_horizontal_list .article.newsletter .newsletter-input' );
    if( nlFormEl && sendLink ) {
        options = {
            errorPrefix            : '',
            evaluateOnSubmit       : false,
            evaluateFieldsOnBlur   : false,
            evaluateFieldsOnChange : false
        }
        var nlFormValidator = new Form.Validator( nlFormEl, options);
        sendLink.addEvent('click', function(e){
            e.stop();
            if( nlFormValidator.validate() ) {
                url = nlFormEl.get('action');
                request = new Request.HTML({ url: url, evalScripts: false,
                    onSuccess: function() {
                        nlInput.set( 'value', '' );
                    }
                 }).post( nlFormEl );
            } else {
                alert( 'Email is not valid!' );
            }
        });
    }
});




window.addEvent('domready', function() {

    var sliders = document.id( document.body ).getElements( '.article_horizontal_list .article .slider-picture' );
    sliders.each(function(item){
        var pictureEl = item.getElement( 'a.picture' );
        var titleBgEl = item.getElement( '.title-bg' );
        var titleEl = item.getElement( '.title' );

        titleBgEl.setStyle( 'opacity', 0 );
        titleBgEl.show();
        titleEl.set('tween', {transition: Fx.Transitions.Pow.easeOut});
        height = titleBgEl.getStyle('height').toInt();
        titleBgEl.setStyle( 'height', height );
        titleEl.setStyle('margin-top', height);
        titleBgEl.setStyle( 'opacity', 1 );

        pictureEl.addEvents({
            'mouseover': function(){
               titleEl.tween('margin-top', 0);
            },
            'mouseleave': function(){
               titleEl.tween('margin-top', height);
            }
        });
        titleBgEl.addEvents({
            'mouseover': function(){
               titleEl.tween('margin-top', 0);
            },
            'mouseleave': function(){
               titleEl.tween('margin-top', height);
            }
        });

    });

});





