// JavaScript Document

function checkContact()
{
	if(document.getElementById('Name').value == '')
	{
		alert('You must fill in the name field in order to continue.');
		document.getElementById('Name').focus();
		return false;
	}
	if(document.getElementById('Email').value == '')
	{
		alert('You must fill in the email field in order to continue.');
		document.getElementById('Email').focus();
		return false;
	}
	if(document.getElementById('Comments').value == '')
	{
		alert('You must fill in the comments field in order to continue.');
		document.getElementById('Comments').focus();
		return false;
	}
	document.getElementById('form_submit').submit();
	return true;
}

function confirmSignup()
{
	//check to make sure required fields are present
	if(document.getElementById("first_name").value == "")
	{
		alert("You must enter a first name in order to continue");
		document.getElementById("first_name").focus();
		
		return false;
	}
	
	if(document.getElementById("last_name").value == "")
	{
		alert("You must enter a last name in order to continue");
		document.getElementById("last_name").focus();
		
		return false;
	}
	
	if(document.getElementById("email").value == "")
	{
		alert("You must enter an email address in order to continue");
		document.getElementById("email").focus();
		
		return false;
	}
	
	if(document.getElementById("password").value == "")
	{
		alert("You must enter a password in order to continue");
		document.getElementById("password").focus();
		
		return false;
	}
	
    var valid="123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*()-_";

    for(var i = 0; i < length; i++)
	{
        if(valid.indexOf(string.charAt(i)) < 0)
		{
			alert("The password cannot contain special characters");
			
			document.getElementById("password").value         = "";
			document.getElementById("confirm_password").value = "";
			
			document.getElementById("password").focus();
		
            return false;
        }
    }
	
	if(document.getElementById("city").value == "")
	{
		alert("You must enter a city in order to continue");
		document.getElementById("city").focus();
		
		return false;
	}
	
	if(document.getElementById("state").value == "")
	{
		alert("You must enter a state in order to continue");
		document.getElementById("state").focus();
		
		return false;
	}
	
	if(document.getElementById("zip").value == "")
	{
		alert("You must enter a zip code in order to continue");
		document.getElementById("zip").focus();
		
		return false;
	}
	
	if(document.getElementById("country").value == "")
	{
		alert("You must enter a country in order to continue");
		document.getElementById("country").focus();
		
		return false;
	}
	document.getElementById('form_signup').submit();
	return true;
}

function checkAccountUpdate()
{
	if(document.getElementById("email").value == "")
	{
		alert("You must enter an email address in order to continue");
		document.getElementById("email").focus();
		
		return false;
	}	
	
	//check to make sure passwords match
	if(document.getElementById("password").value != document.getElementById("confirm_password").value)
	{
		alert("The password and confirmation do not match.  Please try again.");
		
		document.getElementById("password").value         = "";
		document.getElementById("confirm_password").value = "";
		
		document.getElementById("password").focus();
		
		return false;
	}
	
    var valid="123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*()-_";

    for(var i = 0; i < length; i++)
	{
        if(valid.indexOf(string.charAt(i)) < 0)
		{
			alert("The password cannot contain special characters");
			
			document.getElementById("password").value         = "";
			document.getElementById("confirm_password").value = "";
			
			document.getElementById("password").focus();
		
            return false;
        }
    }
	
	//check to make sure required fields are present
	if(document.getElementById("first_name").value == "")
	{
		alert("You must enter a first name in order to continue");
		document.getElementById("first_name").focus();
		
		return false;
	}
	
	if(document.getElementById("last_name").value == "")
	{
		alert("You must enter a last name in order to continue");
		document.getElementById("last_name").focus();
		
		return false;
	}
	
	if(document.getElementById("phone").value == "")
	{
		alert("You must enter a phone in order to continue");
		document.getElementById("phone").focus();
		
		return false;
	}
	
	if(document.getElementById("address1").value == "")
	{
		alert("You must enter a address1 in order to continue");
		document.getElementById("address1").focus();
		
		return false;
	}
	
	if(document.getElementById("city").value == "")
	{
		alert("You must enter a city in order to continue");
		document.getElementById("city").focus();
		
		return false;
	}
	
	if(document.getElementById("state").value == "")
	{
		alert("You must enter a state in order to continue");
		document.getElementById("state").focus();
		
		return false;
	}
	
	if(document.getElementById("zip").value == "")
	{
		alert("You must enter a zip in order to continue");
		document.getElementById("zip").focus();
		
		return false;
	}
	
	if(document.getElementById("country").value == "")
	{
		alert("You must enter a country in order to continue");
		document.getElementById("country").focus();
		
		return false;
	}
	
	document.getElementById("form_update").submit();
	return true;
}