$(document).ready(function() {
    $(".fancys").fancybox({
        'zoomOpacity'       : true,
        'padding'           : 2,
        'overlayShow'       : true,
        'zoomSpeedIn'       : 200,
        'zoomSpeedOut'      : 200,
        'overlayColor'      : '#000',
        'overlayOpacity'    : 0.5
    });

    $('#join .button').click(function(){
        $.ajax({
            type: 'POST',
            url: '/maillist',
            data: { email : $('#mail').get(0).value},
            success: function(html){
                $('.join_txt').hide();
                $('.join_txt').fadeIn().html(html);
                $('#mail').val('your e-mail');
            }
        });
    return false;
    });
    $('#mail').focus(function() {

      $(this).val() == '';

    });
    $('#top').cycle({
        fx: 'fade', // choose your transition type, ex: fade, scrollUp, shuffle, etc...
        speed:  1000,
        timeout: 5000,
        next: '#next',
        prev: '#prev'
    });

    $('#datepick').datepick({
        buttonImageOnly: true,
        dateFormat: 'yy-mm-dd'
    });

    $('.topic').hide();
    $('.image').hover(function(){
        $('.topic', this).stop(true, true).slideDown(300);
    }, function() {
        $('.topic', this).stop(true, true).slideUp(300);
    });

});

function removeUser(id){
    $.prompt('Dzēst ierakstu?',{
        buttons: { Ok: true, Cancel: false },
        prefix:'cleanblue',
        focus: 1,
        top:'35%',
        opacity: '0.6',
        overlayspeed: 'fast',
        callback: function(v,m,f){
            if(v){
                document.location.href=''+id;
            }
            else{}
        }
    });
}

tinyMCE.init({
                mode : "textareas",
                plugins : "table,paste",

                file_browser_callback : "tinyBrowser",

                paste_create_linebreaks : false,
                paste_create_paragraphs : false,
                paste_remove_spans : true,
                paste_remove_styles : true,
                paste_use_dialog : true,
                paste_strip_class_attributes : "all",

                forced_root_block : false,
                force_br_newlines: true,
                force_p_newlines : true,
                convert_urls : true,

                theme : "advanced",
                theme_advanced_buttons1 : "bold,italic,underline,separator,strikethrough,justifyleft,justifycenter,justifyright,justifyfull,bullist,numlist,undo,redo,link,unlink,separator,tablecontrols",
                theme_advanced_buttons2 : "removeformat,separator,sub,sup,separator,pasteword, image, code",
                theme_advanced_buttons3 : "",
                theme_advanced_buttons3_add_before : "tablecontrols,separator",
                theme_advanced_font_sizes : "10px,11px,12px,13px,14px,15px,16px,17px",
                theme_advanced_toolbar_location : "top",
                theme_advanced_toolbar_align : "left"
});

