(function ($) {	
	$(document).ready(function(){	
		
		var currentURL = window.location.toString().split("/");
		$('a[href$="' + currentURL[currentURL.length-1] + '"]').parent().addClass('active'); 
		
		/*$('.toolbar select').selectHide();	
		$('.optionselect select').selectHide();
		//fisheyeProducts.megaMenu();			
		$(".products-grid li").equalHeights(210);*/
		
		$('.selecthide').selectHide();
		$('.input-text').placeholder();
		$('#mini-password').passFocusBlur();
		
		$tweetList = $('.tweet_list');
		if( $tweetList.find('li').length > 2 ){
			$('.twitter .next, .twitter .prev').click(function(){
				return false;								   
			});
			$tweetList.jCarouselLite({
				btnNext: ".twitter .prev",
				btnPrev: ".twitter .next",
				visible: 2,
				easing: 'easeOutSine',
				mouseWheel: true,
				scroll: 1,
				vertical: true,
				speed: 300,
				circular: false
			});
		}	
		
		$blogList = $('#blog_list');
		if( $blogList.find('li').length > 3 ){
			$('.blog .next, .blog .prev').click(function(){
				return false;								   
			});
			$blogList.jCarouselLite({
				btnNext: ".blog .prev",
				btnPrev: ".blog .next",
				visible: 3,
				easing: 'easeOutSine',
				mouseWheel: true,
				scroll: 1,
				vertical: true,
				speed: 300,
				circular: false
			});
		}	
		
		var $askExpert = $('#ask_expert');
		var docHeight = $(document).height();
		$askExpert.css('height', docHeight + 'px');
		$askExpert.children('.wrapper').css('height', docHeight + 'px');
		$askExpert.find('a').scrollFollow({
			speed: 500,
			offset: 20
		});	
		
		
		fisheyeCommon.infoboxes();
		
		/* this is to fix a ie7 reflow issue on the stockist page */
		var $footer = $('.footer');
		$('#salon_payintend, #salon_hearabout, #salon_type').change(function(){
			$footer.toggleClass('ie7ReflowFix');									  
		});
		
	});
	
	window.fisheyeCommon = function() {		
		
		var infoboxes = function(){
			
			var $infoBoxes = $('#cart_list li');
			$infoBoxes.each(function(){
				
				$infoBox = $(this);
				$infolink = $infoBox.find('.infolink');
				$infolink.hover(function(){						
					var $parent = $(this).parents('li');					
					if( !$parent.hasClass('active') ){
						$infoBoxes.removeClass('active');
						$parent.addClass('active');
					}else{
						$infoBoxes.removeClass('active');
					}
					return false;
				});
				
				$infoBox.bind( "clickoutside", function(event){
					$(this).removeClass('active');
				});
				
			});
		
		};
		
		return {
			infoboxes : infoboxes
		};
		
	}();
	
})(jQuery);
/* 
 * v0.02 Selectbox hide plugin for jQuery
 */
(function($){$.fn.selectHide=function(){return this.each(function(){var $this=$(this);$this.css('opacity','0');$this.wrap('<div class="select_wrap" />');$this.before('<span class="selected_text"></span><span class="btn"></span>');var selected_text=$this.parent().children('.selected_text');new_text=$this.children('option:selected').text();if(new_text==''){new_text=$this.children('optgroup').children('option:selected').text();}
selected_text.html(new_text);$this.change(function(){new_text=$this.children('option:selected').text();if(new_text==''){new_text=$this.children('optgroup').children('option:selected').text();}
selected_text.html(new_text);});});};})(jQuery);	
/* 
 * v0.01 password focus, blur plugin for jQuery
 */
(function(a){a.fn.passFocusBlur=function(){return this.each(function(){var b=a(this);if(b.val()==""){b.addClass("empty_password")}b.focus(function(){b.removeClass("empty_password")});b.blur(function(){if(b.val()==""){b.addClass("empty_password")}})})}})(jQuery);

/*!
 * HTML5 Placeholder jQuery Plugin v1.2
 * @link http://github.com/mathiasbynens/Placeholder-jQuery-Plugin
 * @author Mathias Bynens <http://mathiasbynens.be/>
 */
(function(a){a.fn.placeholder=function(){if(this[0]&&'placeholder' in document.createElement('input')){return this}function b(c){if(c.val()===''||c.val()===c.attr('placeholder')){c.addClass('placeholder').val(c.attr('placeholder'))}else{c.removeClass('placeholder')}}a('form:has([placeholder])').submit(function(){a('.placeholder',this).val('')});a(window).unload(function(){a('.placeholder').val('')});return this.each(function(){var c=a(this);if(c.is(':password')||!c.is(':input')){return}b(c);c.focus(function(){if(c.val()===c.attr('placeholder')){c.val('').removeClass('placeholder')}}).blur(function(){b(c)})})}})(jQuery);
/*
 * jQuery outside events - v1.1 - 3/16/2010
 * http://benalman.com/projects/jquery-outside-events-plugin/
 * 
 * Copyright (c) 2010 "Cowboy" Ben Alman
 * Dual licensed under the MIT and GPL licenses.
 * http://benalman.com/about/license/
 */
(function($,c,b){$.map("click dblclick mousemove mousedown mouseup mouseover mouseout change select submit keydown keypress keyup".split(" "),function(d){a(d)});a("focusin","focus"+b);a("focusout","blur"+b);$.addOutsideEvent=a;function a(g,e){e=e||g+b;var d=$(),h=g+"."+e+"-special-event";$.event.special[e]={setup:function(){d=d.add(this);if(d.length===1){$(c).bind(h,f)}},teardown:function(){d=d.not(this);if(d.length===0){$(c).unbind(h)}},add:function(i){var j=i.handler;i.handler=function(l,k){l.target=k;j.apply(this,arguments)}}};function f(i){$(d).each(function(){var j=$(this);if(this!==i.target&&!j.has(i.target).length){j.triggerHandler(e,[i.target])}})}}})(jQuery,document,"outside");
/**
 * 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);
		});
	}
})(jQuery);
/* 
 * v0.05 showmore plugin for jQuery
 */
(function ($) {	
	$.fn.showmore = function ( options ) {
		
		var settings = {
		  'maxHeight' : 200,
		  'btnHeight' : 30,
		  'duration' : 300,
		  'moreLabel' : 'Show More',
		  'lessLabel' : 'Show Less',
		  'iconPosition' : 'after'
		};
				
		return this.each(function () {	
								   
			if ( options ) { 
				$.extend( settings, options );
			}
			
			var $this = $(this);
			var staticHeight = $this.height();
			
			$this.css({
				'height' : 'auto',
				'overflow' : 'hidden'
			});
			
			var origHeight = $this.height();
			if( origHeight > settings.maxHeight ){
				$this.css('height', (settings.maxHeight - settings.btnHeight ) + 'px');
				if( settings.iconPosition == 'after' ){
					var showMore_hmtl = '<span class="showtext">'+ settings.moreLabel +'</span><span class="icon"></span>';
					var showLess_html = '<span class="showtext">'+ settings.lessLabel +'</span><span class="icon"></span>';
				}else if( settings.iconPosition == 'before' ){
					var showMore_hmtl = '<span class="icon"></span><span class="showtext">'+ settings.moreLabel +'</span>';
					var showLess_html = '<span class="icon"></span><span class="showtext">'+ settings.lessLabel +'</span>';
				}
				$this.wrap('<div class="sm_wrapper" />');
					$this.parent()
						.append('<a href="#" class="showmore more clearfix">'+ showMore_hmtl +'</a>')
						.css({
							'position' : 'relative',
							'padding-bottom' : settings.btnHeight +'px'
						});
						
					$this.parent().children('.showmore').toggle(				
					function () {
						$this = $(this);
						$this.html(showLess_html)
						.addClass('less')
						.removeClass('more');
						$this.siblings().stop(true, true).animate({
							height: origHeight		  
						}, settings.duration);
					},
					function () {
						$this = $(this);
						$this.html(showMore_hmtl)
						.removeClass('less')
						.addClass('more');
						$this.siblings().stop(true, true).animate({
							height: (settings.maxHeight - settings.btnHeight )	  
						}, settings.duration);
					}
				);	
				
			}else{
				$this.css({
					'height' : staticHeight + 'px'
				});
			}
			
			
		});//end: return
	};//end: fn		
})(jQuery);

/*!
 * jCarouselLite UI 1.8.2
 */
(function($){$.fn.jCarouselLite=function(o){o=$.extend({btnPrev:null,btnNext:null,btnGo:null,mouseWheel:false,auto:null,speed:200,easing:null,vertical:false,circular:true,visible:3,start:0,scroll:1,beforeStart:null,afterEnd:null},o||{});return this.each(function(){var b=false,animCss=o.vertical?"top":"left",sizeCss=o.vertical?"height":"width";var c=$(this),ul=$("ul",c),tLi=$("li",ul),tl=tLi.size(),v=o.visible;if(o.circular){ul.prepend(tLi.slice(tl-v-1+1).clone()).append(tLi.slice(0,v).clone());o.start+=v}var f=$("li",ul),itemLength=f.size(),curr=o.start;c.css("visibility","visible");f.css({overflow:"hidden",float:o.vertical?"none":"left"});ul.css({margin:"0",padding:"0",position:"relative","list-style-type":"none","z-index":"1"});c.css({overflow:"hidden",position:"relative","z-index":"2",left:"0px"});var g=o.vertical?height(f):width(f);var h=g*itemLength;var j=g*v;f.css({width:f.width(),height:f.height()});ul.css(sizeCss,h+"px").css(animCss,-(curr*g));c.css(sizeCss,j+"px");if(o.btnPrev)$(o.btnPrev).click(function(){return go(curr-o.scroll)});if(o.btnNext)$(o.btnNext).click(function(){return go(curr+o.scroll)});if(o.btnGo)$.each(o.btnGo,function(i,a){$(a).click(function(){return go(o.circular?o.visible+i:i)})});if(o.mouseWheel&&c.mousewheel)c.mousewheel(function(e,d){return d>0?go(curr-o.scroll):go(curr+o.scroll)});if(o.auto)setInterval(function(){go(curr+o.scroll)},o.auto+o.speed);function vis(){return f.slice(curr).slice(0,v)};function go(a){if(!b){if(o.beforeStart)o.beforeStart.call(this,vis());if(o.circular){if(a<=o.start-v-1){ul.css(animCss,-((itemLength-(v*2))*g)+"px");curr=a==o.start-v-1?itemLength-(v*2)-1:itemLength-(v*2)-o.scroll}else if(a>=itemLength-v+1){ul.css(animCss,-((v)*g)+"px");curr=a==itemLength-v+1?v+1:v+o.scroll}else curr=a}else{if(a<0||a>itemLength-v)return;else curr=a}b=true;ul.animate(animCss=="left"?{left:-(curr*g)}:{top:-(curr*g)},o.speed,o.easing,function(){if(o.afterEnd)o.afterEnd.call(this,vis());b=false});if(!o.circular){$(o.btnPrev+","+o.btnNext).removeClass("disabled");$((curr-o.scroll<0&&o.btnPrev)||(curr+o.scroll>itemLength-v&&o.btnNext)||[]).addClass("disabled")}}return false}})};function css(a,b){return parseInt($.css(a[0],b))||0};function width(a){return a[0].offsetWidth+css(a,'marginLeft')+css(a,'marginRight')};function height(a){return a[0].offsetHeight+css(a,'marginTop')+css(a,'marginBottom')}})(jQuery);
/* 
 * mousewheel plugin Copyright (c) 2009 Brandon Aaron (http://brandonaaron.net) Version: 3.0.2
 */
(function(c){var a=["DOMMouseScroll","mousewheel"];c.event.special.mousewheel={setup:function(){if(this.addEventListener){for(var d=a.length;d;){this.addEventListener(a[--d],b,false)}}else{this.onmousewheel=b}},teardown:function(){if(this.removeEventListener){for(var d=a.length;d;){this.removeEventListener(a[--d],b,false)}}else{this.onmousewheel=null}}};c.fn.extend({mousewheel:function(d){return d?this.bind("mousewheel",d):this.trigger("mousewheel")},unmousewheel:function(d){return this.unbind("mousewheel",d)}});function b(f){var d=[].slice.call(arguments,1),g=0,e=true;f=c.event.fix(f||window.event);f.type="mousewheel";if(f.wheelDelta){g=f.wheelDelta/120}if(f.detail){g=-f.detail/3}d.unshift(f,g);return c.event.handle.apply(this,d)}})(jQuery);
/*!
 * jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/
 */
jQuery.easing.jswing=jQuery.easing.swing;jQuery.extend(jQuery.easing,{def:"easeOutQuad",swing:function(e,f,a,h,g){return jQuery.easing[jQuery.easing.def](e,f,a,h,g)},easeInQuad:function(e,f,a,h,g){return h*(f/=g)*f+a},easeOutQuad:function(e,f,a,h,g){return -h*(f/=g)*(f-2)+a},easeInOutQuad:function(e,f,a,h,g){if((f/=g/2)<1){return h/2*f*f+a}return -h/2*((--f)*(f-2)-1)+a},easeInCubic:function(e,f,a,h,g){return h*(f/=g)*f*f+a},easeOutCubic:function(e,f,a,h,g){return h*((f=f/g-1)*f*f+1)+a},easeInOutCubic:function(e,f,a,h,g){if((f/=g/2)<1){return h/2*f*f*f+a}return h/2*((f-=2)*f*f+2)+a},easeInQuart:function(e,f,a,h,g){return h*(f/=g)*f*f*f+a},easeOutQuart:function(e,f,a,h,g){return -h*((f=f/g-1)*f*f*f-1)+a},easeInOutQuart:function(e,f,a,h,g){if((f/=g/2)<1){return h/2*f*f*f*f+a}return -h/2*((f-=2)*f*f*f-2)+a},easeInQuint:function(e,f,a,h,g){return h*(f/=g)*f*f*f*f+a},easeOutQuint:function(e,f,a,h,g){return h*((f=f/g-1)*f*f*f*f+1)+a},easeInOutQuint:function(e,f,a,h,g){if((f/=g/2)<1){return h/2*f*f*f*f*f+a}return h/2*((f-=2)*f*f*f*f+2)+a},easeInSine:function(e,f,a,h,g){return -h*Math.cos(f/g*(Math.PI/2))+h+a},easeOutSine:function(e,f,a,h,g){return h*Math.sin(f/g*(Math.PI/2))+a},easeInOutSine:function(e,f,a,h,g){return -h/2*(Math.cos(Math.PI*f/g)-1)+a},easeInExpo:function(e,f,a,h,g){return(f==0)?a:h*Math.pow(2,10*(f/g-1))+a},easeOutExpo:function(e,f,a,h,g){return(f==g)?a+h:h*(-Math.pow(2,-10*f/g)+1)+a},easeInOutExpo:function(e,f,a,h,g){if(f==0){return a}if(f==g){return a+h}if((f/=g/2)<1){return h/2*Math.pow(2,10*(f-1))+a}return h/2*(-Math.pow(2,-10*--f)+2)+a},easeInCirc:function(e,f,a,h,g){return -h*(Math.sqrt(1-(f/=g)*f)-1)+a},easeOutCirc:function(e,f,a,h,g){return h*Math.sqrt(1-(f=f/g-1)*f)+a},easeInOutCirc:function(e,f,a,h,g){if((f/=g/2)<1){return -h/2*(Math.sqrt(1-f*f)-1)+a}return h/2*(Math.sqrt(1-(f-=2)*f)+1)+a},easeInElastic:function(f,h,e,l,k){var i=1.70158;var j=0;var g=l;if(h==0){return e}if((h/=k)==1){return e+l}if(!j){j=k*0.3}if(g<Math.abs(l)){g=l;var i=j/4}else{var i=j/(2*Math.PI)*Math.asin(l/g)}return -(g*Math.pow(2,10*(h-=1))*Math.sin((h*k-i)*(2*Math.PI)/j))+e},easeOutElastic:function(f,h,e,l,k){var i=1.70158;var j=0;var g=l;if(h==0){return e}if((h/=k)==1){return e+l}if(!j){j=k*0.3}if(g<Math.abs(l)){g=l;var i=j/4}else{var i=j/(2*Math.PI)*Math.asin(l/g)}return g*Math.pow(2,-10*h)*Math.sin((h*k-i)*(2*Math.PI)/j)+l+e},easeInOutElastic:function(f,h,e,l,k){var i=1.70158;var j=0;var g=l;if(h==0){return e}if((h/=k/2)==2){return e+l}if(!j){j=k*(0.3*1.5)}if(g<Math.abs(l)){g=l;var i=j/4}else{var i=j/(2*Math.PI)*Math.asin(l/g)}if(h<1){return -0.5*(g*Math.pow(2,10*(h-=1))*Math.sin((h*k-i)*(2*Math.PI)/j))+e}return g*Math.pow(2,-10*(h-=1))*Math.sin((h*k-i)*(2*Math.PI)/j)*0.5+l+e},easeInBack:function(e,f,a,i,h,g){if(g==undefined){g=1.70158}return i*(f/=h)*f*((g+1)*f-g)+a},easeOutBack:function(e,f,a,i,h,g){if(g==undefined){g=1.70158}return i*((f=f/h-1)*f*((g+1)*f+g)+1)+a},easeInOutBack:function(e,f,a,i,h,g){if(g==undefined){g=1.70158}if((f/=h/2)<1){return i/2*(f*f*(((g*=(1.525))+1)*f-g))+a}return i/2*((f-=2)*f*(((g*=(1.525))+1)*f+g)+2)+a},easeInBounce:function(e,f,a,h,g){return h-jQuery.easing.easeOutBounce(e,g-f,0,h,g)+a},easeOutBounce:function(e,f,a,h,g){if((f/=g)<(1/2.75)){return h*(7.5625*f*f)+a}else{if(f<(2/2.75)){return h*(7.5625*(f-=(1.5/2.75))*f+0.75)+a}else{if(f<(2.5/2.75)){return h*(7.5625*(f-=(2.25/2.75))*f+0.9375)+a}else{return h*(7.5625*(f-=(2.625/2.75))*f+0.984375)+a}}}},easeInOutBounce:function(e,f,a,h,g){if(f<g/2){return jQuery.easing.easeInBounce(e,f*2,0,h,g)*0.5+a}return jQuery.easing.easeOutBounce(e,f*2-g,0,h,g)*0.5+h*0.5+a}});
/**
 * jquery.scrollFollow.js
 * Copyright (c) 2008 Net Perspective (http://kitchen.net-perspective.com/)
 * Licensed under the MIT License (http://www.opensource.org/licenses/mit-license.php)
 * @author R.A. Ray
 * @projectDescription	jQuery plugin for allowing an element to animate down as the user scrolls the page.
 * @version 0.4.0
 */
(function($){$.scrollFollow=function(box,options)
{box=$(box);var position=box.css('position');function ani()
{box.queue([]);var viewportHeight=parseInt($(window).height());var pageScroll=parseInt($(document).scrollTop());var parentTop=parseInt(box.cont.offset().top);var parentHeight=parseInt(box.cont.attr('offsetHeight'));var boxHeight=parseInt(box.attr('offsetHeight')+(parseInt(box.css('marginTop'))||0)+(parseInt(box.css('marginBottom'))||0));var aniTop;if(isActive)
{if(options.relativeTo=='top')
{if(box.initialOffsetTop>=(pageScroll+options.offset))
{aniTop=box.initialTop;}
else
{aniTop=Math.min((Math.max((-parentTop),(pageScroll-box.initialOffsetTop+box.initialTop))+options.offset),(parentHeight-boxHeight-box.paddingAdjustment));}}
else if(options.relativeTo=='bottom')
{if((box.initialOffsetTop+boxHeight)>=(pageScroll+options.offset+viewportHeight))
{aniTop=box.initialTop;}
else
{aniTop=Math.min((pageScroll+viewportHeight-boxHeight-options.offset),(parentHeight-boxHeight));}}
if((new Date().getTime()-box.lastScroll)>=(options.delay-20))
{box.animate({top:aniTop},options.speed,options.easing);}}};var isActive=true;if($.cookie!=undefined)
{if($.cookie('scrollFollowSetting'+box.attr('id'))=='false')
{var isActive=false;$('#'+options.killSwitch).text(options.offText).toggle(function()
{isActive=true;$(this).text(options.onText);$.cookie('scrollFollowSetting'+box.attr('id'),true,{expires:365,path:'/'});ani();},function()
{isActive=false;$(this).text(options.offText);box.animate({top:box.initialTop},options.speed,options.easing);$.cookie('scrollFollowSetting'+box.attr('id'),false,{expires:365,path:'/'});});}
else
{$('#'+options.killSwitch).text(options.onText).toggle(function()
{isActive=false;$(this).text(options.offText);box.animate({top:box.initialTop},0);$.cookie('scrollFollowSetting'+box.attr('id'),false,{expires:365,path:'/'});},function()
{isActive=true;$(this).text(options.onText);$.cookie('scrollFollowSetting'+box.attr('id'),true,{expires:365,path:'/'});ani();});}}
if(options.container=='')
{box.cont=box.parent();}
else
{box.cont=$('#'+options.container);}
box.initialOffsetTop=parseInt(box.offset().top);box.initialTop=parseInt(box.css('top'))||0;if(box.css('position')=='relative')
{box.paddingAdjustment=parseInt(box.cont.css('paddingTop'))+parseInt(box.cont.css('paddingBottom'));}
else
{box.paddingAdjustment=0;}
$(window).scroll(function()
{$.fn.scrollFollow.interval=setTimeout(function(){ani();},options.delay);box.lastScroll=new Date().getTime();});$(window).resize(function()
{$.fn.scrollFollow.interval=setTimeout(function(){ani();},options.delay);box.lastScroll=new Date().getTime();});box.lastScroll=0;ani();};$.fn.scrollFollow=function(options)
{options=options||{};options.relativeTo=options.relativeTo||'top';options.speed=options.speed||500;options.offset=options.offset||0;options.easing=options.easing||'swing';options.container=options.container||this.parent().attr('id');options.killSwitch=options.killSwitch||'killSwitch';options.onText=options.onText||'Turn Slide Off';options.offText=options.offText||'Turn Slide On';options.delay=options.delay||0;this.each(function()
{new $.scrollFollow(this,options);});return this;};})(jQuery);
