// JavaScript Document// JavaScript Document for email validation
function IsEmpty(obj, msg)
{
	
	
	if(obj.value==0)
	{
		if ((msg.length)!=0)
		{
			alert(msg);
			obj.focus();
		}
		return false;
	}
	return true;



}

function IsEmail(val, msg)
{

	con=val.value;
	if(!(IsEmpty(con, "")))
	{
		if ((msg.length)!=0)
		{
			alert(msg);
			val.focus();
		}
		
		
		return false;
	}
	var filter=/^.+@.+\..{2,3}$/
	if (filter.test(con))
		return true;
	else
	{
		if ((msg.length)!=0)
		{
			alert(msg);
			val.focus();
		}
		return false;
	}
	return true;
}


function IsDate(con, msg)
{
	var s=con.value;
	
	if(!(IsEmpty(con, "")))
	{
		if ((msg.length)!=0)
		{
			alert(msg);
		}
		con.focus();

		return false;
	}
	var pos=s.indexOf('-');
	if (pos!=-1)
	{
		var jdate=s.substring(0, pos);
		s=s.substring(pos+1, s.length);		
		pos=s.indexOf('-');
		if (pos!=-1)
		{
			var jmonth=s.substring(0,pos);
			if (jmonth>12)
			{
				if ((msg.length)!=0)
				{
					alert(msg);
				}
				con.focus();

				return false;
			}
			s=s.substring(pos+1, s.length);
			pos=s.indexOf('-');
			if (pos!=-1)
			{
				if ((msg.length)!=0)
				{
					alert(msg);
				}
				con.focus();
				
				return false;
			}
			jyear=s;
			
			if(jyear<1960)
			{
				
				if ((msg.length)!=0)
				{
					alert(msg);
					
				}
				con.focus();

				return false;
			}	
			if(jyear.length!==4)
			{
			
			alert(msg);
			return false;
			
			}
		
			switch(jmonth)
			{
				case '4':
				case '6':
				case '9':
				case '11':
					nodays=30;
					break;
				case '2':
					if(jyear%4==0)
						nodays=29;
				else
					nodays=28;
					break;
				default :
					nodays=31;
			}
			if(jdate>nodays)
			{
				if ((msg.length)!=0)
				{
					alert(msg);
				}
				con.focus();

				return false;
			}
		
		return true;
		
		}
	}
	if ((msg.length)!=0)
	{
		alert(msg);
	}
	con.focus();

	return false;
}
