// JavaScript Document

function isEmailAddr(email)
{
	var result = false
	var theStr = new String(email)
	var index = theStr.indexOf("@");
	if (index > 0)
	{
		var pindex = theStr.indexOf(".",index);
		if ((pindex > index+1) && (theStr.length > pindex+1))
		result = true;
	}
	return result;
}
	
function check()
{
	if(document.query.name.value == "")
	{
		alert("Name not given");
		document.query.name.focus();
		return false;
	}
	
	if(document.query.address.value == "")
	{
		alert("Address not given");
		document.query.address.focus();
		return false;
	}

	if(document.query.telephone.value == "")
	{
		alert("Telephone not given");
		document.query.telephone.focus();
		return false;
	}
	
	if(document.query.mobile.value == "")
	{
		alert("Mobile not given");
		document.query.mobile.focus();
		return false;
	}

	if(document.query.email.value == "")
	{
		alert("Email Address not given");
		document.query.email.focus();
		return false;
	}
	
	if(!isEmailAddr(document.query.email.value))
	{
		alert("Please provide correct email address in the form: yourname@yourdomain.com");
		document.query.email.focus();
		return false;
	}
	
	if(document.query.generalquery.value == "")
	{
		alert("General Query not given");
		document.query.generalquery.focus();
		return false;
	}
	
	if(document.query.hearabout.value == "")
	{
		alert("Where did you hear about us?");
		document.query.hearabout.focus();
		return false;
	}
}	

function checkQuote()
{
	if(document.query.name.value == "")
	{
		alert("Full Name not given");
		document.query.name.focus();
		return false;
	}
	
	if(document.query.address.value == "")
	{
		alert("Address not given");
		document.query.address.focus();
		return false;
	}

	if(document.query.email.value == "")
	{
		alert("Email Address not given");
		document.query.email.focus();
		return false;
	}
	
	if(!isEmailAddr(document.query.email.value))
	{
		alert("Please provide correct email address in the form: yourname@yourdomain.com");
		document.query.email.focus();
		return false;
	}
	
	if(document.query.telephone.value == "")
	{
		alert("Home Phone not given");
		document.query.telephone.focus();
		return false;
	}
	
	if(document.query.mobile.value == "")
	{
		alert("Mobile Number not given");
		document.query.mobile.focus();
		return false;
	}

	if(!(document.query.solar.checked || document.query.wood.checked || document.query.geothermal.checked))
	{
		alert("Select at least one Energy Type");
		return false;
	}

	if(!(document.query.newbuilding.checked || document.query.extension.checked || document.query.heatingconversion.checked))
	{
		alert("Select at least one Project Type");
		return false;
	}

	if(document.query.housesize.value == "")
	{
		alert("House size not given");
		document.query.housesize.focus();
		return false;
	}

	if(document.query.roomsize.value == "")
	{
		alert("Room / Floor size not given");
		document.query.roomsize.focus();
		return false;
	}

	if(document.query.heatsource.value == "")
	{
		alert("Main Heat Source not given");
		document.query.heatsource.focus();
		return false;
	}

	if(document.query.heatingsystem.value == "")
	{
		alert("Heating system not given");
		document.query.heatingsystem.focus();
		return false;
	}

	if(document.query.occupants.value == "")
	{
		alert("Number of occupants required");
		document.query.occupants.focus();
		return false;
	}

	if(document.query.bathrooms.value == "")
	{
		alert("Number of bathrooms required");
		document.query.bathrooms.focus();
		return false;
	}

	if(document.query.hearabout.value == "")
	{
		alert("How did you hear about us?");
		document.query.hearabout.focus();
		return false;
	}
}	
