/*
 * jQuery Label In plug-in version 1.0
 * Last Update : June 09, 2008
 * New features:
 *
 * Bug Fixed:
 *
 * Copyright (c) 2007 E-wave web design
 *   http://www.ewave.com.au/
 *
 * Licensed under the GPL license:
 *   http://www.gnu.org/licenses/gpl.html
 *
 * @requires jQuery v 1.2.1 or later
 * @name    labelIn
 * @usage        $('#selector').labelIn();
 * 
 * HTML
 * <form id="form1">
 * <input id="input1" type="text" name="Label"></input>
 * <input type="submit" value="Submit>
 * </form>
 *
 * Description
 * Display info to specify content of input tag, on focus info is removed.
 * Aslo Apply a class to the input tag
 *
 * 
 * @param li_class 
 *     this class is added to input tag when empty    
 * 
 * @param attribute 
 *     display the content of this attribute when tag is empaty    
 * 
 */
 jQuery.fn.labelIn = function(settings) {

    var iSelector = this;

    settings = jQuery.extend({
        version        : '1.0',
        li_class    : 'labelIn',
        attribute    : 'name'
}, settings);

    init();
    
    function init() {
        if($.trim($(iSelector).val()) == "") {
            $(iSelector).val($(iSelector).attr(settings['attribute']));
            $(iSelector).addClass(settings["li_class"]);
        }
    }

    return iSelector.focus(function() {
            $(iSelector).removeClass(settings["li_class"]);
            if($(iSelector).val() == $(iSelector).attr(settings['attribute'])) {
                    $(iSelector).val("");
            }
    }).blur(function() {
            if($.trim($(iSelector).val()) == "") {
                    $(iSelector).val($(iSelector).attr(settings['attribute']));
                    $(iSelector).addClass(settings["li_class"]);
        } else
            $(iSelector).removeClass(settings["li_class"]);
    });
    
    
};
  


