function IsValidEmail(email)
{
	var ParStr = /^.+@.+\..{2,6}$/
	return ParStr.test(email);
}

function IsLongEnough(objid, objname, length, message)
{
	var obj;

	// Check for an empty object.
	obj = document.getElementById(objid);
	if (obj == null)
	{
		alert('Object : ' + objid + ' was not found.');
		return false;
	}

	// Trim value
	if (obj.value.replace( /^\s+|\s+$/, "" ).length < length)
	{
		if (message == null)
			alert(objname + ' field must be at least ' + length + ' characters long.');
		else
			alert(message);
		obj.focus();
		return false;
	}

	return true;
}

function IsNotEmpty(objid, objname, message)
{
	var obj;

	// Check for an empty object.
	obj = document.getElementById(objid);
	if (obj == null)
	{
		alert('Object : ' + objid + ' was not found.');
		return false;
	}

	// Trim value
	if (obj.value.replace( /^\s+|\s+$/, "" ).length == 0)
	{
		if (message == null)
			alert(objname + ' must not be left blank.');
		else
			alert(message);
		obj.focus();
		return false;
	}

	return true;
}


/************************************************************************************
*****		FUNCTIONALITY TO VALIDATE AN ORGANISATION'S DETAILS		*****
************************************************************************************
function ValidateOrganisationDetails()
{
	var obj;

	// Check that these fields are at least 6 characters long.
	if (!CheckLength('txtOrgName', 'Organisation Name', 6))
		return false;
	if (!IsAddressValid())
		return false;
	if (!IsContactValid())
		return false;
	
	//Ensure that a company sector has been chosen
	obj = document.getElementById('cmbCompanySector');
	if (obj.value == 0)
	{
		alert('Please choose a Company Sector for the organisation.');
		obj.focus();
		return false;
	}
	
	// Check if eClips is empty or does not contain numbers
	obj = document.getElementById('txtNumOfeClips');
	// Trim value
	if (obj.value.replace( /^\s+|\s+$/, "" ) == '')
	{
		alert('Please enter the number of users for the organisation.');
		obj.focus();
		return false;
	}
	if (isNaN(obj.value))
	{
		alert('Please enter the number of users for the organisation.\nA number was expected.');
		obj.focus();
		return false;
	}
	
	//Check the number of user My Archive accounts requested
	obj = document.getElementById('txtNumOfMyArchive');
	// Trim value
	if (obj.value.replace( /^\s+|\s+$/, "" ) == '')
	{
		alert('Please enter the number of required My Archive accounts.');
		obj.focus();
		return false;
	}
	if (isNaN(obj.value))
	{
		alert('Please enter the number of required My Archive accounts.\nA number was expected.');
		obj.focus();
		return false;
	}

	return true;
}

function CheckLength(objid, objname, length)
{
	return IsLongEnough(objid, objname, length, 'Not all of the organisation detail fields have been completed.\n' + objname + ' field must be at least ' + length + ' characters long.');
}

//Ensure that the Address, Town and Postcode are not empty
function IsAddressValid()
{
	if (!IsNotEmpty('txtOrgAddress', 'Address'))
		return false;
	if (!IsNotEmpty('txtOrgTown', 'Town'))
		return false;
	if (!IsNotEmpty('txtOrgPCode', 'Post Code'))
		return false;

	return true;
}

//Ensure that the full name is at least 6 characters long and that each Contact Name & Surname are not empty
//Finally the email address must contain an '@' character
function IsContactValid()
{
	var obj;

	// Check for an empty object.
	obj = document.getElementById('txtContactName').value + document.getElementById('txtContactSurname').value;
	// Trim value
	if (obj.replace( /^\s+|\s+$/, "" ).length < 6)
	{
		alert('The Contact Name & Surname fields must together be at least 6 characters in length.');
		
		document.getElementById('txtContactSurname').focus();
		obj = document.getElementById('txtContactName');
		if (obj.value == '')
			obj.focus();
		return false;
	}
	if (!IsNotEmpty('txtContactName', 'Name'))
		return false;
	if (!IsNotEmpty('txtContactSurname', 'Surname'))
		return false;
	if (!CheckLength('txtContactPhone', 'Contact Phone', 6))
		return false;

	//Ensure a valid email in both length and inclusion of '@'
	if (!CheckLength('txtContactEmail', 'Contact Email', 6))
		return false;
	obj = document.getElementById('txtContactEmail');
	if (!IsValidEmail(obj.value))
	{
		alert('The contact email seems to be invalid.');
		obj.focus();
		return false;
	}
	
	return true;
}
*/