/**
 * Applies on-focus and on-blur events to input fields with the class 'intuitive'.
 * The title of the input will be displayed until it is clicked.
 */
(function($) {
		var passwordFields = new Array();
		window.intuitiveCheck = function() {
			for (i = 0; i < passwordFields.length; i++) {
				var pwd = passwordFields[i].pwd;
				var txt = passwordFields[i].txt;
				var last = passwordFields[i].last;
				if (pwd.val() != last) {
					txt.hide();
					pwd.show();
					passwordFields[i].last = pwd.val();
				}
			}
		};
		window.scrollInterval = setInterval('window.intuitiveCheck()', 500);
		
		$(function(){
			$("input.intuitive").each(function() {
				var title = $(this).attr('title');
				var isPwd = ($(this).attr('type') == 'password');
				var _clone = null;
				if (!isPwd) {
					$(this).focus(function() { 
						if ($(this).val() == title) $(this).val('').attr('edited', 'true'); 
					})
					.blur(function() {
						if ($(this).val() == '') $(this).val(title).attr('edited', 'false');
					});
					$(this).blur().attr('edited', $(this).val() != title ? 'true' : 'false');
				} else {
					$(this).blur(function() {
						if ($(this).val() == '') {
							$(this).hide();
							_clone.show();
						}
					});
					var _this = $(this);
					_clone = $("<input type='text' />")
						.insertAfter(_this).attr({
							'class':_this.attr('class'), 
							'style':_this.attr('style'), 
							'value':title,
							'title':title,
							'size' :_this.attr('size')
						})
						.focus(function() {
							_clone.hide();
							_this.show().focus();
						})
					;
					if (_this.val() != '') {
						_clone.hide();
					} else {
						_this.hide();
					}
					// Will check for altering of password field
					passwordFields.push({pwd:_this, txt:_clone, last:_this.val()});
				}
			});
		});
})(jQuery || $jQ132);

