function validateform(frm)
{
	if (frm.fldFirstname.value=="")
	{	window.alert("Please enter your Firstname");
		frm.fldFirstname.focus();
		return false;
	}
	
	if (frm.fldSurname.value=="")
	{	window.alert("Please enter your Surname");
		frm.fldSurname.focus();
		return false;
	}	


	if (frm.fldTel.value=="")
	{	window.alert("Please enter a telephone / mobile number");
		frm.fldTel.focus();
		return false;
	}

	if (frm.fldEmailAddress.value=="")
	{	window.alert("Please enter your email address");
		frm.fldEmailAddress.focus();
		return false;
	}

	if (!eMailcheck(frm.fldEmailAddress.value) )
	{	window.alert("Please enter a valid email address");
		frm.fldEmailAddress.focus();
		return false;
	}

	if (frm.fldConfirmEmailAddress.value=="")
	{	window.alert("Please enter your email address again to confirm spelling.");
		frm.fldConfirmEmailAddress.focus();
		return false;
	}

	if (!eMailcheck(frm.fldConfirmEmailAddress.value) )
	{	window.alert("Please enter a valid email address to confirm spelling");
		frm.fldConfirmEmailAddress.focus();
		return false;
	}


	if (frm.fldEmailAddress.value !== frm.fldConfirmEmailAddress.value)
	{	window.alert("Please check you have entered your email address correctly twice to confirm spelling.");
		frm.fldEmailAddress.focus();
		return false;
	}	

	if (frm.fldWhichPaper.value=="")
	{	window.alert("Please select which paper(s) you wish your ad placed in.");
		frm.fldWhichPaper.focus();
		return false;
	}	


	if (frm.fldAdType.value=="")
	{	window.alert("Please select which Ad Type you wish to place.");
		frm.fldAdType.focus();
		return false;
	}	
	
	if (frm.fldAdFormat.value=="")
	{	window.alert("Please select which Ad Format you wish to place.");
		frm.fldAdFormat.focus();
		return false;
	}		


	if (frm.fldAdSection.value=="")
	{	window.alert("Please select which Classified Section you wish to place your ad in.");
		frm.fldAdSection.focus();
		return false;
	}	


	if (frm.fldTextMessage.value=="")
	{	window.alert("Please enter the text for your ad.");
		frm.fldTextMessage.focus();
		return false;
	}		
	

	if (frm.strCAPTCHA.value=="")
	{	window.alert("Please enter our Anti-Spam code.");
		frm.strCAPTCHA.focus();
		return false;
	}
	
		return true;
}


function alertBoxedAds (frm)
{
	if (frm.fldAdFormat.value=="Boxed")
	{
		window.alert("Please note that boxed ads have a minimum charge of £15.00\nWe will contact you on receipt of your classified ad with exact costs.");	
	}	

	calculateCost(frm);
}
function calculateCost(frm)
{
	var totalCost = 0;
	var extrawords = parseInt(frm.w_count.value)-20;

	switch (frm.fldAdType.value)
	{
		case "Business": totalCost += 8.90; break;
		case "Private": totalCost += 4.45; break;
		default: totalCost += 0;
	}

	if (extrawords > 0)
	{
		
		if (frm.fldAdType.value=="Business")
		{	totalCost += (extrawords*0.10) }	
		else
		{	totalCost += (extrawords*0.05) }
	}
	
	if (frm.fldAdFormat.value=="Boxed")
	{
		totalCost = 15.00
	}

	switch (frm.fldWhichPaper.value)
	{
		case "Spectators and Chronicle": totalCost *= 2; break;
		default: totalCost *= 1;
	}	

	if( (frm.w_count.value!=="") & ( parseFloat(frm.w_count.value)>0))
	{frm.fldApproximateCost.value=totalCost.toFixed(2);}
	else
	{frm.fldApproximateCost.value="0";}	
	
}