$(document).ready(function(){
    $("a[rel='photo-gallery']").colorbox({transition:"elastic"});
    $('div.photos').cycle({
        fx:    'fade',
        speed:  1500,
        timeout: 1000,
        pause: 1
     });

     $("input.date").datepicker({ dateFormat: 'yy-mm-dd' });
     $("input.datetime").datetimepicker({
         dateFormat: 'yy-mm-dd',
         timeFormat: 'hh:mm',
         stepHour: 1,
         stepMinute: 1
    });

     $("div.photo-year").click(function() {
         $("ul", this).toggle(300);
     });

     $('a.boxy').live('click', function(e) {
         var url = $(this).attr('href');
         var title = $(this).attr('title');

         e.preventDefault();
         e.stopPropagation();

         Boxy.load(url, {
             title: title,
             closable: true,
             afterShow: function() {
                 var box = this;

                 $('#email-registration').bind('submit', function(e) {
                     e.preventDefault();
                     e.stopPropagation();

                     var form   = $(this);
                     var action = form.attr('action');
                     var params = form.serialize()
                     $.post(action, params, function(json) {
                         console.log(json);
                         $("#registration-result").text(json);
                     }, 'json');
                 });
             }
         });
     });
});

