/*! Respond.js v1.0.1pre: min/max-width media query polyfill. (c) Scott Jehl. MIT/GPLv2 Lic. j.mp/respondjs */
(function(e,h){e.respond={};respond.update=function(){};respond.mediaQueriesSupported=h;if(h){return}var u=e.document,r=u.documentElement,i=[],k=[],p=[],o={},g=30,f=u.getElementsByTagName("head")[0]||r,b=f.getElementsByTagName("link"),d=[],a=function(){var B=b,w=B.length,z=0,y,x,A,v;for(;z<w;z++){y=B[z],x=y.href,A=y.media,v=y.rel&&y.rel.toLowerCase()==="stylesheet";if(!!x&&v&&!o[x]){if(y.styleSheet&&y.styleSheet.rawCssText){m(y.styleSheet.rawCssText,x,A);o[x]=true}else{if(!/^([a-zA-Z]+?:(\/\/)?)/.test(x)||x.replace(RegExp.$1,"").split("/")[0]===e.location.host){d.push({href:x,media:A})}}}}t()},t=function(){if(d.length){var v=d.shift();n(v.href,function(w){m(w,v.href,v.media);o[v.href]=true;t()})}},m=function(G,v,x){var E=G.match(/@media[^\{]+\{([^\{\}]+\{[^\}\{]+\})+/gi),H=E&&E.length||0,v=v.substring(0,v.lastIndexOf("/")),w=function(I){return I.replace(/(url\()['"]?([^\/\)'"][^:\)'"]+)['"]?(\))/g,"$1"+v+"$2$3")},y=!H&&x,B=0,A,C,D,z,F;if(v.length){v+="/"}if(y){H=1}for(;B<H;B++){A=0;if(y){C=x;k.push(w(G))}else{C=E[B].match(/@media ([^\{]+)\{([\S\s]+?)$/)&&RegExp.$1;k.push(RegExp.$2&&w(RegExp.$2))}z=C.split(",");F=z.length;for(;A<F;A++){D=z[A];i.push({media:D.match(/(only\s+)?([a-zA-Z]+)(\sand)?/)&&RegExp.$2,rules:k.length-1,minw:D.match(/\(min\-width:[\s]*([\s]*[0-9]+)px[\s]*\)/)&&parseFloat(RegExp.$1),maxw:D.match(/\(max\-width:[\s]*([\s]*[0-9]+)px[\s]*\)/)&&parseFloat(RegExp.$1)})}}j()},l,q,j=function(E){var v="clientWidth",x=r[v],D=u.compatMode==="CSS1Compat"&&x||u.body[v]||x,z={},C=u.createDocumentFragment(),B=b[b.length-1],w=(new Date()).getTime();if(E&&l&&w-l<g){clearTimeout(q);q=setTimeout(j,g);return}else{l=w}for(var y in i){var F=i[y];if(!F.minw&&!F.maxw||(!F.minw||F.minw&&D>=F.minw)&&(!F.maxw||F.maxw&&D<=F.maxw)){if(!z[F.media]){z[F.media]=[]}z[F.media].push(k[F.rules])}}for(var y in p){if(p[y]&&p[y].parentNode===f){f.removeChild(p[y])}}for(var y in z){var G=u.createElement("style"),A=z[y].join("\n");G.type="text/css";G.media=y;if(G.styleSheet){G.styleSheet.cssText=A}else{G.appendChild(u.createTextNode(A))}C.appendChild(G);p.push(G)}f.insertBefore(C,B.nextSibling)},n=function(v,x){var w=c();if(!w){return}w.open("GET",v,true);w.onreadystatechange=function(){if(w.readyState!=4||w.status!=200&&w.status!=304){return}x(w.responseText)};if(w.readyState==4){return}w.send(null)},c=(function(){var v=false;try{v=new XMLHttpRequest()}catch(w){v=new ActiveXObject("Microsoft.XMLHTTP")}return function(){return v}})();a();respond.update=a;function s(){j(true)}if(e.addEventListener){e.addEventListener("resize",s,false)}else{if(e.attachEvent){e.attachEvent("onresize",s)}}})(this,(function(f){if(f.matchMedia){return true}var e,i=document,c=i.documentElement,g=c.firstElementChild||c.firstChild,h=!i.body,d=i.body||i.createElement("body"),b=i.createElement("div"),a="only all";b.id="mq-test-1";b.style.cssText="position:absolute;top:-99em";d.appendChild(b);b.innerHTML='_<style media="'+a+'"> #mq-test-1 { width: 9px; }</style>';if(h){c.insertBefore(d,g)}b.removeChild(b.firstChild);e=b.offsetWidth==9;if(h){c.removeChild(d)}else{d.removeChild(b)}return e})(this));;

/*jslint bitwise: true, eqeqeq: true, immed: true, newcap: true, nomen: false,
 onevar: false, plusplus: false, regexp: true, undef: true, white: true, indent: 2
 browser: true */

/*global jQuery: true Drupal: true window: true */

(function ($) {
  /**
   * Druthos object is created if it doesn't exist.
   */
  Drupal.behaviors.druthos = Drupal.behaviors.druthos || {};
  
  /**
  * Attach handler.
  */
  Drupal.behaviors.druthos = {
    attach: function (context, settings) {
      var addCommentTrigger = $('.comment-add a');
      var addCommentForm = $('#comment-new');

      // Add only if the comment form exists on the page.
      if (addCommentForm.length > 0) {
        // Bind click event handlers to all .comment_add links
        addCommentTrigger.bind('click', {scrollTarget: addCommentForm}, Drupal.behaviors.druthos.scrollTo);
      }
      
      // Set all sidebars to the height of their parent container.
      Drupal.behaviors.druthos.equalizeColumns($('.box'));

      Drupal.behaviors.druthos.enhanceRotatingBanner();
    }
  };
  
  /**
   * Scrolls the page to the clicked element's location
   * @param {event} event
   *   The event.
   */
  Drupal.behaviors.druthos.scrollTo = function (event) {
    // Keep the page from jumping to the hash target
    event.preventDefault();
    var toolbar = {};
    toolbar.menuHeight = $('.toolbar-menu', '#toolbar').height() || 0;
    toolbar.drawerHeight = $('.toolbar-drawer', '#toolbar').height() || 0;
    var targetOffset = event.data.scrollTarget.offset().top - toolbar.menuHeight - toolbar.drawerHeight;
    $('html,body').animate({scrollTop: targetOffset}, 1000);
  };
  
  /**
   * Equalizes all .col elements in a stack to the height of the tallest .col
   *
   * @param {DomElement} stacks
   *   Set of .stack DomElements
   */
  Drupal.behaviors.druthos.equalizeColumns = function (stacks) {
    for (var i = 0; i < stacks.length; i++) {
      // Get the current stack reference
      var _this = stacks.eq(i);
      // Instantiate the boxHeight variable
      var boxHeight = 0;
      // Get the columns in the stack
      var cols = _this.find('.tb-height-balance');
      // We don't need to balance the columns if only one column is present
      if (cols.length > 1) {
        for (var j = 0; j < cols.size(); j++) {
          var col = cols.eq(j);
          // Only balance the height if the col is visible
          if (col.css('display') !== 'none' && col.css('visibility') !== 'hidden') {
            var colHeight = col.outerHeight(false);
            if (colHeight > boxHeight) {
              // If the height of the col is more than previous height, use it
              boxHeight = colHeight;
            }
          }
        }
      }
      // Only set the min-heights if boxHeight was assigned a real value
      if (boxHeight > 0) {
        cols.css('min-height', boxHeight);
      }
    }
  };
  
  /**
   * Adds a click handler to the layout wrapper of the rotating banner.  Otherwise this element
   * would obsure the link wrapped around the image element
   */
  Drupal.behaviors.druthos.enhanceRotatingBanner = function () {
    var layouts = $('.layout-wrapper', '.rotating-banner');
    var len = layouts.length;
    if (len > 0) {
      while (len--) {
        Drupal.behaviors.druthos.pseudoLink(layouts.eq(len));
      }
    }
  };
  
  /**
   * Navigates to the designated element's data-link attribute value
   * 
   * @param {DomElement} element
   *   Element that the pseudo link will be applied to
   *
   * @attribute 
   *   data-link is an element attribute that uses the HTML5 data- pattern to store information in the DOM
   */
  Drupal.behaviors.druthos.pseudoLink = function (element) {
    var link = element.attr('data-link');
    if (link && link.length > 0) {
      //Bind a click event to the slide layout wrapper if it has a link, stored in data-link attribute
      element.click(function (event) {
        window.location = $(event.currentTarget).attr('data-link');
      });
    }
  };
    
})(jQuery);
;
Drupal.behaviors.ie = (function () {
    var v = 3,
			div = document.createElement("div"),
			a = div.all || [];

    while (div.innerHTML = "<!--[if gt IE " + (++v) + "]><br><![endif]-->", a[0]);

    return v > 4 ? v : !v;
})();

(function ($) {

	/**
	* ST object is created if it doesn't exist.
	*/
	Drupal.behaviors.st = Drupal.behaviors.st || {};

	/**
	* Attach handler.
	*/
	Drupal.behaviors.st = {
		attach: function (context, settings) {

			Drupal.behaviors.st.placeholders();
			Drupal.behaviors.st.bubblePops();
		}
	};

	Drupal.behaviors.st.placeholders = function (event) {

		if (!Modernizr.input.placeholder) {

			$('[placeholder]').focus(function () {
				var input = $(this);
				if (input.val() == input.attr('placeholder')) {
					input.val('');
					input.removeClass('placeholder');
				}
			}).blur(function () {
				var input = $(this);
				if (input.val() == '' || input.val() == input.attr('placeholder')) {
					input.addClass('placeholder');
					input.val(input.attr('placeholder'));
				}
			}).blur();

			$('[placeholder]').parents('form').submit(function () {
				$(this).find('[placeholder]').each(function () {
					var input = $(this);
					if (input.val() == input.attr('placeholder')) {
						input.val('');
					}
				})
			});
		}
	};

	Drupal.behaviors.st.bubblePops = function (event) {

        if(Drupal.behaviors.ie && Drupal.behaviors.ie <= 7)
            return;

		var current = null;

		var els = $('.views-field-field-issue-cover');

		els.CreateBubblePopup({
			position: 'top',
			align: 'center',
			tail: {
				align: 'center',
				hidden: false
			},
			manageMouseEvents: true,
			selectable: true,
			afterHidden: function () {
				els.UnfreezeAllBubblePopups();
			},
			openingSpeed: 1,
			openingDelay: 1,
			closingSpeed: 1,
			closingDelay: 1,
			innerHtml: '<img src="' + Drupal.settings.basePath + 'sites/all/modules/jquery_plugin/bubblepopup/loading.gif" />',
			themeName: 'all-black',
			themePath: Drupal.settings.basePath + 'sites/all/modules/jquery_plugin/bubblepopup/jquerybubblepopup-theme'
		});

		els.mouseover(function () {

			var cover = $(this);

			$("<div/>").load(cover.find('a').attr('href') + ' .view-display-id-block_articles .item-list', function (data) {

				cover.SetBubblePopupInnerHtml($(this).html(), false);
				els.FreezeAllBubblePopups();
				cover.UnfreezeBubblePopup();
			});
		});
	};
})(jQuery);


;

