// $Id: at.js,v 1.1.2.3 2010/12/01 13:48:24 jmburnz Exp $
(function ($) {
  /**
   * Insert WAI-ARIA Landmark Roles (Roles for Accessible Rich Internet Applications)
   * http://www.w3.org/TR/2006/WD-aria-role-20060926/
   */
  Drupal.behaviors.adaptivetheme = {
    attach: function(context) {

      // Set role="banner" on the header element.
      $("#page > header").attr("role", "banner");

      // Set role="main" on #main-content div.
      $("#main-content").attr("role", "main");

      // Set role="search" on search forms.
      $("#search-theme-form").attr("role", "search");

      // Set role="contentinfo" on the page footer.
      $("footer").attr("role", "contentinfo");

      // Set role=article on nodes.
      $(".article").attr("role", "article");

      // Set role="nav" on navigation-like blocks.
      $("nav, .admin-panel, #breadcrumb").attr("role", "navigation");
      
      // Set role="complementary" on navigation-like blocks.
      $("aside").attr("role", "complementary");

      // Set role="region" on section elements.
      $("section").attr("role", "region");

      // Set role="region" on section elements.
      $("#search-block-form, #search-form").attr("role", "search");

    }
  };

  /**
   * In most instances this will be called using the built in theme settings.
   * However, if you want to use this manually you can call this file
   * in the info file and user the ready function e.g.:
   * 
   * This will set sidebars and the main content column all to equal height:
   *  (function ($) {
   *    Drupal.behaviors.adaptivetheme = {
   *      attach: function(context) {
   *        $('#content-column, .sidebar').equalHeight();
   *      }
   *    };
   *  })(jQuery);
   */
  jQuery.fn.equalHeight = function () {
    var height = 0;
    var maxHeight = 0;

    // Store the tallest element's height
    this.each(function () {
      height = jQuery(this).outerHeight();
      maxHeight = (height > maxHeight) ? height : maxHeight;
    });

    // Set element's min-height to tallest element's height
    return this.each(function () {
      var t = jQuery(this);
      var minHeight = maxHeight - (t.outerHeight() - t.height());
      var property = jQuery.browser.msie && jQuery.browser.version < 7 ? 'height' : 'min-height';

      t.css(property, minHeight + 'px');
   });
  };

})(jQuery);;
// bigTarget.js - A jQuery Plugin
// Version 1.0.1
// Written by Leevi Graham - Technical Director - Newism Web Design & Development
// http://newism.com.au
// Notes: Tooltip code from fitted.js - http://www.trovster.com/lab/plugins/fitted/

// create closure
(function($) {
	// plugin definition
	$.fn.bigTarget = function(options) {
		debug(this);
		// build main options before element iteration
		var opts = $.extend({}, $.fn.bigTarget.defaults, options);
		// iterate and reformat each matched element
		return this.each(function() {
			// set the anchor attributes
			var $a = $(this);
			var href = $a.attr('href');
			var title = $a.attr('title');
			// build element specific options
			var o = $.meta ? $.extend({}, opts, $a.data()) : opts;
			// update element styles
			$a.parents(o.clickZone)
				.hover(function() {
					$h = $(this);
					$h.addClass(o.hoverClass);
					if(typeof o.title != 'undefined' && o.title === true && title != '') {
						$h.attr('title',title);
					}
				}, function() {
					
					$h.removeClass(o.hoverClass);
					if(typeof o.title != 'undefined' && o.title === true && title != '') {
						$h.removeAttr('title');
					}
				})
				// click
				.click(function() {
					if(getSelectedText() == "")
					{
						if($a.is('[rel*=external]')){
							window.open(href);
							return false;
						}
						else {
							//$a.click(); $a.trigger('click');
							window.location = href;
						}
					}
				});
		});
	};
	// private function for debugging
	function debug($obj) {
		if (window.console && window.console.log)
		window.console.log('bigTarget selection count: ' + $obj.size());
	};
	// get selected text
	function getSelectedText(){
		if(window.getSelection){
			return window.getSelection().toString();
		}
		else if(document.getSelection){
			return document.getSelection();
		}
		else if(document.selection){
			return document.selection.createRange().text;
		}
	};
	// plugin defaults
	$.fn.bigTarget.defaults = {
		hoverClass	: 'hover',
		clickZone	: 'li:eq(0)',
		title		: true
	};
// end of closure
})(jQuery);;
/*
 * Legacy unit-conversion script
*/
function convert(form){
  // find out which option is selected then
  // assign the value of the selected option 
  var i = form.fromunits.selectedIndex;
  var fromvalue = form.fromunits.options[i].value;
  var j = form.tounits.selectedIndex;
  var tovalue = form.tounits.options[j].value;
  // perform the conversion
  form.tovalue.value = (form.fromvalue.value * fromvalue) / tovalue;
  return true;
}

(function($){
  $(function() {

    // hack to disable the root menu item of each sub menu in the main manu
    $('.menu-block-1 > ul > li:gt(0) > a').click(function() {return false;});
    $('.menu-block-3 > ul > li:gt(0) > a').click(function() {return false;}).css('cursor', 'default');
    

    // script to the tracking form
    $('#tracker-container ul a').click(function() {
      $('#tracker-container ul li').removeClass('active');
      var tid = this.href.substr(this.href.indexOf('#') + 1);
      $('#tracker-container .forms-container input[name=shipper]').val(tid);
      $(this).parent().addClass('active');
      $('#tracker-container h2').text($(this).text());
      return false;
    });

    // hack to allow edit links within a bigtaget area
    $('.bigtarget .views-field-edit-node a').click(function(e) {
      e.stopPropagation();
      var d = this.pathname + this.search;
      if(d[0] === '/')
        window.location = '#overlay=' + escape(d.substr(1));
      else
        window.location = '#overlay=' + escape(d);
      return false;
    });

    $('.bigtarget .bigtarget-link a').bigTarget({
      hoverClass: 'over', // CSS class applied to the click zone onHover
      clickZone : '.bigtarget' // jQuery parent selector
    });

    jQuery.extend(
      jQuery.expr[':'], {
        regex: function(a, i, m, r) {
          var r = new RegExp(m[3], 'i');
          return r.test(jQuery(a).text());
        }
      }
    );
    //var switchTo5x=true;stLight.options({publisher:'45ca7d31-3292-4dae-a029-069eec8cc49a'});
  });
})(jQuery);

;

