<!-- employee/profile javascript functions start -->

function validLogon(myForm)
{
	if (myForm.Logon.value.length == 0) 
	{
		alert("A value must be entered for the Logon field")
		myForm.Logon.focus()
		return false
	}

	if (myForm.Pwd.value.length == 0) 
	{
		alert("A value must be entered for the Password field")
		myForm.Pwd.focus()
		return false
	}

	return true
}


function validEmployee(myForm) 
{
	var strTmp = ""

	strTmp = keepChars("0123456789", myForm.Hrid.value)
	myForm.Hrid.value = strTmp
	if (strTmp == "") 
	{
		alert("The Employee HRID field is a required entry. Please correct the entry and try again.");
		myForm.Hrid.focus()
		return false
	}

	strTmp = trim(myForm.Email.value)
	myForm.Email.value = strTmp
	if (strTmp == "") 
	{
		alert("The E-mail field is a required entry. Please correct the entry and try again.");
		myForm.Email.focus()
		return false
	}

	strTmp = trim(myForm.Fname.value)
	myForm.Fname.value = strTmp
	if (strTmp == "") 
	{
		alert("The First Name field is a required entry. Please correct the entry and try again.");
		myForm.Fname.focus()
		return false
	}

	strTmp = trim(myForm.Lname.value)
	myForm.Lname.value = strTmp
	if (strTmp == "") 
	{
		alert("The Last Name field is a required entry. Please correct the entry and try again.");
		myForm.Lname.focus()
		return false
	}

	strTmp = trim(myForm.Gender.value)
	myForm.Gender.value = strTmp
	if (strTmp == "") 
	{
		alert("The Gender field is a required entry. Please correct the entry and try again.");
		myForm.Gender.focus()
		return false
	}

	strTmp = trim(myForm.City.value)
	myForm.City.value = strTmp
	if (strTmp == "") 
	{
		alert("The City field is a required entry. Please correct the entry and try again.");
		myForm.City.focus()
		return false
	}

	strTmp = trim(myForm.State.value)
	myForm.State.value = strTmp
	if (strTmp == "") 
	{
		alert("The State/Province field is a required entry. Please correct the entry and try again.");
		myForm.State.focus()
		return false
	}

	strTmp = trim(myForm.Postal.value)
	myForm.Postal.value = strTmp
	if (strTmp == "") 
	{
		alert("The Postal field is a required entry. Please correct the entry and try again.");
		myForm.Postal.focus()
		return false
	}

	strTmp = trim(myForm.Country.value)
	myForm.Country.value = strTmp
	if (strTmp == "") 
	{
		alert("The Country field is a required entry. Please correct the entry and try again.");
		myForm.Country.focus()
		return false
	}

	return true
}

function showSaved(myForm) 
{

	strTmp = myForm.myGender.value
	for (x=0; x < myForm.Gender.length; x++)
	{
		if (strTmp == myForm.Gender.options[x].value)
		{
			myForm.Gender.selectedIndex = x
			break
		}
	}

	strTmp = myForm.myState.value
	for (x=0; x < myForm.State.length; x++)
	{
		if (strTmp == myForm.State.options[x].value)
		{
			myForm.State.selectedIndex = x
			break
		}
	}
	
	strTmp = myForm.myCountry.value
	for (x=0; x < myForm.Country.length; x++)
	{
		if (strTmp == myForm.Country.options[x].value)
		{
			myForm.Country.selectedIndex = x
			break
		}
	}

	// highlight SMS service provider
	strTmp = myForm.myMobileSvc.value
	for (x=0; x < myForm.MobileSvc.length; x++)
	{
		if (strTmp == myForm.MobileSvc.options[x].value)
		{
			myForm.MobileSvc.selectedIndex = x
			break
		}
	}
}

function validPwd(myForm)
{
	minSize = 8
	oldPwd = myForm.PwdOld.value
	newPwd = myForm.PwdNew.value

	// validate length
	if (oldPwd.length < minSize)
	{
		alert("The Old Password must have a minimum length of " + minSize)
		return false
	}

	if (newPwd.length < minSize)
	{
		alert("The New Password must have a minimum length of " + minSize)
		return false
	}
	
	// validate change
	if (newPwd == oldPwd)
	{
		alert("The New and Old Password CANNOT be the same.")
		return false
	}

	return true
}

function changePwd(myForm)
{
	minSize = 8
	oldPwd = myForm.PwdOld.value
	newPwd = myForm.PwdNew.value
	verPwd = myForm.PwdVerify.value
	
	var result = confirm("Are you sure you want to change your password?")
	if (result == false )
		return
	
	// validate length
	if (oldPwd.length < minSize)
	{
		alert("The Old Password must have a minimum length of " + minSize)
		return false
	}

	if (newPwd.length < minSize)
	{
		alert("The New Password must have a minimum length of " + minSize)
		return false
	}
	
	// validate change
	if (newPwd == oldPwd)
	{
		alert("The New and Old Password CANNOT be the same.")
		return false
	}

	if (newPwd != verPwd)
	{
		alert("The New Password and Verify Password ARE NOT the same.")
		return false
	}

	myFormPwd = window.document.frmEditPwd
	myFormPwd.PwdOld.value = oldPwd
	myFormPwd.PwdNew.value = newPwd
	myFormPwd.submit()
	return true
}

// toggle password view to display=1 or hide=-1
function togglePwd(myForm)
{
	myFlag = parseInt(myForm.viewFlag.value)
	myFlag *= -1

	objFld = "tblPwd"
	myItem = eval( document.getElementById(objFld) )

	if (myFlag == 1)
	{
		myView = ''
	    myItem.style.display = myView;
	}
	else
	{
		myView = 'none'
	    myItem.style.display = myView;
	}

	myForm.viewFlag.value = myFlag
}



function validLogon(myForm)
{
	minSize = 8
	oldLogon = myForm.LogonOld.value
	newLogon = myForm.LogonNew.value

	// validate length
	if (oldLogon.length < minSize)
	{
		alert("The Old Logon must have a minimum length of " + minSize)
		return false
	}

	if (newLogon.length < minSize)
	{
		alert("The New Logon must have a minimum length of " + minSize)
		return false
	}
	
	// validate change
	if (newLogon == oldLogon)
	{
		alert("The New and Old Logon CANNOT be the same.")
		return false
	}

	return true
}

function changeLogon(myForm)
{
	minSize = 8
	oldLogon = myForm.LogonOld.value
	newLogon = myForm.LogonNew.value
	verLogon = myForm.LogonVerify.value
	
	var result = confirm("Are you sure you want to change your Logon?")
	if (result == false )
		return
	
	// validate length
	if (oldLogon.length < minSize)
	{
		alert("The Old Logon must have a minimum length of " + minSize)
		return false
	}

	if (newLogon.length < minSize)
	{
		alert("The New Logon must have a minimum length of " + minSize)
		return false
	}
	
	// validate change
	if (newLogon == oldLogon)
	{
		alert("The New and Old Logon CANNOT be the same.")
		return false
	}

	if (newLogon != verLogon)
	{
		alert("The New Logon and Verify Logon ARE NOT the same.")
		return false
	}

	myFormLogon = window.document.frmEditLogon
	myFormLogon.LogonOld.value = oldLogon
	myFormLogon.LogonNew.value = newLogon
	myFormLogon.submit()
	return true
}

// toggle logon view to display=1 or hide=-1
function toggleLogon(myForm)
{
	myFlag = parseInt(myForm.viewFlag.value)
	myFlag *= -1

	objFld = "tblLogon"
	myItem = eval( document.getElementById(objFld) )

	if (myFlag == 1)
	{
		myView = ''
	    myItem.style.display = myView;
	}
	else
	{
		myView = 'none'
	    myItem.style.display = myView;
	}

	myForm.viewFlag.value = myFlag
}

