// <![CDATA[

var valid;
var lastone = 0;
function highlight (inputField, textAlert)
{

		valid = false;
		var errmsg = document.createElement('p');
		errmsg.id = 'err';
		var msg = document.createTextNode(textAlert);
		errmsg.appendChild(msg);
		// check if element with id 'err' exisits, if not then create it
		if (document.getElementById('err')) {
			document.getElementById('errDiv').removeChild(document.getElementById('err'));
		}
		document.getElementById('errDiv').appendChild(errmsg);
		var inputbox = document.getElementById(inputField);
			if (lastone && (lastone != inputbox))
			{
				lastone.style.borderColor = '#ccc';
				lastone.style.backgroundColor = '#fff';
			}
			lastone = inputbox; 

		inputbox.style.borderColor = '#ff0000';
		inputbox.style.backgroundColor = '#ffcccc';
		inputbox.focus();
		
}

function validate_book_del(pageForm) {
	
	valid = true;
	
	if (pageForm.number.value == "") 
	{
		highlight('number', 'Please enter the number of delegate places you wish to book:');
	}
	else if (pageForm.total.value == "")
	{
		highlight('total', 'Please enter the total amount:');
	}
	else if (pageForm.email.value == "")
	{
		highlight('email', 'Please enter your email address:');
	}
	else if (pageForm.name.value == "")
	{
		highlight('name', 'Please enter your name:');	
	}
	else if (pageForm.company.value == "")
	{
		highlight('company', 'Please enter your company:');	
	}
	else if (pageForm.address1.value == "")
	{
		highlight('address1', 'Please enter your address:');	
	}
	else if (pageForm.phone.value == "")
	{
		highlight('phone', 'Please enter your phone number:');	
	}
	else if (pageForm.country.selectedIndex == 0)
	{
		highlight('country', 'Please enter your country:');	
	}
	
	return valid ;
}
function validate_aroa_join(pageForm) {
	
	valid = true;
	
	if (pageForm.email.value == "")
	{
		highlight('email', 'Please enter your email address:');
	}
	else if (pageForm.name.value == "")
	{
		highlight('name', 'Please enter your name:');	
	}
	else if (pageForm.company.value == "")
	{
		highlight('company', 'Please enter your company:');	
	}
	else if (pageForm.address1.value == "")
	{
		highlight('address1', 'Please enter your address:');	
	}
	else if (pageForm.phone.value == "")
	{
		highlight('phone', 'Please enter your phone number:');	
	}
	else if (pageForm.country.selectedIndex == 0)
	{
		highlight('country', 'Please enter your country:');	
	}
	return valid ;
}

function validate_book_ex(pageForm) {
	
	valid = true;
	
	if (pageForm.size.value == "") 
	{
		highlight('size', 'Please enter size of stand required:');
	}
	else if (pageForm.email.value == "")
	{
		highlight('email', 'Please enter your email address:');
	}
	else if (pageForm.name.value == "")
	{
		highlight('name', 'Please enter your name:');	
	}
	else if (pageForm.company.value == "")
	{
		highlight('company', 'Please enter your company:');	
	}
	else if (pageForm.address1.value == "")
	{
		highlight('address1', 'Please enter your address:');	
	}
	else if (pageForm.phone.value == "")
	{
		highlight('phone', 'Please enter your phone number:');	
	}
	else if (pageForm.country.selectedIndex == 0)
	{
		highlight('country', 'Please enter your country:');	
	}	
	
	return valid ;
}

function validate_contact(pageForm) {
	
	valid = true;
	
	if (pageForm.email.value == "")
	{
		highlight('email', 'Please enter your email address:');
	}
	else if (pageForm.name.value == "")
	{
		highlight('name', 'Please enter your name:');	
	}
	else if (pageForm.company.value == "")
	{
		highlight('company', 'Please enter your company:');	
	}
	else if (pageForm.phone.value == "")
	{
		highlight('phone', 'Please enter your phone number:');	
	}
	else if (pageForm.address1.value == "")
	{
		highlight('address1', 'Please enter your address:');	
	}
	else if (pageForm.country.selectedIndex == 0)
	{
		highlight('country', 'Please enter your country:');	
	}
	else if (pageForm.message.value == "")
	{
		highlight('message', 'Please enter a message:');	
	}
	return valid ;
}

function validate_tdh_subs(pageForm) {
	
	valid = true;
	
	if (pageForm.email.value == "")
	{
		highlight('email', 'Please enter your email address:');
	}
	else if (pageForm.name.value == "")
	{
		highlight('name', 'Please enter your name:');	
	}
	else if (pageForm.address1.value == "")
	{
		highlight('address1', 'Please enter your address:');	
	}
	else if (pageForm.company.value == "")
	{
		highlight('company', 'Please enter your company:');	
	}
	else if (pageForm.phone.value == "")
	{
		highlight('phone', 'Please enter your phone number:');	
	}
	else if (pageForm.country.selectedIndex == 0)
	{
		highlight('country', 'Please enter your country:');	
	}
	return valid ;
}

function validate_tdh_ad(pageForm) {
	
	valid = true;
	
	if (pageForm.email.value == "")
	{
		highlight('email', 'Please enter your email address:');
	}
	else if (pageForm.name.value == "")
	{
		highlight('name', 'Please enter your name:');	
	}
	else if (pageForm.address1.value == "")
	{
		highlight('address1', 'Please enter your address:');	
	}
	else if (pageForm.company.value == "")
	{
		highlight('company', 'Please enter your company:');	
	}
	else if (pageForm.phone.value == "")
	{
		highlight('phone', 'Please enter your phone number:');	
	}
	else if (pageForm.country.selectedIndex == 0)
	{
		highlight('country', 'Please enter your country:');	
	}
	
	return valid ;
}
function calculate (places)
{
	var cost = 450;
	var discount = (cost / 100);
	
	if(places <= 2)
	{
		discount = 0;
	}
	else if (places >= 3 && places <=5)
	{
		discount = discount*15;
		cost = cost - discount;
	}
	else if (places >= 6 && places <=10)
	{
		discount = discount*25;
		cost = cost - discount;
	}
	else if (places >= 11)
	{
		discount = discount*35;
		cost = cost - discount;
	}
	document.getElementById('r_num').value = places;
	document.getElementById('subtotal').value = 450*places;
	document.getElementById('sdf').value = (discount*places).toFixed(2);
	document.getElementById('total').value = (cost*places).toFixed(2);
}
// ]]>