/*!
 * Color animation jQuery-plugin
 * http://www.bitstorm.org/jquery/color-animation/
 * Based on code copyright 2007 John Resig
 * Copyright 2010 Edwin Martin <edwin@bitstorm.org>
 * Released under the MIT and GPL licenses.
 */

(function(d){function h(a,b,c){return"#"+g(a[0]+c*(b[0]-a[0]))+g(a[1]+c*(b[1]-a[1]))+g(a[2]+c*(b[2]-a[2]))}function g(a){a=parseInt(a).toString(16);return a.length==1?"0"+a:a}function e(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)];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];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])];return c}var i=["color","backgroundColor","borderBottomColor","borderLeftColor","borderRightColor","borderTopColor","outlineColor"];d.each(i,function(a,b){d.fx.step[b]=function(c){if(!c.init){c.a=e(d(c.elem).css(b));c.end=e(c.end);c.init=true}c.elem.style[b]=h(c.a,c.end,c.pos)}});d.fx.step.borderColor=function(a){if(!a.init)a.end=e(a.end);var b=i.slice(2,6);d.each(b,function(c,f){a.init||(a[f]={a:e(d(a.elem).css(f))});a.elem.style[f]=h(a[f].a,a.end,a.pos)});
a.init=true}})(jQuery);


/*!
 * Shadow animation jQuery-plugin
 * http://www.bitstorm.org/jquery/shadow-animation/
 * Copyright 2010 Edwin Martin <edwin@bitstorm.org>
 * Contributor: Mark Carver
 * Released under the MIT and GPL licenses.
 */
jQuery(function(e){function i(){var a=e("script:first"),b=a.css("color"),c=false;if(/^rgba/.test(b))c=true;else try{c=b!=a.css("color","rgba(0, 0, 0, 0.5)").css("color");a.css("color",b)}catch(d){}return c}function j(a,b,c){var d=[];a.c&&d.push("inset");typeof b.left!="undefined"&&d.push(parseInt(a.left+c*(b.left-a.left))+"px "+parseInt(a.top+c*(b.top-a.top))+"px");typeof b.blur!="undefined"&&d.push(parseInt(a.blur+c*(b.blur-a.blur))+"px");typeof b.a!="undefined"&&d.push(parseInt(a.a+c*(b.a-a.a))+
"px");if(typeof b.color!="undefined"){var g="rgb"+(e.support.d?"a":"")+"("+parseInt(a.color[0]+c*(b.color[0]-a.color[0]))+","+parseInt(a.color[1]+c*(b.color[1]-a.color[1]))+","+parseInt(a.color[2]+c*(b.color[2]-a.color[2]));if(e.support.d)g+=","+parseFloat(a.color[3]+c*(b.color[3]-a.color[3]));g+=")";d.push(g)}return d.join(" ")}function h(a){var b,c,d={};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*([0-1]{1}?\.?[0-9]*)\s*\)/.exec(a))c=[parseInt(b[1]),parseInt(b[2]),parseInt(b[3]),parseFloat(b[4])];if(b=/([0-9]+)(?:px)?\s+([0-9]+)(?:px)?(?:\s+([0-9]+)(?:px)?)?(?:\s+([0-9]+)(?:px)?)?/.exec(a))d={left:parseInt(b[1]),top:parseInt(b[2]),
blur:b[3]?parseInt(b[3]):undefined,a:b[4]?parseInt(b[4]):undefined};d.c=/inset/.test(a);d.color=c;return d}e.extend(e,{support:{rgba:i()}});var f;e.each(["boxShadow","MozBoxShadow","WebkitBoxShadow"],function(a,b){a=e("html").css(b);if(typeof a=="string"&&a!=""){f=b;return false}});if(f)e.fx.step.shadow=function(a){if(!a.init){a.b=h(e(a.elem).css(f));a.end=e.extend({},a.b,h(a.options.curAnim.shadow));a.init=true}a.elem.style[f]=j(a.b,a.end,a.pos)}});

/*
 * jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/
 *
 * Uses the built in easing capabilities added In jQuery 1.1
 * to offer multiple easing options
 *
 * TERMS OF USE - jQuery Easing
 * 
 * Open source under the BSD License. 
 * 
 * Copyright Â© 2008 George McGinley Smith
 * All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without modification, 
 * are permitted provided that the following conditions are met:
 * 
 * Redistributions of source code must retain the above copyright notice, this list of 
 * conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright notice, this list 
 * of conditions and the following disclaimer in the documentation and/or other materials 
 * provided with the distribution.
 * 
 * Neither the name of the author nor the names of contributors may be used to endorse 
 * or promote products derived from this software without specific prior written permission.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 *  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
 *  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 *  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 
 * OF THE POSSIBILITY OF SUCH DAMAGE. 
 *
*/

// t: current time, b: begInnIng value, c: change In value, d: duration
jQuery.easing['jswing'] = jQuery.easing['swing'];

jQuery.extend( jQuery.easing,
{
	def: 'easeOutQuad',
	swing: function (x, t, b, c, d) {
		//alert(jQuery.easing.default);
		return jQuery.easing[jQuery.easing.def](x, t, b, c, d);
	},
	easeInQuad: function (x, t, b, c, d) {
		return c*(t/=d)*t + b;
	},
	easeOutQuad: function (x, t, b, c, d) {
		return -c *(t/=d)*(t-2) + b;
	},
	easeInOutQuad: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t + b;
		return -c/2 * ((--t)*(t-2) - 1) + b;
	},
	easeInCubic: function (x, t, b, c, d) {
		return c*(t/=d)*t*t + b;
	},
	easeOutCubic: function (x, t, b, c, d) {
		return c*((t=t/d-1)*t*t + 1) + b;
	},
	easeInOutCubic: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t*t + b;
		return c/2*((t-=2)*t*t + 2) + b;
	},
	easeInQuart: function (x, t, b, c, d) {
		return c*(t/=d)*t*t*t + b;
	},
	easeOutQuart: function (x, t, b, c, d) {
		return -c * ((t=t/d-1)*t*t*t - 1) + b;
	},
	easeInOutQuart: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t*t*t + b;
		return -c/2 * ((t-=2)*t*t*t - 2) + b;
	},
	easeInQuint: function (x, t, b, c, d) {
		return c*(t/=d)*t*t*t*t + b;
	},
	easeOutQuint: function (x, t, b, c, d) {
		return c*((t=t/d-1)*t*t*t*t + 1) + b;
	},
	easeInOutQuint: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b;
		return c/2*((t-=2)*t*t*t*t + 2) + b;
	},
	easeInSine: function (x, t, b, c, d) {
		return -c * Math.cos(t/d * (Math.PI/2)) + c + b;
	},
	easeOutSine: function (x, t, b, c, d) {
		return c * Math.sin(t/d * (Math.PI/2)) + b;
	},
	easeInOutSine: function (x, t, b, c, d) {
		return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b;
	},
	easeInExpo: function (x, t, b, c, d) {
		return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b;
	},
	easeOutExpo: function (x, t, b, c, d) {
		return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
	},
	easeInOutExpo: function (x, t, b, c, d) {
		if (t==0) return b;
		if (t==d) return b+c;
		if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
		return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
	},
	easeInCirc: function (x, t, b, c, d) {
		return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b;
	},
	easeOutCirc: function (x, t, b, c, d) {
		return c * Math.sqrt(1 - (t=t/d-1)*t) + b;
	},
	easeInOutCirc: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b;
		return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b;
	},
	easeInElastic: function (x, t, b, c, d) {
		var s=1.70158;var p=0;var a=c;
		if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
		if (a < Math.abs(c)) { a=c; var s=p/4; }
		else var s = p/(2*Math.PI) * Math.asin (c/a);
		return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
	},
	easeOutElastic: function (x, t, b, c, d) {
		var s=1.70158;var p=0;var a=c;
		if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
		if (a < Math.abs(c)) { a=c; var s=p/4; }
		else var s = p/(2*Math.PI) * Math.asin (c/a);
		return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
	},
	easeInOutElastic: function (x, t, b, c, d) {
		var s=1.70158;var p=0;var a=c;
		if (t==0) return b;  if ((t/=d/2)==2) return b+c;  if (!p) p=d*(.3*1.5);
		if (a < Math.abs(c)) { a=c; var s=p/4; }
		else var s = p/(2*Math.PI) * Math.asin (c/a);
		if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
		return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;
	},
	easeInBack: function (x, t, b, c, d, s) {
		if (s == undefined) s = 1.70158;
		return c*(t/=d)*t*((s+1)*t - s) + b;
	},
	easeOutBack: function (x, t, b, c, d, s) {
		if (s == undefined) s = 1.70158;
		return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
	},
	easeInOutBack: function (x, t, b, c, d, s) {
		if (s == undefined) s = 1.70158; 
		if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
		return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
	},
	easeInBounce: function (x, t, b, c, d) {
		return c - jQuery.easing.easeOutBounce (x, d-t, 0, c, d) + b;
	},
	easeOutBounce: function (x, t, b, c, d) {
		if ((t/=d) < (1/2.75)) {
			return c*(7.5625*t*t) + b;
		} else if (t < (2/2.75)) {
			return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
		} else if (t < (2.5/2.75)) {
			return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
		} else {
			return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
		}
	},
	easeInOutBounce: function (x, t, b, c, d) {
		if (t < d/2) return jQuery.easing.easeInBounce (x, t*2, 0, c, d) * .5 + b;
		return jQuery.easing.easeOutBounce (x, t*2-d, 0, c, d) * .5 + c*.5 + b;
	}
});

/*
 *
 * TERMS OF USE - EASING EQUATIONS
 * 
 * Open source under the BSD License. 
 * 
 * Copyright Â© 2001 Robert Penner
 * All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without modification, 
 * are permitted provided that the following conditions are met:
 * 
 * Redistributions of source code must retain the above copyright notice, this list of 
 * conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright notice, this list 
 * of conditions and the following disclaimer in the documentation and/or other materials 
 * provided with the distribution.
 * 
 * Neither the name of the author nor the names of contributors may be used to endorse 
 * or promote products derived from this software without specific prior written permission.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 *  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
 *  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 *  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 
 * OF THE POSSIBILITY OF SUCH DAMAGE. 
 *
 */

/*

Include: JQuery Timers
More info: http://jquery.offput.ca/timers/

*/

jQuery.fn.extend({
	everyTime: function(interval, label, fn, times, belay) {
		return this.each(function() {
			jQuery.timer.add(this, interval, label, fn, times, belay);
		});
	},
	oneTime: function(interval, label, fn) {
		return this.each(function() {
			jQuery.timer.add(this, interval, label, fn, 1);
		});
	},
	stopTime: function(label, fn) {
		return this.each(function() {
			jQuery.timer.remove(this, label, fn);
		});
	}
});

jQuery.extend({
	timer: {
		guid: 1,
		global: {},
		regex: /^([0-9]+)\s*(.*s)?$/,
		powers: {
			// Yeah this is major overkill...
			'ms': 1,
			'cs': 10,
			'ds': 100,
			's': 1000,
			'das': 10000,
			'hs': 100000,
			'ks': 1000000
		},
		timeParse: function(value) {
			if (value == undefined || value == null)
				return null;
			var result = this.regex.exec(jQuery.trim(value.toString()));
			if (result[2]) {
				var num = parseInt(result[1], 10);
				var mult = this.powers[result[2]] || 1;
				return num * mult;
			} else {
				return value;
			}
		},
		add: function(element, interval, label, fn, times, belay) {
			var counter = 0;
			
			if (jQuery.isFunction(label)) {
				if (!times) 
					times = fn;
				fn = label;
				label = interval;
			}
			
			interval = jQuery.timer.timeParse(interval);

			if (typeof interval != 'number' || isNaN(interval) || interval <= 0)
				return;

			if (times && times.constructor != Number) {
				belay = !!times;
				times = 0;
			}
			
			times = times || 0;
			belay = belay || false;
			
			if (!element.$timers) 
				element.$timers = {};
			
			if (!element.$timers[label])
				element.$timers[label] = {};
			
			fn.$timerID = fn.$timerID || this.guid++;
			
			var handler = function() {
				if (belay && this.inProgress) 
					return;
				this.inProgress = true;
				if ((++counter > times && times !== 0) || fn.call(element, counter) === false)
					jQuery.timer.remove(element, label, fn);
				this.inProgress = false;
			};
			
			handler.$timerID = fn.$timerID;
			
			if (!element.$timers[label][fn.$timerID]) 
				element.$timers[label][fn.$timerID] = window.setInterval(handler,interval);
			
			if ( !this.global[label] )
				this.global[label] = [];
			this.global[label].push( element );
			
		},
		remove: function(element, label, fn) {
			var timers = element.$timers, ret;
			
			if ( timers ) {
				
				if (!label) {
					for ( label in timers )
						this.remove(element, label, fn);
				} else if ( timers[label] ) {
					if ( fn ) {
						if ( fn.$timerID ) {
							window.clearInterval(timers[label][fn.$timerID]);
							delete timers[label][fn.$timerID];
						}
					} else {
						for ( var fn in timers[label] ) {
							window.clearInterval(timers[label][fn]);
							delete timers[label][fn];
						}
					}
					
					for ( ret in timers[label] ) break;
					if ( !ret ) {
						ret = null;
						delete timers[label];
					}
				}
				
				for ( ret in timers ) break;
				if ( !ret ) 
					element.$timers = null;
			}
		}
	}
});

if (jQuery.browser.msie)
	jQuery(window).one("unload", function() {
		var global = jQuery.timer.global;
		for ( var label in global ) {
			var els = global[label], i = els.length;
			while ( --i )
				jQuery.timer.remove(els[i], label);
		}
	});


/*

DicksCotton.com JS
http://dickscottons.com

*/

jQuery(function($){

  $(document).ready(function(){ 
  
    $('.colors li a').tipsy({gravity: 's'});
    
    $('#block-related-slider').jcarousel({
      	wrap: 'circular'
      });
    

    var $home_bnr = $('.homepage_banner');
    
    if ($home_bnr) {
    
      $('.home_product', $home_bnr).each(function(index) {
        
        var $this = $(this);
        
        $this.parent().css({
          'position' : 'relative'
        });
        
        $this.css({
          'position': 'absolute',
          'width': $this.outerWidth() + 'px',
          'height': $this.outerHeight() + 'px'
        });
        
        $this.bind('mouseenter',function(){
          var $me = $(this);
          var cWidth = $me.outerWidth(),
              cHeight = $me.outerHeight(),
              fWidth = 216,
              fHeight = 216;
              
          $me.stop();
          $me.find('.product_image').stop();
          $me.css({
              'top' : '-2px',
              'left' : '-2px',
              'border' : '2px solid #ffffff',
              'z-index' : '75'
            })
            
          $me.addClass('isZoomed');
    
          $me.animate({
              width: fWidth,
              height: fHeight,
              left: '-10px',
              top: '-10px',
              borderColor: '#77a4cb',
              shadow: '0 0 3px'
            }, 300, 'easeOutCubic');
          
        });
        
        $this.bind('mouseleave', function() {
          var $me = $(this);
          var fWidth = $me.parent().outerWidth(),
              fHeight = $me.parent().outerHeight();
          
          $me.stop();
          $me.find('.product_image').stop();
          $me.css('z-index', '65');
          $me.animate({
              width: fWidth,
              height: fHeight,
              top: -2,
              left: -2,
              borderColor: '#ffffff',
              shadow: '0 0 0'
            }, 300, 'easeOutCubic', function(){
                $me.css({
                    'top' : '0px',
                    'left' : '0px',
                    'z-index' : '',
                    'border' : ''
                  });
                $me.removeClass('isZoomed');
              });
    
        
        });
        
      });
    }
  
/*
    var $cartLink = $('.top-link-cart'),
          $cartModal = $('#topCart');
    
      $cartLink.bind('click', function(e) {
        e.preventDefault();
        
        if ($cartModal.data('open') == true) {
          $cartModal.stopTime('hide');
          $cartModal.hide();
          $cartLink.removeClass('cartOpen');
          $cartModal.data('open', false);
        } else {
          $cartLink.addClass('cartOpen');
          $cartModal.css({
            'top': ($cartLink.position().top + $cartLink.outerHeight()) + 'px',
            'left': ($cartLink.position().left + $cartLink.outerWidth() - $cartModal.outerWidth()) + 'px'
          });
          $cartModal.show();
          $cartModal.data('open', true);
        }
        
      });
      
      $cartLink.bind('mouseenter', function() {
        if ($cartModal.data('open') == true) {
          $cartModal.stopTime('hide');
        }
      });
      
      $cartLink.bind('mouseleave', function() {
        if ($cartModal.data('open') == true) {
          $cartModal.oneTime(1000,'hide', function() {
            $cartModal.hide();
            $cartLink.removeClass('cartOpen');
            $cartModal.data('open', false);
          });
        }
      });
      
      $cartModal.bind('mouseenter', function() {
        if ($cartModal.data('open') == true) {
          $cartModal.stopTime('hide');
        }
      });
      
      $cartModal.bind('mouseleave', function() {
        if ($cartModal.data('open') == true) {
          $cartModal.oneTime(1000,'hide', function() {
            $cartModal.hide();
            $cartLink.removeClass('cartOpen');
            $cartModal.data('open', false);
          });
        }
      });
      */
      
      var $dropdown_btn = $('.dropdown_button');
      var $dropdown = $('.dropdown', $dropdown_btn);
      var border_width = 2;   
      
      $dropdown_btn.each(function(index){
        var pos = $(this).position();
        
        
        $(this).css({
          'top': pos.top + 'px',
          'left': pos.left + 'px'
        });
      });
      
      $dropdown_btn.each(function(index){
        var pos = $(this).position();
        
        $(this).css({
          'position': 'absolute'
        });
      });

      $dropdown.each(function(index){
        var pos = $(this).position();
        
        $(this).css({
          'top': ($dropdown_btn.outerHeight()) + 'px',
        }).hide();
        
        if ( $(this).hasClass('align-right') ) {
          $(this).css({
            'left': $(this).parent('.dropdown_button').outerWidth() + ($(this).outerWidth() * -1) + 2 + 'px',
          });
        }
      });

      
      $('.dropdown_button').bind('mouseenter', function() {
        var $dropdown = $('.dropdown', $(this));
        var $btn = $(this);
        
          
        
        $('.dropdown_button', $(this).parent()).each(function(index){
          var $which = $(this),
              $which_menu = $('.dropdown', $which);
          
          if($which.data('open') == true){
            $which.css({
               'top': $(this).position().top + border_width + 'px',
               'left': $(this).position().left + border_width + 'px'
            });
          }
          $which_menu.hide();
          $which.removeClass('dropOpen');
          $which.data('open', false);
          $which.stopTime('hide');
          
        });
        
        
        $btn.css({
           'top': $btn.position().top - border_width + 'px',
           'left': $btn.position().left - border_width + 'px'
        });
        
        $(this).addClass('dropOpen');
        $(this).parent().data('open', $(this));
        $dropdown.show();
        $(this).stopTime('hide');
        $btn.data('open',true);
      });
      
      $('.dropdown_button').bind('mouseleave', function() {
        var $dropdown = $('.dropdown', $(this));
        var $btn = $(this);

        
        $btn.oneTime(500, 'hide', function() {
          $(this).css({
             'top': $(this).position().top + border_width + 'px',
             'left': $(this).position().left + border_width + 'px'
          });
          $dropdown.hide();
          $btn.removeClass('dropOpen');
          $btn.data('open',false);
          $(this).parent().data('open', false);
        });
      });
      
  });


});
