$.homeURL = $('link[rel=index]').attr('href');
$.themeURL = ($.homeURL) ? $.homeURL+'wp-content/themes/ecmb/' : '';
$.isie7 = ($.browser.msie && parseInt($.browser.version) == 7) ? true : false;

//snippet for IE7 visibility fix with jQuery - http://remysharp.com/2008/10/17/jquery-really-visible/
jQuery.extend(
  jQuery.expr[ ":" ], 
  { reallyvisible : function (a) { return !(jQuery(a).is(':hidden') || jQuery(a).parents(':hidden').length); }}
);

//manages link clicks
$('a').live('click',function(e) { 
	if($(this).hasClass('external')) {
		e.preventDefault(); window.open(this.href);
	} else if($(this).attr('href') == '#') {
		e.preventDefault();
	} else if($(this).attr('href').match(/^#/)) {
		e.preventDefault();
		if(window.location.hash == $(this).attr('href')) { window.location.hash = '#'; return; }
		var pos = $(window).scrollTop(); // get scroll position
		window.location.hash = $(this).attr('href').substr(1);
		$(window).scrollTop(pos); // set scroll position back
		$('#accordion').scrollTop(0);
	}
});

//remove the focus in IE and firefox
if($.browser.mozilla || $.browser.msie) { $('a').live('click',function() { $(this).blur(); }); }


//used for feature detection
var testDiv_ = document.createElement('div');
var testInput_ = document.createElement('input');

//HTML5 placeholder support
if('placeholder' in testInput_) { } else {
	$('input[type=text]').each(function() {
		var placeholder_ = $(this).attr('placeholder') || $('label[for='+$(this).attr('id')+']').text().toLowerCase();
		$(this).attr('placeholder','');
		$(this).val(placeholder_);
		$(this).bind('focus',function() { if($.trim($(this).val()) == placeholder_) { $(this).val('').css('color','#000'); } })
		         .bind('blur',function() { if(!$.trim($(this).val())) { $(this).val(placeholder_).css('color','#d5b9b9'); } })
				 .css('color','#d5b9b9');
	});
}

/* common jQuery includes */

/* jquery easing code */
jQuery.easing.jswing=jQuery.easing.swing,jQuery.extend(jQuery.easing,{def:"easeOutQuad",swing:function(a,b,c,d,e){return jQuery.easing[jQuery.easing.def](a,b,c,d,e)},easeInQuad:function(a,b,c,d,e){return d*(b/=e)*b+c},easeOutQuad:function(a,b,c,d,e){return-d*(b/=e)*(b-2)+c},easeInOutQuad:function(a,b,c,d,e){if((b/=e/2)<1)return d/2*b*b+c;return-d/2*(--b*(b-2)-1)+c},easeInCubic:function(a,b,c,d,e){return d*(b/=e)*b*b+c},easeOutCubic:function(a,b,c,d,e){return d*((b=b/e-1)*b*b+1)+c},easeInOutCubic:function(a,b,c,d,e){if((b/=e/2)<1)return d/2*b*b*b+c;return d/2*((b-=2)*b*b+2)+c},easeInQuart:function(a,b,c,d,e){return d*(b/=e)*b*b*b+c},easeOutQuart:function(a,b,c,d,e){return-d*((b=b/e-1)*b*b*b-1)+c},easeInOutQuart:function(a,b,c,d,e){if((b/=e/2)<1)return d/2*b*b*b*b+c;return-d/2*((b-=2)*b*b*b-2)+c},easeInQuint:function(a,b,c,d,e){return d*(b/=e)*b*b*b*b+c},easeOutQuint:function(a,b,c,d,e){return d*((b=b/e-1)*b*b*b*b+1)+c},easeInOutQuint:function(a,b,c,d,e){if((b/=e/2)<1)return d/2*b*b*b*b*b+c;return d/2*((b-=2)*b*b*b*b+2)+c},easeInSine:function(a,b,c,d,e){return-d*Math.cos(b/e*(Math.PI/2))+d+c},easeOutSine:function(a,b,c,d,e){return d*Math.sin(b/e*(Math.PI/2))+c},easeInOutSine:function(a,b,c,d,e){return-d/2*(Math.cos(Math.PI*b/e)-1)+c},easeInExpo:function(a,b,c,d,e){return b==0?c:d*Math.pow(2,10*(b/e-1))+c},easeOutExpo:function(a,b,c,d,e){return b==e?c+d:d*(-Math.pow(2,-10*b/e)+1)+c},easeInOutExpo:function(a,b,c,d,e){if(b==0)return c;if(b==e)return c+d;if((b/=e/2)<1)return d/2*Math.pow(2,10*(b-1))+c;return d/2*(-Math.pow(2,-10*--b)+2)+c},easeInCirc:function(a,b,c,d,e){return-d*(Math.sqrt(1-(b/=e)*b)-1)+c},easeOutCirc:function(a,b,c,d,e){return d*Math.sqrt(1-(b=b/e-1)*b)+c},easeInOutCirc:function(a,b,c,d,e){if((b/=e/2)<1)return-d/2*(Math.sqrt(1-b*b)-1)+c;return d/2*(Math.sqrt(1-(b-=2)*b)+1)+c},easeInElastic:function(a,b,c,d,e){var f=1.70158,g=0,h=d;if(b==0)return c;if((b/=e)==1)return c+d;g||(g=e*.3);if(h<Math.abs(d)){h=d;var f=g/4}else var f=g/(2*Math.PI)*Math.asin(d/h);return-(h*Math.pow(2,10*(b-=1))*Math.sin((b*e-f)*2*Math.PI/g))+c},easeOutElastic:function(a,b,c,d,e){var f=1.70158,g=0,h=d;if(b==0)return c;if((b/=e)==1)return c+d;g||(g=e*.3);if(h<Math.abs(d)){h=d;var f=g/4}else var f=g/(2*Math.PI)*Math.asin(d/h);return h*Math.pow(2,-10*b)*Math.sin((b*e-f)*2*Math.PI/g)+d+c},easeInOutElastic:function(a,b,c,d,e){var f=1.70158,g=0,h=d;if(b==0)return c;if((b/=e/2)==2)return c+d;g||(g=e*.3*1.5);if(h<Math.abs(d)){h=d;var f=g/4}else var f=g/(2*Math.PI)*Math.asin(d/h);if(b<1)return-0.5*h*Math.pow(2,10*(b-=1))*Math.sin((b*e-f)*2*Math.PI/g)+c;return h*Math.pow(2,-10*(b-=1))*Math.sin((b*e-f)*2*Math.PI/g)*.5+d+c},easeInBack:function(a,b,c,d,e,f){f==undefined&&(f=1.70158);return d*(b/=e)*b*((f+1)*b-f)+c},easeOutBack:function(a,b,c,d,e,f){f==undefined&&(f=1.70158);return d*((b=b/e-1)*b*((f+1)*b+f)+1)+c},easeInOutBack:function(a,b,c,d,e,f){f==undefined&&(f=1.70158);if((b/=e/2)<1)return d/2*b*b*(((f*=1.525)+1)*b-f)+c;return d/2*((b-=2)*b*(((f*=1.525)+1)*b+f)+2)+c},easeInBounce:function(a,b,c,d,e){return d-jQuery.easing.easeOutBounce(a,e-b,0,d,e)+c},easeOutBounce:function(a,b,c,d,e){return(b/=e)<1/2.75?d*7.5625*b*b+c:b<2/2.75?d*(7.5625*(b-=1.5/2.75)*b+.75)+c:b<2.5/2.75?d*(7.5625*(b-=2.25/2.75)*b+.9375)+c:d*(7.5625*(b-=2.625/2.75)*b+.984375)+c},easeInOutBounce:function(a,b,c,d,e){if(b<e/2)return jQuery.easing.easeInBounce(a,b*2,0,d,e)*.5+c;return jQuery.easing.easeOutBounce(a,b*2-e,0,d,e)*.5+d*.5+c}});
/* jquery background image animationg */
(function(a){function d(a){a=a.replace(/left|top/g,"0px"),a=a.replace(/right|bottom/g,"100%"),a=a.replace(/([0-9\.]+)(\s|\)|$)/g,"$1px$2");var b=a.match(/(-?[0-9\.]+)(px|\%|em|pt)\s(-?[0-9\.]+)(px|\%|em|pt)/);return[parseFloat(b[1],10),b[2],parseFloat(b[3],10),b[4]]}if(!document.defaultView||!document.defaultView.getComputedStyle){var b=jQuery.curCSS;jQuery.curCSS=function(a,c,d){c==="background-position"&&(c="backgroundPosition");if(c!=="backgroundPosition"||!a.currentStyle||a.currentStyle[c])return b.apply(this,arguments);var e=a.style;if(!d&&e&&e[c])return e[c];return b(a,"backgroundPositionX",d)+" "+b(a,"backgroundPositionY",d)}}var c=a.fn.animate;a.fn.animate=function(a){"background-position"in a&&(a.backgroundPosition=a["background-position"],delete a["background-position"]),"backgroundPosition"in a&&(a.backgroundPosition="("+a.backgroundPosition);return c.apply(this,arguments)},a.fx.step.backgroundPosition=function(b){if(!b.bgPosReady){var c=a.curCSS(b.elem,"backgroundPosition");c||(c="0px 0px"),c=d(c),b.start=[c[0],c[2]];var e=d(b.options.curAnim.backgroundPosition);b.end=[e[0],e[2]],b.unit=[e[1],e[3]],b.bgPosReady=!0}var f=[];f[0]=(b.end[0]-b.start[0])*b.pos+b.start[0]+b.unit[0],f[1]=(b.end[1]-b.start[1])*b.pos+b.start[1]+b.unit[1],b.elem.style.backgroundPosition=f[0]+" "+f[1]}})(jQuery);
/* jquery color animation */
(function(a){function d(a){var b,c;if(b=/#([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})/.exec(a))c=[parseInt(b[1],16),parseInt(b[2],16),parseInt(b[3],16),1];else if(b=/#([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])/.exec(a))c=[parseInt(b[1],16)*17,parseInt(b[2],16)*17,parseInt(b[3],16)*17,1];else if(b=/rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(a))c=[parseInt(b[1]),parseInt(b[2]),parseInt(b[3]),1];else if(b=/rgba\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([01\.]*)\s*\)/.exec(a))c=[parseInt(b[1],10),parseInt(b[2],10),parseInt(b[3],10),parseFloat(b[4])];return c}function c(b,c,d){var e="rgb"+(a.support.rgba?"a":"")+"("+parseInt(b[0]+d*(c[0]-b[0]),10)+","+parseInt(b[1]+d*(c[1]-b[1]),10)+","+parseInt(b[2]+d*(c[2]-b[2]),10);a.support.rgba&&(e+=","+(b&&c?parseFloat(b[3]+d*(c[3]-b[3])):1)),e+=")";return e}function b(){var b=a("script:first"),c=b.css("color"),d=!1;if(/^rgba/.test(c))d=!0;else try{d=c!=b.css("color","rgba(0, 0, 0, 0.5)").css("color"),b.css("color",c)}catch(e){}return d}a.extend(!0,a,{support:{rgba:b()}});var e=["color","backgroundColor","borderBottomColor","borderLeftColor","borderRightColor","borderTopColor","outlineColor"];a.each(e,function(b,e){a.fx.step[e]=function(b){b.init||(b.a=d(a(b.elem).css(e)),b.end=d(b.end),b.init=!0),b.elem.style[e]=c(b.a,b.end,b.pos)}}),a.fx.step.borderColor=function(b){b.init||(b.end=d(b.end));var i=e.slice(2,6);a.each(i,function(e,h){b.init||(b[h]={a:d(a(b.elem).css(h))}),b.elem.style[h]=c(b[h].a,b.end,b.pos)}),b.init=!0}})(jQuery);

//My GenericSlider - so cool

//uglified generic slider - 3442 bytes
//function GenericSlider(a){this._holder=!1,this._list=!1,this._items=!1,this._current=0,this._total=0,this._prev=!1,this._next=!1,this._moveBy=0,this._numShowing=0,this._dir=!1,this._speed=0,this._infinite=!1,$.extend(this,a);var b=this;this._auto&&(this._interval=setTimeout(function(){b.moveTo(b._current-0+1)},this._auto));if(!!this._holder.length){this._list=this._holder.children("ul.slider");if(!this._list.length)return;this._list.children().removeClass("start end tostart toend").attr("rel",""),this._items=this._list.children().not(".hidden"),this._total=this._items.length,this._items.eq(0).addClass("start"),this._items.last().addClass("end");var c=this._holder.parent().find("ul.slider_controls a");this._next=c.filter(".next"),this._prev=c.filter(".prev"),this._easing=this._easing?this._easing:"swing";if(this._infinite){var d=0;while(d<this._numShowing+this._moveBy){if(this._items.eq(d).hasClass("hidden"))continue;this._items.eq(d).clone().removeClass().addClass("tostart").attr("rel","offset"+d).appendTo(this._list),d++}var d=this._items.filter(".end").index(this._items),e=0;while(e>-this._numShowing){if(this._items.eq(d).hasClass("hidden"))continue;this._items.eq(d).clone().removeClass().addClass("toend").attr("rel","offset"+e).prependTo(this._list),d--,e--}var f=this._dir=="top"?"outerHeight":"outerWidth";this._list.css(this._dir,-(this._items[f](!0)*this._numShowing)+"px"),this._current=this._numShowing,this._items=this._list.children().not(".hidden"),this._total=this._items.length,this._list.css(f,this._total*this._items.outerWidth(!0)*this._numShowing)}this.addListeners(),this._total&&this.moveTo(this._current)}}GenericSlider.prototype.addListeners=function(){var a=this;this._next.bind("click",function(b){b.preventDefault(),a.moveTo(a._current+a._moveBy)}),this._prev.bind("click",function(b){b.preventDefault(),a.moveTo(a._current-a._moveBy)})},GenericSlider.prototype.reinit=function(){this._list=this._holder.children("ul.slider"),this._items=this._list.children().not(".hidden"),this._total=this._items.length,this.addListeners()},GenericSlider.prototype.destroy=function(){this._items.each(function(){$(this).attr("rel")&&$(this).remove()}),this._next.unbind(),this._prev.unbind()},GenericSlider.prototype.Animate=function(a){a+this._numShowing>this._total&&(a=0),a<0&&(a=this._total-this._numShowing),this._duringAnimation&&this._duringAnimation.call(this),this._current=a;var b=this._items.eq(this._current).position()[this._dir],c={};c[this._dir]=-b,this._animating=!0;var d=this;this._list.stop().animate(c,this._speed,this._easing,function(){if(d._infinite){if(d._items.eq(d._current).hasClass("tostart"))var a=d._items.filter(".start");else if(d._items.eq(d._current).hasClass("toend"))var a=d._items.filter(".end");if(a){var b=parseInt(d._items.eq(d._current).attr("rel").replace(/[^0-9]/g,"")),c=0;d._items.each(function(b){if($(this).get(0)==a.get(0)){c=b;return!1}}),d._current=c-0+b,d._list.css(d._dir,-a.position()[d._dir]+"px")}d._auto&&(d._interval=setTimeout(function(){d.moveTo(d._current-0+1)},d._auto)),d._animating=!1}d._afterFinish&&d._afterFinish.call(d)})},GenericSlider.prototype.moveTo=function(a){var b=this;if(!this._infinite||!this._animating){if(!this._list.filter(":visible").length){this._afterFinsh&&this._afterFinish.call(this);return}clearInterval(this._interval);if(this._beforeStart)return function(){b._beforeStart.call(b,arguments),b.Animate(a)};this.Animate(a)}}

//development generic slider - 5896 bytes
function GenericSlider(args) {
	this._holder 	= false;
	this._list			= false;
	this._items		= false;
	this._current	= 0;
	this._total		= 0;
	this._prev		= false;
	this._next			= false;
	this._moveBy	= 0;			//int - number to move the slider by
	this._numShowing = 0;
	this._dir = false;				//top for vert or left for horizontal
	this._speed = 0;
	this._infinite = false;
	
	$.extend(this,args);
	var o = this;
	if(this._auto) { this._interval = setTimeout(function() { o.moveTo(o._current-0+1); },this._auto); }
	
		if(!this._holder.length) { return; }
		
		this._list = this._holder.children('ul.slider');
		if(!this._list.length) { return; }		
		
		this._list.children().removeClass('start end tostart toend').attr('rel','');//dont need these from remnants
		this._items = this._list.children().not('.hidden'); //dont count elements that are set to display: none
		this._total = this._items.length;
		
		this._items.eq(0).addClass('start');
		this._items.last().addClass('end');
		
		var links_ = this._holder.parent().find('ul.slider_controls a');
		this._next = links_.filter('.next');
		this._prev = links_.filter('.prev');
		this._easing = (this._easing) ? this._easing : 'swing';
	
		
		if(this._infinite) {
			//duplicate the first (numShowing) and place at the end of the slider
			var i=0;
			while(i<this._numShowing+this._moveBy) {
				if(this._items.eq(i).hasClass('hidden')) { continue; } 
				this._items.eq(i).clone().removeClass().addClass('tostart').attr('rel','offset'+i).appendTo(this._list);
				i++;
			}
			
			//duplicate the last (numShowing) and place at the beginning of the slider
			var i = this._items.filter('.end').index(this._items); //need to provide context to the index
			var m=0;
			while(m>-this._numShowing) {
				if(this._items.eq(i).hasClass('hidden')) { continue; }
				this._items.eq(i).clone().removeClass().addClass('toend').attr('rel','offset'+m).prependTo(this._list);
				i--; m--;
			}
			
			//always start this._list with a negative (dir) of this._items.outerWidth(true)*numShowing
			var cssProp_ = (this._dir == 'top') ? 'outerHeight' : 'outerWidth';
			this._list.css(this._dir,-(this._items[cssProp_](true)*this._numShowing)+'px');
			//update this._current because we've offset the slider now by this._numShowing
			this._current = this._numShowing;
			
			//update the total number of items
			this._items = this._list.children().not('.hidden');
			this._total = this._items.length;
			
			//make sure the slider is wide or tall enough to fit all the panels
			this._list.css(cssProp_,this._total*this._items.outerWidth(true)*this._numShowing);
		}
		
		this.addListeners();
		if(this._total) { this.moveTo(this._current); }
}

GenericSlider.prototype.addListeners = function() {
		var o = this;
		this._next.bind('click',function(e) {
			e.preventDefault();
			o.moveTo(o._current+o._moveBy);
		});
		
		this._prev.bind('click',function(e) {			
			e.preventDefault();
			o.moveTo(o._current-o._moveBy);
		});
}

GenericSlider.prototype.reinit = function() {
	this._list = this._holder.children('ul.slider');
	this._items = this._list.children().not('.hidden'); //dont count hidden elements
	this._total = this._items.length;
	this.addListeners();
}

GenericSlider.prototype.destroy = function() {
	this._items.each(function() { if($(this).attr('rel')) { $(this).remove(); } }); //remove any list items that were placed there because of this._infinite = true
	this._next.unbind(); this._prev.unbind(); //remove the event listeners
}

GenericSlider.prototype.Animate = function(i) {
		if(i+this._numShowing>this._total && !this._infinite) { i=0; }
		if(i<0) { i=this._total-this._numShowing; }
		
		this._current = i;
		
		if(this._duringAnimation) { this._duringAnimation.call(this); }
		
		var dir_ = this._items.eq(this._current).position()[this._dir];
		var animationArgs = {};
			animationArgs[this._dir] = -dir_			
		this._animating = true;
		
		var o = this;
		this._list.stop().animate(animationArgs,this._speed,this._easing,function() { 
			
			if(o._infinite) {
				//if this._current hasClass (tostart) - go back to the li with a class of start
				//if this._current.hasClass (toend) - go to the li with a class of end
				if(o._items.eq(o._current).hasClass('tostart')) { var slide_ = o._items.filter('.start'); }
				else if(o._items.eq(o._current).hasClass('toend')) { var slide_ = o._items.filter('.end'); }
				
				if(slide_) {				
					var offset_ = parseInt(o._items.eq(o._current).attr('rel').replace(/[^0-9]/g,''));
					
					//The below statement should work, but it doesn't
					//o._current = slide_.index(o._items); //need to provide context to the index function
					//WEIRD ISSUE - slide_.index(o._items) always returns -1 here!!!???
					
					var index_ = 0;
					o._items.each(function(ind_) { if($(this).get(0) == slide_.get(0)) { index_ = ind_; return false; /* break out of this loop */ } });
					o._current = index_-0+offset_; //get what position we are currently at now
					
					o._list.css(o._dir,-slide_.position()[o._dir]+'px');
				}
				o._animating = false;
			}			
			if(o._auto) { o._interval = setTimeout(function() { o.moveTo(o._current-0+1); },o._auto); }
			if(o._afterFinish) { o._afterFinish.call(o); } 
		});
}

GenericSlider.prototype.moveTo = function(i) {
		var o = this;
		if(this._infinite && this._animating) { return; } //we can only have an infinite carousel if we don't allow users to continually push the buttons
		if(!this._items.filter(':visible').length) { if(this._afterFinsh) { this._afterFinish.call(this); } return;}
		clearInterval(this._interval);
		if(this._beforeStart) { return function() { o._beforeStart.call(o,arguments); o.Animate(i); }; } //how to start the animation after this function is completed?
		this.Animate(i);
}

//how to initiate a GenericSlider object
/*var init = {};
	init['_holder'] = $('#sliderwrap .wrap');
	init['_moveBy'] = 1;
	init['_numShowing'] = 1;
	init['_speed'] = 800;
	init['_easing'] = 'easeInOutBack';
	init['_dir'] = 'top'; //or 'left';
	init['_auto'] = 10000; //ms to autoadvance after
	init['_infinite'] = true; //infinite circular slider
	//callback functions - inside all of these functions 'this' refers to the GenericSlider object
	init['_beforeStart'] = function() { };
	init['_duringAnimation'] = function() { };
	init['_afterFinish'] = function() {  };*/
	
if($('#modules').length) {
	$('#modules li')
		.bind('mouseenter',function() { $(this).children('a').stop().animate({left:0},300,'easeInOutSine'); })
		.bind('mouseleave',function() { $(this).children('a').stop().animate({left:-230},300,'easeInOutSine'); })
		
	if($('#modules .slider').length) {
		$.ModSliderArgs = {};

			$.ModSliderArgs._holder = $('#modules .slider').parent();			
				$.ModSliderArgs._holder.append('<ul class="slider_links"></ul>');
			$.ModSliderArgs._moveBy = 1;
			$.ModSliderArgs._numShowing = 1;
			$.ModSliderArgs._speed = 800;
			$.ModSliderArgs._easing = 'easeInOutSine';
			$.ModSliderArgs._dir = 'left';
			$.ModSliderArgs._auto = 3500;
			$.ModSliderArgs._duringAnimation = function() { 
			
				this._holder
					.find('ul.slider_links li')
					.children()
					.stop()
					.animate({backgroundColor:'#fff'},300)
					.parent()
					.eq(this._current)
					.children()
					.delay(300)
					.stop()
					.animate({backgroundColor:'#c5a18e'},300); 
			};
			
			$.ModSlider = new GenericSlider($.ModSliderArgs);
			$.ModSlider._items.each(function(ind,item) {
				var class_ = (ind == 0) ? "replace selected" : "replace";
				$.ModSlider._holder.find('ul.slider_links').append("<li><a href='#' class='"+class_+"'>Slide "+ind+"</a></li>");
			})
			
			$.ModSlider._holder.find('ul.slider_links a').bind('click',function() { $.ModSlider.moveTo($(this).parent().index()); });
			$.ModSlider._items
				.bind('mouseover',function() { clearInterval($.ModSlider._interval); })
				.bind('mouseleave',function() { $.ModSlider._interval = setTimeout(function() { $.ModSlider.moveTo($.ModSlider._current-0+1); },$.ModSlider._auto);});
	}
}

if($('#slider').length && !$('body').hasClass('home')) {
	$.InternalSliderArgs = {};

			$.InternalSliderArgs._holder = $('#slider').children('div.wrap');
				$.InternalSliderArgs._holder.append('<ul class="slider_links"></ul>');
			$.InternalSliderArgs._moveBy = 1;
			$.InternalSliderArgs._numShowing = 1;
			$.InternalSliderArgs._speed = 600;
			$.InternalSliderArgs._easing = 'easeInOutSine';
			$.InternalSliderArgs._dir = 'top';
			$.InternalSliderArgs._auto = 4000;
			$.InternalSliderArgs._infinite = true;
			$.InternalSliderArgs._duringAnimation = function() { 
			
				var current_ = (this._current == this._total-2) ? 0 : this._current-1;

				this._holder
					.find('ul.slider_links li')
					.children()
					.stop()
					.animate({backgroundColor:'#737273'},600)
					.parent()
					.eq(current_)
					.children()
					.stop()
					.animate({backgroundColor:'#e57d51'},600); 
			};
			
			$.InternalSlider = new GenericSlider($.InternalSliderArgs);
			var startClass = false;
			$.InternalSlider._items.each(function(ind,item) {
				if($(this).hasClass('tostart') || $(this).hasClass('toend')) { return; }
				var class_ = (!startClass) ? "replace selected" : "replace";
				$.InternalSlider._holder.find('ul.slider_links').append("<li><a href='#' class='"+class_+"'>Slide "+ind+"</a></li>");
				startClass = true;
			})
			
			$.InternalSlider._holder.find('ul.slider_links a').bind('click',function() { 
				$.InternalSlider.moveTo($(this).parent().index()-0+1); 
			});
			$.InternalSlider._items
				.bind('mouseover',function() { clearInterval($.InternalSlider._interval); })
				.bind('mouseleave',function() { $.InternalSlider._interval = setTimeout(function() { $.InternalSlider.moveTo($.InternalSlider._current-0+1); },$.InternalSlider._auto);});
}

if($('#accordion').length && $('body').hasClass('home')) {
	
	$.ProductSliderArgs = {
		_moveBy : 1,
		_numShowing : 1,
		_speed : 500,
		_dir : 'top',
		_infinite : true,
	};

	$('#accordion ul.slider').each(function(item,ind) {
		$.ProductSliderArgs._holder = $(this).parent();
		window['Product'+ind] = new GenericSlider($.ProductSliderArgs);
	});
}

/* stupid IE7 keeps the element width even after the specified font is loaded and changes the element width */
$(document).ready(function() { 
	if($.isie7) {
		$('#nav').children().each(function() {
			$(this).css('width',$(this).width()+'px');
		});
	}
});



$(window).load(function() {

	if($('#imageslider').length) {			
		$('#imageslider').nivoSlider({
			effect:'fade', // Specify sets like: 'fold,fade,sliceDown'
			slices:1, // For slice animations
			boxCols: 1, // For box animations
			boxRows: 1, // For box animations
			animSpeed:1000, // Slide transition speed
			pauseTime:5000, // How long each slide will show
			startSlide:0, // Set starting Slide (0 index)
			directionNav:false, // Next & Prev navigation
			directionNavHide:false, // Only show on hover
			controlNav:false, // 1,2,3... navigation
			controlNavThumbs:false, // Use thumbnails for Control Nav
			controlNavThumbsFromRel:false, // Use image rel for thumbs
			controlNavThumbsSearch: '.jpg', // Replace this with...
			controlNavThumbsReplace: '_thumb.jpg', // ...this in thumb Image src
			keyboardNav:false, // Use left & right arrows
			pauseOnHover:true, // Stop animation while hovering
			manualAdvance:false, // Force manual transitions
			captionOpacity:0.8, // Universal caption opacity
			prevText: 'Prev', // Prev directionNav text
			nextText: 'Next' // Next directionNav text
		});
	}
	
});
