// JavaScript Document
function Obj_error(objE)
{
	objE.style.borderColor = '#ff0000';
	objE.focus();
}
function Obj_good(objG)
{
	objG.style.borderColor = '#006600';
}
function Check_YourName()
{
	obj = document.getElementById('fnm');
	objV = obj.value;
	if(objV.length < 2)
	{
		alert('The name you entered is not a valid name.');
		Obj_error(obj);
		return false;
	}
	objS = objV.toUpperCase();
	for (i=0; i < objS.length; i++)
	{
		if(objS.charCodeAt(i) < 65 || objS.charCodeAt(i) > 90)
		{
			//character is not A-Z
			if(objS.charCodeAt(i) != 32)
			{
				//character is not a space
				//string is not a valid name
				alert('The name you entered contains invalid characters.');
				Obj_error(obj);
				return false;
			}
		}
	}
	Obj_good(obj);
	return true;
}
function Check_YourEmail()
{
	obj = document.getElementById('fem');
	objV = obj.value;
	if(objV.length < 6)
	{
		alert('The address you entered is not a valid e-mail address.');
		Obj_error(obj);
		return false;
	}
	if(objV.indexOf('@') < 2)
	{
		alert('The address you entered is not a valid e-mail address.');
		Obj_error(obj);
		return false;
	}
	if(objV.lastIndexOf('.') < objV.indexOf('@') + 3)
	{
		alert('The address you entered is not a valid e-mail address.');
		Obj_error(obj);
		return false;
	}
	if(objV.lastIndexOf('.') > objV.length - 3)
	{
		alert('. The address you entered is not a valid e-mail address.');
		Obj_error(obj);
		return false;
	}
	objS = objV.toUpperCase();
	for (i=0; i < objS.length; i++)
	{
		if(objS.charCodeAt(i) < 65 || objS.charCodeAt(i) > 90)
		{
			//character is not A-Z
			if(objS.charCodeAt(i) < 48 || objS.charCodeAt(i) > 57)
			{
				//character is not a number
				if(objS.charCodeAt(i) != 45 &&objS.charCodeAt(i) != 46 && objS.charCodeAt(i) != 64 && objS.charCodeAt(i) != 95)
				{
					//character is not - . @ or _
					alert('The address you entered is not a valid e-mail address.');
					Obj_error(obj);
					return false;
				}
			}
		}
	}
	Obj_good(obj);
	return true;
}
function Check_Subject()
{
	obj = document.getElementById('sct');
	objV = obj.value;
	if(objV.length < 1)
	{
		cnfrm=confirm('The Subject is empty. Do you wish to continue?');
		if(cnfrm==false)
		{
			Obj_error(obj);
			return false;
		}else{
			Obj_good(obj);
			return true;
		}
	}else{
		Obj_good(obj);
		return true;
	}
}
function Check_Body()
{
	obj = document.getElementById('by');
	objV = obj.value;
	if(objV.length < 1)
	{
		cnfrm=confirm('The Body is empty. Do you wish to continue?');
		if(cnfrm==false)
		{
			Obj_error(obj);
			return false;
		}else{
			Obj_good(obj);
			return true;
		}
	}else{
		Obj_good(obj);
		return true;
	}
}
function vld(){
	if(!Check_YourName()){return false;}
	if(!Check_YourEmail()){return false;}
	if(!Check_Subject()){return false;}
	if(!Check_Body()){return false;}
	return true;
	
}
