var xmlHttp


function checkform(theform)
{
	if (theform.surname1.value == "")
	{
		alert("Please enter your surname.");
		theform.surname1.focus();
		return (false);
	}
	
	if (theform.firstname1.value == "")
	{
		alert("Please enter your first name.");
		theform.firstname1.focus();
		return (false);
	}
	
	if (theform.address1.value == "")
	{
		alert("Please enter your address.");
		theform.address1.focus();
		return (false);
	}
	
	if (theform.postcode1.value == "")
	{
		alert("Please enter your postcode.");
		theform.postcode1.focus();
		return (false);
	}
	
	if (theform.telephone1.value == "")
	{
		alert("Please enter your telephone.");
		theform.telephone1.focus();
		return (false);
	}
	
	if (theform.email1.value == "")
	{
		alert("Please enter your email.");
		theform.email1.focus();
		return (false);
	}
	
	
	var checkEmail = "@.";
	var checkStr = theform.email1.value;
	var EmailValid = false;
	var EmailAt = false;
	var EmailPeriod = false;
	for (i = 0;  i < checkStr.length;  i++)
	{
	ch = checkStr.charAt(i);
	for (j = 0;  j < checkEmail.length;  j++)
	{
	if (ch == checkEmail.charAt(j) && ch == "@")
	EmailAt = true;
	if (ch == checkEmail.charAt(j) && ch == ".")
	EmailPeriod = true;
		  if (EmailAt && EmailPeriod)
			break;
		  if (j == checkEmail.length)
			break;
		}
		// if both the @ and . were in the string
	if (EmailAt && EmailPeriod)
	{
			EmailValid = true
			break;
		}
	}
	
	if (!EmailValid)
	{
	alert("Please enter a valid email address.");
	return false;
	}
	
	// Cbeck if second person has been selected
	
	chosen = ""
	len = theform.spouse.length
	
	for (i = 0; i <len; i++) 
	{
		if (theform.spouse[i].checked) 
		{
			chosen = theform.spouse[i].value
		}
	}
	
	if (chosen == 1) 
	{
		if (theform.surname2.value == "")
		{
			alert("Please enter your partners surname.");
			theform.surname2.focus();
			return (false);
		}
		
		if (theform.firstname2.value == "")
		{
			alert("Please enter your partners first name.");
			theform.firstname2.focus();
			return (false);
		}
		
		if (theform.telephone2.value == "")
		{
			alert("Please enter your partners telephone number.");
			theform.telephone2.focus();
			return (false);
		}

	}
		
		
//	if (theform.bankname.value == "")
//	{
//		alert("Please enter your banks name.");
//		theform.bankname.focus();
//		return (false);	
//	}

//	if (theform.bankaddress.value == "")
//	{
//		alert("Please enter your banks address.");
//		theform.bankaddress.focus();
//		return (false);	
//	}

	
	
	return true;
}

function confirmation(conform)
{

	if (conform.accountname.value == "")
	{
		alert("Please enter your account name.");
		conform.accountname.focus();
		return (false);	
	}
	
	if (conform.sc1.value == "" || conform.sc2.value == "" || conform.sc3.value == "")
	{
		alert("Please enter your full sort code.");
		conform.sc1.focus();
		return (false);	
	}
	
	if (conform.accountnumber.value == "")
	{
		alert("Please enter your account number.");
		conform.accountnumber.focus();
		return (false);	
	}
	
	if (conform.confirmacceptance.checked == false)
	{
		alert("Please confirm your acceptance of our terms and conditions.");
		return (false);	
	}
	
}

function checkaccounts(form)
{
	
	if (form.confirmacceptance.checked == false)
	{
		alert("Please confirm your acceptance of our terms and conditions.");
		return (false);	
	}
	
//	var accnum = form.accountnumber.value
//	var sc = form.sc1.value + form.sc2.value + form.sc3.value
	
	
	//alert (accnum);
	//alert (sc);
	

//	var url="checkaccountdetails.asp?acc=" + accnum + "&sc=" + sc
//	xmlHttp=GetXmlHttpObject(stateChanged)
//	xmlHttp.open("GET", url , aftershow, true)
	//window.open(url);
//	xmlHttp.send(null)

//	return (false);
	
} 

function stateChanged() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
	//removeLock('loginasp');
	var resp = xmlHttp.responseText; 
	//var stat = resp.getElementsByTagName('stat')[0].firstChild.data;
	alert(resp);
	} 
} 


function GetXmlHttpObject(handler)
{ 
var objXmlHttp=null

if (navigator.userAgent.indexOf("Opera")>=0)
{
	alert("This example doesn't work in Opera") 
	return 
}
if (navigator.userAgent.indexOf("MSIE")>=0)
{ 
var strName="Msxml2.XMLHTTP"
	if (navigator.appVersion.indexOf("MSIE 5.5")>=0)
	{
	strName="Microsoft.XMLHTTP"
	} 
	try
	{ 
	objXmlHttp=new ActiveXObject(strName)
	objXmlHttp.onreadystatechange=handler 
	return objXmlHttp
	} 

	catch(e)
{ 
alert("Error. Scripting for ActiveX might be disabled") 
return 
} 
} 
if (navigator.userAgent.indexOf("Mozilla")>=0)
{
objXmlHttp=new XMLHttpRequest()
objXmlHttp.onload=handler
objXmlHttp.onerror=handler 
return objXmlHttp
}
} 
