			// code starts here for checking emails
			
				// Code to Check Email Id
				function checkmail(em)
				
				{
					
					var val=em.value
					var dotIndx;
					var atIndx;
					var startIdx;
					dotIndx=-1
					atIndx=-1
					startIdx=0
					var atCnt=0;
					var dotCnt = 0;
					
					if(val.indexOf("'") != -1)
					{
							alert("Please enter a valid email address.");
							em.focus();
							em.select();
							return  false;
					}
					
					if((val.indexOf(".",startIdx)) == 0 || (val.indexOf("@",startIdx)) == 0)
						{
							alert("Please enter a valid email address.");
							em.focus();
							em.select();
							return  false;
						}
					while ((val.indexOf(".",startIdx)) != -1)
					{
						dotIndx=val.indexOf(".",startIdx)
						startIdx=dotIndx + 1
						if (val.charAt(startIdx) == ".")
							{
								alert( "Please enter a valid email address.");
								em.focus();
								em.select();
								return  false;
							}
						dotCnt = dotCnt + 1;
					}
					
					if (atCnt>2)
					{
						alert( "Please enter a valid email address.");
						em.focus();
						em.select();
						return  false;
					}
					
					startIdx=0
					
					while ((val.indexOf("@",startIdx)) != -1)
					{
						atIndx=val.indexOf("@",startIdx)
						startIdx=atIndx + 1
						atCnt = atCnt+1;
					}
					
					if (dotCnt == 0)
					{
						alert( "Please enter a valid email address.");
						em.focus();
						em.select();
						return  false;
					}
					
					if (dotIndx < atIndx || (dotIndx-atIndx) < 2)
					{
						alert( "Please enter a valid email address.");
						em.focus();
						em.select();
						return  false;
						
					}
					
					if ((val.indexOf("@") != -1) && (val.indexOf(".") != -1) && (val.length > 6))
						
						return  true;
				
					else
						
						{
						
							alert( "Please enter a valid email address.");
							em.focus();
							em.select();
							return  false;
						
						}
					
				}
																			   
			// code ends here for checking emails			
