function chk_dealer_create(oForm)
{
	var oForm = document.frm_create;
	
	var username = strtrim(oForm.username.value);
	var firstname = strtrim(oForm.first_name.value);
	var lastname = strtrim(oForm.last_name.value);
	var password = strtrim(oForm.password.value);
	var password2 = strtrim(oForm.password2.value);
	if((username == "")||(!is_alphabet(username.substring(0,1))))
	{
		alert("Invalid User Name.\nThe username cannot be empty and it must start with an alphabet.");
		oForm.username.focus();
		oForm.username.select();
		return false;
	}
	if(password == "")
	{
			alert("Invalid Password.\nThe password cannot be empty.");
			oForm.password.focus();
			oForm.password.select();
			return false;
	}
	if(password != password2)
	{
			alert("Invalid Password.\nThe password must be same.");
			oForm.password.focus();
			oForm.password.select();
			return false;
	}
	if((lastname == "")||(!is_alphabet(lastname.substring(0,1))))
	{
		alert("Invalid Last Name.\nThe last name cannot be empty and it must start with an alphabet.");
		oForm.last_name.focus();
		oForm.last_name.select();
		return false;
	}
	if(firstname != "")
	{
		if(!is_alphabet(firstname.substring(0,1)))
		{
			alert("Invalid First Name.\nThe first name must start with an alphabet.");
			oForm.first_name.focus();
			oForm.first_name.select();
			return false;
		}
	}
	if(strtrim(oForm.email.value) != "")
	{
		if(!is_email(strtrim(oForm.email.value)))
		{
			alert("Invalid Email Address.");
			oForm.email.focus();
			oForm.email.select();
			return false;
		}
	}
	oForm.action = "";
	oForm.method = "post";
	oForm.submit();
}

function check_add_boat(oForm){
	/*if(strtrim(oForm.name.value) == ''){
		alert('Error: Cannot leave \'name\' field empty.');
		oForm.name.focus();
		return false;
	}*/
	if(strtrim(oForm.email.value) == ''){
		alert('Error: Cannot leave \'username\' field empty.');
		oForm.email.focus();
		return false;
	}
	if(!is_email(strtrim(oForm.email.value))){
		alert('Error: Invalid \'email\' entered.');
		oForm.email.focus();
		oForm.email.select();
		return false;
	}
	if (strtrim(oForm.pwd.value) == ''){
		alert('Error: Cannot leave \'password\' field empty.');
		oForm.pwd.focus();
		return false;
	 }
	 if (strtrim(oForm.pwd.value) != strtrim(oForm.confpwd.value)){
		alert("Please enter confirm password correctly.");
		oForm.confpwd.focus();
		return false;
	 }
	  if(strtrim(oForm.phone.value) == ''){
		alert('Error: Cannot leave \'phone\' field empty.');
		oForm.phone.focus();
		return false;
	}
	if(strtrim(oForm.price.value) == ''){
		alert('Error: Cannot leave \'price\' field empty.');
		oForm.price.focus();
		return false;
	}
	if(strtrim(oForm.city.value) == 'other'){
		alert('Error: Please select city.');
		oForm.city.focus();
		return false;
	}
	if(strtrim(oForm.make.value) == ''){
		alert('Error: Cannot leave \'make\' field empty.');
		oForm.make.focus();
		return false;
	}
	/*if(strtrim(oForm.model.value) == ''){
		alert('Error: Cannot leave \'model\' field empty.');
		oForm.model.focus();
		return false;
	}*/
	if(strtrim(oForm.length.value)!='' && !isInt(oForm.length)){
		alert('Error: Only numbers are allowed in \'boat length\' field.');
		oForm.length.focus();
		return false;
	}
	if(strtrim(oForm.beam.value)!='' && !isInt(oForm.beam)){
		alert('Error: Only numbers are allowed \'beam\' field.');
		oForm.beam.focus();
		return false;
	}
	if(strtrim(oForm.draft.value)!='' && !isInt(oForm.draft)){
		alert('Error: Only numbers are allowed in \'draft\' field.');
		oForm.draft.focus();
		return false;
	}
	if(strtrim(oForm.engine_hours.value)!='' && !isInt(oForm.engine_hours)){
		alert('Error: Only numbers are allowed in \'engine hours\' field.');
		oForm.engine_hours.focus();
		return false;
	}
	if(strtrim(oForm.horsepower.value)!='' && !isInt(oForm.horsepower)){
		alert('Error: Only numbers are allowed in \'horse power\' field.');
		oForm.horsepower.focus();
		return false;
	}
	if(strtrim(oForm.cruising_speed.value)!='' && !isInt(oForm.cruising_speed)){
		alert('Error: Only numbers are allowed in \'cruising speed\' field.');
		oForm.cruising_speed.focus();
		return false;
	}
	if(strtrim(oForm.max_speed.value)!='' && !isInt(oForm.max_speed)){
		alert('Error: Only numbers are allowed in \'max speed\' field.');
		oForm.max_speed.focus();
		return false;
	}
	if(strtrim(oForm.water.value)!='' && !isInt(oForm.water)){
		alert('Error: Only numbers are allowed in \'water\' field.');
		oForm.water.focus();
		return false;
	}
	if(strtrim(oForm.fuel_capacity.value)!='' && !isInt(oForm.fuel_capacity)){
		alert('Error: Only numbers are allowed in fuel \'capacity\' field.');
		oForm.fuel_capacity.focus();
		return false;
	}
	return true;	
}


function gotoPage(pageNum){
	redirect_to('index.php?m=oth&a=dealer_list&pnum='+pageNum);
}

function gotoPageSurveyor(pageNum){
	redirect_to('index.php?m=oth&a=surveyor_list&pnum='+pageNum);
}

