
	/*----------------------------------------------------------------------

		ClicFields - jquery.clicfields.js

		Developed by Designition Ltd - www.designition.co.uk

		ALL RIGHTS RESERVED - Copyright 2009 Clic Online

	----------------------------------------------------------------------*/

	(function($) {

		$.fn.clicfields = function(options) {
			//	Define default options
			$.fn.clicfields.defaults = {}

			//	Roll options into a usable variable
			var opts = $.extend({}, $.fn.clicfields.defaults, options);

			var labels = new Object;

			//	Do the actual thing, yeah?
			return this.each(function() {

				field    = $(this);
				field_id = field.attr('id');

				label      = $('label[for=' + field_id + ']');
				label_text = label.html();

				label.remove();

				labels[field_id] = label_text;

				$.each(labels, function(input, label) {

					is_empty = $('input#' + input).val() == '';
					is_pass  = $('input#' + input).attr('type') == 'password';

					if (is_empty) $('input#' + input).val(label);

//					if (is_pass && field.val() == label) field.attr('type', 'text');

					$('input#' + input)
						.focus(function() {
							$(this).addClass('focus');
							if ($(this).val() == label) $(this).val('');
//							if (is_pass) field.attr('type', 'password');
						})
						.blur(function() {
							$(this).removeClass('focus');
							if ($(this).val() == '') {
//								if (is_pass) field.attr('type', 'text');
								$(this).val(label);
							}
						});
					
				});

				
			});
		}

	})(jQuery);
