(function ($) {

var sprawk = {};

sprawk.poptopics = function(selectId, currVal) {
	var code = $("#edit-sprawk-groupcode").val();
	var pass = $("#edit-sprawk-grouppassword").val();
	$.getJSON("/sprawk/api/groupTopicsJSON.jsp", {groupCode: code, password: pass}, function(j){
		var options = '';
		options += '<option value=\'\'>' + 'Select a topic' + '</option>';
		for (var i = 0; i < j.length; i++) {
			options += '<option value="' + j[i].optionValue + '" ' + (currVal == j[i].optionValue ? 'selected="selected"' : "") + '>' + j[i].optionDisplay + '</option>';
		}
		$("select#" + selectId).html(options);
	});
};

sprawk.testpass = function() {
	var code = $("#edit-sprawk-groupcode").val();
	var pass = $("#edit-sprawk-grouppassword").val();
	$('#sprawk-testpassresult').load('/sprawk/api/testGroupPass.jsp?groupCode='+code+'&password='+encodeURIComponent(pass));    
};

/**
 *
 * @param sourceText
 */
sprawk.t = function(sourceText) {
  if (this.t_cache === undefined) {
    this.t_cache = new Cache();
  }
  var retVal = sourceText;
  if (userLocale == 'en') {
    // no need to translate, but we need to build the string if it's parameterized
    /* This will only work well as long as there are no gaps in the sequence of parameters and the sequence
     begins at 0. I.e., 'my text {0} {2}' won't work as there is no {1} */
    for (var i = 1; i < arguments.length; i++) {
      retVal = retVal.replace(new RegExp('\{' + (i - 1) + '\}', 'g'), arguments[i]);
    }
    retVal = this.applyWikiFormatting(retVal);
  }
  else if (sourceText !== undefined && $.trim(sourceText).length !== 0) {
    // iterate through params
    var url = '/sprawk/api/translateHtmlSnippet';
    var params = 't=' + encodeURIComponent(sourceText) + '&tl=' + userLocale + '&g=' + sprawk_g + '&k=' + sprawk_k + '&src=' + encodeURIComponent(window.location.href);
    for (var i = 1; i < arguments.length; i++) {
      params += '&param=' + encodeURIComponent(arguments[i]);
    }
    var cacheKey = params; //Includes the source text and all the parameters
    var cached = this.t_cache.getItem(cacheKey);
    if (cached !== null) {
      retVal = cached;
    } else {
      jQuery.ajax({
        async: false,
        type: 'get',
        url: url,
        data: params,
        success: function(data, textStatus, XMLHttpRequest) {
          retVal = data;
        }
      });
      this.t_cache.setItem(cacheKey, retVal);
    }
  }
  return retVal;
};

/* This function returns the original source, assembled from parameters if needed,
 * and invokes the callback function with the result of the translation. */
sprawk.aT = function(sourceText, callback) {
  if (this.t_cache === undefined) {
    this.t_cache = new Cache();
  }
  var processed = sourceText;
  /* Apply pattern and parameters */
  for (var i = 2; i < arguments.length; i++) {
    processed = processed.replace(new RegExp('\{' + (i - 2) + '\}', 'g'), arguments[i]);
  }

  processed = sprawk.applyWikiFormatting(processed);

  if (userLocale != 'en') {
    if (sourceText !== undefined && $.trim(sourceText).length !== 0) {
      // iterate through params
      var url = '/sprawk/api/translateHtmlSnippet';
      var params = 't=' + encodeURIComponent(sourceText) + '&tl=' + userLocale + '&g=' + sprawk_g + '&k=' + sprawk_k + '&src=' + encodeURIComponent(window.location.href);
      for (var i = 2; i < arguments.length; i++) {
        params += '&param=' + encodeURIComponent(arguments[i]);
      }
      var cacheKey = params; //Includes the source text and all the parameters
      var cached = this.t_cache.getItem(cacheKey);
      if (cached !== null) {
        callback(cached);
      } else {
        jQuery.ajax({
          async: true,
          type: 'get',
          url: url,
          data: params,
          success: function(data) {
            if (sprawk.t_cache === undefined) {
              sprawk.t_cache = new Cache();
            }
            sprawk.t_cache.setItem(cacheKey, data);
            callback(data);
          }
        });
      }
    }
  }
  return processed;
};

sprawk.applyWikiFormatting = function(text) {
  text = text.replace(/\*([^<>]*?)\*/g, '<b>$1</b>'); //Bold text
  text = text.replace(/#([^<>]*?)#/g, '<em>$1</em>'); //Emphasized text
  text = text.replace(/\/([^<>]*?)\//g, '<i>$1</i>'); //Italic text
  text = text.replace(/\[(sprawk)\]/i, '<span class="lowlight">$1</span>'); //Style the sprawk "logo"
  return text;
};

/* This function takes a string in the form of a variable name (including "complex"
 * like myObj.property). The variable "root" must be global but the window scope should
 * not be explicit. Second parameter is the string to be translated. Third argument is
 * an optional callback function to be invoked when the translation is available. Any additional
 * arguments are passed as translation parameters to aT() */
sprawk.assignAT = function(identifier, value, callbackOrFirstParam) {
  /* Force dot notation for easy splitting, if not in that format already */
  identifier = identifier.replace(/^\s*\[(.*?)\]\s*$/, '$1'); //Remove surrounding brackets
  identifier = identifier.replace(/\]\[/, '.'); //Replace "delimiting" brackets with dots
  var parts = identifier.split('.');
  
  /* If no value is passed, use the value already in the named variable */
  if(typeof value == 'undefined' || value === null || value === ''){
    value = this.getVar(parts);
  }
  
  /* Check to see if third argument exists and if so if it's a function or a translation param */
  var firstParam = 2;
  var extraCallback = function(){};
  if(typeof callbackOrFirstParam == 'function'){
    extraCallback = callbackOrFirstParam;
    firstParam = 3;
  }

  /* Orignally we used the static Array.concat() but that was not widely supported yet */
  var args = [];
  args.push(value);
  args.push(function(text) {
    sprawk.assignVar(parts, text);
    extraCallback(text);
  });
  args.concat(this.asArray(arguments).slice(firstParam));
  /* Returns the value that is also assigned to the
   * variable named in identifier (parts). The value is the un-translated but parameter-parsed
   * string that aT() returns. aT() is provided a callback function that assigns the translated
   * value to the variable named in identifier once returned from server.
   */
  return this.assignVar(parts, this.aT.apply(null, args));
};

sprawk.getVar = function(parts){
  var cur = window;
  for(var i=0; i<parts.length; i++){
    cur = cur[parts[i]];
  }
  return cur;
}

sprawk.assignVar = function(parts, value) {
  var cur = window;
  for(var i=0; i<parts.length-1; i++){
	cur = cur[parts[i]];
  }
  cur[parts[i]] = value;
  return value; //Not needed but useful
}

sprawk.asArray = function(args) {
  var arr = [];
  for (var i = 0; i < args.length; i++) {
    arr[i] = args[i];
  }
  return arr;
};


jQuery.fn.aTHtml = function(text) {
  var me = this;
  /* Orignally we used the static Array.concat() but that was not widely supported yet */
  var args = [];
  args.push(text);
  args.push(function(translated) {
    me.html(translated);
  });
  args.concat(asArray(arguments).slice(1));
  me.html(sprawk.aT.apply(null, args));
  return this;
};

Drupal.behaviors.sprawk_test_pass = function (context) {
  $('.form-test-button').bind('click', function() {
      sprawk.testpass();
      return false;
    });
}

})(jQuery);;
;
/*
 MIT LICENSE
 Copyright (c) 2007 Monsur Hossain (http://www.monsur.com)

 Permission is hereby granted, free of charge, to any person
 obtaining a copy of this software and associated documentation
 files (the "Software"), to deal in the Software without
 restriction, including without limitation the rights to use,
 copy, modify, merge, publish, distribute, sublicense, and/or sell
 copies of the Software, and to permit persons to whom the
 Software is furnished to do so, subject to the following
 conditions:

 The above copyright notice and this permission notice shall be
 included in all copies or substantial portions of the Software.

 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
 OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 OTHER DEALINGS IN THE SOFTWARE.
 */

// ****************************************************************************
// CachePriority ENUM
// An easier way to refer to the priority of a cache item
var CachePriority = {
  Low: 1,
  Normal: 2,
  High: 4
};

// ****************************************************************************
// Cache constructor
// Creates a new cache object
// INPUT: maxSize (optional) - indicates how many items the cache can hold.
//                             default is -1, which means no limit on the
//                             number of items.
function Cache(maxSize) {
  this.items = {};
  this.count = 0;
  if (maxSize == null) {
    maxSize = -1;
  }
  this.maxSize = maxSize;
  this.fillFactor = 0.75;
  this.purgeSize = Math.round(this.maxSize * this.fillFactor);

  this.stats = {};
  this.stats.hits = 0;
  this.stats.misses = 0;
}

// ****************************************************************************
// Cache.getItem
// retrieves an item from the cache, returns null if the item doesn't exist
// or it is expired.
// INPUT: key - the key to load from the cache
Cache.prototype.getItem = function(key) {

  /*
  if (key == undefined) {
    throw "Key in cache was undefined";
  }
  */

  // retrieve the item from the cache
  var item = this.items[key];

  if (item != null) {
    // neither null nor undefined
    if (!this._isExpired(item)) {
      // if the item is not expired
      // update its last accessed date
      item.lastAccessed = new Date().getTime();
    } else {
      // if the item is expired, remove it from the cache
      this._removeItem(key);
      item = null;
    }
  }

  // return the item value (if it exists), or null
  var returnVal = null;
  if (item != null) {
    returnVal = item.value;
    this.stats.hits++;
  } else {
    this.stats.misses++;
  }
  return returnVal;
};

// ****************************************************************************
// Cache.setItem
// sets an item in the cache
// parameters: key - the key to refer to the object
//             value - the object to cache
//             options - an optional parameter described below
// the last parameter accepts an object which controls various caching options:
//      expirationAbsolute: the datetime when the item should expire
//      expirationSliding: an integer representing the seconds since
//                         the last cache access after which the item
//                         should expire
//      priority: How important it is to leave this item in the cache.
//                You can use the values CachePriority.Low, .Normal, or
//                .High, or you can just use an integer.  Note that
//                placing a priority on an item does not guarantee
//                it will remain in cache.  It can still be purged if
//                an expiration is hit, or if the cache is full.
//      callback: A function that gets called when the item is purged
//                from cache.  The key and value of the removed item
//                are passed as parameters to the callback function.
Cache.prototype.setItem = function(key, value, options) {

  function CacheItem(k, v, o) {
    if ((k === null) || (k == '')) {
      throw new Error("key cannot be null or empty");
    }
    this.key = k;
    this.value = v;
    if (o == null) {
      o = {};
    }
    if (o.expirationAbsolute != null) {
      o.expirationAbsolute = o.expirationAbsolute.getTime();
    }
    if (o.priority == null) {
      o.priority = CachePriority.Normal;
    }
    this.options = o;
    this.lastAccessed = new Date().getTime();
  }

  // add a new cache item to the cache
  if (this.items[key] != null) {
    this._removeItem(key);
  }
  this._addItem(new CacheItem(key, value, options));

  // if the cache is full, purge it
  if ((this.maxSize > 0) && (this.count > this.maxSize)) {
    this._purge();
  }
};

// ****************************************************************************
// Cache.clear
// Remove all items from the cache
Cache.prototype.clear = function() {

  // loop through each item in the cache and remove it
  for (var key in this.items) {
    if (this.items.hasOwnProperty(key)) {
      this._removeItem(key);
    }
  }
};

// ****************************************************************************
// Cache._purge (PRIVATE FUNCTION)
// remove old elements from the cache
Cache.prototype._purge = function() {

  var tmparray = [];

  // loop through the cache, expire items that should be expired
  // otherwise, add the item to an array
  for (var key in this.items) {
    if (this.items.hasOwnProperty(key)) {
      var item = this.items[key];
      if (this._isExpired(item)) {
        this._removeItem(key);
      } else {
        tmparray.push(item);
      }
    }
  }

  if (tmparray.length > this.purgeSize) {

    // sort this array based on cache priority and the last accessed date
    tmparray = tmparray.sort(function(a, b) {
      if (a.options.priority != b.options.priority) {
        return b.options.priority - a.options.priority;
      } else {
        return b.lastAccessed - a.lastAccessed;
      }
    });

    // remove items from the end of the array
    while (tmparray.length > this.purgeSize) {
      var ritem = tmparray.pop();
      this._removeItem(ritem.key);
    }
  }
};

// ****************************************************************************
// Cache._addItem (PRIVATE FUNCTION)
// add an item to the cache
Cache.prototype._addItem = function(item) {
  this.items[item.key] = item;
  this.count++;
};

// ****************************************************************************
// Cache._removeItem (PRIVATE FUNCTION)
// Remove an item from the cache, call the callback function (if necessary)
Cache.prototype._removeItem = function(key) {
  var item = this.items[key];
  /*
  if (item === undefined) {
    throw "Key not found: " + key;
  }
  */

  delete this.items[key];
  this.count--;

  // if there is a callback function, call it at the end of execution
  if (item.options.callback !== null) {
    var callback = function() {
      item.options.callback(item.key, item.value);
    };
    setTimeout(callback, 0);
  }
};

// ****************************************************************************
// Cache._isExpired (PRIVATE FUNCTION)
// Returns true if the item should be expired based on its expiration options
Cache.prototype._isExpired = function(item) {
  var now = new Date().getTime();
  var expired = false;
  if ((item.options.expirationAbsolute) && (item.options.expirationAbsolute < now)) {
    // if the absolute expiration has passed, expire the item
    expired = true;
  }
  if ((!expired) && (item.options.expirationSliding)) {
    // if the sliding expiration has passed, expire the item
    var lastAccess = item.lastAccessed + (item.options.expirationSliding * 1000);
    if (lastAccess < now) {
      expired = true;
    }
  }
  return expired;
};

Cache.prototype.toHtmlString = function() {
  var returnStr = this.count + " item(s) in cache<br /><ul>";
  for (var key in this.items) {
    if (this.items.hasOwnProperty(key)) {
      var item = this.items[key];
      returnStr = returnStr + "<li>" + item.key.toString() + " = " + item.value.toString() + "</li>";
    }
  }
  returnStr = returnStr + "</ul>";
  return returnStr;
};;
/**
* hoverIntent r6 // 2011.02.26 // jQuery 1.5.1+
* <http://cherne.net/brian/resources/jquery.hoverIntent.html>
* 
* @param  f  onMouseOver function || An object with configuration options
* @param  g  onMouseOut function  || Nothing (use configuration options object)
* @author    Brian Cherne brian(at)cherne(dot)net
*/
(function($){$.fn.hoverIntent=function(f,g){var cfg={sensitivity:7,interval:100,timeout:0};cfg=$.extend(cfg,g?{over:f,out:g}:f);var cX,cY,pX,pY;var track=function(ev){cX=ev.pageX;cY=ev.pageY};var compare=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);if((Math.abs(pX-cX)+Math.abs(pY-cY))<cfg.sensitivity){$(ob).unbind("mousemove",track);ob.hoverIntent_s=1;return cfg.over.apply(ob,[ev])}else{pX=cX;pY=cY;ob.hoverIntent_t=setTimeout(function(){compare(ev,ob)},cfg.interval)}};var delay=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);ob.hoverIntent_s=0;return cfg.out.apply(ob,[ev])};var handleHover=function(e){var ev=jQuery.extend({},e);var ob=this;if(ob.hoverIntent_t){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t)}if(e.type=="mouseenter"){pX=ev.pageX;pY=ev.pageY;$(ob).bind("mousemove",track);if(ob.hoverIntent_s!=1){ob.hoverIntent_t=setTimeout(function(){compare(ev,ob)},cfg.interval)}}else{$(ob).unbind("mousemove",track);if(ob.hoverIntent_s==1){ob.hoverIntent_t=setTimeout(function(){delay(ev,ob)},cfg.timeout)}}};return this.bind('mouseenter',handleHover).bind('mouseleave',handleHover)}})(jQuery);;
/* Copyright (c) 2010 Brandon Aaron (http://brandonaaron.net)
 * Licensed under the MIT License (LICENSE.txt).
 *
 * Version 2.1.2
 */
(function(a){a.fn.bgiframe=(a.browser.msie&&/msie 6\.0/i.test(navigator.userAgent)?function(d){d=a.extend({top:"auto",left:"auto",width:"auto",height:"auto",opacity:true,src:"javascript:false;"},d);var c='<iframe class="bgiframe"frameborder="0"tabindex="-1"src="'+d.src+'"style="display:block;position:absolute;z-index:-1;'+(d.opacity!==false?"filter:Alpha(Opacity='0');":"")+"top:"+(d.top=="auto"?"expression(((parseInt(this.parentNode.currentStyle.borderTopWidth)||0)*-1)+'px')":b(d.top))+";left:"+(d.left=="auto"?"expression(((parseInt(this.parentNode.currentStyle.borderLeftWidth)||0)*-1)+'px')":b(d.left))+";width:"+(d.width=="auto"?"expression(this.parentNode.offsetWidth+'px')":b(d.width))+";height:"+(d.height=="auto"?"expression(this.parentNode.offsetHeight+'px')":b(d.height))+';"/>';return this.each(function(){if(a(this).children("iframe.bgiframe").length===0){this.insertBefore(document.createElement(c),this.firstChild)}})}:function(){return this});a.fn.bgIframe=a.fn.bgiframe;function b(c){return c&&c.constructor===Number?c+"px":c}})(jQuery);;
/*
 * Superfish v1.4.8 - jQuery menu widget
 * Copyright (c) 2008 Joel Birch
 *
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 *
 * CHANGELOG: http://users.tpg.com.au/j_birch/plugins/superfish/changelog.txt
 */

(function($){
  $.fn.superfish = function(op){
    var sf = $.fn.superfish,
      c = sf.c,
      $arrow = $(['<span class="',c.arrowClass,'"> &#187;</span>'].join('')),
      over = function(){
        var $$ = $(this), menu = getMenu($$);
        clearTimeout(menu.sfTimer);
        $$.showSuperfishUl().siblings().hideSuperfishUl();
      },
      out = function(){
        var $$ = $(this), menu = getMenu($$), o = sf.op;
        clearTimeout(menu.sfTimer);
        menu.sfTimer=setTimeout(function(){
          o.retainPath=($.inArray($$[0],o.$path)>-1);
          $$.hideSuperfishUl();
          if (o.$path.length && $$.parents(['li.',o.hoverClass].join('')).length<1){over.call(o.$path);}
        },o.delay);
      },
      getMenu = function($menu){
        var menu = $menu.parents(['ul.',c.menuClass,':first'].join(''))[0];
        sf.op = sf.o[menu.serial];
        return menu;
      },
      addArrow = function($a){ $a.addClass(c.anchorClass).append($arrow.clone()); };

    return this.each(function() {
      var s = this.serial = sf.o.length;
      var o = $.extend({},sf.defaults,op);
      o.$path = $('li.'+o.pathClass,this).slice(0,o.pathLevels).each(function(){
        $(this).addClass([o.hoverClass,c.bcClass].join(' '))
          .filter('li:has(ul)').removeClass(o.pathClass);
      });
      sf.o[s] = sf.op = o;

      $('li:has(ul)',this)[($.fn.hoverIntent && !o.disableHI) ? 'hoverIntent' : 'hover'](over,out).each(function() {
        if (o.autoArrows) addArrow( $('>a:first-child',this) );
      })
      .not('.'+c.bcClass)
        .hideSuperfishUl();

      var $a = $('a',this);
      $a.each(function(i){
        var $li = $a.eq(i).parents('li');
        $a.eq(i).focus(function(){over.call($li);}).blur(function(){out.call($li);});
      });
      o.onInit.call(this);

    }).each(function() {
      var menuClasses = [c.menuClass];
      if (sf.op.dropShadows  && !($.browser.msie && $.browser.version < 7)) menuClasses.push(c.shadowClass);
      $(this).addClass(menuClasses.join(' '));
    });
  };

  var sf = $.fn.superfish;
  sf.o = [];
  sf.op = {};
  sf.IE7fix = function(){
    var o = sf.op;
    if ($.browser.msie && $.browser.version > 6 && o.dropShadows && o.animation.opacity!=undefined)
      this.toggleClass(sf.c.shadowClass+'-off');
    };
  sf.c = {
    bcClass: 'sf-breadcrumb',
    menuClass: 'sf-js-enabled',
    anchorClass: 'sf-with-ul',
    arrowClass: 'sf-sub-indicator',
    shadowClass: 'sf-shadow'
  };
  sf.defaults = {
    hoverClass: 'sfHover',
    pathClass: 'overideThisToUse',
    pathLevels: 1,
    delay: 800,
    animation: {opacity:'show'},
    speed: 'normal',
    autoArrows: true,
    dropShadows: true,
    disableHI: false, // true disables hoverIntent detection
    onInit: function(){}, // callback functions
    onBeforeShow: function(){},
    onShow: function(){},
    onHide: function(){}
  };
  $.fn.extend({
    hideSuperfishUl : function(){
      var o = sf.op,
        not = (o.retainPath===true) ? o.$path : '';
      o.retainPath = false;
      var $ul = $(['li.',o.hoverClass].join(''),this).add(this).not(not).removeClass(o.hoverClass)
          .find('>ul').hide().css('visibility','hidden');
      o.onHide.call($ul);
      return this;
    },
    showSuperfishUl : function(){
      var o = sf.op,
        sh = sf.c.shadowClass+'-off',
        $ul = this.addClass(o.hoverClass)
          .find('>ul:hidden').css('visibility','visible');
      sf.IE7fix.call($ul);
      o.onBeforeShow.call($ul);
      $ul.animate(o.animation,o.speed,function(){ sf.IE7fix.call($ul); o.onShow.call($ul); });
      return this;
    }
  });
})(jQuery);;
/*
 * Supersubs v0.2b - jQuery plugin - LAST UPDATE: MARCH 23rd, 2011
 * Copyright (c) 2008 Joel Birch
 *
 * Jan 16th, 2011 - Modified a little in order to work with NavBar menus as well.
 *
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 *
 * This plugin automatically adjusts submenu widths of suckerfish-style menus to that of
 * their longest list item children. If you use this, please expect bugs and report them
 * to the jQuery Google Group with the word 'Superfish' in the subject line.
 *
 */

(function($){ // $ will refer to jQuery within this closure

  $.fn.supersubs = function(options){
    var opts = $.extend({}, $.fn.supersubs.defaults, options);
	// return original object to support chaining
    return this.each(function() {
      // cache selections
      var $$ = $(this);
      // support metadata
      var o = $.meta ? $.extend({}, opts, $$.data()) : opts;
      // get the font size of menu.
      // .css('fontSize') returns various results cross-browser, so measure an em dash instead
      var fontsize = $('<li id="menu-fontsize">&#8212;</li>').css({
        'padding' : 0,
        'position' : 'absolute',
        'top' : '-99999em',
        'width' : 'auto'
      }).appendTo($$).width(); //clientWidth is faster, but was incorrect here
      // remove em dash
      $('#menu-fontsize').remove();

      // Jump on level if it's a "NavBar"
      if ($$.hasClass('sf-navbar')) {
        $$ = $('li > ul', $$);
      }
      // cache all ul elements 
      $ULs = $$.find('ul:not(.sf-megamenu)');
      // loop through each ul in menu
      $ULs.each(function(i) {
        // cache this ul
        var $ul = $ULs.eq(i);
        // get all (li) children of this ul
        var $LIs = $ul.children();
        // get all anchor grand-children
        var $As = $LIs.children('a');
        // force content to one line and save current float property
        var liFloat = $LIs.css('white-space','nowrap').css('float');
        // remove width restrictions and floats so elements remain vertically stacked
        var emWidth = $ul.add($LIs).add($As).css({
          'float' : 'none',
          'width'  : 'auto'
        })
        // this ul will now be shrink-wrapped to longest li due to position:absolute
        // so save its width as ems. Clientwidth is 2 times faster than .width() - thanks Dan Switzer
        .end().end()[0].clientWidth / fontsize;
        // add more width to ensure lines don't turn over at certain sizes in various browsers
        emWidth += o.extraWidth;
        // restrict to at least minWidth and at most maxWidth
        if (emWidth > o.maxWidth)    { emWidth = o.maxWidth; }
        else if (emWidth < o.minWidth)  { emWidth = o.minWidth; }
        emWidth += 'em';
        // set ul to width in ems
        $ul.css('width',emWidth);
        // restore li floats to avoid IE bugs
        // set li width to full width of this ul
        // revert white-space to normal
        $LIs.css({
          'float' : liFloat,
          'width' : '100%',
          'white-space' : 'normal'
        })
        // update offset position of descendant ul to reflect new width of parent
        .each(function(){
          var $childUl = $('>ul',this);
          var offsetDirection = $childUl.css('left')!==undefined ? 'left' : 'right';
          $childUl.css(offsetDirection,emWidth);
        });
      });

    });
  };
  // expose defaults
  $.fn.supersubs.defaults = {
    minWidth: 9, // requires em unit.
    maxWidth: 25, // requires em unit.
    extraWidth: 0 // extra width can ensure lines don't sometimes turn over due to slight browser differences in how they round-off values
  };

})(jQuery); // plugin code ends;
/*
* Supposition v0.2 - an optional enhancer for Superfish jQuery menu widget - LAST UPDATE: MARCH 23rd, 2011
*
* Copyright (c) 2008 Joel Birch - based mostly on work by Jesse Klaasse and credit goes largely to him.
* Special thanks to Karl Swedberg for valuable input.
* 
* Dec 28th, 2010 - Modified for the Superfish project for Drupal (http://drupal.org/project/superfish)
*
* jQuery version: 1.3.x or higher.
*
* Dual licensed under the MIT and GPL licenses:
* 	http://www.opensource.org/licenses/mit-license.php
* 	http://www.gnu.org/licenses/gpl.html
*/

(function($){
  $.fn.supposition = function(){
    var $w = $(window), /*do this once instead of every onBeforeShow call*/
    _offset = function(dir) {
      return window[dir == 'y' ? 'pageYOffset' : 'pageXOffset']
      || document.documentElement && document.documentElement[dir=='y' ? 'scrollTop' : 'scrollLeft']
      || document.body[dir=='y' ? 'scrollTop' : 'scrollLeft'];
    },
    onHide = function(){
      this.css({Top:'',Right:'',Bottom:'',Left:''});
    },
    onBeforeShow = function(){
      this.each(function(){
        var $u = $(this);
        $u.css('display','block');
        var menuWidth = $u.width(),
        menuParentWidth = $u.closest('li').outerWidth(true),
        menuParentLeft = $u.closest('li').offset().left,
        totalRight = $w.width() + _offset('x'),
        menuRight = $u.offset().left + menuWidth,
        exactMenuWidth = (menuRight > (menuParentWidth + menuParentLeft)) ? menuWidth - (menuRight - (menuParentWidth + menuParentLeft)) : menuWidth;  
        if ($u.parents('.sf-js-enabled').hasClass('rtl')) {
          if (menuParentLeft < exactMenuWidth) {
            $u.css('left', menuParentWidth + 'px');
            $u.css('right', 'auto');
          }
        }
        else {
          if (menuRight > totalRight && menuParentLeft > menuWidth) {
            $u.css('right', menuParentWidth + 'px');
            $u.css('left', 'auto');
          }
        }
        var windowHeight = $w.height(),
        offsetTop = $u.offset().top,
        menuParentHeight = $u.parent().outerHeight(true),
        menuHeight = $u.height(),
        baseline = windowHeight + _offset('y');
        var expandUp = ((offsetTop + menuHeight > baseline) && (offsetTop > menuHeight));
        if (expandUp) {
          $u.css('bottom', menuParentHeight + 'px');
          $u.css('top', 'auto');
        }
        $u.css('display','none');
      });
    };

    return this.each(function() {
    var o = $.fn.superfish.o[this.serial]; /* get this menu's options */

    /* if callbacks already set, store them */
    var _onBeforeShow = o.onBeforeShow,
    _onHide = o.onHide;

    $.extend($.fn.superfish.o[this.serial],{
    onBeforeShow: function() {
    onBeforeShow.call(this); /* fire our Supposition callback */
    _onBeforeShow.call(this); /* fire stored callbacks */
    },
    onHide: function() {
    onHide.call(this); /* fire our Supposition callback */
    _onHide.call(this); /* fire stored callbacks */
    }
    });
    });
  };
})(jQuery);;
/*
 * sf-Touchscreen v1.0b - Provides touchscreen compatibility for the jQuery Superfish plugin. - LAST UPDATE: MARCH 23rd, 2011
 *
 * Developer's notes:
 * Built as a part of the Superfish project for Drupal (http://drupal.org/project/superfish) 
 * Found any bug? have any cool ideas? contact me right away! http://drupal.org/user/619294/contact
 *
 * jQuery version: 1.3.x or higher.
 *
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
*/

(function($){
  $.fn.sftouchscreen = function() {
    // Return original object to support chaining.
    return this.each( function() {
      // Select hyperlinks from parent menu items.
      $(this).find('li > ul').closest('li').children('a').each( function() {
	    var $item = $(this);
        // No .toggle() here as it's not possible to reset it.
        $item.click( function(event){
	      // Already clicked? proceed to the URI.
          if ($item.hasClass('sf-clicked')) {
            var $uri = $item.attr('href');
            window.location = $uri;
          }
          else {
            event.preventDefault();
            $item.addClass('sf-clicked');
          }
        }).closest('li').mouseleave( function(){
          // So, we reset everything.
          $item.removeClass('sf-clicked');
        });
	  });
    });
  };
})(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);
;

