function watermark(inputId,text){
	var inputBox = document.getElementById(inputId);
	if (inputBox.value.length > 0){
		inputBox.style.color = "black";
		inputBox.style.fontStyle = "normal";
		if (inputBox.value == text)
			inputBox.value = '';
	}
	else {
		inputBox.style.color = "gray";
		inputBox.style.fontStyle = "italic";
		inputBox.value = text;
	}
}

function watermark_handy(inputId,text){
	var inputBox = document.getElementById(inputId);
	if (inputBox.value.length > 0 && inputBox.value != "+43"){
		inputBox.style.color = "black";
		inputBox.style.fontStyle = "normal";
		if (inputBox.value == text)
			inputBox.value = '+43';
	}
	else {
		inputBox.style.color = "gray";
		inputBox.style.fontStyle = "italic";
		inputBox.value = text;
	}
}

function changeInputType(oldObject, oType) {
	var newObject = document.createElement('input');
	newObject.type = oType;
	if(oldObject.size) newObject.size = oldObject.size;
	if(oldObject.value) newObject.value = oldObject.value;
	if(oldObject.name) newObject.name = oldObject.name;
	if(oldObject.id) newObject.id = oldObject.id;
	if(oldObject.className) newObject.className = oldObject.className;
	//var newObject = oldObject.cloneNode(true);
	//newObject.type = oType;
	oldObject.parentNode.replaceChild(newObject,oldObject);
	return newObject;
}

function watermark_pw_focus(inputId,text){
	var inputBox = document.getElementById(inputId);

	oldText = inputBox.value;
	newInputBox = changeInputType(inputBox, 'password');
	newInputBox.style.color = "black";
	newInputBox.style.fontStyle = "normal";
	if (oldText == text)
		newInputBox.value = '';
	else
		newInputBox.value = oldText;
	setTimeout(function() { newInputBox.focus(); }, 200);
	
}

function watermark_pw_blur(inputId,text){
	var inputBox = document.getElementById(inputId);
	if (inputBox.value.length == 0){
		newInputBox = changeInputType(inputBox, 'text');
		newInputBox.style.color = "gray";
		newInputBox.style.fontStyle = "italic";
		newInputBox.value = text;
	}
}

