/* LavaLamp Menu */
(function($) {
$.fn.lavaLamp = function(o) {
    o = $.extend({ fx: "linear", speed: 500, click: function(){} }, o || {});

    return this.each(function() {
        var me = $(this), noop = function(){},
            $back = $('<li class="back"><div class="left"></div></li>').appendTo(me),
            $li = $("li", this), curr = $("li.sel", this)[0] || $($li[0]).addClass("sel")[0];

        $li.not(".back").hover(function() {
            move(this);
        }, noop);

        $(this).hover(noop, function() {
            move(curr);
        });

        $li.click(function(e) {
            setCurr(this);
            return o.click.apply(this, [e, this]);
        });

        setCurr(curr);

        function setCurr(el) {
            $back.css({ "left": el.offsetLeft+"px", "width": el.offsetWidth+"px" });
            curr = el;
        };

        function move(el) {
            $back.each(function() {
                $(this).dequeue(); }
            ).animate({
                width: el.offsetWidth,
                left: el.offsetLeft
            }, o.speed, o.fx);
        };

    });
};
})(jQuery);

/* Sliding Labels */
$(function(){
$('#searchWrap .slider label').each(function(){
	var labelColor = '#665';
	var restingPosition = '5px';

	// style the label with JS for progressive enhancement
	$(this).css({
		'color' : labelColor,
		 	'position' : 'absolute',
	 		'top' : '6px',
			'font-weight' : '700',
			'left' : restingPosition,
			'display' : 'inline',
    	               'z-index' : '99'
	});

	// grab the input value
	if ($(this).next('input').length)
	var inputval = $(this).next('input').val();
	else
	var inputval = $(this).next('textarea').val();

	// grab the label width, then add 5 pixels to it
	var labelwidth = $(this).width();
	var labelmove = labelwidth + 5;

	//onload, check if a field is filled out, if so, move the label out of the way
	if(inputval !== ''){
		$(this).stop().animate({ 'left':'-'+labelmove }, 1);
	}    	

	// if the input is empty on focus move the label to the left
	// if it's empty on blur, move it back
	$('input,textarea').focus(function(){
		var label = $(this).prev('label');
		var width = $(label).width();
		var adjust = width + 5;
		var value = $(this).val();

		if(value == ''){
			label.stop().animate({ 'left':'-'+adjust }, 'fast');
			label.css({ 'color':'#FFF' });
		} else {
			label.css({ 'left':'-'+adjust });
			label.css({ 'color':labelColor });
		}
	}).blur(function(){
		var label = $(this).prev('label');
		var value = $(this).val();
		if(value == ''){
			label.stop().animate({ 'left':restingPosition }, 'fast');
			label.css({ 'color':labelColor });
		}
	});
})
});

/*
 * jQuery Easing v1.1 - http://gsgd.co.uk/sandbox/jquery.easing.php
 *
 * Uses the built in easing capabilities added in jQuery 1.1
 * to offer multiple easing options
 *
 * Copyright (c) 2007 George Smith
 * Licensed under the MIT License:
 *   http://www.opensource.org/licenses/mit-license.php
 */
jQuery.extend(jQuery.easing,{easeIn:function(x,t,b,c,d){return jQuery.easing.easeInQuad(x,t,b,c,d)},easeOut:function(x,t,b,c,d){return jQuery.easing.easeOutQuad(x,t,b,c,d)},easeInOut:function(x,t,b,c,d){return jQuery.easing.easeInOutQuad(x,t,b,c,d)},expoin:function(x,t,b,c,d){return jQuery.easing.easeInExpo(x,t,b,c,d)},expoout:function(x,t,b,c,d){return jQuery.easing.easeOutExpo(x,t,b,c,d)},expoinout:function(x,t,b,c,d){return jQuery.easing.easeInOutExpo(x,t,b,c,d)},bouncein:function(x,t,b,c,d){return jQuery.easing.easeInBounce(x,t,b,c,d)},bounceout:function(x,t,b,c,d){return jQuery.easing.easeOutBounce(x,t,b,c,d)},bounceinout:function(x,t,b,c,d){return jQuery.easing.easeInOutBounce(x,t,b,c,d)},elasin:function(x,t,b,c,d){return jQuery.easing.easeInElastic(x,t,b,c,d)},elasout:function(x,t,b,c,d){return jQuery.easing.easeOutElastic(x,t,b,c,d)},elasinout:function(x,t,b,c,d){return jQuery.easing.easeInOutElastic(x,t,b,c,d)},backin:function(x,t,b,c,d){return jQuery.easing.easeInBack(x,t,b,c,d)},backout:function(x,t,b,c,d){return jQuery.easing.easeOutBack(x,t,b,c,d)},backinout:function(x,t,b,c,d){return jQuery.easing.easeInOutBack(x,t,b,c,d)}});
