function fillInput(element, text, password){
	if (password) {
		var pwd = $(element);
		
		if (pwd.getAttribute('type') == 'password'  && pwd.getValue()  == '') {
			var parent = pwd.up();
			pwd.remove();
			
			var input = document.createElement('input');
			input.setAttribute('type', 'text');
			input.setAttribute('value', text);
			input.setAttribute('name', 'password');
			input.onblur = function() {fillInput(this, "Password", true);};
			input.onfocus = function() {clearInput(this, "Password", true);};
			parent.appendChild(input);
		}
	}
	else {
		if ($(element).getValue() == ''){
			$(element).value = text;
		}
	}
}
function clearInput(element, text, password){

	if (password) {
		var pwd = $(element);
		
		var parent = pwd.up();
		if (pwd.getAttribute('type') == 'text')	{
			pwd.remove();
			
			var input = document.createElement('input');
			input.setAttribute('type', 'password');
			input.setAttribute('value', '');
			input.setAttribute('name', 'password');
			input.onblur = function() {fillInput(this, "Password", true);};
			input.onfocus = function() {clearInput(this, "Password", true);};
			parent.appendChild(input);
			input.focus();
			
			pwd = $$('input[name="password"]')[0];
			pwd.focus();
		}
	}
	else{
		if ($(element).getValue() == text)
			$(element).value = '';
	}
}

function initInput(formname, name, text, password){
	if (password) {
		var pwd = $$('input[name="'+name+'"]')[0];
		if (!(pwd))
			return;
		
			var parent = pwd.up();
			pwd.remove();
			var input = document.createElement('input');
			input.setAttribute('type', 'text');
			input.setAttribute('value', text);
			input.setAttribute('name', 'password');
			input.onblur = function() {fillInput(this, "Password", true);};
			input.onfocus = function() {clearInput(this, "Password", true);};
			parent.appendChild(input);

	}
}
