/*
* COPYRIGHT 2011 Jobvite, Inc. All rights reserved. This copyright notice is Copyright Management 
* Information under 17 USC 1202 and is included to protect this work and deter copyright infringement.  
* Removal or alteration of this Copyright Management Information without the express written permission 
* of Jobvite, Inc. is prohibited, and any such unauthorized removal or alteration will be a violation of 
* federal law.
*/
function otherNamePopup()
{
	var d = new OverlayDialog('Please Enter Your Information', '*Required');
	d.set_width(330);
	d.addAlert('AlertOther');
	d.addTextInput('*First Name', 'OtherFirstName');
	d.addTextInput('*Last Name', 'OtherLastName');
	d.addTextInput('*Email', 'OtherEmail');
	d.addCancel();
	d.addButton('Save', 'otherNameSave()');
	d.display();
}
function otherNameSave()
{
	var firstName = document.getElementById('OtherFirstName').value;
	var lastName = document.getElementById('OtherLastName').value;
	var email = document.getElementById('OtherEmail').value;
	var hasError = false;
	if (email.length == 0)
	{
		hasError = true;
		document.getElementById('OtherEmail').style.backgroundColor = '#ffd8d9';
		document.getElementById('OtherEmail').focus();
	}
	else
		document.getElementById('OtherEmail').style.backgroundColor = 'White';
	if (lastName.length == 0)
	{
		hasError = true;
		document.getElementById('OtherLastName').style.backgroundColor = '#ffd8d9';
		document.getElementById('OtherLastName').focus();
	}
	else
		document.getElementById('OtherLastName').style.backgroundColor = 'White';
	if (firstName.length == 0)
	{
		hasError = true;
		document.getElementById('OtherFirstName').style.backgroundColor = '#ffd8d9';
		document.getElementById('OtherFirstName').focus();
	}
	else
		document.getElementById('OtherFirstName').style.backgroundColor = 'White';
	if (hasError)
	{
		alertMessage('AlertOther', 'Please fill out missing information.');
		return;
	}
	var result = email.match('\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*');
	if (result != null)
	{
		for (var i = 0; i < result.length; i++)
		{
			if (result[i].length > 0)
			{
				email = result[i];
				break;
			}
		}
	}
	else
		email = '';
	if (email.length == 0)
	{
		hasError = true;
		document.getElementById('OtherEmail').style.backgroundColor = '#ffd8d9';
		document.getElementById('OtherEmail').focus();
		alertMessage('AlertOther', 'Must be email address.');
		return;
	}
	var o = document.getElementById('OtherNameNewName');
	if (o)
		o.value = firstName + '\n' + lastName + '\n' + email;
	var o = document.getElementById('OriginalName');
	if (o)
		o.innerHTML = firstName + ' ' + lastName + ' (' + email + ')';
	if (OverlayDialogInstance)
		OverlayDialogInstance.close();
	if (typeof(OtherNameCallback) == 'function')
		OtherNameCallback();
}


