function checkvalid()
{
	if(validate() == true)
	{
		document.frmlregistrationvet.submit();		
	}
}

function validate()
{
	var selposition = document.frmlregistrationvet.selposition.value;
	if(selposition == "0")
	{
		alert("Please select Registration Position");
		document.frmlregistrationvet.selposition.focus();
		return false;
	}

	var name = document.frmlregistrationvet.name.value;
	if(ltrim(name).length < 1)
	{
		alert("Please enter your Name");
		document.frmlregistrationvet.name.focus();
		return false;
	}

	var address1 = document.frmlregistrationvet.address1.value;
	if(ltrim(address1).length < 1)
	{
		alert("Please enter Address Line 1");
		document.frmlregistrationvet.address1.focus();
		return false;
	}

	var county = document.frmlregistrationvet.county.value;
	if(county == "0")
	{
		alert("Please select your County");
		document.frmlregistrationvet.county.focus();
		return false;
	}

	var postalcode = document.frmlregistrationvet.postalcode.value;
	if(ltrim(postalcode).length < 1)
	{
		alert("Please enter your Postal Code");
		document.frmlregistrationvet.postalcode.focus();
		return false;
	}

	var region = document.frmlregistrationvet.region.value;
	if(region == "0")
	{
		alert("Please enter your Region");
		document.frmlregistrationvet.region.focus();
		return false;
	}

	var phoneno = document.frmlregistrationvet.phoneno.value;
	if(ltrim(phoneno).length < 1)
	{
		alert("Please enter your Telephone Number");
		document.frmlregistrationvet.phoneno.focus();
		return false;
	}

	var emailid = document.frmlregistrationvet.emailid.value;
	if(emailid.length > 0)
	{
		if(isvalid_email(emailid) == false)
		{
			alert("Please check your Email Id");
			document.frmlregistrationvet.emailid.focus();
			return false;
		}
	}

	var q_year = document.frmlregistrationvet.selqualyear.value;
	
	if(q_year == "0")
	{
		alert("Please select Qualifying Year");
		document.frmlregistrationvet.selqualyear.focus();
		return false;
	}

	var d_date = document.frmlregistrationvet.d_date.value;
	var d_month = document.frmlregistrationvet.d_month.value;
	var d_year = document.frmlregistrationvet.d_year.value;

	if(d_date != "" || d_month != "" || d_year != "")
	{
		if(d_date == "")
		{
			alert("Please select birth date");
			document.frmlregistrationvet.d_date.focus();
			return false;
		}
		if(d_month == "")
		{
			alert("Please select birth month");
			document.frmlregistrationvet.d_month.focus();
			return false;
		}
		if(d_year == "")
		{
			alert("Please select birth year");
			document.frmlregistrationvet.d_year.focus();
			return false;
		}
	}

	var chkqualified = document.frmlregistrationvet.chkqualified.checked;
	var chklisted = document.frmlregistrationvet.chklisted.checked;
	var chkunqualified = document.frmlregistrationvet.chkunqualified.checked;
	var chkAssessor = document.frmlregistrationvet.chkAssessor.checked;
	
	if(chkqualified == false && chklisted == false && chkunqualified == false && chkAssessor == false)
	{
		alert("Please select a skill");
		document.frmlregistrationvet.chkqualified.focus();
		return false;
	}

	var a_date = document.frmlregistrationvet.a_date.value;
	var a_month = document.frmlregistrationvet.a_month.value;
	var a_year = document.frmlregistrationvet.a_year.value;

	if(a_date == "" || a_month == "" || a_year == "")
	{
		alert("Please select Date Available");
		document.frmlregistrationvet.a_date.focus();
		return false;
	}

	return true;
}

function intval(str)
{
	return parseInt(str,10);
}

function isvalid_hour(hour)
{
	var inthour = intval(hour);
	if(isNaN(inthour) == true)
	{
		return false;
	}
	if(inthour < 0 || inthour >= 12)
	{
		return false;
	}
	return true;
}

function isvalid_min(minute)
{
	var intminute = intval(minute);
	if(isNaN(intminute) == true)
	{
		return false;
	}
	if(intminute < 0 || intminute >= 60)
	{
		return false;
	}
	return true;
}

function ltrim(str)
{
	var i;
	var newstr = "";
	var char;
	var flag = 0;

	for(i=0;i<str.length;i++)
	{
		char = str.charAt(i);
		if(char >= 'a' && char <= 'z')
		{
			newstr = newstr.concat(char);
			flag = 1;
		}
		if(char >= 'A' && char <= 'Z')
		{
			newstr = newstr.concat(char);
			flag = 1;
		}
		if(char >= '0' && char <= '9')
		{
			newstr = newstr.concat(char);
			flag = 1;
		}	
		if(flag == 1)
		{
			if(char == ' ' || char == "-" || char == '-')
			{
				newstr = newstr.concat(char);
			}
		}
	}
	return newstr;
}

function isvalid_cardno(str)
{
	if(isNaN(Number(str)) == true)
	{
		return false;
	}
	if(ltrim(str).length < 10)
	{
		return false;
	}
	return true;
}

function isvalid_telno(str)
{
	if(isNaN(Number(str)) == true)
	{
		return false;
	}
	else
	{
		return true;
	}
}

var emailfilter=/^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/i;

function isvalid_email(str)
{
	return emailfilter.test(str);
}



