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

//gallery titles

    $('.topic').hide();
    $('.image').hover(function(){  
        $('.topic', this).stop(true, true).slideDown(300);
    }, function() {  
        $('.topic', this).stop(true, true).slideUp(300);
    });  
   
//Slideshow
    $('#minigal').cycle({
        fx: 'fade', // choose your transition type, ex: fade, scrollUp, shuffle, etc...
        speed:  3000,
        timeout: 500 
    });

var d=new Date();
    events('/events/'+d.getFullYear()+'/'+('0' + (d.getMonth() + 1)).slice(-2));
});

//delete confirm
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{}
        }
    });
}

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

function events(d) {
    $.ajax({
        type: 'GET',
        url: d,
        success: function(html){
            $('#events').hide().fadeIn(500).html(html);
            $('.pg').click(function(){
                events($(this).attr('rel'));
            });
            $('.mark').hover(function(){
                $('.event', this).stop(true, true).fadeIn(300);
            }, function() {
                $('.event', this).stop(true, true).fadeOut(300);
            });
            $('.event').hide();
        }
    });
}

//tinyMCE
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"
});

