Date.format = 'yyyy-mm-dd';
jQuery.fn.exists = function(){return jQuery(this).length>0;}


 $(document).ready(function(){
    $('.pickdate').datePicker({
        clickInput:true, startDate:'2000-01-01'
    });

    $(".picktime").timePicker({
        startTime: "08.00",
        endTime: "17.00",
        show24Hours: false,
        separator:'.',
        step: 15
    });


    if ($('#slideshow').exists()) {
        $('#slideshow').cycle({
            speed: 5200,
            fx: 'scrollUp',
            speedIn: 300
        });
    }

    if ($('textarea#content').exists()) {
        CKEDITOR.replace('content', {
            filebrowserBrowseUrl : '/administer/browse/'
        });

    }


    $('#content_body_inside img').each( function() {
        var thiscaption = $(this).attr('alt');
        position = $(this).position();
        var width = $(this).width();
        var baby = document.createElement('div');
        $(baby).html(thiscaption).addClass('caption');
        $(this).before(baby);
    });


    if ($('#middle_container_2').length != 0) {
        var section_height = $('#section_menu').height();
        var body_height = $('#content_body').height();
        var banners_height = $('#banners').height();
        // alert('section_height = ' + section_height + '\nbody_height = ' + body_height + '\nbanners_height = ' + banners_height);
        var highest = section_height;
        if (body_height > highest) {
            highest = body_height;
        }
        if (banners_height > highest) {
            highest = banners_height;
        }
        // alert(highest); // sanity check
        $('#main').height(highest+60);
    }

 });

