
/* Merged Plone Javascript file
 * This file is dynamically assembled from separate parts.
 * Some of these parts have 3rd party licenses or copyright information attached
 * Such information is valid for that section,
 * not for the entire composite file
 * originating files are separated by - filename.js -
 */

/* - ++resource++plonetruegallery-portlet.js - */
// http://www.rf-news.de/portal_javascripts/++resource++plonetruegallery-portlet.js?original=1
(function($){$.fn.imagesLoaded=function(callback){var elems=this.filter('img'),len=elems.length;elems.bind('load',function(){if(--len<=0){callback.call(elems,this)}}).each(function(){if(this.complete||this.complete===undefined){var src=this.src;this.src='#';this.src=src}})};
function set_controls_position(container){var width=container.find('img').width();var left=(width/2)-43;container.find('div.gallery-portlet-controls').css("left",left)}
function get_image(link){var linkele=link[0];if(linkele.active!=undefined&&linkele.active){return}
linkele.active=true;var container=link.parents('dl.applied-portlet-gallery');var controls=link.parents('div.gallery-portlet-controls');var portlet_item=link.parents('dd.portletItem');var next=controls.find('span.next a');var prev=controls.find('span.prev a');var img=container.find('img');$.ajax({url:'@@get-image-for-gallery-portlet',data:link.attr('href').split('?')[1],type:'GET',success: function(data,results){eval("var json="+data);var newimg=document.createElement('img');newimg.src=json.src;newimg.width=img.width();newimg=$(newimg);newimg.css('display','none');portlet_item.css('height',img.height());img.fadeOut(1000, function(){img.replaceWith(newimg);newimg.imagesLoaded(function(){portlet_item.animate({height:$(this).height()},500,'linear');$(this).fadeIn(1000, function(){linkele.active=false})},newimg)
var linked=newimg.parent()
linked.attr('href',json['image-link']);linked.attr('title',json['title']);linked.attr('alt',json['description']);next.attr('href',next.attr('href').split('?')[0]+'?'+json['next-url']);prev.attr('href',prev.attr('href').split('?')[0]+'?'+json['prev-url']);set_controls_position(container)})}})}
function get_timeout_ele(portlet){if(portlet.hasClass('portletItem')){portlet=portlet.parent()}
return portlet.find("input.timeout_id")}
function get_timeout_id(portlet){var timeout_id=get_timeout_ele(portlet);if(timeout_id.size()==0){return 0}else{return parseInt(timeout_id.attr('value'))}}
function set_timeout_id(portlet,val){var timeout_id=get_timeout_ele(portlet);if(timeout_id.size()==0){portlet.append('<input type="hidden" name="timeout_id" class="timeout_id" value="'+val+'" />')}else{timeout_id.attr('value',val)}}
function perform_play(portlet){portlet.find('span.next a').trigger('click');set_timeout_id(portlet,setTimeout(function(){perform_play(portlet)},5000))}
function play(portlet){portlet.find('span.play-pause').addClass('timed');set_timeout_id(portlet,setTimeout(function(){perform_play(portlet)},5000))}
function pause(portlet){clearTimeout(get_timeout_id(portlet));portlet.find('span.play-pause').removeClass('timed')}
$(document).ready(function(){$('dl.portletGallery span.next a,dl.portletGallery span.prev a').click(function(){get_image($(this));return false});$('dl.portletGallery span.play-pause').css({'display':'inline'});var portlets=$('dl.portletGallery');portlets.addClass('applied-portlet-gallery');portlets.each(function(){var portlet=$(this);set_controls_position(portlet);if(portlet.hasClass('timed')){play(portlet)}else{pause(portlet)}});$('dl.portletGallery span.play-pause a').click(function(){var portlet=$(this).parent().parent().parent();if(portlet.find('span.play-pause').hasClass('timed')){pause(portlet)}else{play(portlet)}
return false});$('dl.portletGallery').hover(
function(){var controls=$(this).find('div.gallery-portlet-controls:not(.hide)');controls.fadeIn()},
function(){var controls=$(this).find('div.gallery-portlet-controls:not(.hide)');controls.fadeOut()})})})(jQuery);

/* - ++resource++pipbox.js - */
/*****************

   PIPbox tools for attaching JQuery Tools bling to CSS with option
   parameter strings.
   
   This uses overlayhelpers.js in plone.app.jquerytools for most of
   the real work.

*****************/


/******
    pb.doSetup
    parameter: an options object(p)
    options vary by type and subtype of bling.
******/
pb.doSetup = function(p) {
    switch (p.type) {
    case 'overlay':
        jQuery(function() {
            jQuery(p.selector).prepOverlay(p);
        });
        break;
    case 'tabs':
        jQuery(function() {
            var config = p.config || {};
            config.tabs = p.tabs || config.tabs || 'a';
            jQuery(p.tabcontainer).addClass('pbactive').tabs(p.panes, config);
            jQuery(p.panes).addClass('pbactive');
        });
        break;
    }
};


/******
    pb.doConfig
    parameter: a config object(s)
    for JQ Tools global configuration
******/
pb.doConfig = function(p) {
    var tools = jQuery.tools;
    var tool = p.tool;

    if (tool) {
        for (var key in p) {
            if (key != 'tool') {
                tools[tool].conf[key] = p[key];
            }
        }
    }
};


/* - popupforms.js - */
/*jslint browser: true, laxbreak: true */
/*global jQuery */

/******
    Standard popups
******/

var common_content_filter = '#content>*:not(div.configlet),dl.portalMessage.error,dl.portalMessage.info';
var common_jqt_config = {fixed:false,speed:'fast',mask:{color:'#000',opacity: 0.4,loadSpeed:0,closeSpeed:0}};
jQuery.extend(jQuery.tools.overlay.conf, common_jqt_config);


jQuery(function($){

    if (jQuery.browser.msie && parseInt(jQuery.browser.version, 10) < 7) {
        // it's not realistic to think we can deal with all the bugs
        // of IE 6 and lower. Fortunately, all this is just progressive
        // enhancement.
        return;
    }
    
    // method to show error message in a noform
    // situation.
    function noformerrorshow(el, noform) {
        var o = $(el);
        var emsg = o.find('dl.portalMessage.error');
        if (emsg.length) {
            o.children().replaceWith(emsg);
            return false;
        } else {
            return noform;
        }
    }

    // After deletes we need to redirect to the target page.
    function redirectbasehref(el, responseText) {
        var mo = responseText.match(/<base href="(.+?)"/i);
        if (mo.length === 2) {
            return mo[1];
        }
        return location;
    }

    // login form
    $('#portal-personaltools a[href$=/login], #portal-personaltools a[href$=/login_form], .discussion a[href$=/login_form]').prepOverlay(
        {
            subtype: 'ajax',
            filter: common_content_filter,
            formselector: 'form#login_form',
            noform: function () {
                if (location.href.search(/pwreset_finish$/) >= 0) {
                    return 'redirect';
                } else {
                    return 'reload';
                }
            },
            redirect: function () {
                var href = location.href;
                if (href.search(/pwreset_finish$/) >= 0) {
                    return href.slice(0, href.length-14) + 'logged_in';
                } else {
                    return href;
                }
            }
        }
    );

    // contact form
    $('#siteaction-contact a').prepOverlay(
        {
            subtype: 'ajax',
            filter: common_content_filter,
            formselector: 'form',
            noform: function(el) {return noformerrorshow(el, 'close');}
        }
    );

    // display: select content item / change content item
    $('#contextSetDefaultPage, #folderChangeDefaultPage').prepOverlay(
        {
            subtype: 'ajax',
            filter: common_content_filter,
            formselector: 'form[name="default_page_form"]',
            noform: function(el) {return noformerrorshow(el, 'reload');},
            closeselector: '[name=form.button.Cancel]',
            width:'40%'
        }
    );

    // advanced state
    $('dl#plone-contentmenu-workflow a#advanced').prepOverlay(
        {
            subtype: 'ajax',
            filter: common_content_filter,
            formselector: 'form[action$="/content_status_history"]',
            noform: function(el) {return noformerrorshow(el, 'reload');},
            closeselector: '[name=form.button.Cancel]'
        }
    );
    
    // Delete dialog
    $('dl#plone-contentmenu-actions a#delete').prepOverlay(
        {
            subtype: 'ajax',
            filter: common_content_filter,
            formselector: 'form[action~="delete_confirmation"]',
            noform: function(el) {return noformerrorshow(el, 'redirect');},
            redirect: redirectbasehref,
            closeselector: '[name=form.button.Cancel]',
            width:'50%'
        }
    );

    // Rename dialog
    $('dl#plone-contentmenu-actions a#rename').prepOverlay(
        {
            subtype: 'ajax',
            formselector: 'form[action="folder_rename_form"]',
            filter: common_content_filter,
            closeselector: '[name=form.button.Cancel]',
            width:'40%'
        }
    );

    // Select default view dialog
    $('dl#plone-contentmenu-display a#contextSetDefaultPage').prepOverlay(
        {
            subtype: 'ajax',
            filter: common_content_filter,
            formselector: 'form[action$="select_default_page"]',
            noform: function(el) {return noformerrorshow(el, 'reload');},
            closeselector: '[name=form.button.Cancel]'
        }
    );


    if (ploneFormTabbing.initializeForm && ! $.fn.ploneTabInit) {
        // emulate Plone 4 form tabbing in Plone 3.x
        $.fn.ploneTabInit = function(pbo) {
            return this.each(function() {
                var item = $(this);

                item.find("form.enableFormTabbing,div.enableFormTabbing").each(ploneFormTabbing.initializeForm);
                item.find("dl.enableFormTabbing").each(ploneFormTabbing.initializeDL);
            });
        };
    }


});



