function FrypeSay(title, url, titlePrefix ){
    window.open(
        'http://www.frype.lt/say/ext/add.php?title=' + encodeURIComponent(title) +
        '&link=' + encodeURIComponent( url ) +
        (titlePrefix ? '&titlePrefix=' + encodeURIComponent( titlePrefix ) : ''),
        '',
        'location=1,status=1,scrollbars=0,resizable=0,width=530,height=400'
        );
    return false;
}


var InvitationBlock = new Class({
	
    Implements: Options,
	
    options: {
        button_id: 'invitation_change_btn',
        image_id: 'invitation_btn_image',
        value: 'Turi tai pamatyti!',

        name: 'invitation',
        container_id: 'invitation_popup_outbox',
        //Paslėpimo mygtukas (id)
        button_hide: 'invitation_hide',
        //Atidarymo mygtukas (klasė)
        button_show: 'invitation_show'
    },


    slider: null,
	
    /**
     * Konstruktorius
     */
    initialize: function(options) {
        this.setOptions(options);
        this.initAnimation();
        $(this.options.name + '_submit').addEvent('click', this.submit.bind(this));
    },

    initAnimation: function() {
        this.slider = new Fx.Slide('invitation_popup_inbox', {
            onComplete: function() {
                $('invitation_popup_outbox').getElements('div')[0].style.height = "auto";
            }
        });


        if ($(this.options.button_hide)) {
            $(this.options.button_hide).addEvent('click', function(e) {
                e = new Event(e);
                this.slider.slideOut();
                e.stop();
                return false;
            }.bind(this));
        }


        var show_elements = $$('.invitation_show');
        show_elements.each(function(el){
            el.addEvent('click', function(e) {
                e = new Event(e);
                $(this.options.name + '_to').focus();
                this.slider.toggle();
                e.stop();
                return false;
            }.bind(this));
        }.bind(this));
    },


    slideToBox: function() {
        var fx = new Fx.Scroll(window).toElement(this.options.container_id);
    },

    hideBox: function() {
        if (this.slider) {
            this.slider.hide();
        }
    },
	
    submit: function() {
        var submitForm = true;
        var reEmail = new RegExp("[^@]{1,64}@[^@]{1,255}");


        if ($('invitation_error_1')) {
            $('invitation_error_1').className = "hide";
            if($(this.options.name + '_form').email.value.search(reEmail) == -1) {
                $('invitation_error_1').className = "show";
                submitForm = false;
            }
        }

        if ($('invitation_error_3')) {
            $('invitation_error_3').className = "hide";
            if($(this.options.name + '_form').from.value.search(reEmail) == -1) {
                $('invitation_error_3').className = "show";
                submitForm = false;
            }
        }

        if ($('invitation_error_2')) {
            $('invitation_error_2').className = "hide";
            if($(this.options.name + '_form').message.value == "") {
                $('invitation_error_2').className = "show";
                submitForm = false;
            }
        }
        
        if (submitForm) {
            $(this.options.name + '_form').submit();
        }
		
        return false;
    },
	
    /**
     * Išblendina sėkmingai išsiųstos žinutės pranešimą.
     */
    fadeOutSuccess: function() {
        var element_id = this.options.name + '_success';
        var fx = new Fx.Slide(element_id);
		
        fx.slideOut('vertical');
    },
	
    injectSuccessFader: function() {
        var element_id = this.options.name + '_success';

        if($(element_id)) {
            setTimeout(this.fadeOutSuccess.bind(this), 5000);
        }
    }
});
