	//Check registration form for constraints
	//Also verify password correctness
	function verifyRegister(frm)
	{
		var certified = true;
		var pmatch = true;
		var plength = true;
		
		clearMessages();

		if(frm.firstname.value.length == 0)
		{
			document.getElementById("e_firstname").style.display = "inline";
			certified = false;
		}
		if(frm.lastname.value.length == 0)
		{
			document.getElementById("e_lastname").style.display = "inline";
			certified = false;
		}
		if(frm.email.value.length == 0)
		{
			document.getElementById("e_email").style.display = "inline";
			certified = false;
		}
		if(frm.address1.value.length == 0)
		{
			document.getElementById("e_address1").style.display = "inline";
			certified = false;
		}
		if(frm.city.value.length == 0)
		{
			document.getElementById("e_city").style.display = "inline";
			certified = false;
		}
		if(frm.zip.value.length == 0)
		{
			document.getElementById("e_zip").style.display = "inline";
			certified = false;
		}
		if(frm.phone.value.length == 0)
		{
			document.getElementById("e_phone").style.display = "inline";
			certified = false;
		}
		if(frm.fax.length == 0)
		{
			document.getElementById("e_fax").style.display = "inline";
			certified = false;
		}
		if(frm.state.value == "ns")
		{
			document.getElementById("e_state").style.display = "inline";
			certified = false;
		}
		if(frm.username.value.length == 0)
		{
			document.getElementById("e_username").style.display = "inline";
			certified = false;
		}

		if(frm.captcha.value.length == 0)
		{
			document.getElementById("e_captcha").style.display = "inline";
			certified = false;
		}
		if(!certified)
		{
			alert('You have not filled out all the required fields. Please fill out all fields marked with an *.');
			return false;
		}
		else
		{
			if(frm.password.value.length <6)
			{
				plength = false;
			}
			if(frm.password.value != frm.verifypassword.value)
			{
				pmatch = false;
			}
			if(!checkEmail(frm.email.value))
			{
				alert('Please enter a valid email address.');
				document.getElementById("e_email").style.display = "inline";
				certified = false;
			}
			if(!checkZip(frm.zip.value))
			{
				alert('Please enter a valid zip code.');
				document.getElementById("e_zip").style.display = "inline";
			}
			if(!checkPhone(frm.phone.value))
			{
				alert('Please enter a valid phone number.\n\txxx-xxx-xxxx');
				document.getElementById("e_phone").style.display = "inline";
				certified = false;
			}
			if(!checkPhone(frm.fax.value))
			{
				alert('Please enter a valid fax number.\n\txxx-xxx-xxxx');
				document.getElementById("e_fax").style.display = "inline";
				return false;
			}
			
			else if (!plength)
			{
				alert('Your password must be at least 6 characters. Please try again.');
				return false;
			}
			else if(!pmatch)
			{
				alert('Your passwords do not match. Please make sure they are typed exactly the same.');
				return false;
			}
			else if (!frm.terms.checked)
			{
					alert('Please review and accept the Terms and Conditions of Hot Springs Village Auction House');
					return false;
			}
			else
			{
				return true;
			}
		}
	}
	
	function verifyPassword(frm)
	{
		if(frm.oldpassword.value == frm.password.value)
		{
			alert('Your old and new password are the same, there is no need to update.');
			return false;
		}
		if(frm.password.value.length < 6)
		{
			alert('Your password must be at least 6 characters. Please enter any combination of letters and numbers, long than 6 characters.');
			return false;
		}
		if(frm.password.value != frm.verifypassword.value)
		{
			alert('Your new password does not match the verify password. Please retype them.');
			return false
		}
	}
	
	
	//Perform various checks on users bid amount, before passing the value
	function checkBid(startBid,currentBid,newbid,bidIncrement,buyItNow)
	{
		
		newbid = parseFloat(newbid);
		if(bidIncrement == 0)
			bidIncrement = 1;
			
		if(newbid < startBid)
		{
			alert('Your bid must be higher than the starting bid value. Pleas enter a new value.');
			return false;
		}
		else if (newbid < currentBid)
		{
			alert('Your bid is lower than the current winning bid value. Please enter a new value. ');
			return false;
		}
		else if ((currentBid -newbid) % bidIncrement != 0)
		{
			alert('Your bid must be incremented by $' + bidIncrement + '. Please bid again.');
			return false;
		}
		else if (newbid > buyItNow)
		{
			return confirm('You have offerred a bid higher then the Buy It Now price. We do not allow the bidding to exceed the BIN price. If you select Okay, we will reduce your bid to $' + (buyItNow - bidIncrement) + '. By clicking Cancel, you can lower your bid or elect to buy the property at the BIN price. Thank you!');
		}

		return true;
	}
	
	//Checks for valid email addresses
	function checkEmail(val)
	{
		var re = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
		if(re.test(val))
			return true;
		else
			return false;
	}
	
	function checkZip(val)
	{
		var re = /^\d{5}$/;
		if(re.test(val))
			return true;
		else
			return false;
	}
	
	function checkPhone(val)
	{
		var re = /^\d{3}-\d{3}-\d{4}$/
		if(re.test(val))
			return true;
		else
			return false;
	}

	function resendValidation()
	{
		var userid = document.getElementById('userid').value;

		window.open('resendValid.php?userid=' + userid,'valid','width=200,height=255');
	}

	function verifyContact(frm)
	{

		var certified = true;
		if(frm.email.value.length == 0)
		{
			document.getElementById("e_email").style.display = "inline";
			certified = false;
		}
		
		if(frm.phone.value.length == 0)
		{
			document.getElementById("e_phone").style.display = "inline";
			certified = false;
		}
	
		if(!checkEmail(frm.email.value))
		{
			alert('Please enter a valid email address.');
			document.getElementById("e_email").style.display = "inline";
			return false;
		}
		
		if(!checkPhone(frm.phone.value))
		{
			alert('Please enter a valid phone number.\n\txxx-xxx-xxxx');
			document.getElementById("e_phone").style.display = "inline";
			return false;
		}
	
		else
		{
			return true;
		}
	}

	function verifyAccount(frm)
	{
		var certified = true;

		if(frm.firstname.value.length == 0)
		{
			document.getElementById("e_firstname").style.display = "inline";
			certified = false;
		}
		if(frm.lastname.value.length == 0)
		{
			document.getElementById("e_lastname").style.display = "inline";
			certified = false;
		}
		if(frm.email.value.length == 0)
		{
			document.getElementById("e_email").style.display = "inline";
			certified = false;
		}
		
		if(frm.username.value.length == 0)
		{
			document.getElementById("e_username").style.display = "inline";
			certified = false;
		}
	
		if(!checkEmail(frm.email.value))
		{
			alert('Please enter a valid email address.');
			document.getElementById("e_email").style.display = "inline";
			return false;
		}

		if(!certified)
		{
			alert('You have incorrectly filled in one or more fields. Please fix the fields marked with a red *. Thank you.');
		}
		return certified;
	}

	function clearMessages()
	{
		var msgs = document.getElementsByTagName("span");

		for(var i=0; i < msgs.length; i++)
		{
			if(msgs[i].className == "error")
			{
				msgs[i].style.display = "none";
			}
		}
	}

