// $Id: jquery.textsize.js,v 1.3 2009/12/10 23:16:50 christianzwahlen Exp $

(function($) {
  $(document).ready(function(){
    $("a.ts_increase_variable").attr({ href: "#" });
    $("a.ts_decrease_variable").attr({ href: "#" });
    $("a.ts_normal_variable").attr({ href: "#" });
    $("a.ts_increase_fix").attr({ href: "#" });
    $("a.ts_decrease_fix").attr({ href: "#" });
    $("a.ts_normal_fix").attr({ href: "#" });
    function textsizeDisplayCalc(ts_v) {
      if (textsizeDisplay == 1) {
        ts_c = (100 * ts_v / textsizeNormal);
        return Math.round(ts_c);
      }
      else {
        return ts_v;
      }
    }
    function textsizeIncrease(ts_a, ts_b) {
      if (ts_a == textsizeMaximum) {
        return ts_a;
      }
      else {
        return 1*ts_a + 1*textsizeIncrement;
      }
    }
    function textsizeDecrease(ts_a, ts_b) {
      if (ts_a == textsizeMinimum) {
        return ts_a;
      }
      else {
        return 1*ts_a - 1*textsizeIncrement;
      }
    }
    function TSremoveBC(){
      var tsElement = $(textsizeElement + textsizeElementClass);
      var tsClasses = tsElement.attr('class').split(' ');
      for( var i in tsClasses ){
        if( tsClasses[i].substring(0,8) == 'textsize' ){
          tsElement.removeClass( tsClasses[i] );
          break;
        }
      }
    }
    function tsIncrease(){
      TSremoveBC();
      $("#textsize_current").empty();
      $("#textsize_current").append((textsizeNormalDisplay + textsizeIncrementDisplay) + '%');
      $("#textsize_current").attr({ title: textsizeCurrentText + ": " + (textsizeNormalDisplay + textsizeIncrementDisplay) + '%'});
      $(textsizeElement + textsizeElementClass).addClass('textsize-' + (textsizeNormal + textsizeIncrement));
      $(textsizeElement + textsizeElementClass).css("font-size", (textsizeNormal + textsizeIncrement) + "%");
      $.cookie('textsize', textsizeIncrease(textsizeNormalDisplay, textsizeIncrementDisplay), { expires: textsizeCookieExpires, path: textsizeCookieDomain});
      return false;
    }
    function tsDecrease(){
      TSremoveBC();
      $("#textsize_current").empty();
      $("#textsize_current").append((textsizeNormalDisplay - textsizeIncrementDisplay) + '%');
      $("#textsize_current").attr({ title: textsizeCurrentText + ": " + (textsizeNormalDisplay - textsizeIncrementDisplay) + '%'});
      $(textsizeElement + textsizeElementClass).addClass('textsize-' + (textsizeNormal - textsizeIncrement));
      $(textsizeElement + textsizeElementClass).css("font-size", (textsizeNormal - textsizeIncrement) + "%");
      $.cookie('textsize', textsizeDecrease(textsizeNormalDisplay, textsizeIncrementDisplay), { expires: textsizeCookieExpires, path: textsizeCookieDomain});
      return false;
    }
    function tsNormal(){
      TSremoveBC();
      $("#textsize_current").empty();
      $("#textsize_current").append(textsizeNormalDisplay + '%');
      $("#textsize_current").removeClass('error');
      $("#textsize_current").attr({ title: textsizeCurrentText + ": " + textsizeNormalDisplay + '%'});
      $(textsizeElement + textsizeElementClass).addClass('textsize-' + textsizeNormal);
      $(textsizeElement + textsizeElementClass).css("font-size", textsizeNormal + "%");
      $.cookie('textsize', textsizeNormal, { expires: textsizeCookieExpires, path: textsizeCookieDomain});
      return false;
    }
    function tsForm() {
      var ts_val = $("#edit-textsize-select").val();
      var ts_val_d = textsizeDisplayCalc($("#edit-textsize-select").val());
      TSremoveBC();
      $.cookie('textsize', ts_val, { expires: textsizeCookieExpires, path: textsizeCookieDomain});
      $(textsizeElement + textsizeElementClass).addClass("textsize-" + ts_val);
      $("#textsize_current").empty();
      $("#textsize_current").append(ts_val_d + '%');
      $("#textsize_current").attr({ title: textsizeCurrentText + ": " + ts_val_d + '%'});
      $(textsizeElement + textsizeElementClass).addClass('textsize-' + ts_val);
      $(textsizeElement + textsizeElementClass).css("font-size", ts_val + "%");
    }
    $("a.ts_increase_variable[href=#]").click(
      function (){
        if ($.cookie("textsize") && $.cookie("textsize") < textsizeMaximum) {
          TSremoveBC();
          $.cookie('textsize', textsizeIncrease($.cookie("textsize"), textsizeIncrement), { expires: textsizeCookieExpires, path: textsizeCookieDomain});
          $("#textsize_current").empty();
          $("#textsize_current").append( textsizeDisplayCalc($.cookie("textsize")) + '%');
          $("#textsize_current").attr({ title: textsizeCurrentText + ": " + textsizeDisplayCalc($.cookie("textsize")) + '%'});
          $("#textsize_current").removeClass('error');
          $(textsizeElement + textsizeElementClass).addClass('textsize-' + $.cookie("textsize"));
          $(textsizeElement + textsizeElementClass).css("font-size", $.cookie("textsize") + "%");
          return false;
        }
        else if ($.cookie("textsize") && ($.cookie("textsize") == textsizeMaximum) && textsizeReset == 0) {
          $("#textsize_current").empty();
          $("#textsize_current").append( '<abbr title="' + Drupal.t('Maximum') + '" class="textsize">' + Drupal.t('Max.') + '</abbr> ' + textsizeDisplayCalc(textsizeMaximum) + '%');
          $("#textsize_current").addClass('error');
          return false;
        }
        else if ($.cookie("textsize") && ($.cookie("textsize") == textsizeMaximum) && textsizeReset == 1) {
          tsNormal()
          return false;
        }
      }
    );
    $("a.ts_increase_fix[href=#]").click(
      function (){
        if ($.cookie("textsize") && $.cookie("textsize") < (textsizeNormal + textsizeIncrement)) {
          TSremoveBC();
          $.cookie('textsize', (textsizeNormal + textsizeIncrement), { expires: textsizeCookieExpires, path: textsizeCookieDomain});
          $("#textsize_current").empty();
          $("#textsize_current").append( textsizeDisplayCalc($.cookie("textsize")) + '%');
          $("#textsize_current").attr({ title: textsizeCurrentText + ": " + textsizeDisplayCalc($.cookie("textsize")) + '%'});
          $("#textsize_current").removeClass('error');
          $(textsizeElement + textsizeElementClass).addClass('textsize-' + (textsizeNormal + textsizeIncrement));
          $(textsizeElement + textsizeElementClass).css("font-size", (textsizeNormal + textsizeIncrement) + "%");
          return false;
        }
        else if ($.cookie("textsize") && $.cookie("textsize") == (textsizeNormal + textsizeIncrement)) {
          $("#textsize_current").empty();
          $("#textsize_current").append( '<abbr title="' + Drupal.t('Maximum') + '" class="textsize">' + Drupal.t('Max.') + '</abbr> ' + textsizeDisplayCalc((textsizeNormal + textsizeIncrement)) + '%');
          $("#textsize_current").addClass('error');
          return false;
        }
        else {
          tsIncrease()
        }
      }
    );
    $("a.ts_decrease_variable[href=#]").click(
      function (){
        if ($.cookie("textsize") && $.cookie("textsize") > textsizeMinimum) {
          TSremoveBC();
          $.cookie('textsize', textsizeDecrease($.cookie("textsize"), textsizeIncrement), { expires: textsizeCookieExpires, path: textsizeCookieDomain});
          $("#textsize_current").empty();
          $("#textsize_current").append( textsizeDisplayCalc($.cookie("textsize")) + '%');
          $("#textsize_current").attr({ title: textsizeCurrentText + ": " + textsizeDisplayCalc($.cookie("textsize")) + '%'});
          $("#textsize_current").removeClass('error');
          $(textsizeElement + textsizeElementClass).addClass('textsize-' + $.cookie("textsize"));
          $(textsizeElement + textsizeElementClass).css("font-size", $.cookie("textsize") + "%");
          return false;
        }
        else if ($.cookie("textsize") && ($.cookie("textsize") == textsizeMinimum) && textsizeReset == 0) {
          $("#textsize_current").empty();
          $("#textsize_current").append( '<abbr title="' + Drupal.t('Minimum') + '" class="textsize">' + Drupal.t('Min.') + '</abbr> ' + textsizeDisplayCalc(textsizeMinimum) + '%');
          $("#textsize_current").addClass('error');
          return false;
        }
        else if ($.cookie("textsize") && ($.cookie("textsize") == textsizeMinimum) && textsizeReset == 1) {
          tsNormal()
          return false;
        }
      }
    );
    $("a.ts_decrease_fix[href=#]").click(
      function (){
        if ($.cookie("textsize") && $.cookie("textsize") > (textsizeNormal - textsizeIncrement)) {
          TSremoveBC();
          $.cookie('textsize', (textsizeNormal - textsizeIncrement), { expires: textsizeCookieExpires, path: textsizeCookieDomain});
          $("#textsize_current").empty();
          $("#textsize_current").append( textsizeDisplayCalc($.cookie("textsize")) + '%');
          $("#textsize_current").attr({ title: textsizeCurrentText + ": " + textsizeDisplayCalc($.cookie("textsize")) + '%'});
          $("#textsize_current").removeClass('error');
          $(textsizeElement + textsizeElementClass).addClass('textsize-' + (textsizeNormal - textsizeIncrement));
          $(textsizeElement + textsizeElementClass).css("font-size", (textsizeNormal - textsizeIncrement) + "%");
          return false;
        }
        else if ($.cookie("textsize") && $.cookie("textsize") == (textsizeNormal - textsizeIncrement)) {
          $("#textsize_current").empty();
          $("#textsize_current").append( '<abbr title="' + Drupal.t('Minimum') + '" class="textsize">' + Drupal.t('Min.') + '</abbr> ' + textsizeDisplayCalc((textsizeNormal - textsizeIncrement)) + '%');
          $("#textsize_current").addClass('error');
          return false;
        }
        else {
          tsDecrease()
        }
      }
    );
    $("a.ts_normal_variable[href=#]").click(
      function (){
        tsNormal();
        return false;
      }
    );
    $("a.ts_normal_fix[href=#]").click(
      function (){
        tsNormal();
        return false;
      }
    );
    $("#edit-textsize-select").change(tsForm);
    $("#edit-textsize-submit").hide();
    $("img.ts_rollover").hover(
      function(){
        if($(this).attr("src").indexOf("16_hover") == -1) {
          var newSrc = $(this).attr("src").replace("16.gif","16_hover.gif#hover");
          $(this).attr("src",newSrc);
        }
      },
      function(){
        if($(this).attr("src").indexOf("16_hover.gif#hover") != -1) {
          var oldSrc = $(this).attr("src").replace("16_hover.gif#hover","16.gif");
          $(this).attr("src",oldSrc);
        }
        else if($(this).attr("src").indexOf("16_focus.gif#focus") != -1) {
          var oldSrc = $(this).attr("src").replace("16_focus.gif#focus","16.gif");
          $(this).attr("src",oldSrc);
        }
      }
    );
    $("a.ts_rollover").focus(
      function(){
        var tsIMG = $(this).children("img");
        if($(tsIMG).attr("src").indexOf("16_hover.gif#hover") != -1) {
          var newSrc = $(tsIMG).attr("src").replace("16_hover.gif#hover","16_focus.gif#focus");
          $(tsIMG).attr("src",newSrc);
        }
      }
    );
  });
})(jQuery);
;

/**
 * Cookie plugin 1.0
 *
 * Copyright (c) 2006 Klaus Hartl (stilbuero.de)
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 *
 */
jQuery.cookie=function(b,j,m){if(typeof j!="undefined"){m=m||{};if(j===null){j="";m.expires=-1}var e="";if(m.expires&&(typeof m.expires=="number"||m.expires.toUTCString)){var f;if(typeof m.expires=="number"){f=new Date();f.setTime(f.getTime()+(m.expires*24*60*60*1000))}else{f=m.expires}e="; expires="+f.toUTCString()}var l=m.path?"; path="+(m.path):"";var g=m.domain?"; domain="+(m.domain):"";var a=m.secure?"; secure":"";document.cookie=[b,"=",encodeURIComponent(j),e,l,g,a].join("")}else{var d=null;if(document.cookie&&document.cookie!=""){var k=document.cookie.split(";");for(var h=0;h<k.length;h++){var c=jQuery.trim(k[h]);if(c.substring(0,b.length+1)==(b+"=")){d=decodeURIComponent(c.substring(b.length+1));break}}}return d}};
;

(function($) {
  Drupal.behaviors.custom_search = {
    attach: function(context) {

      if (!Drupal.settings.custom_search.solr) {
        // Check if the search box is not empty on submit
        $('form.search-form', context).submit(function(){
          var box = $(this).find('input.custom-search-box');
          if (box.val() != undefined && (box.val() == '' || box.val() == $(this).find('input.default-text').val())) {
            $(this).find('input.custom-search-box').addClass('error');
            return false;
          }
          // If basic search is hidden, copy or value to the keys
          if ($(this).find('#edit-keys').parents('div.element-invisible').attr('class') == 'element-invisible') {
            $(this).find('#edit-keys').val($(this).find('#edit-or').val());
            $(this).find('#edit-or').val('');
          }
          return true;
        });
      }

      // Search from target
      $('form.search-form').attr('target', Drupal.settings.custom_search.form_target);

      // Clear default text on focus, and put it back on blur. Also displays Popup.
      $('form.search-form input.custom-search-box', context)
        .blur(function(){
          $this = $(this);
          $parentForm = $this.parents('form');
          if ($this.val() == '') {
            $this.addClass('custom-search-default-value');
            $this.val($parentForm.find('input.default-text').val());
          }
        })
        .bind('click focus', function(e){
          $this = $(this);
          $parentForm = $this.parents('form');
          if ($this.val() == $parentForm.find('input.default-text').val()) $this.val('');
          $this.removeClass('custom-search-default-value');
          // check if there's something in the popup and displays it
          var popup = $parentForm.find('fieldset.custom_search-popup');
          if (popup.find('input,select').length && !popup.hasClass('opened')) popup.fadeIn().addClass('opened');
          e.stopPropagation();
        }
      );
      $(document).bind('click focus', function(){
        $('fieldset.custom_search-popup').hide().removeClass('opened');
      });

      // Handle checkboxes
      $('.custom-search-selector input:checkbox', context).each(function(){
        var el = $(this);
        if (el.val() == 'c-all') {
          el.change(function(){
            $(this).parents('.custom-search-selector').find('input:checkbox[value!=c-all]').attr('checked', false);
          });
        }
        else {
          if (el.val().substr(0,2) == 'c-') {
            el.change(function(){
              $('.custom-search-selector input:checkbox').each(function(){
                if ($(this).val().substr(0,2) == 'o-') $(this).attr('checked', false);
              });
              $(this).parents('.custom-search-selector').find('input:checkbox[value=c-all]').attr('checked', false);
            });
          } else {
            el.change(function(){
              $(this).parents('.custom-search-selector').find('input:checkbox[value!='+el.val()+']').attr('checked', false);
            });
          }
        }
      });

      // Reselect types and terms in advanced search
      var edit_keys = $('#edit-keys').val();
      if(edit_keys) {
        // types
        var pos = edit_keys.indexOf('type:');
        if (pos) {
          var pos2 = edit_keys.indexOf(' ',pos);
          if (pos2==-1) pos2 = edit_keys.length;
          var types = edit_keys.substring(pos+5,pos2);
          types = types.split(',');
          for (var i in types) {
            $('.search-form input:checkbox[value='+types[i]+']').attr('checked', true);
          }
        }
        // terms
        var pos = edit_keys.indexOf('term:');
        if (pos) {
          var pos2 = edit_keys.indexOf(' ',pos);
          if (pos2==-1) pos2 = edit_keys.length;
          var terms = edit_keys.substring(pos+5,pos2);
          terms = terms.split(',');
          for (var i in terms) {
            $('#edit-term option[value='+terms[i]+']').attr('selected', true);
          }
        }
      }

      var popup = $('fieldset.custom_search-popup:not(.custom_search-processed)', context).addClass("custom_search-processed");
      popup.click(function(e){
        e.stopPropagation();
      })
      popup.append('<a class="custom_search-popup-close" href="#">' + Drupal.t('Close') + '</a>');
      $('a.custom_search-popup-close').click(function(e){
        $('fieldset.custom_search-popup.opened').hide().removeClass('opened');
        e.preventDefault();
      });

    }
  }
})(jQuery);;
// $Id: compact_forms.js,v 1.11 2011/01/09 05:51:15 sun Exp $

(function ($) {

Drupal.compactForms = {};

/**
 * Compact Forms jQuery plugin.
 */
$.fn.compactForm = function (stars) {
  stars = stars || 0;

  this.each(function () {
    $(this).addClass('compact-form').find('label').each(function () {
      var context = this.form;
      var $label = $(this);
      if (!$label.attr('for')) {
        return;
      }
      var $field = $('#' + $label.attr('for'), context);
      if (!$field.length || !$field.is('input:text,input:password,textarea')) {
        return;
      }
      // Store the initial field value, in case the browser is going to
      // automatically fill it in upon focus.
      var initial_value = $field.val();

      if (initial_value != '') {
        // Firefox doesn't like .hide() here for some reason.
        $label.css('display', 'none');
      }

      $label.parent().addClass('compact-form-wrapper');
      $label.addClass('compact-form-label');
      $field.addClass('compact-form-field');

      if (stars === 0) {
        $label.find('.form-required').hide();
      }
      else if (stars === 2) {
        $label.find('.form-required').insertAfter($field).prepend('&nbsp;');
      }

      $field.focus(function () {
        // Some browsers (e.g., Firefox) are automatically inserting a stored
        // username and password into login forms. In case the password field is
        // manually emptied afterwards, and the user jumps back to the username
        // field (without changing it), and forth to the password field, then
        // the browser automatically re-inserts the password again. Therefore,
        // we also need to test against the initial field value.
        if ($field.val() === initial_value || $field.val() === '') {
          $label.fadeOut('fast');
        }
      });

      $field.blur(function () {
        if ($field.val() === '') {
          $label.fadeIn('slow');
        }
      });

      // Chrome adds passwords after page load, so we need to track changes.
      $field.change(function () {
        if ($field.get(0) != document.activeElement) {
          if ($field.val() === '') {
            $label.fadeIn('fast');
          }
          else {
            $label.css('display', 'none');
          }
        }
      });
    });
  });
};

/**
 * Attach compact forms behavior to all enabled forms upon page load.
 */
Drupal.behaviors.compactForms = {
  attach: function (context, settings) {
    if (!settings || !settings.compactForms) {
      return;
    }
    $('#' + settings.compactForms.forms.join(',#'), context).compactForm(settings.compactForms.stars);

    // Safari adds passwords without triggering any event after page load.
    // We therefore need to wait a bit and then check for field values.
    if ($.browser.safari) {
      setTimeout(Drupal.compactForms.fixSafari, 200);
    }
  }
};

/**
 * Checks for field values and hides the corresponding label if non-empty.
 *
 * @todo Convert $.fn.compactForm to always use a function like this.
 */
Drupal.compactForms.fixSafari = function () {
  $('label.compact-form-label').each(function () {
    var $label = $(this);
    var context = this.form;
    if ($('#' + $label.attr('for'), context).val() != '') {
      $label.css('display', 'none');
    }
  });
}

})(jQuery);
;
(function ($) {

$(document).ready(function() {

  // Accepts a string; returns the string with regex metacharacters escaped. The returned string
  // can safely be used at any point within a regex to match the provided literal string. Escaped
  // characters are [ ] { } ( ) * + ? - . , \ ^ $ # and whitespace. The character | is excluded
  // in this function as it's used to separate the domains names.
  RegExp.escapeDomains = function(text) {
    return (text) ? text.replace(/[-[\]{}()*+?.,\\^$#\s]/g, "\\$&") : '';
  }

  // Attach onclick event to document only and catch clicks on all elements.
  $(document.body).click(function(event) {
    // Catch the closest surrounding link of a clicked element.
    $(event.target).closest("a,area").each(function() {

      var ga = Drupal.settings.googleanalytics;
      // Expression to check for absolute internal links.
      var isInternal = new RegExp("^(https?):\/\/" + window.location.host, "i");
      // Expression to check for special links like gotwo.module /go/* links.
      var isInternalSpecial = new RegExp("(\/go\/.*)$", "i");
      // Expression to check for download links.
      var isDownload = new RegExp("\\.(" + ga.trackDownloadExtensions + ")$", "i");
      // Expression to check for the sites cross domains.
      var isCrossDomain = new RegExp("^(https?|ftp|news|nntp|telnet|irc|ssh|sftp|webcal):\/\/.*(" + RegExp.escapeDomains(ga.trackCrossDomains) + ")", "i");

      // Is the clicked URL internal?
      if (isInternal.test(this.href)) {
        // Is download tracking activated and the file extension configured for download tracking?
        if (ga.trackDownload && isDownload.test(this.href)) {
          // Download link clicked.
          var extension = isDownload.exec(this.href);
          _gaq.push(["_trackEvent", "Downloads", extension[1].toUpperCase(), this.href.replace(isInternal, '')]);
        }
        else if (isInternalSpecial.test(this.href)) {
          // Keep the internal URL for Google Analytics website overlay intact.
          _gaq.push(["_trackPageview", this.href.replace(isInternal, '')]);
        }
      }
      else {
        if (ga.trackMailto && $(this).is("a[href^=mailto:],area[href^=mailto:]")) {
          // Mailto link clicked.
          _gaq.push(["_trackEvent", "Mails", "Click", this.href.substring(7)]);
        }
        else if (ga.trackOutbound && this.href) {
          if (ga.trackDomainMode == 2 && isCrossDomain.test(this.href)) {
            // Top-level cross domain clicked. document.location is handled by _link internally.
            _gaq.push(["_link", this.href]);
          }
          else if (ga.trackOutboundAsPageview) {
            // Track all external links as page views after URL cleanup.
            // Currently required, if click should be tracked as goal.
            _gaq.push(["_trackPageview", '/outbound/' + this.href.replace(/^(https?|ftp|news|nntp|telnet|irc|ssh|sftp|webcal):\/\//i, '').split('/').join('--')]);
          }
          else {
            // External link clicked.
            _gaq.push(["_trackEvent", "Outbound links", "Click", this.href]);
          }
        }
      }
    });
  });
});

})(jQuery);
;

