// JavaScript for input prompt colors and types (passwords, etc)
//Variable to save prompt messages
var fieldPrompts = new Array();

function inputFocus(fieldObj) {
if (fieldObj.className=='inputPrompt') {
if (fieldObj.id=='password') {
//change field type and reset obj reference
changeInputType('password', 'password');
fieldObj = document.getElementById('password');
}
fieldPrompts[fieldObj.id] = fieldObj.value;
fieldObj.value = '';
fieldObj.className = 'inputStd';
fieldObj.select();
fieldObj.focus();
}
}

function inputBlur(fieldObj) {
if (fieldObj.value=='') {
if (fieldObj.id=='password') {
//change field type and reset obj reference
changeInputType('password', 'text');
fieldObj = document.getElementById('password');
}
fieldObj.value = fieldPrompts[fieldObj.id];
fieldObj.className = 'inputPrompt';
}
}

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

function setPrompts(userName, password) { //Run onload of the page
document.getElementById('username').className = 'inputPrompt';
document.getElementById('username').value = userName;
changeInputType('password', 'text');
document.getElementById('password').value = password;
document.getElementById('password').className = 'inputPrompt';
}
