/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

(function($){
    $.labelInput = function(field){
        $(field).each(function() {
            var $this = $(this);

            if($this.attr('type') == 'password'){
                var LabelPassword = $('.pswd_'+$this.attr('id'));
                LabelPassword.click(function(){
                    $this.focus();
                });
                if(LabelPassword.text() == '') {
                    LabelPassword.html($this.attr('rel')).show();
                }
                $this.focus(function() {
                    if(LabelPassword.text() == $this.attr('rel')) {
                        LabelPassword.css('color','#aaa');
                    }
                });
                $this.blur(function() {
                    LabelPassword.css('color','#333');
                    if(LabelPassword.text() == '' && $this.val() == '') {
                        LabelPassword.html($this.attr('rel')).show();
                    }
                });
                $this.keydown(function(){
                    LabelPassword.css('color','#333');
                    if(LabelPassword.text() == $this.attr('rel')) {
                        LabelPassword.html('').hide();
                    }
                });

            } else {
                if($this.val() == '') {
                    $this.val($this.attr('rel'));
                }
                $this.focus(function() {
                    if($this.val() == $this.attr('rel')) {
                        $this.css('color','#aaa');
                    }
                });
                $this.blur(function() {
                    $this.css('color','#333');
                    if($this.val() == '') {
                        $this.val($this.attr('rel'));
                    }
                });
                $this.keydown(function(){
                    $this.css('color','#333');
                    if($this.val() == $this.attr('rel')) {
                        $this.val('');
                    }
                });

                $this.parent('form').submit(function(){
                    if($this.val() == $this.attr('rel')){
                        $this.val('');
                    }
                });
            }
        });
    };
})(jQuery);

(function($){
    $.labelText = function(field){
        $(field).each(function() {
            var $this = $(this);
            if($this.val() == '') {
                $this.val($this.attr('rel'));
            }
            $this.focus(function() {
                if($this.val() == $this.attr('rel')) {
                    $this.css('color','#aaa');
                }
            });
            $this.blur(function() {
                $this.css('color','#333');
                if($this.val() == '') {
                    $this.val($this.attr('rel'));
                }
            });
            $this.keydown(function(){
                $this.css('color','#333');
                if($this.val() == $this.attr('rel')) {
                    $this.val('');
                }
            });

            $this.parent('form').submit(function(){
                if($this.val() == $this.attr('rel')){
                    $this.val('');
                }
            });
        });
    };
})(jQuery);
