/*
 * jQuery WG Input value default plug-in 1.0
 * Copyright (c) 2008 Roberto Lee
 */
 /*
 * jQuery plug-in Search Box  1.0
 *
 * Copyright (c) 2008 Roberto Lee (webgenerator.com)
 * Dual licensed under the MIT (MIT-LICENSE.txt)
 * and GPL (GPL-LICENSE.txt) licenses.
 *
 * Date: 2009-1-29
 * Rev: 1
 */


jQuery.fn.WG_InputDefault = function(parameters) {// 'this' is a jQuery object at this point - with all the jQuery functions
	defaults = {
		starttext: "zoek",
		if_empty: function() {}
	};
  	return this.each(function() {// return so we don't break the chain now we are inside of a jQuery function, the DOM element is the context so 'this' has changed to become a DOM element.
		jQuery.extend(defaults, parameters);
		var inpfield = jQuery(this);
		var defaultvalue = defaults.starttext;

		inpfield.bind("focus click blur",function(){
			if (inpfield.val() == defaultvalue)
			{
				inpfield.val("");
			}
		});

		inpfield.blur(function(){
			SetDefaultValue();
		});

		function SetDefaultValue()
		{
			if (inpfield.val() == "")
			{
				inpfield.val(defaultvalue);
			}
		}

		SetDefaultValue()
	});
};





/*
	USAGE SAMPLE
    $(document).ready(function() {
			jQuery("input[name="ss"]").WG_InputDefault({
					starttext:  'zoek...'
			});
    });
*/


