Signin  Pricing  Examples  Support

Libraries > js_X3-wHbi3XmFmiu9zuztEIWaFEBq9e1qCpXFylFuBTVs.js

js_X3-wHbi3XmFmiu9zuztEIWaFEBq9e1qCpXFylFuBTVs.js - Search Live Website Code
It's like doing CTRL+F on millions of websites' source code



NerdyData is a search engine for source code. Search the source code of 200 million websites.


JAVASCRIPT FILE http://familycircle.mdpcdn.com/sites/familycircle.com/files/js/js_X3-wHbi3XmFmiu9zuztEIWaFEBq9e1qCpXFylFuBTVs.js

Function Explorer
















Libraries on familycircle.mdpcdn.com


js_2oprhSxHObLkKKdpomrTHfQcc5tkagdvAU3rrbLUq-0.js

js_6xxOefVmRfAoNuXC8wNN6WTFeLNtd1Hin1ni3XHfhJg.js

js_9DOY5hsq2A3AfovkQNLVNDHuX4wsjny06S2MZ32plFQ.js

js_kdSPcG-Fx-cX23OTZKg4cFwqa6RQXbR5LHdTAtDO2S0.js

js_sDco9wLkq12OdsmMP0oOj4BKtWt1rtErKtNNKwwvYqI.js

js_TnheDIKMzzeAfcQGumuo8VN8W1ntG0MLiU8ZMOa4nPs.js

js_X3-wHbi3XmFmiu9zuztEIWaFEBq9e1qCpXFylFuBTVs.js

js_Y_cowT_8ZCUXAEzhvSC3eveJvF-olkCnV7FC34UjPIQ.js



Explore More


rmw_jslib.js

popup.js

swfaddress.js

swfcommons.js

js_X3-wHbi3XmFmiu9zuztEIWaFEBq9e1qCpXFylFuBTVs.js
				
var FORMALIZE=function(e,t,n,r){function i(e){var t=n.createElement("b");return t.innerHTML="<!--[if IE "+e+"]><br><![endif]-->",!!t.getElementsByTagName("br").length}var s="placeholder"in n.createElement("input"),o="autofocus"in n.createElement("input"),u=i(6),a=i(7);return{go:function(){var e,t=this.init;for(e in t)t.hasOwnProperty(e)&&t[e]()},init:{disable_link_button:function(){e(n.documentElement).on("click","a.button_disabled",function(){return!1})},full_input_size:function(){if(!a||!e("textarea, input.input_full").length)return;e("textarea, input.input_full").wrap('<span class="input_full_wrap"></span>')},ie6_skin_inputs:function(){if(!u||!e("input, select, textarea").length)return;var t=/button|submit|reset/,n=/date|datetime|datetime-local|email|month|number|password|range|search|tel|text|time|url|week/;e("input").each(function(){var r=e(this);this.getAttribute("type").match(t)?(r.addClass("ie6_button"),this.disabled&&r.addClass("ie6_button_disabled")):this.getAttribute("type").match(n)&&(r.addClass("ie6_input"),this.disabled&&r.addClass("ie6_input_disabled"))}),e("textarea, select").each(function(){this.disabled&&e(this).addClass("ie6_input_disabled")})},autofocus:function(){if(o||!e(":input[autofocus]").length)return;var t=e("[autofocus]")[0];t.disabled||t.focus()},placeholder:function(){if(s||!e(":input[placeholder]").length)return;FORMALIZE.misc.add_placeholder(),e(":input[placeholder]").each(function(){if(this.type==="password")return;var t=e(this),n=t.attr("placeholder");t.focus(function(){t.val()===n&&t.val("").removeClass("placeholder_text")}).blur(function(){FORMALIZE.misc.add_placeholder()}),t.closest("form").submit(function(){t.val()===n&&t.val("").removeClass("placeholder_text")}).on("reset",function(){setTimeout(FORMALIZE.misc.add_placeholder,50)})})}},misc:{add_placeholder:function(){if(s||!e(":input[placeholder]").length)return;e(":input[placeholder]").each(function(){if(this.type==="password")return;var t=e(this),n=t.attr("placeholder");(!t.val()||t.val()===n)&&t.val(n).addClass("placeholder_text")})}}}}(jQuery,this,this.document);jQuery(document).ready(function(){FORMALIZE.go()});
/*
 *	jQuery dotdotdot 1.6.16
 *
 *	Copyright (c) Fred Heusschen
 *	www.frebsite.nl
 *
 *	Plugin website:
 *	dotdotdot.frebsite.nl
 *
 *	Dual licensed under the MIT and GPL licenses.
 *	http://en.wikipedia.org/wiki/MIT_License
 *	http://en.wikipedia.org/wiki/GNU_General_Public_License
 */
!function(t,e){function n(t,e,n){var r=t.children(),o=!1;t.empty();for(var i=0,d=r.length;d>i;i++){var l=r.eq(i);if(t.append(l),n&&t.append(n),a(t,e)){l.remove(),o=!0;break}n&&n.detach()}return o}function r(e,n,i,d,l){var s=!1,c="table, thead, tbody, tfoot, tr, col, colgroup, object, embed, param, ol, ul, dl, blockquote, select, optgroup, option, textarea, script, style",u="script, .dotdotdot-keep";return e.contents().detach().each(function(){var f=this,h=t(f);if("undefined"==typeof f||3==f.nodeType&&0==t.trim(f.data).length)return!0;if(h.is(u))e.append(h);else{if(s)return!0;e.append(h),l&&e[e.is(c)?"after":"append"](l),a(i,d)&&(s=3==f.nodeType?o(h,n,i,d,l):r(h,n,i,d,l),s||(h.detach(),s=!0)),s||l&&l.detach()}}),s}function o(e,n,r,o,d){var c=e[0];if(!c)return!1;var f=s(c),h=-1!==f.indexOf(" ")?" ":" ",p="letter"==o.wrap?"":h,g=f.split(p),v=-1,w=-1,b=0,y=g.length-1;for(o.fallbackToLetter&&0==b&&0==y&&(p="",g=f.split(p),y=g.length-1);y>=b&&(0!=b||0!=y);){var m=Math.floor((b+y)/2);if(m==w)break;w=m,l(c,g.slice(0,w+1).join(p)+o.ellipsis),a(r,o)?(y=w,o.fallbackToLetter&&0==b&&0==y&&(p="",g=g[0].split(p),v=-1,w=-1,b=0,y=g.length-1)):(v=w,b=w)}if(-1==v||1==g.length&&0==g[0].length){var x=e.parent();e.detach();var T=d&&d.closest(x).length?d.length:0;x.contents().length>T?c=u(x.contents().eq(-1-T),n):(c=u(x,n,!0),T||x.detach()),c&&(f=i(s(c),o),l(c,f),T&&d&&t(c).parent().append(d))}else f=i(g.slice(0,v+1).join(p),o),l(c,f);return!0}function a(t,e){return t.innerHeight()>e.maxHeight}function i(e,n){for(;t.inArray(e.slice(-1),n.lastCharacter.remove)>-1;)e=e.slice(0,-1);return t.inArray(e.slice(-1),n.lastCharacter.noEllipsis)<0&&(e+=n.ellipsis),e}function d(t){return{width:t.innerWidth(),height:t.innerHeight()}}function l(t,e){t.innerText?t.innerText=e:t.nodeValue?t.nodeValue=e:t.textContent&&(t.textContent=e)}function s(t){return t.innerText?t.innerText:t.nodeValue?t.nodeValue:t.textContent?t.textContent:""}function c(t){do t=t.previousSibling;while(t&&1!==t.nodeType&&3!==t.nodeType);return t}function u(e,n,r){var o,a=e&&e[0];if(a){if(!r){if(3===a.nodeType)return a;if(t.trim(e.text()))return u(e.contents().last(),n)}for(o=c(a);!o;){if(e=e.parent(),e.is(n)||!e.length)return!1;o=c(e[0])}if(o)return u(t(o),n)}return!1}function f(e,n){return e?"string"==typeof e?(e=t(e,n),e.length?e:!1):e.jquery?e:!1:!1}function h(t){for(var e=t.innerHeight(),n=["paddingTop","paddingBottom"],r=0,o=n.length;o>r;r++){var a=parseInt(t.css(n[r]),10);isNaN(a)&&(a=0),e-=a}return e}if(!t.fn.dotdotdot){t.fn.dotdotdot=function(e){if(0==this.length)return t.fn.dotdotdot.debug('No element found for "'+this.selector+'".'),this;if(this.length>1)return this.each(function(){t(this).dotdotdot(e)});var o=this;o.data("dotdotdot")&&o.trigger("destroy.dot"),o.data("dotdotdot-style",o.attr("style")||""),o.css("word-wrap","break-word"),"nowrap"===o.css("white-space")&&o.css("white-space","normal"),o.bind_events=function(){return o.bind("update.dot",function(e,d){e.preventDefault(),e.stopPropagation(),l.maxHeight="number"==typeof l.height?l.height:h(o),l.maxHeight+=l.tolerance,"undefined"!=typeof d&&(("string"==typeof d||d instanceof HTMLElement)&&(d=t("<div />").append(d).contents()),d instanceof t&&(i=d)),g=o.wrapInner('<div class="dotdotdot" />').children(),g.contents().detach().end().append(i.clone(!0)).find("br").replaceWith("  <br />  ").end().css({height:"auto",width:"auto",border:"none",padding:0,margin:0});var c=!1,u=!1;return s.afterElement&&(c=s.afterElement.clone(!0),c.show(),s.afterElement.detach()),a(g,l)&&(u="children"==l.wrap?n(g,l,c):r(g,o,g,l,c)),g.replaceWith(g.contents()),g=null,t.isFunction(l.callback)&&l.callback.call(o[0],u,i),s.isTruncated=u,u}).bind("isTruncated.dot",function(t,e){return t.preventDefault(),t.stopPropagation(),"function"==typeof e&&e.call(o[0],s.isTruncated),s.isTruncated}).bind("originalContent.dot",function(t,e){return t.preventDefault(),t.stopPropagation(),"function"==typeof e&&e.call(o[0],i),i}).bind("destroy.dot",function(t){t.preventDefault(),t.stopPropagation(),o.unwatch().unbind_events().contents().detach().end().append(i).attr("style",o.data("dotdotdot-style")||"").data("dotdotdot",!1)}),o},o.unbind_events=function(){return o.unbind(".dot"),o},o.watch=function(){if(o.unwatch(),"window"==l.watch){var e=t(window),n=e.width(),r=e.height();e.bind("resize.dot"+s.dotId,function(){n==e.width()&&r==e.height()&&l.windowResizeFix||(n=e.width(),r=e.height(),u&&clearInterval(u),u=setTimeout(function(){o.trigger("update.dot")},100))})}else c=d(o),u=setInterval(function(){if(o.is(":visible")){var t=d(o);(c.width!=t.width||c.height!=t.height)&&(o.trigger("update.dot"),c=t)}},500);return o},o.unwatch=function(){return t(window).unbind("resize.dot"+s.dotId),u&&clearInterval(u),o};var i=o.contents(),l=t.extend(!0,{},t.fn.dotdotdot.defaults,e),s={},c={},u=null,g=null;return l.lastCharacter.remove instanceof Array||(l.lastCharacter.remove=t.fn.dotdotdot.defaultArrays.lastCharacter.remove),l.lastCharacter.noEllipsis instanceof Array||(l.lastCharacter.noEllipsis=t.fn.dotdotdot.defaultArrays.lastCharacter.noEllipsis),s.afterElement=f(l.after,o),s.isTruncated=!1,s.dotId=p++,o.data("dotdotdot",!0).bind_events().trigger("update.dot"),l.watch&&o.watch(),o},t.fn.dotdotdot.defaults={ellipsis:"... ",wrap:"word",fallbackToLetter:!0,lastCharacter:{},tolerance:0,callback:null,after:null,height:null,watch:!1,windowResizeFix:!0},t.fn.dotdotdot.defaultArrays={lastCharacter:{remove:[" "," ",",",";",".","!","?"],noEllipsis:[]}},t.fn.dotdotdot.debug=function(){};var p=1,g=t.fn.html;t.fn.html=function(n){return n!=e&&!t.isFunction(n)&&this.data("dotdotdot")?this.trigger("update",[n]):g.apply(this,arguments)};var v=t.fn.text;t.fn.text=function(n){return n!=e&&!t.isFunction(n)&&this.data("dotdotdot")?(n=t("<div />").text(n).html(),this.trigger("update",[n])):v.apply(this,arguments)}}}(jQuery);;
var adService = adService || {};
/* Initialize AnimationFrame shim */
if (AnimationFrame !== undefined) AnimationFrame.shim();

// Debounced resize
(function(e){var t=e.event,n,r;n=t.special.debouncedresize={setup:function(){e(this).on("resize",n.handler)},teardown:function(){e(this).off("resize",n.handler)},handler:function(e,i){var s=this,o=arguments||[],u=function(){e.type="debouncedresize";t.dispatch.apply(s,o)};if(r){clearTimeout(r)}i?u():r=setTimeout(u,n.threshold)},threshold:150}})(jQuery);

// Uses requestanimationframe for timeouts and intervals, just pass true to either function as last argument
// Needed for an iOS fix
(function(){if(window.getTimeouts!==undefined)return;var e="rafTimer",t={},n={},r=window.setTimeout,i=window.setInterval,s=window.clearTimeout,o=window.clearInterval,u=window.requestAnimationFrame,a=function(e,r){var i=r||false,s=i?n:t;if(s[e]){s[e].callback=undefined;s[e].loop=false;return true}else{return false}},f=function(r,i,s){function h(){var e=(new Date).getTime();if(c[o].loop!==false){c[o].requestededFrame=u(h);c[o].loop=e<=f}else{if(c[o].callback)c[o].callback();if(l){f=(new Date).getTime()+i;c[o].loop=e<=f;c[o].requestedFrame=u(h)}else{delete c[o]}}}var o,a=r.name||e+Math.floor(Math.random()*1e3),f=(new Date).getTime()+i,l=s||false,c=l?n:t;o=a+""+f;c[o]={};c[o].loop=true;c[o].callback=r;h();return o},l=function(e,t,n,s){if(n){return f(e,t,s)}else{return s?i(e,t):r(e,t)}},c=function(t,n){if(t&&t.indexOf&&t.indexOf(e)>-1){return a(t,n)}else{return n?o(t):s(t)}};window.getTimeouts=function(){return{timeouts:t,intervals:n}};window.setTimeout=function(e,t,n){return l(e,t,n)};window.setInterval=function(e,t,n){return l(e,t,n,true)};window.clearTimeout=function(e){return c(e)};window.clearInterval=function(e){return c(e,true)}})();

// From http://stackoverflow.com/a/14223920
function iOSversion() {
  if (/iP(hone|od|ad)/.test(navigator.platform)) {
    // supports iOS 2.0 and later: <http://bit.ly/TJjs1V>
    var v = (navigator.appVersion).match(/OS (\d+)_(\d+)_?(\d+)?/);
    return [parseInt(v[1], 10), parseInt(v[2], 10), parseInt(v[3] || 0, 10)];
  }
  return false;
}

/*
Prevent Overscroll on iOS devices
https://github.com/luster-io/prevent-overscroll

The MIT License (MIT)

Copyright (c) 2014 luster-io

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.
 */
/*var overscroll = function(el) {
  el.addEventListener('touchstart', function() {
    var top = el.scrollTop
      , totalScroll = el.scrollHeight
      , currentScroll = top + el.offsetHeight
    //If we're at the top or the bottom of the containers
    //scroll, push up or down one pixel.
    //
    //this prevents the scroll from "passing through" to
    //the body.
    if(top === 0) {
      el.scrollTop = 1
    } else if(currentScroll === totalScroll) {
      el.scrollTop = top - 1
    }
  });
  el.addEventListener('touchmove', function(evt) {
    //if the content is actually scrollable, i.e. the content is long enough
    //that scrolling can occur
    if(el.offsetHeight < el.scrollHeight)
      evt._isScroller = true
  });
}
document.addEventListener('touchmove', function(evt) {
  //In this case, the default behavior is scrolling the body, which
  //would result in an overflow.  Since we don't want that, we preventDefault.
  if(!evt._isScroller) {
    evt.preventDefault()
  }
});
*/

;(function(){"use strict";function e(t,r){function s(e,t){return function(){return e.apply(t,arguments)}}var i;r=r||{};this.trackingClick=false;this.trackingClickStart=0;this.targetElement=null;this.touchStartX=0;this.touchStartY=0;this.lastTouchIdentifier=0;this.touchBoundary=r.touchBoundary||10;this.layer=t;this.tapDelay=r.tapDelay||200;this.tapTimeout=r.tapTimeout||700;if(e.notNeeded(t)){return}var o=["onMouse","onClick","onTouchStart","onTouchMove","onTouchEnd","onTouchCancel"];var u=this;for(var a=0,f=o.length;a<f;a++){u[o[a]]=s(u[o[a]],u)}if(n){t.addEventListener("mouseover",this.onMouse,true);t.addEventListener("mousedown",this.onMouse,true);t.addEventListener("mouseup",this.onMouse,true)}t.addEventListener("click",this.onClick,true);t.addEventListener("touchstart",this.onTouchStart,false);t.addEventListener("touchmove",this.onTouchMove,false);t.addEventListener("touchend",this.onTouchEnd,false);t.addEventListener("touchcancel",this.onTouchCancel,false);if(!Event.prototype.stopImmediatePropagation){t.removeEventListener=function(e,n,r){var i=Node.prototype.removeEventListener;if(e==="click"){i.call(t,e,n.hijacked||n,r)}else{i.call(t,e,n,r)}};t.addEventListener=function(e,n,r){var i=Node.prototype.addEventListener;if(e==="click"){i.call(t,e,n.hijacked||(n.hijacked=function(e){if(!e.propagationStopped){n(e)}}),r)}else{i.call(t,e,n,r)}}}if(typeof t.onclick==="function"){i=t.onclick;t.addEventListener("click",function(e){i(e)},false);t.onclick=null}}var t=navigator.userAgent.indexOf("Windows Phone")>=0;var n=navigator.userAgent.indexOf("Android")>0&&!t;var r=/iP(ad|hone|od)/.test(navigator.userAgent)&&!t;var i=r&&/OS 4_\d(_\d)?/.test(navigator.userAgent);var s=r&&/OS ([6-9]|\d{2})_\d/.test(navigator.userAgent);var o=navigator.userAgent.indexOf("BB10")>0;e.prototype.needsClick=function(e){switch(e.nodeName.toLowerCase()){case"button":case"select":case"textarea":if(e.disabled){return true}break;case"input":if(r&&e.type==="file"||e.disabled){return true}break;case"label":case"iframe":case"video":return true}return/\bneedsclick\b/.test(e.className)};e.prototype.needsFocus=function(e){switch(e.nodeName.toLowerCase()){case"textarea":return true;case"select":return!n;case"input":switch(e.type){case"button":case"checkbox":case"file":case"image":case"radio":case"submit":return false}return!e.disabled&&!e.readOnly;default:return/\bneedsfocus\b/.test(e.className)}};e.prototype.sendClick=function(e,t){var n,r;if(document.activeElement&&document.activeElement!==e){document.activeElement.blur()}r=t.changedTouches[0];n=document.createEvent("MouseEvents");n.initMouseEvent(this.determineEventType(e),true,true,window,1,r.screenX,r.screenY,r.clientX,r.clientY,false,false,false,false,0,null);n.forwardedTouchEvent=true;e.dispatchEvent(n)};e.prototype.determineEventType=function(e){if(n&&e.tagName.toLowerCase()==="select"){return"mousedown"}return"click"};e.prototype.focus=function(e){var t;if(r&&e.setSelectionRange&&e.type.indexOf("date")!==0&&e.type!=="time"&&e.type!=="month"){t=e.value.length;e.setSelectionRange(t,t)}else{e.focus()}};e.prototype.updateScrollParent=function(e){var t,n;t=e.fastClickScrollParent;if(!t||!t.contains(e)){n=e;do{if(n.scrollHeight>n.offsetHeight){t=n;e.fastClickScrollParent=n;break}n=n.parentElement}while(n)}if(t){t.fastClickLastScrollTop=t.scrollTop}};e.prototype.getTargetElementFromEventTarget=function(e){if(e.nodeType===Node.TEXT_NODE){return e.parentNode}return e};e.prototype.onTouchStart=function(e){var t,n,s;if(e.targetTouches.length>1){return true}t=this.getTargetElementFromEventTarget(e.target);n=e.targetTouches[0];if(r){s=window.getSelection();if(s.rangeCount&&!s.isCollapsed){return true}if(!i){if(n.identifier&&n.identifier===this.lastTouchIdentifier){e.preventDefault();return false}this.lastTouchIdentifier=n.identifier;this.updateScrollParent(t)}}this.trackingClick=true;this.trackingClickStart=e.timeStamp;this.targetElement=t;this.touchStartX=n.pageX;this.touchStartY=n.pageY;if(e.timeStamp-this.lastClickTime<this.tapDelay){e.preventDefault()}return true};e.prototype.touchHasMoved=function(e){var t=e.changedTouches[0],n=this.touchBoundary;if(Math.abs(t.pageX-this.touchStartX)>n||Math.abs(t.pageY-this.touchStartY)>n){return true}return false};e.prototype.onTouchMove=function(e){if(!this.trackingClick){return true}if(this.targetElement!==this.getTargetElementFromEventTarget(e.target)||this.touchHasMoved(e)){this.trackingClick=false;this.targetElement=null}return true};e.prototype.findControl=function(e){if(e.control!==undefined){return e.control}if(e.htmlFor){return document.getElementById(e.htmlFor)}return e.querySelector("button, input:not([type=hidden]), keygen, meter, output, progress, select, textarea")};e.prototype.onTouchEnd=function(e){var t,o,u,a,f,l=this.targetElement;if(!this.trackingClick){return true}if(e.timeStamp-this.lastClickTime<this.tapDelay){this.cancelNextClick=true;return true}if(e.timeStamp-this.trackingClickStart>this.tapTimeout){return true}this.cancelNextClick=false;this.lastClickTime=e.timeStamp;o=this.trackingClickStart;this.trackingClick=false;this.trackingClickStart=0;if(s){f=e.changedTouches[0];l=document.elementFromPoint(f.pageX-window.pageXOffset,f.pageY-window.pageYOffset)||l;l.fastClickScrollParent=this.targetElement.fastClickScrollParent}u=l.tagName.toLowerCase();if(u==="label"){t=this.findControl(l);if(t){this.focus(l);if(n){return false}l=t}}else if(this.needsFocus(l)){if(e.timeStamp-o>100||r&&window.top!==window&&u==="input"){this.targetElement=null;return false}this.focus(l);this.sendClick(l,e);if(!r||u!=="select"){this.targetElement=null;e.preventDefault()}return false}if(r&&!i){a=l.fastClickScrollParent;if(a&&a.fastClickLastScrollTop!==a.scrollTop){return true}}if(!this.needsClick(l)){e.preventDefault();this.sendClick(l,e)}return false};e.prototype.onTouchCancel=function(){this.trackingClick=false;this.targetElement=null};e.prototype.onMouse=function(e){if(!this.targetElement){return true}if(e.forwardedTouchEvent){return true}if(!e.cancelable){return true}if(!this.needsClick(this.targetElement)||this.cancelNextClick){if(e.stopImmediatePropagation){e.stopImmediatePropagation()}else{e.propagationStopped=true}e.stopPropagation();e.preventDefault();return false}return true};e.prototype.onClick=function(e){var t;if(this.trackingClick){this.targetElement=null;this.trackingClick=false;return true}if(e.target.type==="submit"&&e.detail===0){return true}t=this.onMouse(e);if(!t){this.targetElement=null}return t};e.prototype.destroy=function(){var e=this.layer;if(n){e.removeEventListener("mouseover",this.onMouse,true);e.removeEventListener("mousedown",this.onMouse,true);e.removeEventListener("mouseup",this.onMouse,true)}e.removeEventListener("click",this.onClick,true);e.removeEventListener("touchstart",this.onTouchStart,false);e.removeEventListener("touchmove",this.onTouchMove,false);e.removeEventListener("touchend",this.onTouchEnd,false);e.removeEventListener("touchcancel",this.onTouchCancel,false)};e.notNeeded=function(e){var t;var r;var i;if(typeof window.ontouchstart==="undefined"){return true}r=+(/Chrome\/([0-9]+)/.exec(navigator.userAgent)||[,0])[1];if(r){if(n){t=document.querySelector("meta[name=viewport]");if(t){if(t.content.indexOf("user-scalable=no")!==-1){return true}if(r>31&&document.documentElement.scrollWidth<=window.outerWidth){return true}}}else{return true}}if(o){i=navigator.userAgent.match(/Version\/([0-9]*)\.([0-9]*)/);if(i[1]>=10&&i[2]>=3){t=document.querySelector("meta[name=viewport]");if(t){if(t.content.indexOf("user-scalable=no")!==-1){return true}if(document.documentElement.scrollWidth<=window.outerWidth){return true}}}}if(e.style.msTouchAction==="none"){return true}if(e.style.touchAction==="none"){return true}return false};e.attach=function(t,n){return new e(t,n)};if(typeof define=="function"&&typeof define.amd=="object"&&define.amd){define(function(){return e})}else if(typeof module!=="undefined"&&module.exports){module.exports=e.attach;module.exports.FastClick=e}else{window.FastClick=e}})();

$(function() {
    FastClick.attach(document.body);
});

/**
  * Used for to shorten dek content
  * Source: http://viralpatel.net/blogs/dynamically-shortened-text-show-more-link-jquery/
 **/
jQuery.fn.shorten = function(settings) {
  var config = {
    showChars : 250,
    ellipsesText : "...",
    moreText : "See More",
    lessText : "Less"
  };

  if (settings) {
    $.extend(config, settings);
  }

  $('.morelink').die();
  $('.morelink').live('click', function() {
    var $this = $(this);
    if ($this.hasClass('less')) {
      $this.removeClass('less');
      $this.html(config.moreText);
    } else {
      $this.addClass('less');
      $this.html(config.lessText);
    }
    $this.parent().prev().toggle();
    $this.prev().toggle();
    return false;
  });

  return this.each(function() {
    var $this = $(this);

    var content = $this.html();
    if (content.length > config.showChars) {
      var c = content.substr(0, config.showChars);
      var h = content.substr(config.showChars , content.length - config.showChars);
      var html = c + '<span class="moreellipses">' + config.ellipsesText + '</span><span class="morecontent"><span>' + h + '</span>&nbsp;<a href="javascript://nop/" class="morelink">' + config.moreText + '</a></span>';
      $this.html(html);
      $(".morecontent span").hide();
    }
  });
};
// Using the closure to map jQuery to $.
(function($) {
  /* Global variables */
  var meredith = meredith || {};
  meredith.breakpoints = {
      landscapephone: 320,
      mobiletwopanels: 405,
      twocolumns: 768,
      twocolumnstwopanels: 800,
      tablet: 980,
      desktop: 1060,
      socialDesktop: 1100,
      wide: 1260
  };
  meredith.currentBreakpoint = window.innerWidth;
  meredith.lastBreakpoint = this.currentBreakpoint;
  meredith.timeouts = {}; // use an object to store meredith.timeouts
  meredith.lastScroll = 0;
  meredith.scroll = 0;
  meredith.scrolling = false;
  // meredith.getScroll = function() { return $("body").hasClass("admin-menu") ? meredith.scroll - $("#admin-menu").height() : meredith.scroll; };
  meredith.isMobile = function() { return window.innerWidth < meredith.breakpoints.twocolumns; };
  meredith.isTablet = function() { return window.innerWidth >= meredith.breakpoints.twocolumns && window.innerWidth < meredith.breakpoints.desktop; };
  meredith.isDesktop = function() { return window.innerWidth >= meredith.breakpoints.desktop; };
  meredith.mouseSupport = false;
  meredith.touchSupport = false;
  meredith.isTouch = function() { return $("html").hasClass("touch") || meredith.touchSupport; };
  meredith.browseOpen = false;
  
  var headroom, hidingOverflow = false, $menu;
  meredith.breakpointQueries = {
    maxLandscapephone: '(max-width:'+meredith.breakpoints.landscapephone+'px)',
    minTwocolumns: '(min-width:'+meredith.breakpoints.twocolumns+'px)',
    maxTwocolumns: '(max-width:'+(meredith.breakpoints.twocolumns-1)+'px)',
    minTablet: '(min-width:'+meredith.breakpoints.tablet+'px)',
    maxTablet: '(max-width:'+(meredith.breakpoints.tablet-1)+'px)',
    minDesktop: '(min-width:'+meredith.breakpoints.desktop+'px)',
    maxDesktop: '(max-width:'+(meredith.breakpoints.desktop-1)+'px)',
    minWide: '(min-width:'+meredith.breakpoints.wide+'px)',
    minTwocolumnsMaxWide: '(min-width:'+meredith.breakpoints.twocolumns+'px) and (max-width:'+meredith.breakpoints.wide+'px)'
  };
  
  var iOSVersion = iOSversion();
  if (iOSVersion) $("html").addClass("ios-device");
  
  $(window)
    .on('debouncedresize', function() {
      meredith.lastBreakpoint = meredith.currentBreakpoint;
      meredith.currentBreakpoint = window.innerWidth;
    })
    .on('scroll', function() {
      meredith.lastScroll = meredith.scroll;
      meredith.scroll = $(this).scrollTop();
      meredith.scrolling = true;
      clearTimeout(meredith.timeouts.recordIsScrolling);
      meredith.timeouts.recordIsScrolling = setTimeout(function() {
        meredith.scrolling = false;
      }, 1000, true);
    })
    .on('mousemove', function() {
      meredith.mouseSupport = true;
      $(this).off('mousemove');
    });
  document.addEventListener("touchmove", function(e) {
    if (!meredith.touchSupport)
      meredith.touchSupport = true;
    meredith.lastScroll = meredith.scroll;
    meredith.scroll = $(window).scrollTop();
  }, false);
  
  /*$(document).ready(function() {
    $menu = $("#block-tb-megamenu-main-menu .tb-megamenu > .nav-collapse");
    enquire.register(meredith.breakpointQueries.minTwocolumnsMaxWide, {
      match: function() {
        if (!hidingOverflow) {
          $("#header").css("overflow", "hidden");
          $menu.children("ul").css("overflow", "hidden");
          hidingOverflow = true;
        }
      },
      unmatch: function() {
        $("#header").removeAttr("style");
        $menu.children("ul").removeAttr("style");
      }
    });
  });*/
  Drupal.behaviors.headerEvents = {
    attach: function() {
      /* Code for showing menu items and moving into "More" menu */
      var toggleMenu = function() { // Toggles the Browse menu
          var a = $browseButton.hasClass("open") ? "transition.slideUpOut" : "transition.slideDownIn";
          $browseButton.toggleClass("open").next(".nav-collapse").velocity(a, {
            duration: 300,
            complete: function() {
              if (!$browseButton.hasClass("open"))
                $browseButton.removeAttr("style");
            }
          });
        },
        toggleMenuItem = function(context, action) { // Toggles individual menu items
          if (action == undefined) action = $(context).hasClass("open") ? "close" : "open";
          var doDelay = $(context).siblings("li.open").length > 0;
          if (action == "open" && $(context).siblings("li.open").length) toggleMenuItem($(context).siblings("li.open"), "close");
          var dd = $(context).children(".dropdown-menu");
          if (!meredith.isMobile()
                && (!meredith.isDesktop() || (meredith.isDesktop() && !$headerContainer.hasClass("headroom--top")))
                && $(".header-mobile-icon.user").hasClass("open")
             )
            toggleUserButton("close");
          if (action == "open" && !dd.is(":visible") || action == "close" && dd.is(":visible")) {
            if (action == "open")
              $(context).siblings("li.open").length ? dd.delay(100).show(0).children(".mega-dropdown-inner").hide() : dd.show().children(".mega-dropdown-inner").hide();
            dd
              .children(".mega-dropdown-inner")
              .velocity("stop", true)
              .velocity(action == "open" ? "slideDown" : "slideUp", {
                delay: doDelay ? 100 : 0,
                duration: 100,
                easing: "linear"
              });
  
            if (action == "open") {
              $(context).add(dd).addClass("open");
            } else if (action == "close") {
              $(this).add(dd).removeAttr("style");
              $(context).add(dd).removeClass("open");
            }
  
            if (!meredith.isMobile() && !$(context).hasClass("single-column")) {
              $("#header-container > .faux-full-width").velocity(action == "open" ? "slideDown" : "slideUp", {
                duration: 100,
                easing: "linear",
                delay: doDelay ? 100 : 0,
                complete: function() {
                  if (action == "open")
                    $("#header-container > .faux-full-width").height($(context).children(".tb-megamenu-submenu").height());
                }
              });
            }
            if (meredith.isMobile()) {
              $(context).children("i.fa-angle-right").velocity({
                rotateZ: action == "open" ? "90deg" : "0deg"
              }, {
                duration: 100,
                easing: "linear"
              });
            }
          }
        },
        enableMenuToggle = function(context) { // Enables menu toggling depending on breakpoint
          if (!$(context).hasClass("menubind")) {
            $(context).add($(context).children("a")).off(); // disable tbmegamenus and our previous events
            if (!meredith.isMobile()) { // Add hovering events
              $(context)
                .on("mouseenter", function() {
                  var $this = this, $$this = $(this);
                  if (!$$this.hasClass("open")) {
                    // Setting a timeout so if user moves mouse over menu items quickly, menu items won't show unless interaction is deliberate.
                    meredith.timeouts.mouseEnterTimeout = setTimeout(function() {
                      clearTimeout(meredith.timeouts.mouseEnterTimeout);
                      toggleMenuItem($this, "open");
                    }, 200, true);
                  }
                })
                .on("mouseleave", function(e) {
                  clearTimeout(meredith.timeouts.mouseEnterTimeout);
                  var $this = this, $$this = $(this);
                  if ($$this.hasClass("open")) {
                    if ($(e.toElement).hasClass("faux-full-width") || $(e.relatedTarget).hasClass("faux-full-width")) return;
                    meredith.timeouts.mouseLeaveTimeout = setTimeout(function() {
                      clearTimeout(meredith.timeouts.mouseLeaveTimeout);
                      toggleMenuItem($this, "close");
                    }, 100, true);
                  }
                });
            }
            $(context) // Add click event
              .addClass("menubind")
              .on("click", function(e) {
                var ddv = $(this).children(".dropdown-menu"),
                    href = $(e.target).attr("href");
                if (!ddv.length || (ddv.length && ddv.is(":visible") && (($(e.target).is("a") || $(e.target).parents("a").length || $(e.target).parents(".dropdown-menu").length) && (href !== "" && href !== "#")))) { // if clicking on the link, go to it
                  return;
                }
                else {
                  clearTimeout(meredith.timeouts.mouseEnterTimeout);
                  toggleMenuItem(this, ddv.is(":visible") ? "close" : "open");
                  return false;
                }
              });
          }
        },
        disableMenuToggle = function(context, removeStyle) {
          if (removeStyle === undefined) removeStyle = true;
          $(context).off("mouseover mouseout mouseenter mouseleave click").removeClass("menubind");
          if (removeStyle) $(context).removeAttr("style").children("div").removeAttr("style");
        },
        resetMenuToggle = function(context) {
          disableMenuToggle(context);
          enableMenuToggle(context);
        },
        items = null, // the menu items
        moreObj = $('<li class="tb-megamenu-item level-1 mega tb-megamenu-li dropdown more single-column right-aligned">\
                  <a href="#" class="dropdown-toggle">More</a> <i class="fa fa-sort-desc"></i>\
                  <i class="fa-angle-right"></i><i class="fa-angle-down"></i>\
                  <div class="tb-megamenu-submenu dropdown-menu mega-dropdown-menu nav-child">\
                    <div class="mega-dropdown-inner">\
                      <div class="tb-megamenu-row row-fluid">\
                        <div id="tb-megamenu-column-1" class="tb-megamenu-column span12 mega-col-nav">\
                          <div class="tb-megamenu-column-inner mega-inner clearfix">\
                            <ul class="tb-megamenu-subnav mega-nav level-1 items-2">\
                            </ul>\
                          </div>\
                        </div>\
                      </div>\
                    </div>\
                  </div>\
                </li>');
  
      $("#header-container > .faux-full-width").on("mouseleave.hideMenu", function(e) {
        if (!$(e.toElement).parents("#block-tb-megamenu-main-menu").length && !$(e.relatedTarget).parents("#block-tb-megamenu-main-menu").length)
          toggleMenuItem($("#block-tb-megamenu-main-menu .tb-megamenu-submenu.open").parent("li"), "close");
      });
  
      $("body").click(function(e) {
        if (!$(e.toElement).parents("#block-tb-megamenu-main-menu").length && !$(e.relatedTarget).parents("#block-tb-megamenu-main-menu").length)
          toggleMenuItem($("#block-tb-megamenu-main-menu .tb-megamenu-submenu.open").parent("li"), "close");
      });
  
      var
        moreWidths = 0, $items, moreAdded = false, moreItemsAdded = false, sheet,
        removeMoreMenu = function() {
          $(document.head).find("style#headerMenuWidths").remove();
        },
        makeMoreMenu = function() {
          $mainmenu = $("#block-tb-megamenu-main-menu").children(".content").children(".tb-megamenu").children(".nav-collapse");
          items = $("#block-tb-megamenu-main-menu").find("ul.tb-megamenu-nav.level-0 > li.tb-megamenu-item.level-1:not(.more):not(.subscribe):not(.last)");
          var lx = $mainmenu.offset().left - ($("#header").offset().left/* + 20*/),
              rx = ($("#header").offset().left + (parseInt($("#header").css("padding-left")) * 2) + $("#header").width()) - ($mainmenu.offset().left + $mainmenu.width()),
              total = 0,
              w,
              selector,
              x = lx + rx,
              moreWidthsDelta = items.first().outerWidth(true); // used to test for change in item size. if not equal to previous comparison, redo
          if (moreWidths === moreWidthsDelta) return;
  
          moreWidths = moreWidthsDelta;
          if (moreAdded) {
            removeMoreMenu();
          }
          else {
            $("ul.tb-megamenu-nav.level-0")
              .find("li.filler")
              .remove()
              .end()
              .find("li.last")
              .before(moreObj);
            $moreWidth = moreObj.outerWidth(true);
            if (!moreItemsAdded) {
              // since first 3 items should always be shown, start at 4th item
              for (var i = 3; i < items.length; i++) {
                // append to more menu
                $('<li class="' + items.eq(i).attr("class").replace('level-1', 'level-2') + '"></li>')
                  .html(items.eq(i).children('a').clone().wrap('<div>').parent().html())
                  .appendTo(moreObj.find("ul.tb-megamenu-subnav"));
              }
              moreItemsAdded = true;
            }
          }
  
          sheet = (function() {
            var style = document.createElement("style");
            style.type = "text/css";
            style.id = "headerMenuWidths";
            style.appendChild(document.createTextNode(""));
            document.head.appendChild(style);
            return style.sheet;
          })();
  
          for (var i = 0; i < items.length; i++) {
            // append to more menu
            selector = '.'+items.eq(i).attr("class").replace(/\s*menubind\s*/g, '').replace(/ /g, '.');
            total += items.eq(i).outerWidth(true);
            if (i === items.length - 1)
              w = x + total < w ? w : x + total + 20;
            else
              w = x + total + $moreWidth + 20;
            sheet.insertRule("@media only screen and (min-width: " + w + "px) { #header #block-tb-megamenu-main-menu .nav-collapse ul.tb-megamenu-nav > li.more .tb-megamenu-subnav li"+selector.replace('level-1', 'level-2')+" { display: none; } #header #block-tb-megamenu-main-menu .nav-collapse ul.tb-megamenu-nav > li"+selector+" { display: inline-block; } }", 0);
            if (i === items.length - 1) {
              sheet.insertRule("@media only screen and (min-width: " + w + "px) { #header #block-tb-megamenu-main-menu .nav-collapse ul.tb-megamenu-nav { width: 100%; text-align: justify; text-justify: distribute; } #header #block-tb-megamenu-main-menu .nav-collapse ul.tb-megamenu-nav li.last { width: 100%; display: inline-block; } #header #block-tb-megamenu-main-menu .nav-collapse ul.tb-megamenu-nav > li.more { display: none !important; } }", 0);
            }
          }
  
  
          sheet.insertRule("#header #block-tb-megamenu-main-menu .nav-collapse ul.tb-megamenu-nav > li.more { display: inline-block; }", 0);
          sheet.insertRule("#header #block-tb-megamenu-main-menu .nav-collapse ul.tb-megamenu-nav > li:nth-child(n+4) { display: none; }", 0);
          sheet.insertRule("#header #block-tb-megamenu-main-menu .nav-collapse ul.tb-megamenu-nav { width: 100%; }", 0);
  
          moreAdded = true;
        };
  
        var $bannerContainer = $("#header-banner-container"),
            $headerContainer = $("#header-container"),
            adminMenuHeight = function() {
              if ($("body").hasClass("admin-menu"))
                return $("#admin-menu").length === 0 ? 30 : $("#admin-menu").height();
              return 0;
            }, amH, bcH;
  
        var setupHeader = function() {
          // Using headroom.js library (http://wicky.nillia.ms/headroom.js/)
          if (!meredith.isMobile() || meredith.isMobile() && !meredith.isTouch() /* Old blackberry devices? Devices that don't have touch support? */) {
            // Undo anything done while in mobile
            $(document).off("scroll.mobileHeader touchmove.mobileHeader");
            clearTimeout(meredith.timeouts.removeCheckMobileHeaderScroll);
            clearInterval(meredith.timeouts.checkMobileHeader);
  
            $headerContainer
              .css("top", 0)
              .headroom({
                "tolerance": 0,
                "offset": 0,
                "classes": {
                  "initial": "animated",
                  "pinned": "headroom--pinned",
                  "unpinned": "headroom--unpinned",
                  "top": "headroom--top",
                  "notTop": "headroom--not-top"
                },
                onPin: headroom.functions.onPin,
                onUnpin: headroom.functions.onUnpin,
                onTop: headroom.functions.onTop,
                onNotTop: headroom.functions.onNotTop
              });
            headroom.data = $headerContainer.data("headroom");
          } else if (meredith.isMobile() && meredith.isTouch()) {
            if (headroom.data !== null)
              $headerContainer.headroom("destroy");
            $headerContainer.removeClass("headroom--top");
            /**
             *  The headroom.js+velocity.js approach is a bit laggy on mobile devices,
             *  so just going to use jquery's animate and a timeout that watches the
             *  scroll position.
             **/
            var t = $(document).scrollTop(), h = $headerContainer.height(), set = false, pinned = true;
            var checkTop = function() {
              var tt = $(document).scrollTop();
              if (tt > t && tt > h && pinned) { // moved down
                meredith.timeouts.hideMobileHeader = setTimeout(function() {
                  if (!meredith.browseOpen && !$("#block-search-form").find("input.form-text").is(":focus")) {
                    $headerContainer.stop().animate({
                      top: -40
                    });
                  }
                }, 2000, true);
                pinned = false;
              } else if ((tt < t || tt < h) && !pinned) { // moved up
                clearTimeout(meredith.timeouts.hideMobileHeader);
                $headerContainer.stop().animate({
                  top: 0
                });
                pinned = true;
              }
              t = tt;
            };
            $(document).on('scroll.mobileHeader touchmove.mobileHeader', function(e) {
              clearTimeout(meredith.timeouts.removeCheckMobileHeaderScroll);
              if (!meredith.browseOpen && !$("#block-search-form").find("input.form-text").is(":focus") && !set) {
                meredith.timeouts.checkMobileHeader = setInterval(checkTop, 250, true);
                set = true;
                meredith.timeouts.removeCheckMobileHeader = setTimeout(function() {
                  clearInterval(meredith.timeouts.checkMobileHeader);
                  set = false;
                }, 5000, true);
              }
            });
          }
        };
  
        headroom = {
          ontop: meredith.scroll <= 0,
          adLoaded: false,
          adWaitTime: this.adLoaded ? 2000 : 0,
          adDisplayed: false,
          data: null,
          reachedTop: true,
          topBannerMouseMoved: false,
          topBannerHeight: 0,
          fullHeaderHeight: -1,
          functions: {
            setTopAdRemoval: function() {
              if (!$("body").hasClass("node-type-slideshow")) {
                clearTimeout(meredith.timeouts.removeAd);
                meredith.timeouts.removeAd = setTimeout(function() {
                  if (!headroom.ontop
                    && !headroom.topBannerMouseMoved
                    && (!meredith.scrolling || (meredith.scrolling && meredith.scroll > meredith.lastScroll))
                    && meredith.scroll >= $("#content-container").offset().top - $("#block-tb-megamenu-main-menu").height()) {
                    $bannerContainer.velocity("stop").velocity("slideUp", {
                      duration: 100,
                      complete: function() {
                        $bannerContainer.show().css({position: "absolute", top: parseInt($bannerContainer.css("top"))});
                      }
                    });
                    $headerContainer.velocity("stop").velocity({
                      marginTop: 0,
                      top: adminMenuHeight()
                    }, 100, function() {
                      if ($headerContainer.hasClass("headroom--top"))
                        $headerContainer.css("top", adminMenuHeight() + $bannerContainer.height() - 1);
                    });
                    headroom.data.offset = meredith.isDesktop() ? $bannerContainer.height() + 110 : $bannerContainer.height();
                  } else {
                    clearTimeout(meredith.timeouts.removeAd);
                    headroom.functions.setTopAdRemoval();
                  }
                }, headroom.adWaitTime, true);
              }
            },
            hideTopAd: function() {
              if (headroom.adLoaded && !$("body").hasClass("node-type-slideshow") && !meredith.isMobile()) {
                if (meredith.scroll >= $("#content-container").offset().top - $("#block-tb-megamenu-main-menu").height())
                  headroom.functions.setTopAdRemoval();
                else {
                  $(window).on('scroll.headerBannerRemove touchmove.headerBannerRemove', function() {
                    if (meredith.scroll >= $("#content-container").offset().top - $("#block-tb-megamenu-main-menu").height()) {
                      headroom.functions.setTopAdRemoval();
                      $(window).off('scroll.headerBannerRemove touchmove.headerBannerRemove');
                    }
                  });
                }
                headroom.adDisplayed = true;
              }
            },
            adOnLoaded: function() {
              if (!headroom.adLoaded) {
                if (!meredith.isMobile())
                  $("body").addClass("top-ad-loaded");
  
                amH = adminMenuHeight();
                bcH = $bannerContainer.height();
                hcH = $("#header").height();
                if (!meredith.isMobile() && !headroom.adDisplayed) {
                  headroom.adLoaded = true;
                  headroom.adWaitTime = 2000;
  
                  if (headroom.ontop)
                    headroom.data.offset = meredith.isDesktop()
                      ? hcH - $("#block-tb-megamenu-main-menu").height()
                      : 0;
  
                  $bannerContainer
                    .velocity("slideDown", 100, function() {
                      if (meredith.scroll >= $bannerContainer.outerHeight(true) + $headerContainer.outerHeight(true))
                        headroom.functions.setTopAdRemoval();
                      $bannerContainer.css("top", amH);
                    });
  
                  $("body").velocity({
                    "paddingTop": hcH + bcH + (amH >= 30 ? amH - 30 : 0) - 1 + (meredith.isDesktop() ? 20 : 15)
                  }, {
                    duration: 100,
                    complete: function() {
                      $("body").css("paddingTop", "");
                    }
                  });
  
                  $headerContainer.velocity({
                    top: bcH + amH - 1
                  }, 100);
                }
  
                // Prevent ad from closing if user moves over it
                if (!$("body").hasClass("node-type-slideshow")) {
                  $("#block-meredith-karma-leaderboard-flex-1")
                    .on("mouseenter.hideTopAd", function() {
                      headroom.topBannerMouseMoved = true;
                      clearTimeout(meredith.timeouts.removeAd);
                    })
                    .on("mouseleave.hideTopAd", function() {
                      headroom.topBannerMouseMoved = false;
                      clearTimeout(meredith.timeouts.removeAd);
                      headroom.functions.hideTopAd();
                    });
                }
              }
            },
            onPin: function() {
            },
            onUnpin: function() {
            },
            onTop: function() {
              // Don't do anything in tablet if iOS and search is being interacted with
              if (iOSVersion && $("#block-search-form").hasClass("opened")) return;
  
              headroom.reachedTop = false;
              amH = adminMenuHeight() * 1;
              bcH = $bannerContainer.height();
              hcH = $headerContainer.height();
              if (meredith.isDesktop())
                headroom.fullHeaderHeight = $("#header").height();
              if (meredith.scroll <= 0) {
                headroom.reachedTop = true;
                headroom.data.offset = meredith.isDesktop()
                  ? hcH - $("#block-tb-megamenu-main-menu").height()
                  : 0;
              }
  
              if (meredith.isDesktop())
                $("#block-search-form").removeClass("opened").children(".content").removeAttr("style");
              $("#block-meredith-blocks-login-links").removeAttr("style");
  
              if (headroom.adLoaded) {
                if (!headroom.ontop) { // if not already on top
                  var t;
                  if (meredith.scroll > 0) {
                    $(window).on("scroll.headerBannerAtTop touchmove.headerBannerAtTop", function() {
                      if (meredith.scroll <= 0) {
                        headroom.reachedTop = true;
                        headroom.ontop = true;
                        headroom.data.offset = meredith.isDesktop() ? $("#block-tb-megamenu-main-menu").offset().top - bcH - amH : 0;
                        $bannerContainer.css("position", "fixed");
                        $(window).off('scroll.headerBannerAtTop touchmove.headerBannerAtTop');
  
                        t = bcH + amH - 1;
                        if (t < amH) t = amH;
                        $headerContainer
                          .removeAttr("style")
                          .css({
                            position: "absolute",
                            top: t
                          });
                      }
                      else if (!$("body").hasClass("node-type-slideshow") && !meredith.isMobile()) {
                        t = bcH + amH - 1/* + meredith.scroll*/;
                        if (t <= 0) t = amH;
                        $headerContainer.css({
                          position: "absolute",
                          top: t
                        });
                      }
                    });
                  }
                  else {
                    headroom.data.offset = meredith.isDesktop() ? $("#block-tb-megamenu-main-menu").offset().top : 0;
                  }
  
                  if (!$("body").hasClass("node-type-slideshow") && !meredith.isMobile()) {
                    t = bcH + amH - 1;
                    if (t < amH) t = amH;
                    $headerContainer.css({
                      position: "absolute",
                      top: t
                    });
                    if (meredith.scroll <= 0) {
                      $bannerContainer.css("position", "fixed");
                      $(window).off('scroll.headerBannerAtTop touchmove.headerBannerAtTop');
                    }
                  }
                }
                clearTimeout(meredith.timeouts.removeAd);
                $(window).off('scroll.headerbanner touchmove.headerbanner');
              }
              headroom.adDisplayed = false;
            },
            onNotTop: function() {
              // Don't do anything in tablet if iOS and search is being interacted with
              if (iOSVersion && $("#block-search-form").hasClass("opened")) return;
  
              $(window).off('scroll.headerBannerAtTop touchmove.headerBannerAtTop');
  
              if (meredith.scroll > $headerContainer.height() + adminMenuHeight())
                $headerContainer.addClass("headroom--unpinned");
  
              if (headroom.ontop) {
                headroom.ontop = false;
                headroom.functions.hideTopAd();
                toggleMenuItem($("#block-tb-megamenu-main-menu").find("li.tb-megamenu-item").has(".dropdown-menu:visible"), "hide");
              }
  
              if (!meredith.isMobile()) {
                if ($headerContainer.css("position") == "absolute")
                  $headerContainer.removeAttr("style");
                headroom.functions.hideTopAd();
              }
  
              if ($bannerContainer.css("position") == "fixed")
                $headerContainer.css("top", $bannerContainer.height() + adminMenuHeight());
            }
          }
        };
  
        // Remove custom styles set on body so there's no 'jump' on the body text when resizing between tablet and desktop
        /*$(window)
          .on('debouncedresize', function() {
            $("body").removeAttr("style");
          });*/
  
        $(document).ready(function() {
          $items = $("#block-tb-megamenu-main-menu").find(".tb-megamenu-nav > li.tb-megamenu-item.level-1.dropdown");
          enquire
            .register(meredith.breakpointQueries.minTwocolumnsMaxWide, {
              match: function() {
                makeMoreMenu();
                enableMenuToggle(moreObj);
              },
              unmatch: function() {
                disableMenuToggle(moreObj);
              },
              continuousMatch: true,
              doDebounce: true,
              debounceTime: 250
            })
            .register(meredith.breakpointQueries.minTwocolumns, {
              match: function(changed) {
                // alert("min two");
                $("#block-tb-megamenu-main-menu .nav-collapse").removeAttr('style');
                resetMenuToggle($items);
                setupHeader();
  
                // Remove any mobile header stuff
                meredith.browseOpen = false;
                $("html, body")
                  .css({
                    height: "auto",
                    position: "static",
                    top: 0
                  });
  
                amH = adminMenuHeight();
                $("body")
                  .css({
                    marginTop: prMarginTop,
                    // paddingTop: (meredith.isDesktop() ? (headroom.fullHeaderHeight === -1 ? 160 : headroom.fullHeaderHeight) : $headerContainer.height()) + $bannerContainer.height() + (amH >= 30 ? amH - 30 : 0) - 1 + (meredith.isDesktop() ? 20 : 15)
                  })
                  // .scrollTop(bodyScrollTop);
  
                /*if (amH > 0)
                  $("body").css({
                    paddingTop: (meredith.isDesktop() ? (headroom.fullHeaderHeight === -1 ? 160 : headroom.fullHeaderHeight) : $headerContainer.height()) + $bannerContainer.height() + (amH >= 30 ? amH - 30 : 0) - 1 + (meredith.isDesktop() ? 20 : 15)
                  });*/
  
                // Remove previous styles and re-calculate top offset of header container
                $headerContainer.removeAttr("style");
                if ($headerContainer.hasClass("headroom--top"))
                  $headerContainer.css("top", adminMenuHeight() + $bannerContainer.height() - 1);
                else if ($headerContainer.hasClass("headroom--not-top"))
                  $headerContainer.css("top", adminMenuHeight() + ($bannerContainer.css("position") == "fixed" ? $bannerContainer.height() : 0));
  
                // if ($bannerContainer.css("position") == "fixed")
                $bannerContainer.css("top", adminMenuHeight());
  
                if (meredith.isDesktop())
                  headroom.data.offset = adminMenuHeight() + ((headroom.fullHeaderHeight === -1 ? 160 : headroom.fullHeaderHeight) - $("#block-tb-megamenu-main-menu > .content > .tb-megamenu").height()) + ($bannerContainer.css("position") == "absolute" ? $bannerContainer.height() : 0);
                else if (meredith.isTablet())
                  headroom.data.offset = adminMenuHeight() + $bannerContainer.height();
  
                $("button.btn.tb-megamenu-button").removeClass("open");
              },
              unmatch: function() {
                resetMenuToggle($items);
                $("#block-tb-megamenu-main-menu .nav-collapse").removeAttr('style');
                setupHeader();
                removeMoreMenu();
                moreAdded = false;
                moreWidths = 0;
                $("html, body")
                  .css({
                    height: "",
                    position: "",
                    top: "",
                    marginTop: ""
                  });
              }
            })
            .register(meredith.breakpointQueries.maxTwocolumns, {
              match: function() {
                enableMenuToggle($items);
                setupHeader();
              }
            })
            .register(meredith.breakpointQueries.maxTwocolumns, {
              match: function() {
                // Remove previous styles and re-calculate top offset of header container
                $headerContainer.removeAttr("style");
                $headerContainer.css("top", adminMenuHeight());
              },
              continuousMatch: true,
              doDebounce: true,
              debounceTime: 250
            })
            .register(meredith.breakpointQueries.minDesktop, {
              match: function() {
                $("#block-search-form").removeAttr("style").children(".content").removeAttr("style");
                if (headroom !== undefined) {
                  if (headroom.data !== null) {
                    if (meredith.scroll <= headroom.data.offset) {
                      $headerContainer.removeClass("headroom--not-top headroom--unpinned headroom--pinned").addClass("headroom--top");
                      headroom.functions.onTop();
                    }
                  }
                }
                // headroom.data.offset = $("#block-tb-megamenu-main-menu").offset().top - $bannerContainer.height() - adminMenuHeight();
              }
            })
            .register(meredith.breakpointQueries.maxDesktop, {
              match: function() {
                if ($("#block-search-form").hasClass("opened"))
                  $("#block-search-form > .content").css({
                    left: 130,
                    right: 5
                  });
                // headroom.data.offset = 0;
                // $headerContainer.removeAttr("style");
              }
            })
          ;
      });
  
      /* Code for Browse button in mobile menu */
      var browseOpen = false,
        $browseButton = $("#block-tb-megamenu-main-menu").find("button.tb-megamenu-button"),
        $userButton = $("#header .header-mobile-icon.user"),
        $closeIcon = $('<button class="fa fa-times"/>'),
        bodyScrollTop = 0, prMarginTop = 0, inputBlurred = false; /* Need a flag for iOS when text field is blurred so not to run code when close icon clicked */
  
      $browseButton
        .off("click")
        .click(function() {
          toggleMenu();
          if ($(this).hasClass("open")) {
            var t = $headerContainer.offset().top;
            bodyScrollTop = $("body").scrollTop();
            prMarginTop = $("body").css("marginTop");
            $headerContainer.css({
              height: "100%",
              overflow: "scroll"
            });
            $('html,body').css({
              position: "fixed",
              height: "100%"
            });
            document.body.style.setProperty("margin-top", "0", "important");
            $("body").scrollTop(bodyScrollTop);
            meredith.browseOpen = true;
          }
          else {
            meredith.browseOpen = false;
            $("html, body").css({
              height: "auto",
              position: "static",
              top: 0
            });
            document.body.style.setProperty("margin-top", prMarginTop, "important");
            $("body").scrollTop(bodyScrollTop);
            $headerContainer.removeAttr("style").css("top", adminMenuHeight());
          }
        });
  
      /* Code for search functionality */
      // The search close icon
      $closeIcon
        .off("click.minDesktopCloseSearch")
        .on("click.maxDesktopCloseSearch", function() {
          $("#block-search-form > .content").velocity({
            right: -200,
            left: "100%",
            display: "block",
            opacity: 0
          }, {
            complete: function() {
              $("#block-search-form").removeClass("opened");
            }
          });
          if (iOSVersion /*&& iOSVersion[0] >= 8*/ && !$("#block-search-form input.form-text").is(":focus") && !inputBlurred) {
            $("html").css({
              position: "static"
            });
            setTimeout(function() {
              $("body").scrollTop(parseInt($("body").css("marginTop"))*-1);
              $("body").css("marginTop", prMarginTop);
            }, 100, true);
          }
          inputBlurred = false;
          return false;
        });
  
      $("#header .block-search input.form-text")
        .on("focus", function() {
          if ($(this).val() == "Search") $(this).val("");
        })
        .on("blur", function() {
          if ($(this).val() == "") $(this).val("Search");
        })
  
      $("#header .header-mobile-icon.search > a").click(function() {
        // Hide other menus
        if (browseOpen || $browseButton.hasClass("open")) {
          toggleMenu();
          browseOpen = false;
          $headerContainer.css({
            position: "fixed",
            top: 0
          });
          $("html, body").css({
            height: "auto",
            position: "static",
            top: 0
          });
          $("body").css("marginTop", prMarginTop).scrollTop(bodyScrollTop);
          $headerContainer.removeAttr("style");
        }
  
        if ($userButton.hasClass("open")) {
          $userButton.removeClass("open").children("#block-meredith-blocks-login-links").velocity("transition.slideUpOut", {
            duration: 300
          });
        }
  
        // Add the close icon
        $("#block-search-form")
          .find(".form-actions")
          .after($closeIcon);
  
        bodyScrollTop = $("body").scrollTop();
        prMarginTop = $("body").css("marginTop");
        if (iOSVersion /*&& iOSVersion[0] >= 8*/) {
          document.body.style.setProperty("margin-top", "");
          window.scrollTo(0, -30);
          $("html").css({
            position: "fixed",
            top: 0,
            bottom: "100%"
          });
          $("body").css("marginTop", -1*bodyScrollTop);
        }
        $("#block-search-form")
          .addClass("opened")
          .removeAttr("style")
          .children(".content")
          .removeAttr("style")
          .velocity({
            right: meredith.isMobile() ? 0 : meredith.isTablet() ? 6 : 30,
            left: meredith.isMobile() ? 0 : 130,
            display: "block",
            opacity: 1
          }, {
            delay: browseOpen ? 100 : 0,
            begin: function() {
              $("#block-search-form").show();
            },
            display: "block"
          })
          .find("input.form-text")
            .on('blur', function() {
              if (iOSVersion /*&& iOSVersion[0] >= 8*/) {
                $("body").scrollTop(bodyScrollTop);
                $("html").css({
                  position: "static"
                });
                $("body").css("marginTop", prMarginTop);
                inputBlurred = true;
              }
            });
        return false;
      });
  
      enquire
        .register(meredith.breakpointQueries.maxTwocolumns, function() {
          if ($("#block-search-form").hasClass("opened")) {
            $("#block-search-form > .content").css({
              left: 0,
              right: 0
            });
          }
        })
        .register(meredith.breakpointQueries.minTwocolumns, function() {
          if ($("#block-search-form").hasClass("opened")) {
            $("#block-search-form > .content").css({
              left: !$headerContainer.hasClass("headroom--top") ? 0 : 130,
              right: $headerContainer.hasClass("headroom--pinned") ? 10 : 30
            });
          }
        });
  
      $("#block-search-form")
        .find(".form-submit").click(function() {
          var text = $("#block-search-form").find(".form-text"),
            border = text.css("border");
          if (text.val() == "" || text.val() == "Search") {
            text.css("border", "1px red solid");
            return false;
          }
        });
  
      /* Code for user icon */
      var userButtonMouseEntered = false; // Need this for tablets, because mouseenter will trigger on tap and we need to remove the active styling if they click it again.
      var toggleUserButton = function(action) {
        $items.removeClass('open');
        var $this = $userButton.children('a');
        if (($this.parent().hasClass("open") || action == "close") /*&& !userButtonMouseEntered*/) {
          if ($headerContainer.children(".faux-full-width:visible").length)
            $headerContainer.children(".faux-full-width").velocity("slideUp", {
              duration: 100,
              easing: "linear"
            });
          $userButton.removeClass("open");
          $this.next("#block-meredith-blocks-login-links").velocity("stop", true).velocity("transition.expandOut", {
            duration: 100,
            complete: function() {
              $this.removeAttr("style");
            }
          });
          userButtonMouseEntered = true;
        } else if ((!$this.parent().hasClass("open") || action == "open") /*&& userButtonMouseEntered*/) {
          $("li.tb-megamenu-item.level-1").children(".dropdown-menu").hide();
          $userButton.addClass("open");
          $this.next("#block-meredith-blocks-login-links").velocity("stop", true).velocity("transition.expandIn", {
            duration: 100
          });
          userButtonMouseEntered = false;
        }
      };
  
      $userButton
        .on("mouseenter", function() {
          if (!meredith.isMobile() && (!meredith.isDesktop() || (meredith.isDesktop() && !$headerContainer.hasClass("headroom--top")))) {
            toggleMenuItem($items, "close");
            meredith.timeouts.openUserMenu = setTimeout(function() {
              toggleUserButton("open");
            }, 350); // need to wait for other menus to close before we can open it
          }
        })
        .on("mouseleave", function() {
          if (!meredith.isMobile() && (!meredith.isDesktop() || (meredith.isDesktop() && !$headerContainer.hasClass("headroom--top")))) {
            clearTimeout(meredith.timeouts.openUserMenu);
            toggleUserButton("close");
          }
        })
        .children("a")
        .on("click", function(e) {
          if ($(e.target).is("a") && $(e.target).parents("#block-meredith-blocks-login-links").length) return;
          clearTimeout(meredith.timeouts.openUserMenu);
          toggleUserButton();
          e.stopPropagation();
          e.stopImmediatePropagation();
          return false;
        })
      ;
  
      try {
        adService.callback = (function() {
          var cached = adService.callback || null;
          return function(e) {
            if (e.slot.getSlotId().getDomId() === 'div-gpt-leaderboard-flex-1' || e.slot.getSlotId().getDomId() === 'div-gpt-mob-adhesive-banner-fixed') {
              headroom.topBannerHeight = e.size[1];
              headroom.functions.adOnLoaded();
            }
            if (cached !== null)
              cached.apply(this, arguments);
          }
        }());
      } catch(e) {
        console.log(e);
      }
  
      // Stop fixed top menu when scrolling past footer
      /*var footerTop;
      $(window).scroll(function() {
        if (!browseOpen) {
          footerTop = meredith.isDesktop()
            ? $("#footer-container").offset().top - $headerContainer.height()
            : $("#block-bean-shop-links-menu").offset().top - $headerContainer.height();
          var dscroll = meredith.scroll, ldscroll = meredith.lastScroll;
  
          if (dscroll >= footerTop - adminMenuHeight() && ldscroll < footerTop - adminMenuHeight()) {
            $headerContainer.removeClass("header--pinned header--unpinned").css({
              position: "absolute",
              top: footerTop
            });
          } else if (dscroll < footerTop - adminMenuHeight() && ldscroll >= footerTop - adminMenuHeight()) {
            $headerContainer.removeAttr("style").addClass("header--pinned");
          }
        }
      });*/
  
      // Copy user links to browse menu
      $("#block-meredith-blocks-login-links")
        .find("ul.profile-links")
        .clone()
        .insertAfter("#block-tb-megamenu-main-menu > .content > .tb-megamenu > .nav-collapse > ul");
    }
  };
  Drupal.behaviors.footerEvents = {
    attach: function() {
      var running = false,
      toggleMenuItem = function(context, action) {
        if (action === undefined) action = $(context).hasClass("open") ? "close" : "open";
        $(context)
          .toggleClass("open")
          .siblings(".content").find("ul.menu")
          .velocity("stop", true)
          .velocity(action == "open" ? "transition.slideDownIn" : "transition.slideUpOut", {
            duration: 100,
            easing: "linear"
          });
      };
  
      enquire.register(meredith.breakpointQueries.maxDesktop, {
        match: function() {
          $("#footer")
            .find(".block-menu, #block-bean-shop-links-menu, #block-meredith-blocks-your-account, #block-meredith-blocks-shop-links-menu-footer")
            .children(".content").find("ul.menu")
            .hide()
            .end().end()
            .children("h2")
            .click(function() {
              toggleMenuItem(this);
            });
            $('#block-meredith-blocks-search-secondary input.form-text')
                    .on('focus', function(){
                        if ($(this).val()=='Search FamilyCircle.com') $(this).val('')
                    })
                    .on('blur', function(){
                        if ($(this).val()=='') $(this).val('Search FamilyCircle.com')
                    })
                    .val('Search FamilyCircle.com');
        },
        unmatch: function() {
          $("#footer")
            .find(".block-menu, #block-bean-shop-links-menu, #block-meredith-blocks-your-account, #block-meredith-blocks-shop-links-menu-footer")
            .children(".content").find("ul.menu, .entity-bean")
            .velocity("transition.slideDownIn", {
              duration: 10
            })
            .end().end()
            .children("h2")
            .off("click");
                    $('#block-meredith-blocks-search-secondary input.form-text')
                    .off('focus')
                    .off('blur')
                    .val('');
        }
      });
  
      // Clicking "back to top"
      $("#block-bean-footer-back-to-top .field-item a").click(function() {
        $("html, body").velocity("scroll", 300, "easeInCirc");
        return false;
      });
    }
  };
  Drupal.behaviors.contentEvents = {
    attach: function(context) {
      // Add the more/less link to the end of the dek if smaller than tablet.
      // Also toggles the display of the link when switching from desktop to mobile or tablet.
      var dekMoreLessAdded = false, $dek, $text, $more, addMoreLess = function() {
        dekMoreLessAdded = true;
        if ($("body").hasClass("node-type-panel")) $dek = $("#block-system-main").find(".field-name-field-dek").find(".field-item");
        else $dek = $("#block-views-content-info-block").find(".views-field-field-dek").children(".field-content");
        if ($dek.text().length && $dek.text().length >= 190) {
          $text = $dek.text();
          isTrimmed = true;
          $more = $('<a href="#">...more</a>');
          $trimmed = $text.substring(0, 190);
          $dek.html($trimmed).append($more);
          $more.click(function(){
            $more.detach();
            if (isTrimmed) {
              $dek.html($text).append($more);
              $more.text("...less");
            }
            else {
              $dek.html($trimmed).append($more);
              $more.text("...more");
            }
            isTrimmed = !isTrimmed;
            return false;
          });
        }
      };
      if (meredith.currentBreakpoint < meredith.breakpoints.desktop) {
        addMoreLess();
      }
      $(window).on("debouncedresize", function() {
        if (meredith.currentBreakpoint >= meredith.breakpoints.desktop && dekMoreLessAdded) {
          if ($more !== undefined) $more.remove();
          $dek.html($text);
          dekMoreLessAdded = false;
        } else if (meredith.currentBreakpoint < meredith.breakpoints.desktop && !dekMoreLessAdded) {
          addMoreLess();
        }
      });
  
      // Make sure story photo slideshows updating pagination count when swiping on mobile
      if ($("body").hasClass("node-type-story")
        && $("#flexslider_views_slideshow_main_story_images-slideshow").length
        && $("#flexslider_views_slideshow_main_story_images-slideshow .flexslider").data("flexslider").vars !== undefined) {
        var flex = $("#flexslider_views_slideshow_main_story_images-slideshow .flexslider").data("flexslider");
        flex.vars.after = function() {
          $("#views_slideshow_slide_counter_story_images-slideshow span.num").text(flex.animatingTo + 1);
        };
      }
  
    }
  };
  
  // This adds two classes to maintain consistent functionality with prior theme for dek panel pages
  Drupal.behaviors.dekCustomizationAddClass = {
    attach: function (context, settings) {
        $('.node-type-panel .field-name-field-dek').addClass('wg_header');
        $('.node-type-panel .field-name-field-dek .field-item').addClass('wg_head_desc');
    }
  };
  // Custom function which truncates the dek for panel pages, requires the external .shorten jquery library, included on line 1382
  Drupal.behaviors.dekCustomizations = {
    attach: function (context) {
        $('.node-type-panel .wg_header .wg_head_desc').shorten({
            "showChars" : 160,
            "moreText"  : "See More",
            "lessText"  : "Less"
        });
      }
    };
  // Same as previous, but for user profile pages  
  Drupal.behaviors.userProfileCustomizations = {
    attach: function (context) {
      $('body.page-user .field-name-field-about-me .field-item').shorten();
    }
  }
  
  Drupal.behaviors.hidePagingLinksOnMobile = {
    attach: function (context) {
      if ($('#mobile-if-visible-test').is(':visible')) {
        $.each($('ul.meredith-paging-navigation'), function(index, list) {
            var $pagerItems = $(list).children('li.pager-item,li.pager-current');
            var $currentItem = $pagerItems.filter('.pager-current');
            var totalItems = $pagerItems.length;
            var currentItemIndex = $pagerItems.index($currentItem);
            if (totalItems > 7) { // we're trimming down to 7 to fit, so if already at or less skip this
              var itemsToRemove = totalItems - 7; // in case there are 8 pages of results
              if (totalItems % 2 == 1 && currentItemIndex == (totalItems - 1) / 2) {
                // center item, so remove one on each end
                $($pagerItems.get(0)).hide();
                $($pagerItems.get(totalItems - 1)).hide();
              }
              else if (currentItemIndex < 4) {
                // drop items at end if current item is index 0-3
                $($pagerItems.get(totalItems - 1)).hide();
                if (itemsToRemove == 2) {
                  $($pagerItems.get(totalItems - 2)).hide();
                }
              }
              else {
                // drop items at start if current item is index 4+
                $($pagerItems.get(0)).hide();
                if (itemsToRemove == 2) {
                  $($pagerItems.get(1)).hide();
                }
              }
            }
        });
      }
    }
  }
  Drupal.behaviors.slideshowEvents = {
    attach: function(context) {
      // Copies and appends the top pager in slideshows to the bottom of each slide to achieve the desired design.
      var $pager = $(".view-meredith-slideshow").children("ul.pager").clone(true, true);
      $(".view-meredith-slideshow").find("ul.slides").find("li").find(".column-2").append($pager);
  
      // Implement our own animations for showing viewall on slideshows
      window.meredith_slideshow_showViewAll = function(slideshowContainer, viewallContainer) {
        slideshowContainer.velocity("slideUp", {
          duration: 500
        });
        return $.Velocity.animate(viewallContainer, "slideDown", {
          delay: 500,
          duration: 500
        });
      };
      window.meredith_slideshow_hideViewAll = function(slideshowContainer, viewallContainer) {
        viewallContainer.velocity("slideUp", {
          duration: 500
        });
        return $.Velocity.animate(slideshowContainer, "slideDown", {
          delay: 500,
          duration: 500
        });
      };
    }
  };
  // Custom function called by the meredith_gigya js to adjust gigya params.
  Drupal.gigya.adjustGigyaParams = function(params) {
    params.shortURLs = "whenRequired";
    var list;
    if (typeof params.shareButtons === 'string')
      list = params.shareButtons.split(', ');
    else
      list = params.shareButtons;
    var shares = [], i;
    for (i in list) {
      if (typeof list[i] === 'string')
        list[i] = {
          provider: list[i]
        };
      if (list[i].provider == 'pinterest' || list[i].provider == 'facebook') {
        var useract = list[i].userAction || jQuery.extend(true, {}, params.userAction);
        var dek = $("#block-views-content-info-block").find(".views-field-field-dek").text().trim();
        if (dek.length == 0) dek = $("h1#page-title").text().trim();
        if (dek.length !== 0) // only use if not empty
          useract.description = dek;
        if (list[i].provider == 'pinterest') useract.description = useract.description.concat(" - FamilyCircle.com");
        if ($("body").hasClass("node-type-slideshow")) {
          useract.description = $("#slideshow-main > ul.slides > li").find(".views-field-body > .field-content > p").first().text().trim().concat(" - FamilyCircle.com");
        }
        shares.push(jQuery.extend(true, {
          userAction: useract
        }, list[i]));
      } else shares.push(list[i]);
    }
    params.shareButtons = shares;
  };
  
  // Change the sharebar buttons if they exist
  var gigyaReady = function(e, context) {
    // The hover sharebar
    var $sharebar = $("#gigya-share-hover"),
        stacked = $("article .field-name-field-photos > .field-items >.field-item").length > 1,
        slideshow = $("article .field-name-field-photos .view-story-images").length > 0,
        singleSlideshow = $("article .field-name-field-photos .story-photo-image-and-caption").length > 0,
        nodeSlideshow = $("body").hasClass("node-type-slideshow"),
        $shareItems;
    if ($sharebar.length && e.containerID == "gigya-share-hover") {
      $shareItems = $sharebar.find("td");
      // Since pinterest is the only one that should be here, just style it directly
      $shareItems.each(function(i, v) {
        var $a = $(v).find("a");
        var $provider = $a.text().toLowerCase().replace('+', '');
        $a.addClass($provider);
        $(v).addClass($provider);
        switch($provider) {
          case "pinterest":
            $a.html('<i class="fa fa-pinterest"></i> <span>pin it</span>');
            break;
          case "facebook":
            $a.html('<i class="fa fa-facebook-square"></i> <span>share</span>');
            break;
        }
      });
      if (stacked) $(".story-photo-image-and-caption").css("position", "static");
      var $sharebarCopy, $mainOffset;
  
      $("#gigya-share-hover").appendTo("#block-system-main");
      var showShareBar = function() {
        if (meredith.currentBreakpoint < meredith.breakpoints.twocolumns && nodeSlideshow) {
          $("#flexslider_views_slideshow_story_images-slideshow, .wg_img_disp_left, .wg_img, .recipe-image .image-wrapper img").off("mouseenter.sharebar").add("#gigya-share-hover").off("mouseleave.sharebar"); // Disable previous events
          $sharebarCopy = $("#gigya-share-hover").clone(true, true);
          $sharebarCopy.removeAttr("style").removeAttr("id").addClass("gigya-share-hover").show();
          var $imgs = $("#slideshow-main").children("ul.slides").children("li").find(".photo-wrapper > img, .photo-wrapper .videoImage > img");
  
          var parent = eval("("+$sharebarCopy.find("a.pinterest").first().attr("onclick").replace(/\.onClick\(\)\; return false\;$/i, '')+")"),
              handler = eval("("+$sharebarCopy.find("a.pinterest").first().attr("onclick").replace(/\(\)\; return false\;$/i, '')+")");
  
          $sharebarCopy.find("a.pinterest").removeAttr("onclick").off("click").click(function() {
            var $img;
            if ("undefined" !== typeof Drupal.settings.meredith.usePinterestImage && Drupal.settings.meredith.usePinterestImage)
              $img = $("meta[property='og:image']").attr("content");
            else
              $img = $(this).parents(".gigya-share-hover").prev("img").attr("src");
            if ($img.length) {
              // Change the image to the current slide
              var match = $img.match(new RegExp("^http\:\/\/", "ig"));
              if (match === null && $img.match(/^http\:\/\/www\.divinecaroline.com\/videos\//ig) == null)
                $img = location.protocol + "//" + location.host + $img;
              $img = $img.replace("styles/slide", "styles/facebook_og_image");
              parent.oButton.userAction.mediaItems[0].src = $img;
              if (nodeSlideshow) parent.oButton.userAction.description = $(this).parents('.column-1').next('.column-2').find(".views-field-body > .field-content > p").first().text().trim().concat(" - FamilyCircle.com");
              handler.apply(parent, arguments || []);
              return false;
            }
          });
  
          $imgs.after($sharebarCopy);
  
          $(window).on("scroll.mobileslideshow", function() {
            $imgs.each(function(i, v) {
              var rect = v.getBoundingClientRect();
              if (rect.bottom <= $(window).height()) {
                $sb = $(v).next(".gigya-share-hover");
                if (!$sb.hasClass("closed")) {
                  $sb.addClass("closed").find("a").velocity({
                    width: 40
                  }, {
                    duration: 500,
                    delay: 1000
                  }).children("span").velocity({
                    opacity: 0
                  }, {
                    display: "none",
                    duration: 500,
                    delay: 1000
                  }).siblings("i").velocity({
                    paddingRight: 0,
                    top: 0,
                    left: 3
                  }, {
                    duration: 500,
                    delay: 1000
                  });
                  $imgs = $imgs.not(v);
                }
              } else return false;
            });
          })
        }
        else {
          if ($sharebarCopy !== undefined) {
            $(".gigya-share-hover").remove();
            $sharebarCopy.remove();
          }
          $(window).off("scroll.mobileslideshow");
  
          $("#flexslider_views_slideshow_story_images-slideshow img, .wg_img_disp_left, .wg_img img")
            .on("mouseenter.sharebar", function(e) {
              if ((stacked || nodeSlideshow || singleSlideshow || slideshow) && this.id !== "gigya-share-hover") {
                var $image = slideshow || nodeSlideshow ? $(this) : $(this).find("img").last(),
                    $offset = $image.offset();
                $offset.bottom = $offset.top + $image.height();
                $offset.right = $offset.left + $image.width();
  
                var $hoverWidth = $("#gigya-share-hover").width(),
                    $hoverHeight = $("#gigya-share-hover").height();
  
                var $mainOffset = $("#main").offset();
                $("#gigya-share-hover").css({
                  top: $offset.bottom - $hoverHeight - 8 - $mainOffset.top,
                  left: $offset.right - $hoverWidth - 5 - $mainOffset.left,
                  right: "auto",
                  bottom: "auto",
                  position: "absolute"
                });
              } else if (singleSlideshow) {
                $("#gigya-share-hover").css({
                  bottom: 25
                });
              }
  
              var $img;
              if ("undefined" !== typeof Drupal.settings.meredith && Drupal.settings.meredith.usePinterestImage) $img = $("meta[property='og:image']").attr("content");
              else if (stacked || singleSlideshow || nodeSlideshow && meredith.currentBreakpoint < meredith.breakpoints.twocolumns) $img = $(this).find("img, .videoImage > img").last().attr("src");
              else $img = $("li.flex-active-slide").find(".column-1 img").attr("src");
              if ($img !== undefined) {
                var match = $img.match(new RegExp("^http\:\/\/", "ig"));
                if (match === null && $img.match(/^http\:\/\/www\.divinecaroline.com\/videos\//ig) == null)
                  $img = location.protocol + "//" + location.host + $img;
                if (nodeSlideshow)
                  $img = $img.replace("styles/slide", "styles/facebook_og_image");
                else
                  $img = $img.replace("story_slideshow", "facebook_og_image");
                $func = eval("("+$("#gigya-share-hover").find("a.pinterest").attr("onclick").replace(".onClick(); return false;", "")+")");
                $func.oButton.userAction.mediaItems[0].src = $img;
                if (nodeSlideshow) $func.oButton.userAction.description = $("#slideshow-main").find("li.flex-active-slide").find(".views-field-body > .field-content > p").first().text().trim().concat(" - FamilyCircle.com");
              }
  
              if (!$("#gigya-share-hover").is(":visible") && !$('#mobile-if-visible-test').is(':visible'))
                $("#gigya-share-hover").stop().show();
            })
            .add("#gigya-share-hover")
            .on("mouseleave.sharebar", function(e) {
              var t = e.toElement || e.relatedTarget || e.target;
              if ((!$(t).parents("#gigya-share-hover").length
              || !$(t).parents(this).length) && meredith.currentBreakpoint >= meredith.breakpoints.twocolumns)
                $("#gigya-share-hover").stop().hide();
            });
        }
      };
  
      showShareBar();
      $(window).on("debouncedresize", function() {
        if (meredith.lastBreakpoint < meredith.breakpoints.twocolumns && meredith.currentBreakpoint >= meredith.breakpoints.twocolumns
          || meredith.lastBreakpoint >= meredith.breakpoints.twocolumns && meredith.currentBreakpoint < meredith.breakpoints.twocolumns) {
          showShareBar();
        }
      });
    }
  
    // Support inline images in stories
    if ($("body").hasClass("node-type-story") && $("#gigya-share-hover").length) {
      $(".field-name-body").find("img:not([nopin='nopin'])").mouseenter(function() {
        $(".story-photo-image-and-caption").css("position", "static");
        $offset = $(this).offset();
        $hoverWidth = $("#gigya-share-hover").width();
        $hoverHeight = $("#gigya-share-hover").height();
        $mainOffset = $("#main").offset();
        $("#gigya-share-hover").css({
          "top": $offset.top + $(this).height() - $hoverHeight - 10 - $mainOffset.top,
          "left": $offset.left + $(this).width() - $hoverWidth - 10 - $mainOffset.left,
          "right": "auto",
          "bottom": "auto",
          "position": "absolute",
          "z-index": 10
        });
        if ("undefined" !== typeof Drupal.settings.meredith.usePinterestImage && Drupal.settings.meredith.usePinterestImage)
          $img = $("meta[property='og:image']").attr("content");
        else
          $img = $(this).attr("src").replace("resize", "styles").replace("story", "facebook_og_image/public/story").replace(/\-\d+x\d+/g, "");
        var match = $img.match(new RegExp("^http\:\/\/", "ig"));
        if (match === null && $img.match(/^http\:\/\/www\.familycircle.com\/videos\//ig) == null)
          $img = location.protocol + "//" + location.host + $img;
        $func = eval("("+$("#gigya-share-hover").find("a.pinterest").attr("onclick").replace(".onClick(); return false;", "")+")");
        $func.oButton.userAction.mediaItems[0].src = $img;
        // if (!$("#gigya-share-hover").is(":visible") && !$('#mobile-if-visible-test').is(':visible'))
            $("#gigya-share-hover").stop().show();
      }).add("#gigya-share-hover").mouseleave(function(e) {
        var t = e.toElement || e.relatedTarget || e.target;
        if ((!$(t).parents("#gigya-share-hover").length
          || !$(t).parents(this).length) && !$('#mobile-if-visible-test').is(':visible'))
          $("#gigya-share-hover").stop().hide();
      });
    }
  
    // Support inline image in recipes
    if ($("body").hasClass("node-type-recipe") && $("#gigya-share-hover").length) {
      $(".recipe-image .image-wrapper img:not([nopin='nopin'])").mouseenter(function() {
        $(".recipe-image").css("position", "static");
        var $offset = $(this).offset(),
            $hoverWidth = $("#gigya-share-hover").width(),
            $hoverHeight = $("#gigya-share-hover").height(),
            $mainOffset = $("#main").offset();
        $("#gigya-share-hover").css({
          "top": $offset.top + $(this).height() - $hoverHeight - 10 - $mainOffset.top,
          "left": $offset.left + $(this).width() - $hoverWidth - 10  - $mainOffset.left,
          "right": "auto",
          "bottom": "auto",
          "position": "absolute",
          "z-index": 10
        });
        var $img = $(this).attr("src"),
            $func = eval("("+$("#gigya-share-hover").find("a.pinterest").attr("onclick").replace(".onClick(); return false;", "")+")");
        $func.oButton.userAction.mediaItems[0].src = $img;
        $("#gigya-share-hover").stop().show();
      }).add("#gigya-share-hover").mouseleave(function(e) {
        var t = e.toElement || e.relatedTarget || e.target;
        if ((!$(t).parents("#gigya-share-hover").length
          || !$(t).parents(this).length) && !$('#mobile-if-visible-test').is(':visible'))
          $("#gigya-share-hover").stop().hide();
      });
    }
  
    // Common function to setup Pinterest sharing and functionality
    setupPinterest = function($a, which) {
      $(document).ready(function() {
        if (which == "bottom")
          $a.html('<i class="fa fa-pinterest"></i> Pin on Pinterest');
        else
          $a.html('<i class="fa fa-pinterest"></i> pin it');
        if (nodeSlideshow) {
          var parent = eval("("+$a.attr("onclick").replace(/\.onClick\(\)\; return false\;$/i, '')+")"),
              handler = eval("("+$a.attr("onclick").replace(/\(\)\; return false\;$/i, '')+")");
          $a.removeAttr("onClick").off("click").click(function() {
            var $img;
            if ("undefined" !== typeof Drupal.settings.meredith && Drupal.settings.meredith.usePinterestImage)
              $img = $("meta[property='og:image']").attr("content");
            else
              $img = $("li.flex-active-slide").find(".photo-wrapper > img, .photo-wrapper .videoImage > img").attr("src");
            if ($img !== undefined) {
              // Change the image to the current slide
              var match = $img.match(new RegExp("^http\:\/\/", "ig"));
              if (match === null && $img.match(/^http\:\/\/www\.familycircle.com\/videos\//ig) == null)
                $img = location.protocol + "//" + location.host + $img;
              $img = $img.replace("styles/slide", "styles/facebook_og_image");
              parent.oButton.userAction.mediaItems[0].src = $img;
              parent.oButton.userAction.description = $("#slideshow-main").find("li.flex-active-slide").find(".views-field-body > .field-content > p").first().text().trim().concat(" - FamilyCircle.com");
              handler.apply(parent, arguments || []);
            }
            return false;
          });
        }
      });
    };
  
    // The bottom sharebar
    $sharebar = $("#gigya-share-vert");
    if ($sharebar.length && e.containerID == "gigya-share-vert") {
      $shareItems = $sharebar.find("td");
      $shareItems.each(function(i, v) {
        $a = $(v).find("a");
        $provider = $a.text().toLowerCase().replace('+', '');
        $a.addClass($provider);
        $(v).addClass($provider);
        switch($provider) {
          case "pinterest":
            setupPinterest($a, "bottom");
            break;
          case "facebook":
            $a.html('<i class="fa fa-facebook-square"></i> Share on Facebook');
            break;
          case "twitter":
            $a.html('<i class="fa fa-twitter"></i> Share on Twitter');
            break;
        }
      });
    }
  
    // The top sharebar
    $sharebar = $("#gigya-share-horz");
    if ($sharebar.length && e.containerID == "gigya-share-horz") {
      $expand = $('<td style="vertical-align:bottom; white-space:nowrap;zoom:1;" class="expand"><div class="gig-button-container gig-button-container-count-none gig-share-button-container gig-button-container-horizontal"><div><a href="#" class="icon-only buttonize"><i class="fa fa-plus"></i></a></div></div></td>');
      $expand.click(function() {
        $(".views-field-field-gigya-share-bar-horz").addClass("open");
        $shareItems = $sharebar.find("td.collapsible");
        $collapse = $sharebar.find("td.collapse");
  
        if (meredith.currentBreakpoint < meredith.breakpoints.socialDesktop) {
          $shareItems = $shareItems.add($sharebar.find("td.twitter"));
          $shareItems.css("zIndex", 0);
        } else
          $shareItems.css("zIndex", 1);
        $collapse.css("zIndex", 2);
        $shareItems = $shareItems.add($collapse);
        $shareItems.velocity({top: 0}, {
          duration: 200,
          display: "block",
          complete: function() {
            $(this).css("zIndex", 1);
          }
        });
        return false;
      });
  
      $collapse = $('<td style="vertical-align:bottom; white-space:nowrap;zoom:1;" class="collapse"><div class="gig-button-container gig-button-container-count-none gig-share-button-container gig-button-container-horizontal"><div><a href="#" class="icon-only buttonize"><i class="fa fa-minus"></i></a></div></div></td>');
      $collapse.click(function() {
        $shareItems = $sharebar.find("td.collapsible");
        $collapse = $sharebar.find("td.collapse");
  
        if (meredith.currentBreakpoint < meredith.breakpoints.socialDesktop) {
          $shareItems = $shareItems.add($sharebar.find("td.twitter"));
          $shareItems.css("zIndex", 0);
        } else
          $shareItems.css("zIndex", 1);
        $collapse.css("zIndex", 2);
        $shareItems = $shareItems.add($collapse);
        $shareItems.velocity({top: -50}, {
          duration: 200,
          display: "none",
          complete: function() {
            $(this).removeAttr("style");
          }
        });
        $(".views-field-field-gigya-share-bar-horz").velocity({
          height: 55
        }, {
          duration: 200,
          complete: function() {
            $(this).removeAttr('style').removeClass('open');
          }
        });
        return false;
      });
  
      $shareItems = $sharebar.find("td");
      $shareItems.each(function(i, v) {
        $a = $(v).find("a");
        $provider = $a.text().toLowerCase().replace('+', '');
        $a.addClass($provider);
        $(v).addClass($provider);
        switch($provider) {
          case "pinterest":
            setupPinterest($a, "top");
            break;
          case "facebook":
            $a.html('<i class="fa fa-facebook-square"></i> share');
            $(v).after($collapse);
            $(v).after($expand);
            break;
          case "twitter":
            $a.html('<i class="fa fa-twitter"></i> tweet');
            break;
          case "google":
            $a.html('<i class="fa fa-google-plus"></i>').addClass('icon-only');
            $(v).addClass("collapsible");
            break;
          case "stumbleupon":
            $a.html('<i class="fa fa-stumbleupon"></i>').addClass('icon-only');
            $(v).addClass("collapsible");
            break;
          case "email":
            $a.html('<i class="fa fa-envelope"></i>').addClass('icon-only');
            $(v).addClass("collapsible");
            break;
          case "print":
            $a.html('<i class="fa fa-print"></i>').addClass('icon-only');
            $(v).addClass("collapsible");
            break;
        }
      });
  
      // Add print button
      var bodyClasses = $("body").attr("class").split(" ");
      var nid = bodyClasses.filter(function(item){
        return /^page\-node\-[0-9]+/.test(item);
      }).join().replace('page-node-', '');
      // if vertical orientation, need to add <tr> otherwise just <td>
      var print_button = '<td style="vertical-align: bottom; white-space: nowrap; zoom: 1;" class="print collapsible"><a class="print icon-only" target="_blank" href="/print/'+nid+'"><i class="fa fa-print"></i></a></td>';
      if ($("#gigya-share-horz tr").length > 1) {
        $("#gigya-share-horz-reaction5 a").parents("tr").after('<tr>' + print_button + '</tr>');
      }
      else {
        $("#gigya-share-horz-reaction5 a").parents("td").after(print_button);
      }
    }
  };
  try {
    gigya.services.socialize.showShareBarUI = (function() {
      var cached = gigya.services.socialize.showShareBarUI;
      return function() {
        arguments = arguments || [];
        arguments[0].onLoad = gigyaReady;
        cached.apply(this, arguments);
      }
    }());
  } catch(e) {
    console.log(e);
  }
}(jQuery));;


A B C D E F G H I J K L M N O P Q R S T U V W X Y Z