function VerifyCheckBox(checkBoxElement)
{
	if (checkBoxElement.checked)	checkBoxElement.value = 'true';
	else checkBoxElement.value = 'false';
}

function ValidateData()
{
	var element = document.getElementById('txtFullName');
	if (element.value == "")
	{
		alert('Name is required.');
		element.focus();
		return (false);
	}
	
	var element = document.getElementById('txtCity');
	if (element.value == "")
	{
		alert('City is required.');
		element.focus();
		return (false);
	}
	
	
	var element = document.getElementById('txtEmail');
	if ((element.value == "") || (element.value == 'Email'))
	{
		alert('Email is required.');
		element.focus();
		return (false);
	}
	else
	{
		if(!ValidateEmail(element.value))
		{
			alert("Please check the emails address");
			element.focus();
			return false;
		}
	}
	
	
	element = document.getElementById('txtPhone');
	
	if(!ValidatePhone(element.value))
	{
		alert("Please, enter a valid cell phone number.");
		element.focus();
		return false;
	}
	
	
	element = document.getElementById('txtExtPhone');
	
	if(!ValidatePhone(element.value))
	{
		alert("Please, enter a valid phone number.");
		element.focus();
		return false;
	}
	
	element = document.getElementById('txtComments');
	if (element.value == "")
	{
		alert('Comments is required.');
		element.focus();
		return (false);
	}

	
	return (true);
}

function ValidatePhone(incoming)
{
	var ValidChars = "0123456789.()- ";
	var IsCorrect=true;
	var Char;

	for (cont = 0; cont < incoming.length && IsCorrect == true; cont++) 
	{ 
		Char = incoming.charAt(cont); 
		if (ValidChars.indexOf(Char) == -1) 
			return false;
	}
	return true;
}

function ValidateEmail(incoming) 
{
	var emailstring = incoming;
	var ampIndex = emailstring.indexOf("@");
	var afterAmp = emailstring.substring((ampIndex + 1), emailstring.length);
	// find a dot in the portion of the string after the ampersand only
	var dotIndex = afterAmp.indexOf(".");
	// determine dot position in entire string (not just after amp portion)
	dotIndex = dotIndex + ampIndex + 1;
	// afterAmp will be portion of string from ampersand to dot
	afterAmp = emailstring.substring((ampIndex + 1), dotIndex);
	// afterDot will be portion of string from dot to end of string
	var afterDot = emailstring.substring((dotIndex + 1), emailstring.length);
	var beforeAmp = emailstring.substring(0,(ampIndex));
	//var email_regex = /^\w(?:\w|-|\.(?!\.|@))*@\w(?:\w|-|\.(?!\.))*\.\w{2,3}/ 
	// index of -1 means "not found"
	
	if ((emailstring.indexOf("@") != "-1") &&
		(emailstring.indexOf(".") != "-1") &&
		(emailstring.length > 5) &&
		(afterAmp.length > 0) &&
		(beforeAmp.length > 1) &&
		(afterDot.length > 1) //&&
		//(email_regex.test(emailstring))
		) 
	{
		return true;
	} 
	else {
		return false;
	}
}


