/**
 * @file
 * Adds javascript functions for font resizing
 */
jQuery(document).ready(function() {
  var originalFontSize = jQuery('body').css('font-size');

  // Reset font size
  jQuery(".resetFont").click(function() {
    mayoColumnsResetHeight();
    jQuery('body').css('font-size', originalFontSize);
    mayoColumnsAdjustHeight();
    return false;
  });

  // Increase font size
  jQuery(".increaseFont").click(function() {
    var currentFontSize = jQuery('body').css('font-size');
    var currentFontSizeNum = parseFloat(currentFontSize, 10);
    var newFontSizeNum = currentFontSizeNum + 1;
    if (20 >= newFontSizeNum) { /* max 20px */
      var newFontSize = newFontSizeNum + 'px';
      mayoColumnsResetHeight();
      jQuery('body').css('font-size', newFontSize);
      mayoColumnsAdjustHeight();
    }
    return false;
  });

  // Decrease font size
  jQuery(".decreaseFont").click(function() {
    var currentFontSize = jQuery('body').css('font-size');
    var currentFontSizeNum = parseFloat(currentFontSize, 10);
    var newFontSizeNum = currentFontSizeNum - 1;
    if (10 <= newFontSizeNum) { /* min 10px */
      var newFontSize = newFontSizeNum + 'px';
      mayoColumnsResetHeight();
      jQuery('body').css('font-size', newFontSize);
      mayoColumnsAdjustHeight();
    }
    return false;
  });
});

function mayoColumnsResetHeight() {
  // reset height of column blocks to 'auto' before chaning font size
  // so that the column blocks can change the size based on the new
  // font size
  if (mayoFunctionExists('mayoEqualHeight')) {
    jQuery("#top-columns .column-block").height('auto');
    jQuery("#bottom-columns .column-block").height('auto');
  }
}
function mayoColumnsAdjustHeight() {
  // equalize the height of the column blocks to the tallest height
  if (mayoFunctionExists('mayoEqualHeight')) {
    mayoEqualHeight(jQuery("#top-columns .column-block"));
    mayoEqualHeight(jQuery("#bottom-columns .column-block"));
  }
}
function mayoFunctionExists(function_name) {
  if (typeof function_name == 'string') {
    return (typeof this.window[function_name] == 'function');
  }
  else {
    return (function_name instanceof Function);
  }
}
;
(function ($) {

Drupal.behaviors.openid = {
  attach: function (context) {
    var loginElements = $('.form-item-name, .form-item-pass, li.openid-link');
    var openidElements = $('.form-item-openid-identifier, li.user-link');
    var cookie = $.cookie('Drupal.visitor.openid_identifier');

    // This behavior attaches by ID, so is only valid once on a page.
    if (!$('#edit-openid-identifier.openid-processed').size()) {
      if (cookie) {
        $('#edit-openid-identifier').val(cookie);
      }
      if ($('#edit-openid-identifier').val() || location.hash == '#openid-login') {
        $('#edit-openid-identifier').addClass('openid-processed');
        loginElements.hide();
        // Use .css('display', 'block') instead of .show() to be Konqueror friendly.
        openidElements.css('display', 'block');
      }
    }

    $('li.openid-link:not(.openid-processed)', context)
      .addClass('openid-processed')
      .click(function () {
         loginElements.hide();
         openidElements.css('display', 'block');
        // Remove possible error message.
        $('#edit-name, #edit-pass').removeClass('error');
        $('div.messages.error').hide();
        // Set focus on OpenID Identifier field.
        $('#edit-openid-identifier')[0].focus();
        return false;
      });
    $('li.user-link:not(.openid-processed)', context)
      .addClass('openid-processed')
      .click(function () {
         openidElements.hide();
         loginElements.css('display', 'block');
        // Clear OpenID Identifier field and remove possible error message.
        $('#edit-openid-identifier').val('').removeClass('error');
        $('div.messages.error').css('display', 'block');
        // Set focus on username field.
        $('#edit-name')[0].focus();
        return false;
      });
  }
};

})(jQuery);
;

