//******************************************************************************************************
function ValidateEmailAddress(vTestEmail)
{
	var objFilter;
	
	objFilter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	if (objFilter.test(vTestEmail))
	{
		return true;
	}
	else
	{
		return false;
	}
}
//******************************************************************************************************
function ValidateQuery()
{
    var strEmailValid;
	if(document.getElementById('txtName').value == '')
	{
		alert('Please enter a value in the name field');
		document.getElementById('txtName').focus();
		return false;
	}
	
	if(document.getElementById('txtSurname').value == '')
	{
		alert('Please enter a value in the surname field');
		document.getElementById('txtSurname').focus();
		return false;
	}
	
	if(document.getElementById('txtCellNumber').value == '' && document.getElementById('txtEmail').value == '')
	{
		alert('Please enter a value in the cell number field or the email field');
		document.getElementById('txtCellNumber').focus();
		return false;
	}
	
	if(document.getElementById('txtEmail').value != '')
	{
		strEmailValid = ValidateEmailAddress(document.getElementById('txtEmail').value);
	    if(strEmailValid == false)
	    {
		    document.getElementById('txtEmail').focus();
		    return false;
	    }
	}	
	
	if(document.getElementById('txtQuery').value == '')
	{
		alert('Please enter a value in the query field');
		document.getElementById('txtQuery').focus();
		return false;
	}
	return true;
}//******************************************************************************************************
function CheckSave(vStringValue, vStringName, vStringSurname, vStringEmail)
{
    if(vStringValue == 'Success')
    {
        alert('Thank you, your query has been successfully submitted.');
        window.open('increase_chance.asp?Name='+vStringName+'&Surname='+vStringSurname+'&Email='+vStringEmail+'','','Height=280px,Width=420px,center=1,help=0,status=0,toolbars=0');
        return;
    }
    if(vStringValue == 'Error')
    {
        alert('Thank you, but your query has generated an error.\nPlease try re-capture your query.\nWe apologise for the inconvienience.');
        return;
    }
    if(vStringValue == 'Exsists')
    {
        alert('Thank you, but your query already exsists in the system and has not been submitted again.');
        return;
    }
}
//******************************************************************************************************
function ValidateIncreaseChance()
{
    var strEmailValid;
	if(document.getElementById('txtFriend1Name').value == '')
	{
		alert('Please enter a value in the name field');
		document.getElementById('txtFriend1Name').focus();
		return false;
	}
	
	if(document.getElementById('txtFriend1Surname').value == '')
	{
		alert('Please enter a value in the surname field');
		document.getElementById('txtFriend1Surname').focus();
		return false;
	}
	
	strEmailValid = ValidateEmailAddress(document.getElementById('txtFriend1Email').value);
	if(strEmailValid == false)
	{
	    alert('Please enter a valid email address into the email field');
		document.getElementById('txtFriend1Email').focus();
		return false;
	}
	
	if(document.getElementById('txtFriend2Name').value == '')
	{
		alert('Please enter a value in the name field');
		document.getElementById('txtFriend2Name').focus();
		return false;
	}
	
	if(document.getElementById('txtFriend2Surname').value == '')
	{
		alert('Please enter a value in the surname field');
		document.getElementById('txtFriend2Surname').focus();
		return false;
	}
	
	strEmailValid = ValidateEmailAddress(document.getElementById('txtFriend2Email').value);
	if(strEmailValid == false)
	{
	    alert('Please enter a valid email address into the email field');
		document.getElementById('txtFriend2Email').focus();
		return false;
	}
	
	return true;
}
//******************************************************************************************************