
/* 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 -
 */

/* - mark_special_links.js - */
/* Scan all links in the document and set classes on them if
 * mark external links is turned on and
 * they point outside the site, or are special protocols.
 * Also implements new window opening for external links.
 * To disable this effect for links on a one-by-one-basis,
 * give them a class of 'link-plain'
 */

function scanforlinks() {
    // first make external links open in a new window, afterwards do the
    // normal plone link wrapping in only the content area

    if (typeof external_links_open_new_window == 'string')
        var elonw = external_links_open_new_window.toLowerCase() == 'true';
    else elonw = false;

    if (typeof mark_special_links == 'string')
        var mslinks = mark_special_links.toLowerCase() == 'true';
    else mslinks = false;

    var url = window.location.protocol + '//' + window.location.host;

    if (elonw)
        // all http links (without the link-plain class), not within this site
        jq('a[href^=http]:not(.link-plain):not([href^=' + url + '])')
            .attr('target', '_blank');

    if (mslinks) {
      var protocols = /^(mailto|ftp|news|irc|h323|sip|callto|https|feed|webcal)/;
      var contentarea = jq(getContentArea());

      // All links with an http href (without the link-plain class), not within this site,
      // and no img children should be wrapped in a link-external span
      contentarea.find(
          'a[href^=http]:not(.link-plain):not([href^=' + url + ']):not(:has(img))')
          .wrap('<span></span>').parent().addClass('link-external')
      // All links without an http href (without the link-plain class), not within this site,
      // and no img children should be wrapped in a link-[protocol] span
      contentarea.find(
          'a[href]:not([href^=http]):not(.link-plain):not([href^=' + url + ']):not(:has(img))')
          .each(function() {
              // those without a http link may have another interesting protocol
              // wrap these in a link-[protocol] span
              if (res = protocols.exec(this.href))
                  jq(this).wrap('<span></span>').parent().addClass('link-' + res[0]);
          });
    }
};
jq(scanforlinks);


/* - collapsiblesections.js - */
// http://www.internationalhousedavis.org/portal_javascripts/collapsiblesections.js?original=1
function activateCollapsibles(){jq('dl.collapsible:not([class$=Collapsible])').find('dt.collapsibleHeader:first').click(function(){var c=jq(this).parents('dl.collapsible:first');if(!c)return true;var t=c.hasClass('inline')?'Inline':'Block';c.toggleClass('collapsed'+t+'Collapsible').toggleClass('expanded'+t+'Collapsible')}).end().each(function(){var s=jq(this).hasClass('collapsedOnLoad')?'collapsed':'expanded';var t=jq(this).hasClass('inline')?'Inline':'Block';jq(this).removeClass('collapsedOnLoad').addClass(s+t+'Collapsible')})};jq(activateCollapsibles);

