function checkUserForm(form, password_need)
{
	if (form.first_name.value.length == 0 || form.first_name.value.match(/^[\s]+$/))
	{
	   alert(alert_str_array['firstname_empty']);
	   form.first_name.focus();
  	   form.first_name.select();
	   return false;
	}
	if (form.last_name.value.length == 0 || form.last_name.value.match(/^[\s]+$/))
	{
	   alert(alert_str_array['lastname_empty']);
	   form.last_name.focus();
	   form.last_name.select();
	   return false;
	}
	if (form.phone.value.length == 0 || form.phone.value.match(/^[\s]+$/))
	{
	   alert(alert_str_array['phone_empty']);
	   form.phone.focus();
   	   form.phone.select();
	   return false;
	}
	if (form.phone.value.match(/^[ 0-9\-\+\(\)]+$/g) == null)
	{
	   alert(alert_str_array['phone_not_valid']);
	   form.phone.focus();
	   form.phone.select();
	   return false;
	}
	if (form.email.value.length == 0 || form.email.value.match(/^[\s]+$/))
	{
	   alert(alert_str_array['email_empty']);
	   form.email.focus();
	   return false;
	}
	if (!doMail(form.email.value))
	{
	   alert(alert_str_array['email_not_valid']);
	   form.email.focus();
   	   form.email.select();
	   return false;
	}
	if (form.login)
	{
		if (form.login.value.length == 0 || form.login.value.match(/^[\s]+$/))
		{
		   alert(alert_str_array['login_empty']);
		   form.login.focus();
		   form.login.select();
		   return false;
		}
		re = new RegExp('^[a-zA-Z0-9_]*$');
		if (!re.test(form.login.value))
		{
			alert(alert_str_array['login_included_not_valid_symbol']);
			form.login.focus();
			form.login.select();
			return false;
		}
	}
	if (form.password)
	{
		if (password_need || form.password.value.length > 0 || form.password_confirmation.value.length > 0)
		{
			if (form.password.value.length == 0 || form.password.value.match(/^[\s]+$/))
			{
			   alert(alert_str_array['password_empty']);
			   form.password.focus();
			   form.password.select();
			   return false;
			}
			if (form.password.value.length < 6)
			{
				alert(alert_str_array['password_can_not_be_shorter_6_symbols']);
				form.password.focus();
			    form.password.select();
				return false;
			}
			re = new RegExp('^[a-zA-Z0-9_]*$');
			if (!re.test(form.password.value))
			{
				alert(alert_str_array['password_includes_not_valid_symbol']);
				form.password.focus();
			    form.password.select();
				return false;
			}
			if (form.password_confirmation.value != form.password.value)
			{
			   alert(alert_str_array['password_not_equal_confirmation']);
			   form.password_confirmation.focus();
			   form.password_confirmation.select();
			   return false;
			}
		}
	}
	if (form.address1.value.length == 0 || form.address1.value.match(/^[\s]+$/))
	{
	   alert(alert_str_array['address_empty']);
	   form.address1.focus();
   	   form.address1.select();
	   return false;
	}
	if (form.zip.value.length == 0 || form.zip.value.match(/^[\s]+$/))
	{
	   alert(alert_str_array['zip_empty']);
	   form.zip.focus();
   	   form.zip.select();
	   return false;
	}

	if (form.zip.value.match(/^[ 0-9a-zA-Z]+$/g) == null)
	{
	   alert(alert_str_array['zip_not_valid']);
	   form.zip.focus();
	   form.zip.select();
	   return false;
	}
    return true;
}

function checkQuantity(form)
{
	for (var i=0;i<form.elements.length;i++)
	{
		if (form.elements[i].name.match(/^quantity_[0-9]+/))
		{
			if (form.elements[i].value.match(/^[0-9]+$/) == null)
			{
			   alert(alert_str_array['quantity_not_valid']);
			   form.elements[i].focus();
			   form.elements[i].select();
			   return false;
			}
		}
	}
	return true;
}


function doGetName(str)
{
	var val = "";
	var name = str.match(/^[a-zA-Z0-9\.\-_]+@/);
	if(name)
	{
		if(name[0].substr(0,1) !="." && name[0].substr(name[0].length-2,2) !=".@") val = name[0];
	}
	return val;
}

function doMail(str)
{
	var val = false;
	var temp = str;
	var name = doGetName(str);
	temp = str.replace(name,"");
	var dns = f_validator_DNS(temp);
	temp = temp.replace(dns,"");
	var col = f_validator_Col(dns);
	if(col !=0 && temp == "" && name !="") val = true;
	return val;
}

function f_validator_DNS(str)
{
	var strTemp = "";
	var DNS = str.match(/^[a-zA-Z0-9\.\-]+/);
	if(DNS)
	{
		strTemp = DNS[0];
	}
	return strTemp;
}

function f_validator_Col(str)
{
	var val = 0;
	var arTemp = new Array();
	var arTemp = str.split(".");
	if(arTemp.length>1 && arTemp.length<6)
	{
		var test = true;
		for(var i=0; i<arTemp.length; i++)
		{
			if(arTemp[i]=="") 
			{
				test = false;
			}
			else if(arTemp[i].substr(0,1) == "-" || arTemp[i].substr(arTemp[i].length-1,1) == "-")
			{
				test = false;
			}
		}
		if(test) val = arTemp.length;
	}
	return val;
}