(function(d){d.each(["backgroundColor","borderBottomColor","borderLeftColor","borderRightColor","borderTopColor","color","outlineColor"],function(f,e){d.fx.step[e]=function(g){if(!g.colorInit){g.start=c(g.elem,e);g.end=b(g.end);g.colorInit=true}g.elem.style[e]="rgb("+[Math.max(Math.min(parseInt((g.pos*(g.end[0]-g.start[0]))+g.start[0]),255),0),Math.max(Math.min(parseInt((g.pos*(g.end[1]-g.start[1]))+g.start[1]),255),0),Math.max(Math.min(parseInt((g.pos*(g.end[2]-g.start[2]))+g.start[2]),255),0)].join(",")+")"}});function b(f){var e;if(f&&f.constructor==Array&&f.length==3){return f}if(e=/rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(f)){return[parseInt(e[1]),parseInt(e[2]),parseInt(e[3])]}if(e=/rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(f)){return[parseFloat(e[1])*2.55,parseFloat(e[2])*2.55,parseFloat(e[3])*2.55]}if(e=/#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(f)){return[parseInt(e[1],16),parseInt(e[2],16),parseInt(e[3],16)]}if(e=/#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(f)){return[parseInt(e[1]+e[1],16),parseInt(e[2]+e[2],16),parseInt(e[3]+e[3],16)]}if(e=/rgba\(0, 0, 0, 0\)/.exec(f)){return a.transparent}return a[d.trim(f).toLowerCase()]}function c(g,e){var f;do{f=d.curCSS(g,e);if(f!=""&&f!="transparent"||d.nodeName(g,"body")){break}e="backgroundColor"}while(g=g.parentNode);return b(f)}var a={aqua:[0,255,255],azure:[240,255,255],beige:[245,245,220],black:[0,0,0],blue:[0,0,255],brown:[165,42,42],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgrey:[169,169,169],darkgreen:[0,100,0],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkviolet:[148,0,211],fuchsia:[255,0,255],gold:[255,215,0],green:[0,128,0],indigo:[75,0,130],khaki:[240,230,140],lightblue:[173,216,230],lightcyan:[224,255,255],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightyellow:[255,255,224],lime:[0,255,0],magenta:[255,0,255],maroon:[128,0,0],navy:[0,0,128],olive:[128,128,0],orange:[255,165,0],pink:[255,192,203],purple:[128,0,128],violet:[128,0,128],red:[255,0,0],silver:[192,192,192],white:[255,255,255],yellow:[255,255,0],transparent:[255,255,255]}})(jQuery);


/**
 * sfSlider
 *
 * @version: 1.0
 *
 * Required settings:
 *  display 	- provide number of items displayed at once
 *
 * Other settings:
 *  time 		- transition time
 *  easing 		- easing for the transition
 *  width 		- width of the scrolled area (by default visible area + right margin on the last visible item)
 *  previous	- previous link text
 *  next		- next link text
 *  wrap		- wrap container selector
 *  slider		- items container selector
 *  items		- items selector
 */ 
eval(function($){jQuery.fn.sfSlider=function(options){var defaults={width:0,display:6,time:500,easing:'swing',previous:'Previous',next:'Next',wrap:'div.wrap',slider:'ul.items',items:'ul.items li'};var settings=$.extend({},defaults,options);return this.each(function(){var $root=$(this);var $wrap=$root.find(settings.wrap);var $slider=$root.find(settings.slider);var $items=$root.find(settings.items);var all=$items.size();var pages=Math.ceil(all/settings.display);if($items.size()<=settings.display)return false;var width=settings.width;if(settings.width===0)width=$wrap.width()+parseInt($items.css('margin-right'),10);var current=1;$root.append('<ul class="index"><li class="prev"><a href="#previous" class="off">'+settings.previous+'</a></li><li class="next"><a href="#next">'+settings.next+'</a></li></ul>');var $controls=$root.find('ul.index');var check=function(){if(current===1){$controls.find('li.prev a').addClass('off');}else{$controls.find('li.prev a').removeClass('off');}if(current===pages){$controls.find('li.next a').addClass('off');}else{$controls.find('li.next a').removeClass('off');}};$controls.find('a').click(function(){var direction=$(this).parent().attr('class');if($slider.is(':animated')||(current==1&&direction=='prev')||(current==pages&&direction=='next'))return false;if(direction=='next'){move='-='+width+'px';current++;}else{move='+='+width+'px';current--;}$slider.animate({'marginLeft':move},settings.time,settings.easing);check();return false;});});};})(jQuery);


/**
 * Product Filter
 * Version: 1.0
 *  
 * Plugin should be applied to the products list and can be modified with following options
 *  - checkboxContainer : selector for container that will hold filter checkboxes, by default "#checkboxcontainer"
 *  - item : selector for product item withing the list, by default "li"
 *  - tags : selector for tags wrapper within the product item element, by default ".tags"
 *  - itemsFound : selector for the "items found" message, by default ".itemsFound". It should have at least one <span /> containing the results number
 *  - hideOnLoad : should all items be displayed or hidden when page is loaded, by default "true" (hidden)
 *  - hiddenMessage : selector for the element with message displayed when all items are hidden, by default ".hideMessage"
 *  - delimiter : delimiter used to separate tags, by default a comma
 *  - createDynamicCheckboxes : should script dynamically create filter checkboxes, by default true
 */
(function(){var SFProductFilter=function(productList,options){this.productList=$(productList);this.checkboxContainer=$(options.checkboxContainer||'#checkboxcontainer');this.items=this.productList.find(options.item||'li');this.tags={};this.itemsFound=$(options.itemsFound||'.itemsFound');this.hideOnLoad=typeof options.hideOnLoad!='undefined'?!!options.hideOnLoad:true;this.hiddenMessage=$(options.hiddenMessage||'.hideMessage');this.createDynamicCheckboxes=typeof options.createDynamicCheckboxes!='undefined'?!!options.createDynamicCheckboxes:true;var delimiter=options.delimiter||',';var self=this,tagElement=options.tags||'.tags';$.each(this.items,function(index,item){var tags=$(item).find(tagElement).text().split(delimiter);if(!tags){return true;}
tags=$.map(tags,function(item){var tag=$.trim(item);if(tag===''){return null;}
self.tags[tag]=tag;return tag;});$(item).data('tags',tags);});if(this.hideOnLoad===true){this.hiddenMessage.show();this.productList.hide();}
if(this.createDynamicCheckboxes===true){this.createCheckboxes();}
this.checkboxContainer.find('input[type=checkbox]').click(function(){self.filter();});this.filter();};SFProductFilter.prototype.createCheckboxes=function(){var self=this;$.each(this.tags,function(index,item){var checkbox,label,p;checkbox=$('<input type="checkbox" value="'+item+'" id="product-list-tag-'+index+'"/>');label=$('<label for="product-list-tag-'+index+'">'+item+'</label>');p=$('<p/>');p.append(checkbox,' ',label);self.checkboxContainer.append(p);});};SFProductFilter.prototype.filter=function(){
var oScroll2 = $('#scrollbar2'); oScroll2.tinyscrollbar();	var activeTags=this.checkboxContainer.find('input:checked').map(function(){return $(this).val();});var activeElements=this.items.filter(function(){var itemTags=$(this).data('tags');var flag=true;$.each(activeTags,function(index,tag){if($.inArray(tag,itemTags)>-1){return true;}
flag=false;return false;});return flag;});var resultsFound=activeElements.length;if(this.hideOnLoad===true&&activeTags.length===0){this.productList.hide();this.hiddenMessage.show();resultsFound=0;}
else{this.productList.show();this.hiddenMessage.hide();}
this.itemsFound.find('span').text(resultsFound);this.items.hide();activeElements.show(); oScroll2.update();
};jQuery.fn.sfProductFilter=function(options){options=options||{};return this.each(function(){var pf=new SFProductFilter(this,options);});};})();


/*
 * hrefID jQuery extention
 */
$.fn.extend({ hrefId: function() { return $(this).attr('href').substr($(this).attr('href').indexOf('#')); } });

// HTML Truncator for jQuery
// by Henrik Nyh <http://henrik.nyh.se> 2008-02-28.
// Free to modify and redistribute with credit.
 
(function($) {

  var trailing_whitespace = true;

  $.fn.truncate = function(options) {

    var opts = $.extend({}, $.fn.truncate.defaults, options);
    
    $(this).each(function() {

      var content_length = $.trim(squeeze($(this).text())).length;
      if (content_length <= opts.max_length)
        return;  // bail early if not overlong

      var actual_max_length = opts.max_length - opts.more.length - 3;  // 3 for " ()"
      var truncated_node = recursivelyTruncate(this, actual_max_length);
      var full_node = $(this).hide();

      truncated_node.insertAfter(full_node);
      
      //findNodeForMore(truncated_node).append(' <a href="#show more content">'+opts.more+'</a>');
      findNodeForMore(truncated_node).append(opts.more);
      findNodeForLess(full_node).append(' <a href="#show less content">'+opts.less+'</a>');
      
      truncated_node.find('a:last').click(function() {
        truncated_node.hide(); full_node.show(); return false;
      });
      full_node.find('a:last').click(function() {
        truncated_node.show(); full_node.hide(); return false;
      });

    });
  }

  // Note that the " (…more)" bit counts towards the max length – so a max
  // length of 10 would truncate "1234567890" to "12 (…more)".
  $.fn.truncate.defaults = {
    max_length: 100,
    more: '…more',
    less: 'less'
  };

  function recursivelyTruncate(node, max_length) {
    return (node.nodeType == 3) ? truncateText(node, max_length) : truncateNode(node, max_length);
  }

  function truncateNode(node, max_length) {
    var node = $(node);
    var new_node = node.clone().empty();
    var truncatedChild;
    node.contents().each(function() {
      var remaining_length = max_length - new_node.text().length;
      if (remaining_length == 0) return;  // breaks the loop
      truncatedChild = recursivelyTruncate(this, remaining_length);
      if (truncatedChild) new_node.append(truncatedChild);
    });
    return new_node;
  }

  function truncateText(node, max_length) {
    var text = squeeze(node.data);
    if (trailing_whitespace)  // remove initial whitespace if last text
      text = text.replace(/^ /, '');  // node had trailing whitespace.
    trailing_whitespace = !!text.match(/ $/);
    var text = text.slice(0, max_length);
    // Ensure HTML entities are encoded
    // http://debuggable.com/posts/encode-html-entities-with-jquery:480f4dd6-13cc-4ce9-8071-4710cbdd56cb
    text = $('<div/>').text(text).html();
    return text;
  }

  // Collapses a sequence of whitespace into a single space.
  function squeeze(string) {
    return string.replace(/\s+/g, ' ');
  }
  
  // Finds the last, innermost block-level element
  function findNodeForMore(node) {
    var $node = $(node);
    var last_child = $node.children(":last");
    if (!last_child) return node;
    var display = last_child.css('display');
    if (!display || display=='inline') return $node;
    return findNodeForMore(last_child);
  };

  // Finds the last child if it's a p; otherwise the parent
  function findNodeForLess(node) {
    var $node = $(node);
    var last_child = $node.children(":last");
    if (last_child && last_child.is('p')) return last_child;
    return node;
  };

})(jQuery);

/**
 * Equal Heights Plugin
 * Equalize the heights of elements. Great for columns or any elements
 * that need to be the same size (floats, etc).
 * 
 * Version 1.0
 * Updated 12/10/2008
 *
 * Copyright (c) 2008 Rob Glazebrook (cssnewbie.com) 
 *
 * Usage: $(object).equalHeights([minHeight], [maxHeight]);
 * 
 * Example 1: $(".cols").equalHeights(); Sets all columns to the same height.
 * Example 2: $(".cols").equalHeights(400); Sets all cols to at least 400px tall.
 * Example 3: $(".cols").equalHeights(100,300); Cols are at least 100 but no more
 * than 300 pixels tall. Elements with too much content will gain a scrollbar.
 * 
 */

(function($) {
	$.fn.equalHeights = function(minHeight, maxHeight) {
		tallest = (minHeight) ? minHeight : 0;
		this.each(function() {
			if($(this).height() > tallest) {
				tallest = $(this).height();
			}
		});
		if((maxHeight) && tallest > maxHeight) tallest = maxHeight;
		return this.each(function() {
			$(this).height(tallest).css("overflow","hidden");
		});
	}
})(jQuery);



$.fn.dynaHeight = function(elements) {
  $(this).each(function() {
	var top = $(this).offset().top;
	var maxBottom = 0;
	$(elements).each(function() {
	  var pos = $(this).offset();
	  var height = $(this).outerHeight(true);
	  var bottom = pos.top + height;
	  if (bottom > maxBottom) {
	    maxBottom = bottom;
	  }
	});
    $(this).css({"height": (maxBottom - top) + "px"});
  });
  return this;
};


/*
 * Scripts
 *
 */
jQuery(function($) {
 
	var Engine = {
		utils : {
			links : function(){
				$('a[rel*=external]').click(function(e){
					e.preventDefault();
					window.open($(this).attr('href'));						  
				});
			},
			mails : function(){
				$('a[href^=mailto:]').each(function(){
					var mail = $(this).attr('href').replace('mailto:','');
					var replaced = mail.replace('/at/','@');
					$(this).attr('href','mailto:'+replaced);
					if($(this).text() == mail) {
						$(this).text(replaced);
					}
				});
			}
		},
		forms : {
			labels : function(){
				var $elements = $('form.newsletter-a p input, form#topform p input');
				$elements.each(function(){
					if($(this).val() !== '') $(this).prevAll('label:first').hide();
				}).focus(function(){
					$(this).prevAll('label:first').hide();
				}).blur(function(){
					if($(this).val() === '') $(this).prevAll('label:first').show();
				});
			}
		},
		fixes : {
			blog : function(){
				// no comments/trackbacks + alternative
				var $comments = $('div.comments-a');
				$comments.each(function(){
					if($(this).find('div.comment').length == 0){
						var fixed = $(this).html().replace(/<\/h2>/i,'</h2><p class="empty">') + '</p>';
						$(this).html(fixed);
					} else {
						$(this).find('div.comment:odd').addClass('alt');
					}
				});
				
				// show/hide comments/trackbacks
				var $links = $('div.post-a p.info a.comments, div.post-a p.info a.trackbacks');
				$links.click(function(){
					$($(this).hrefId()).toggle();
					if($(this).is('.comments')) $($(this).hrefId()).next('div.add-comment-a:first').toggle();
					return false;
				});
				
				// single post (show trackbacks and comments)
				if($('div.post-a').length == 1){
					$('div.comments-a, div.add-comment-a').show();
				}
			},
			separators : function(){
				$('ul[class*=cols]').each(function(){
					var matches = /cols([0-9]+)/i.exec($(this).attr('class'))
					var row = matches[1];
					$(this).find('li').each(function(i){
						if((i+1) % row == 0) $(this).after('<li class="separate"><a href="#top">Back to top</a></li>');
					});
				});
			}
		},
		slider : function(){
			$('#slider ul.items li:nth-child(6n+1)').addClass('start');
			$('#slider').sfSlider({display: 6});
		}
	};

	Engine.utils.links();
	Engine.utils.mails();
	Engine.forms.labels();
	Engine.fixes.blog();
	Engine.fixes.separators();
	Engine.slider();
	
});


/*
 * In-Field Label jQuery Plugin
 * http://fuelyourcoding.com/scripts/infield.html
 *
 * Copyright (c) 2009 Doug Neiner
 * Dual licensed under the MIT and GPL licenses.
 * Uses the same license as jQuery, see:
 * http://docs.jquery.com/License
 *
 * @version 0.1
 */
(function($){
	
    $.InFieldLabels = function(label,field, options){
        // To avoid scope issues, use 'base' instead of 'this'
        // to reference this class from internal events and functions.
        var base = this;
        
        // Access to jQuery and DOM versions of each element
        base.$label = $(label);
        base.label = label;

 		base.$field = $(field);
		base.field = field;
        
		base.$label.data("InFieldLabels", base);
		base.showing = true;
        
        base.init = function(){
			// Merge supplied options with default options
            base.options = $.extend({},$.InFieldLabels.defaultOptions, options);

			// Check if the field is already filled in
			if(base.$field.val() != ""){
				base.$label.hide();
				base.showing = false;
			};
			
			base.$field.focus(function(){
				base.fadeOnFocus();
			}).blur(function(){
				base.checkForEmpty(true);
			}).bind('keydown.infieldlabel',function(e){
				// Use of a namespace (.infieldlabel) allows us to
				// unbind just this method later
				base.hideOnChange(e);
			}).change(function(e){
				base.checkForEmpty();
			}).bind('onPropertyChange', function(){
				base.checkForEmpty();
			});
        };

		// If the label is currently showing
		// then fade it down to the amount
		// specified in the settings
		base.fadeOnFocus = function(){
			if(base.showing){
				base.setOpacity(base.options.fadeOpacity);
			};
		};
		
		base.setOpacity = function(opacity){
			base.$label.stop().animate({ opacity: opacity }, base.options.fadeDuration);
			base.showing = (opacity > 0.0);
		};
		
		// Checks for empty as a fail safe
		// set blur to true when passing from
		// the blur event
		base.checkForEmpty = function(blur){
			if(base.$field.val() == ""){
				base.prepForShow();
				base.setOpacity( blur ? 1.0 : base.options.fadeOpacity );
			} else {
				base.setOpacity(0.0);
			};
		};
		
		base.prepForShow = function(e){
			if(!base.showing) {
				// Prepare for a animate in...
				base.$label.css({opacity: 0.0}).show();
				
				// Reattach the keydown event
				base.$field.bind('keydown.infieldlabel',function(e){
					base.hideOnChange(e);
				});
			};
		};

		base.hideOnChange = function(e){
			if(
				(e.keyCode == 16) || // Skip Shift
				(e.keyCode == 9) // Skip Tab
			  ) return; 
			
			if(base.showing){
				base.$label.hide();
				base.showing = false;
			};
			
			// Remove keydown event to save on CPU processing
			base.$field.unbind('keydown.infieldlabel');
		};
      
		// Run the initialization method
        base.init();
    };
	
    $.InFieldLabels.defaultOptions = {
        fadeOpacity: 0.5, // Once a field has focus, how transparent should the label be
		fadeDuration: 300 // How long should it take to animate from 1.0 opacity to the fadeOpacity
    };
	

    $.fn.inFieldLabels = function(options){
        return this.each(function(){
			// Find input or textarea based on for= attribute
			// The for attribute on the label must contain the ID
			// of the input or textarea element
			var for_attr = $(this).attr('for');
			if( !for_attr ) return; // Nothing to attach, since the for field wasn't used
			
			
			// Find the referenced input or textarea element
			var $field = $(
				"input#" + for_attr + "[type='text']," + 
				"input#" + for_attr + "[type='password']," + 
				"textarea#" + for_attr
				);
				
			if( $field.length == 0) return; // Again, nothing to attach
			
			// Only create object for input[text], input[password], or textarea
            (new $.InFieldLabels(this, $field[0], options));
        });
    };
	
})(jQuery);


/* Classes schedule */

jQuery(function($){
	
	var GMTOffset = -4;
			
	var $root = $('#class-schedule');
	if ($root.length === 0) {
		return;
	}
	
	var ClassSchedule = function(el){
		this.root = $(el);
		this.raw = this.root.find('div.item').detach();		
		
		this.parseData();
		this.nav();
		
		//initialize with all events
		this.root.find('ul.nav a:eq(0)').triggerHandler('click');
	};
	
	ClassSchedule.prototype.parseData = function(){
		var now = new Date();
		this.localizeTime(now);
		
		this.items = this.raw.map($.proxy(function(index, el){
			var itemWeekday = $(el).find('.dDayofweek').text();
			//check if that's the correct weekday
			if (now.getDay() !== parseInt(itemWeekday, 10)) {
				return null;
			}
			
			var eventEnds = this.parseTime($(el).find('.dEndTime').text());
			
			//unable to parse end time
			if (eventEnds === false) {
				return null;				
			}
			
			//event finished
			if (eventEnds.getTime() < now.getTime()) {
				return null;
			}
			
			var eventStarts = this.parseTime($(el).find('.dBegintime').text());
			
			//unable to parse start time
			if (eventStarts === false) {
				return null;
			}
					
			$(el).data({
				'location' : $(el).find('.dLocation').text(),
				'startTime' : eventStarts.getTime()
			});
			
			return el;
		},this));		
		
		this.items.sort(function(a,b){
			var 
				aT = $(a).data('startTime'),
				bT = $(b).data('startTime');
			
			if (aT < bT) {
				return -1;
			}
			if (aT > bT) {
				return 1;
			}
			return 0;
		});
		
		this.root.append(this.items);
	};
	
	
	
	ClassSchedule.prototype.nav = function(){
		this.locations = [];
		this.raw.each($.proxy(function(index, el){
			var location = $(el).find('.dLocation').text();		
			if ($.inArray(location, this.locations) === -1){
				this.locations.push(location);
			}			
		},this));		
		
		var nav = $('<ul class="nav"/>');
		$.each(this.locations,$.proxy(function(index, location){
			var trigger = $('<a href="#">'+location+'</a>');
			trigger.data('location',location);
			
			nav.append($('<li/>').append(trigger));
		},this));
		
		nav.prepend('<li><a href="#">All clubs</a></li>');
		
		var triggers = nav.find('a');
		triggers.click($.proxy(function(e){
			e.preventDefault();
			triggers.removeClass('active');
			$(e.target).addClass('active');
			this.show($(e.target).data('location'));			
		},this));
		
		this.root.prepend(nav);
	};
	
	ClassSchedule.prototype.show = function(location) {
		this.items.hide();

		//all clubs
		if (!location) {
			this.items.show();
			return;
		}
		this.items.each($.proxy(function(index, el){
			if ($(el).data('location') === location) {
				$(el).show();
			}
		},this));
	};
	
	ClassSchedule.prototype.parseTime = function(str){
		var matches = str.match(/([0-9]+):([0-9]+) ?(AM|PM|NOON)/i);
		
		if (matches === null){
			return false;
		}
		
		var eTime = new Date();
		eTime.setMinutes(matches[2]);
		if (matches[3].toUpperCase() === 'PM') {
			eTime.setHours(parseInt(matches[1],10) + 12);
		}
		
		else if (matches[3].toUpperCase() === 'NOON') {
			eTime.setHours(matches[1]);
		}
		
		else {
			eTime.setHours(matches[1]);
		}

		return eTime;
	};
	
	//update time to include local time offset
	ClassSchedule.prototype.localizeTime = function(t) {
		t.setTime(t.getTime() + (t.getTimezoneOffset() + GMTOffset * 60) * 60000);
	};
	
	ClassSchedule = new ClassSchedule($root);
});





//Site Specific Code Here

        $(document).ready(function(){
			//$(".cols").equalHeights();
			$('#sideImage').dynaHeight('#content'); 
			$('#sideNavWrapper').dynaHeight('#col2Wrapper'); 
			$("#holiday-class-Schedule:contains('No items found')").remove();
			//$("div:contains('John')").css("text-decoration", "underline");
		
			
		});


//ORCHARD Bottom Nav start //////////////////////////////////////////////////////////////////////////////////////



(function($) {
	$.verticalTabs = function(el, options) {
		// To avoid scope issues, use 'base' instead of 'this'
		// to reference this class from internal events and functions.
		var base = this;

		// Access to jQuery and DOM versions of element
		base.$el = $(el);
		base.el = el;

		base.init = function() {
			base.options = $.extend({}, $.verticalTabs.defaultOptions, options);

			//Add tabs
			base.$el.tabs(base.options);
			
			//Make them vertical.
			base.$el.addClass('ui-tabs-vertical ui-helper-clearfix')
				.find("li").removeClass('ui-corner-top').addClass('ui-corner-left')
		};

		// Run initializer
		base.init();
	};

	$.verticalTabs.defaultOptions = {
	};

	$.fn.verticalTabs = function(options) {
		return this.each(function() {
			(new $.verticalTabs(this, options));
		});
	};

	$.bottomTabs = function(el, options) {
		// To avoid scope issues, use 'base' instead of 'this'
		// to reference this class from internal events and functions.
		var base = this;

		// Access to jQuery and DOM versions of element
		base.$el = $(el);
		base.el = el;


		base.init = function() {
			base.options = $.extend({}, $.bottomTabs.defaultOptions, options);

			base.$el.tabs();

			base.$el.addClass("ui-tabs-bottom")
				.find(".ui-tabs-nav").add($(".ui-tabs-nav > *", base.$el))
				.removeClass("ui-corner-all ui-corner-top")
				.addClass("ui-corner-bottom");
		};

		// Run initializer
		base.init();
	};

	$.bottomTabs.defaultOptions = {
	};

	$.fn.bottomTabs = function(options) {
		return this.each(function() {
			(new $.bottomTabs(this, options));
		});
	};

})(jQuery);



	$(document).ready(function(){
		var pathArray = window.location.pathname.split( '/' );
		var host = pathArray[1];
		$('body').attr('id' , host);
		
		$(function(){
			$('#slides').slides({
				preload: true,
				preloadImage: 'img/loading.gif',
				play: 5000,
				pause: 2500,
				pagination: true,
				effect: "fade",
				crossfade: true,
				hoverPause: true
			});
		});
		
		jQuery(".slidePanelItem .slidePanelLink").click(function () {
        var slidePanelItem = jQuery(this).closest('.slidePanelItem');
        if (slidePanelItem.hasClass("open")) {
            slidePanelItem.animate({
                bottom: "0px"
            }, 200).toggleClass("open").css('z-index' , 1);
            jQuery('#slidePanelWrapper').css('z-index' , 0);
			return false;

        } else {
            slidePanelItem.animate({
                bottom: "352px"
            }, 200).toggleClass("open").css('z-index' , 500);
			jQuery('#slidePanelWrapper').css('z-index' , 50);
			return false;
        }
    });
		
	});

$(document).ready(function(){
	
  	jQuery("#nav li.selected ul:first").clone().appendTo("#sideNav");
	jQuery("#nav ul li.selected a:first" ).clone().appendTo("#sideNavHeader");

  jQuery("#menuSource li.selected ul:first").clone().appendTo("#sideNav");
  jQuery("#menuSource ul li.selected a:first").clone().appendTo("#sideNavHeader");
  
	jQuery('#pagecontent img:first').addClass('contentHeaderimg');
 
	//jQuery('#mainPhoto img').replaceWith($('#pagecontent img:first'));
	jQuery('#pagecontent img:first').appendTo($('#mainPhoto'));
 
	jQuery('body:not(".community") #rightcol_corporate_content img:first').appendTo($('#top_photo_content'));
 

	$("a.bioLink").fancybox({
		"padding":30,
		"width":400,
		"height":"auto",
		"autoDimensions":false,
		"overlayColor": "#000000"
	});	
	
	
var month=new Array(12);
month[0]="Jan.";
month[1]="Feb.";
month[2]="March";
month[3]="April";
month[4]="May";
month[5]="June";
month[6]="July";
month[7]="August";
month[8]="Sept.";
month[9]="Oct.";
month[10]="Nov.";
month[11]="Dec.";


//var dateMonth=month[date.getMonth()];
//var dateDay=day[date.getDay()];
//var dateYear=date.getFullYear();
//var currentDate2=dateMonth+dateDay+dateYear;

var currentDate = new Date()
var dateMonth = month[currentDate.getMonth()];
var dateDay = currentDate.getDate()
var dateYear = currentDate.getFullYear()

$('#fitnessDate').text(dateMonth + " " + dateDay + ", " + dateYear);



/*
 if ($('#rightcol_corporate_content img:first').is(':empty')) {


 
} else{
 
jQuery('#rightcol_corporate_content img:first').appendTo($('#top_photo_content'));


 
}

 
 */




  //jQuery('#top_photo_content img').replaceWith($('#rightcol_corporate_content img:first'));
  jQuery("#locationsSuperNav").clone().appendTo("#nav ul li#prog_supernav");

	//jQuery('#locationsSuperNav .column1 li#headerYouth').remove();	
 
 
//Super Nav Cloning Scripts

	jQuery("#menuSource li#headerAdult ul").clone().appendTo("#adultSuper");
	jQuery("#menuSource li#headerYouth ul").clone().appendTo("#childSuper1");
	jQuery("#menuSource li#headerYouth ul").clone().appendTo("#childSuper2");

//Mega Menu Scripts

	function addMega(){
		$('#locationsSuperNav').slideToggle("slow");
        }
      	function removeMega(){
		$('#locationsSuperNav').slideToggle("fast");
        }       
    	var megaConfig = {
         interval: 100,
         sensitivity: 2,
         over: addMega,
         timeout: 100,
         out: removeMega
    	};
    	$("li#prog_supernav").hoverIntent(megaConfig)      
	  
	
		jQuery(function($) {
			$('#productsList').sfProductFilter({ 
				'hideOnLoad' : false,
				'checkboxContainer' : '#filter',
				'item' : 'p.item',
				'tags' : 'span.keywords',
				'itemsFound' : '#resultsNumber',
				'hiddenMessage' : '#defaultInfo',
				'delimiter' : ',',
				'createDynamicCheckboxes' : false
			});
		});
	
	
	
});



$(function() {
//change the main div to overflow-hidden as we can use the slider now
$('#scroll-pane').css('overflow','hidden');

//compare the height of the scroll content to the scroll pane to see if we need a scrollbar
var difference = $('#scroll-content').height()-$('#scroll-pane').height();//eg it's 200px longer 

if(difference>0)//if the scrollbar is needed, set it up...
{
   var proportion = difference / $('#scroll-content').height();//eg 200px/500px
   var handleHeight = Math.round((1-proportion)*$('#scroll-pane').height());//set the proportional height - round it to make sure everything adds up correctly later on
   handleHeight -= handleHeight%2; 

   $("#scroll-pane").after('<\div id="slider-wrap"><\div id="slider-vertical"><\/div><\/div>');//append the necessary divs so they're only there if needed
   $("#slider-wrap").height($("#scroll-pane").height());//set the height of the slider bar to that of the scroll pane


   //set up the slider 
   $('#slider-vertical').slider({
      orientation: 'vertical',
      min: 0,
      max: 100,
      value: 100,
      slide: function(event, ui) {//used so the content scrolls when the slider is dragged
         var topValue = -((100-ui.value)*difference/100);
         $('#scroll-content').css({top:topValue});//move the top up (negative value) by the percentage the slider has been moved times the difference in height
      },
      change: function(event, ui) {//used so the content scrolls when the slider is changed by a click outside the handle or by the mousewheel
         var topValue = -((100-ui.value)*difference/100);
         $('#scroll-content').css({top:topValue});//move the top up (negative value) by the percentage the slider has been moved times the difference in height
      }
   });

   //set the handle height and bottom margin so the middle of the handle is in line with the slider
   $(".ui-slider-handle").css({height:handleHeight,'margin-bottom':-0.5*handleHeight});
	
   var origSliderHeight = $("#slider-vertical").height();//read the original slider height
   var sliderHeight = origSliderHeight - handleHeight ;//the height through which the handle can move needs to be the original height minus the handle height
   var sliderMargin =  (origSliderHeight - sliderHeight)*0.5;//so the slider needs to have both top and bottom margins equal to half the difference
   $(".ui-slider").css({height:sliderHeight,'margin-top':sliderMargin});//set the slider height and margins
   
}//end if

//code to handle clicks outside the slider handle
$(".ui-slider").click(function(event){//stop any clicks on the slider propagating through to the code below
   	event.stopPropagation();
   });
   
$("#slider-wrap").click(function(event){//clicks on the wrap outside the slider range
	  var offsetTop = $(this).offset().top;//read the offset of the scroll pane
	  var clickValue = (event.pageY-offsetTop)*100/$(this).height();//find the click point, subtract the offset, and calculate percentage of the slider clicked
	  $("#slider-vertical").slider("value", 100-clickValue);//set the new value of the slider
}); 
	 
//additional code for mousewheel
$("#scroll-pane,#slider-wrap").mousewheel(function(event, delta){
	var speed = 5;
	var sliderVal = $("#slider-vertical").slider("value");//read current value of the slider
	
	sliderVal += (delta*speed);//increment the current value

	$("#slider-vertical").slider("value", sliderVal);//and set the new value of the slider
	
	event.preventDefault();//stop any default behaviour
});




 
 
/*
Cufon.replace('h1', { fontFamily: 'gotham-ehac' });
Cufon.replace('h2', { fontFamily: 'gotham-ehac' });
Cufon.replace('h3', { fontFamily: 'gotham-ehac' });
Cufon.replace('h4', { fontFamily: 'gotham-ehac' });
*/
	 
		
Cufon.replace('.downloads p', { fontFamily: 'gotham-ehac' });
Cufon.replace('.downloads h3', { fontFamily: 'gotham-ehac' });
		
Cufon.replace('#super_why', { fontFamily: 'gotham-ehac' });
		 
Cufon.replace('.super', { fontFamily: 'gotham-ehac' });
Cufon.replace('.memberships', { fontFamily: 'gotham-ehac' });
Cufon.replace('.superEnroll', { fontFamily: 'dinneuzitgrotest' });

Cufon.replace('.super-amount');




});


	
