// Swap value onFocus or onblur of search boxes
(function($){
    $.fn.fieldBlurSwitch = (function(){
        $.log("handling blurswitch")
        $(this).each(function(index, item){
            $this = $(item)
            $.log( "setting up blurswitch for " + $this )
            $this.data("orginal-color", $this.css("color") )
            $this.focus(function(){
                $self = $(this)
                $.log($self, "focused")
                    if( $self.val() == $self.attr("placeholder") ){
                        $self.val("")
                    }
                })

            $this.blur(function(){
                $self = $(this)
                $.log($self, "blur")
                    if( $self.val() == "" ){
                        originalColour = $this.data("orginal-color") || $this.css("color") || "#333333";
                        $self.css("color", "white")
                             .val( $self.attr("placeholder") )
                             .animate({ color: originalColour }, 300, 'easeInExpo')
                             .animate({ color: "#0E9ED4" }, 100, 'easeInExpo')
                             .animate({ color: originalColour }, 200, 'linear');
                    }
                })
            $this.blur();
        });
    });
})(jQuery);


