function validateForm()
{
	trimFields(); //Trim all fields
	//Coupon Code
	if(obj.coupon_code && obj.coupon_code.value != "")
	{
		alert("You have entered a Coupon Code!\nYou must click the 'APPLY' button to avail discount.");
		obj.coupon_code.focus();
		obj.coupon_code.select();
		return;
	}
	//Basic Info
	if(obj.user_name && obj.user_name.value == "")
	{
		alert("Please enter a User Name. It must be unique.\nClick the 'Check' button to check availability.");
		obj.user_name.focus();
		return;
	}
	if(!chkUserName(obj.user_name.value))
	{
		alert("User Name contains illegal characters!\nOnly alphabets and numbers are allowed.");
		obj.user_name.focus();
		obj.user_name.select();
		return;
	}
	if(obj.password.value == "")
	{
		alert("Please enter a Password. It is good to use a strong one.");
		obj.password.focus();
		return;
	}
	if(obj.conf_password.value == "")
	{
		alert("Please re-type the Password.");
		obj.conf_password.focus();
		return;
	}
	if(obj.password.value != obj.conf_password.value)
	{
		alert("The Password and Re-typed Password do not match!");
		obj.conf_password.focus();
		obj.conf_password.select();
		return;
	}
	if(obj.first_name.value == "")
	{
		alert("Please enter the First Name.");
		obj.first_name.focus();
		return;
	}
	if(!chkPersonName(obj.first_name.value))
	{
		alert("First Name contains invalid characters!\nPlease review and correct it.");
		obj.first_name.focus();
		obj.first_name.select();
		return;
	}
	if(obj.last_name.value == "")
	{
		alert("Please enter the Last Name.");
		obj.last_name.focus();
		return;
	}
	if(!chkPersonName(obj.last_name.value))
	{
		alert("Last Name contains invalid characters!\nPlease review and correct it.");
		obj.last_name.focus();
		obj.last_name.select();
		return;
	}
	if(obj.email.value == "")
	{
		alert("Please enter the Email Address.");
		obj.email.focus();
		return;
	}
	if(!chkEmail(obj.email.value))
	{
		alert("Please enter a valid Email Address.\nThe welcome email will be sent to this email.");
		obj.email.focus();
		obj.email.select();
		return;
	}
	if(obj.phone1.value == '')
	{
		alert("Please enter your Phone Number.");
		obj.phone1.focus();
		return;
	}
	if(!chkPhone(obj.phone1.value))
	{
		alert("The Phone Number appears to be invalid.\nIt should be like 999-999-9999.");
		obj.phone1.focus();
		obj.phone1.select();
		return;
	}
	if(obj.fax.value == '')
	{
		alert("Please enter your Fax Number.")
		obj.fax.focus();
		return;
	}
	if(!chkPhone(obj.fax.value))
	{
		alert("The Fax Number appears to be invalid.\nIt should be like 999-999-9999.");
		obj.fax.focus();
		obj.fax.select();
		return;
	}
	//Office Address
	if(obj.o_address1.value == '')
	{
		alert("Please enter the Office Address line 1.\nThe complete office address is displayed on the newsletters.");
		obj.o_address1.focus();
		return;
	}
	if(obj.o_city.value == '')
	{
		alert("Please enter the City for Office Address.\nThe complete office address is displayed on the newsletters.");
		obj.o_city.focus();
		return;
	}
	if(obj.o_state.selectedIndex == 0)
	{
		alert("Please select a State for Office Address.\nThe complete office address is displayed on the newsletters.");
		obj.o_state.focus();
		return;
	}
	if(obj.o_zipcode.value == '')
	{
		alert("Please enter the Zipcode for Office Address.\nThe complete office address is displayed on the newsletters.");
		obj.o_zipcode.focus();
		return;
	}
	if(!chkZip(obj.o_zipcode.value))
	{
		alert("The Zipcode in Office Address appears to be invalid.\nPlease review and correct it.");
		obj.o_zipcode.focus();
		obj.o_zipcode.select();
		return;
	}
	//Billing address
	if(obj.b_address1.value == '')
	{
		alert("Please enter the Billing Address line 1.\nIt should be same as in your Credit Card.");
		obj.b_address1.focus();
		return;
	}
	if(obj.b_city.value == '')
	{
		alert("Please enter the City for Billing Address.\nIt should be same as in your Credit Card.");
		obj.b_city.focus();
		return;
	}
	if(obj.b_state.selectedIndex == 0)
	{
		alert("Please select a State for Billing Address.\nIt should be same as in your Credit Card.");
		obj.b_state.focus();
		return;
	}
	if(obj.b_zipcode.value == '')
	{
		alert("Please enter the Zipcode for Billing Address.\nIt should be same as in your Credit Card.");
		obj.b_zipcode.focus();
		return;
	}
	if(!chkZip(obj.b_zipcode.value))
	{
		alert("The Zipcode in Billing Address appears to be invalid.\nPlease review and correct it.");
		obj.b_zipcode.focus();
		obj.b_zipcode.select();
		return;
	}
	//Sales person assisted
	if(obj.sales_id.selectedIndex == 0)
	{
		alert("Please select a sales person if you received assistance for sign up.");
		obj.sales_id.focus();
		return;
	}
	//Credit Card Info (no cc info for free account)
	if(obj.cc_fname || obj.cc_lname || obj.cc_type || obj.cc_number || obj.exp_month || obj.exp_year || obj.security_code)
	{
		obj.cc_fname.value = obj.cc_fname.value.toUpperCase();
		obj.cc_lname.value = obj.cc_lname.value.toUpperCase();
		if(obj.cc_fname.value == '')
		{
			alert("Please enter your First Name exactly as it appears on your Credit Card.");
			obj.cc_fname.focus();
			return;
		}
		if(obj.cc_lname.value == '')
		{
			alert("Please enter your Last Name exactly as it appears on your Credit Card.");
			obj.cc_lname.focus();
			return;
		}
		if(obj.cc_type.selectedIndex == 0)
		{
			alert("Please select the Credit Card type.");
			obj.cc_type.focus();
			return;
		}
		if(obj.cc_number.value == '')
		{
			alert("Please enter your Credit Card Number.\nDo not put spaces within the numbers.");
			obj.cc_number.focus();
			return;
		}
		if(!chkCCNum(obj.cc_number.value))
		{
			alert("The Credit Card Number appears to be invalid.\nPlease review and correct it.");
			obj.cc_number.focus();
			obj.cc_number.select();
			return;
		}
		if(obj.exp_month.selectedIndex == 0)
		{
			alert("Please select the month of Expiration Date of your Credit Card.");
			obj.exp_month.focus();
			return;
		}
		if(obj.exp_year.selectedIndex == 0)
		{
			alert("Please select the year of Expiration Date of your Credit Card.");
			obj.exp_year.focus();
			return;
		}
		var now = new Date();
		var currMonth = now.getMonth() + 1;
		var currYear = now.getFullYear();
		if(obj.exp_year.value == currYear && obj.exp_month.selectedIndex < currMonth)
		{
			alert("The Credit Card appears to have expired.\nPlease review and enter the correct Expiration Date.");
			obj.exp_month.focus();
			return;
		}
		if(obj.security_code.value == "")
		{
			alert("Please enter the CVV2 Security Code of your Credit Card.");
			obj.security_code.focus();
			return;
		}
	}
	if(obj.accept_terms.checked == false)
	{
		alert("Please accept the terms & conditions of Advisor-Newsletter.com.");
		obj.accept_terms.focus();
		return;
	}
	//All fine?
	obj.action = 'signup.php?opt=signup';
	obj.btnSignUp.disabled = true;
	obj.submit();
}

function copyAddress(chk)
{
	if(chk.checked)
	{
		obj.b_address1.value = obj.o_address1.value;
		obj.b_address2.value = obj.o_address2.value;
		obj.b_city.value = obj.o_city.value;
		obj.b_state.selectedIndex = obj.o_state.selectedIndex;
		obj.b_zipcode.value = obj.o_zipcode.value;
	}
	else
	{
		obj.b_address1.value = '';
		obj.b_address2.value = '';
		obj.b_city.value = '';
		obj.b_state.selectedIndex = '';
		obj.b_zipcode.value = '';
	}
}

function showApply()
{
	trimFields();
	var chkBtn = document.getElementById('chk_coupon_code');
	if(obj.coupon_code.value == "")
	{
		chkBtn.disabled = true;
	}
	else
	{
		chkBtn.disabled = false;
	}
}

function applyCode()
{
	trimFields();
	if(obj.coupon_code.value == "")
	{
		alert("Please enter a Coupon Code to apply discount.");
		obj.coupon_code.focus();
		return;
	}
	//All fine?
	obj.coupon_code.value = obj.coupon_code.value.toUpperCase();
	obj.action = 'signup.php?opt=coupon';
	obj.chk_coupon_code.disabled = true;
	obj.submit();
}

function showCheck()
{
	trimFields();
	var chkBtn = document.getElementById('chk_user_name');
	if(obj.user_name.value == "")
	{
		chkBtn.disabled = true;
	}
	else
	{
		chkBtn.disabled = false;
	}
}

function checkAvailability()
{
	trimFields();
	if(obj.user_name.value == "")
	{
		alert("Please enter a User Name to check.");
		obj.user_name.focus();
		return;
	}
	if(!chkUserName(obj.user_name.value))
	{
		alert("User Name contains illegal characters!\nOnly alphabets and numbers are allowed.");
		obj.user_name.focus();
		obj.user_name.select();
		return;
	}
	//Make AJAX Call to send password by email
	var ajax = new AJAX();
	var arrParam = new Array();
	arrParam['user_name'] = obj.user_name.value;
	ajax.getRequest('check_username.php', arrParam, usernameResponse);
}

function usernameResponse(retVal)
{
	switch(retVal)
	{
		case 'AVAILABLE':
			alert("Congratulations!\nThe User Name '"+obj.user_name.value+"' is available.");
			break;
		case 'NOT_AVAILABLE':
			alert("Sorry!\nThe User Name '"+obj.user_name.value+"' has been already taken.\nPlease choose a different and unique user name.");
			break;
		case 'INVALID':
			alert("Error!\nThe User Name '"+obj.user_name.value+"' is invaild!");
			break;
	}
}

