function hideRow(name)
{
	$(name+'Label').style.display = 'none';
	$(name).style.display = 'none';
}

function showRow(name)
{
	$(name+'Label').style.display = 'block';
	$(name).style.display = 'block';
}

function toggleShowHide(name)
{
	var display = $(name+'DateLabel').style.display;
	if(display == 'none')
		display = 'block';
	else
		display = 'none';

	$(name+'DateLabel').style.display = display;
	$(name+'Day').style.display = display;
	$(name+'Month').style.display = display;
	$(name+'Year').style.display = display;
}

function validateLoginForm()
{
	if ($('emailAddress').value == '' && $('password').value == '')
	{
		alert('Please enter your e-mail address and password');
	}
	else if ($("emailAddress").value == "")
	{
		alert("Please enter your e-mail address");
	}
	else if ($("password").value == "")
	{
		alert("Please enter your password");
	}
	else
	{
		return true;
	}
	
	return false;
}

function validateLoginForm2()
{
	if ($('emailAddress2').value == '' && $('password2').value == '')
	{
		alert('Please enter your e-mail address and password');
	}
	else if ($("emailAddress2").value == "")
	{
		alert("Please enter your e-mail address");
	}
	else if ($("password2").value == "")
	{
		alert("Please enter your password");
	}
	else
	{
		return true;
	}
	
	return false;
}

function validateRegistrationForm()
{
	//return true;
	
	var errors = 0;
	var errorStrings = new Array();
	
	if (!$('radLandlord').checked && !$('radAgent').checked)
	{
		errorStrings[errors++] = 'Please specify whether you are an agent or a landlord';
	}
	
	if ($('newEmailAddress').value == '')
	{
		errorStrings[errors++] = 'Please enter your e-mail address';
	}
	else if ($('newEmailAddress').value != $('emailAddressConfirm').value)
	{
		errorStrings[errors++] = 'Please enter your e-mail address twice for verification, and ensure they match';
	}
	
	if ($('newPassword').value == '')
	{
		errorStrings[errors++] = 'Please enter a password for your account';
	}
	else if ($('newPassword').value != $('passwordConfirm').value)
	{
		errorStrings[errors++] = 'Please enter your password twice for verification, and ensure they match';
	}
	
	if ($('contactName').value == '')
	{
		errorStrings[errors++] = 'Please enter a contact name';
	}
	
	if ($('address').value == '')
	{
		errorStrings[errors++] = 'Please enter your address';
	}
	
	if ($('postcode').value == '')
	{
		errorStrings[errors++] = 'Please enter your postcode';
	}
	
	if ($('telephoneHome').value == '' && $('telephoneMobile').value == '')
	{
		errorStrings[errors++] = 'Please enter a contact phone number';
	}
	
	if ($('captcha').value == '')
	{
		errorStrings[errors++] = 'Please enter the captcha code';
	}
	
	var errorString = "";

	if (errors > 0)
	{
		errorString += "Please correct the following errors before continuing:\n";
		
		for (var i = 0; i < errors; i++)
		{
			errorString += "\t- " + errorStrings[i] + "\n";
		}
	}
	else
	{
		$('s').value = 'Please wait...';
		$('s').disabled = true;
	}
	
	if (errors > 0)
		alert(errorString);

	return (errors == 0);
}

function validateBookingForm()
{
	var errors = 0;
	var errorStrings = new Array();
	
	if ($('address').value == '')
	{
		errorStrings[errors++] = 'Please enter the property\'s address';
	}
	if ($('postcode').value == '')
	{
		errorStrings[errors++] = 'Please enter the property\'s postcode';
	}
	if (!$('radFurnished').checked && !$('radUnfurnished').checked && !$('radPartFurnished').checked)
	{
		errorStrings[errors++] = 'Please indicate whether the property is furnished';
	}
	if ($('numberBedrooms').value == 'Not Specified')
	{
		errorStrings[errors++] = 'Please specify the number of bedrooms';
	}
	
	if ($('additionalRooms').value == '')
	{
		errorStrings[errors++] = 'Please specify the number of additional rooms';
	}
	
	if ($('gasmeter').value == '')
	{
		errorStrings[errors++] = 'Please enter the location of the gas meter';
	}
	if ($('elecmeter').value == '')
	{
		errorStrings[errors++] = 'Please enter the location of the electricity meter';
	}
	if ($('watermeter').value == '')
	{
		errorStrings[errors++] = 'Please enter the location of the water meter';
	}

	var errorString = "";

	if (errors > 0)
	{
		errorString += "Please correct the following errors before continuing:\n";
		
		for (var i = 0; i < errors; i++)
		{
			errorString += "\t- " + errorStrings[i] + "\n";
		}
	}
	else
	{
		$('s').value = 'Please wait...';
		$('s').disabled = true;
	}
	
	if(errors > 0)
		alert(errorString);

	return (errors == 0);
}
