function formValidation(frmSendMail)
	{
		var bCorrect = 0;
		var strEmail = "";
		var strName  = "";
		var strMessage = "";
		
		strEmail = document.frmSendMail.txtEmail.value;
		strName =  document.frmSendMail.txtName.value;
		strMessage = document.frmSendMail.txtareaSubject.value;
			
		//Email address checking starts 	
		var str_current_character;
		var b_valid_email,b_period_present; 
		var i_last_position_of_period,b_correct_length_extension;
		var i_num_at_symbol=0;
		var i_pos_at_symbol;
		var i_length_of_server_name=1;
		var i_pos_consecutive_dots;
		var strEmail=new String(func_trim(strEmail));
		i_length=strEmail.length;
		b_period_present=1;
		b_correct_length_extension=1;
		i_last_position_of_period=0;
	
		if(i_length==0)
		{
			bCorrect = 1;
			alert("Please give your email address");
			document.frmSendMail.txtEmail.focus();
			return false;
		}
	
		for(i_loop=0; i_loop<i_length; i_loop++)
		{
			if(!((strEmail.charCodeAt(i_loop)>=65 && strEmail.charCodeAt(i_loop)<=90)
		 	 	|| (strEmail.charCodeAt(i_loop)>=97 && strEmail.charCodeAt(i_loop)<=122)
		  		|| (strEmail.charCodeAt(i_loop)>=48 && strEmail.charCodeAt(i_loop)<=57)
			 	|| (strEmail.charAt(i_loop)=="@")
			  	|| (strEmail.charAt(i_loop)=="_")
			  	|| (strEmail.charAt(i_loop)=="-")
		  		|| (strEmail.charAt(i_loop)==".")))
			{
				bCorrect = 1;
				alert("Invalid Email address");
				document.frmSendMail.txtEmail.value = " ";
				document.frmSendMail.txtEmail.focus();
				return false;
			}
		}
	
		i_pos_consecutive_dots=strEmail.indexOf('..');
		if(i_pos_consecutive_dots!=-1)
		{
			bCorrect = 1;
			alert("Invalid Email address");
			document.frmSendMail.txtEmail.value = " ";
			document.frmSendMail.txtEmail.focus();
			return false;
		}
	
		var i_pos_space;
		i_pos_space = strEmail.indexOf(' ');
		if(i_pos_space!=-1)
		{
			bCorrect = 1;
			alert("Invalid Email address");
			document.frmSendMail.txtEmail.value = " ";
			document.frmSendMail.txtEmail.focus();
			return false;
		}
	
		i_last_position_of_period = strEmail.lastIndexOf('.');
		if(i_last_position_of_period<=0)
		{
			b_period_present=0;
		}	
	
		if(((i_length-i_last_position_of_period)>4) || ((i_length-i_last_position_of_period)<3))
		{
			b_correct_length_extension=0;
		}
	
		for(i_loop=0;i_loop<=i_length;i_loop++)
		{
			str_current_character=strEmail.charAt(i_loop);
			if (str_current_character=='@')
			{
				i_num_at_symbol=i_num_at_symbol + 1;
			}
		}
	
		if(i_num_at_symbol!=1)
		{
			bCorrect = 1;
			alert("Invalid Email address");
			document.frmSendMail.txtEmail.value = " ";
			document.frmSendMail.txtEmail.focus();
			return false;
		}	
	
		i_pos_at_symbol = strEmail.indexOf('@');
		if(strEmail.charAt(i_pos_at_symbol+1) == '.')
		{
			i_length_of_server_name=0;
		}
	
		if((i_num_at_symbol==1) && (b_period_present==1) && (b_correct_length_extension==1) && (i_length_of_server_name==1))
		{
			b_valid_email=1;
		}
		else
		{
			 b_valid_email=0;
		}
	
		if(b_valid_email==0)
		{
			bCorrect = 1;
			alert("Invalid Email address");
			document.frmSendMail.txtEmail.value = " ";
			document.frmSendMail.txtEmail.focus();
			return false;
		}
		/*else
		{
			return true;
		}*/
		//Email address checking ends 
		
		//Name field checking starts 
		
		var strName = new String(func_trim(strName));
		i_length = strName.length;
		if(i_length == 0 )
		{			
			bCorrect = 1;	
			alert("Please give your name");
			document.frmSendMail.txtName.focus();
			return false;
		}
		/*else
		{
			if(i_length >50 )
			{
				alert("Name field cannot be blank.");
				bCorrect = 1;				
			}
		}*/
		
		//Name field checking ends 
		
		strMessage = new String(func_trim(strMessage));
		i_length = strMessage.length;
		if(i_length == 0 )
		{			
			bCorrect = 1;	
			alert("Please give your message");
			document.frmSendMail.txtareaSubject.focus();
			return false;
		}
		//Message field checking starts
		
		
		//Message field checking ends
		
		function func_trim(param_text)
		{
			var str_text=new String(param_text);
			var str_return_text;
			str_return_text="";
			b_non_blank_started=false;
			b_non_blank_ended=false;
			str_intermediate_blank_chunk="";
			var i_loop;
			for(i_loop=0;i_loop<str_text.length;i_loop++)
			{
				if(str_text.charCodeAt(i_loop)!=32)
				{
					if(!b_non_blank_started)
					{
						b_non_blank_started=true;
					}
					if(b_non_blank_started && !b_non_blank_ended)
					{
						str_return_text+=str_text.charAt(i_loop);
					}
					if(b_non_blank_ended)
					{
						str_return_text+=(str_intermediate_blank_chunk+str_text.charAt(i_loop));
						b_non_blank_ended=false;
						str_intermediate_blank_chunk="";
					}
				}
				else
				{
					if(b_non_blank_started)
					{
						b_non_blank_ended=true;
						str_intermediate_blank_chunk+=" ";
					}
				}
			}
			return str_return_text;
		}

		if(bCorrect == 0)
				{						
					//frmSendMail.submit();
					//alert("Data Inserted successfully");
					return true;			
				}
				else
				{
					return false;
				}						
		
	
}//end function validation

function focus()
{
	document.frmSendMail.txtEmail.focus();

}//end function focus

	
//openWindow
function openWindow(str_url)
{
	var i_popup_left=(screen.width-600)/2;
	var i_popup_top=(screen.height-600)/2;
	var supplementBars='directories=no,location=no,menubar=no,status=no,titlebar=no,toolbar=no,verticalbar=no';
	var supplementOptions='scrollbars=yes,width='+ 350 +',height='+200 +',left='+i_popup_left+',top='+i_popup_top+',resizeable=yes';
	var supplementFeatures=supplementBars + ',' + supplementOptions;
	var supplementReadme='Supplement Details....';
	window.open(str_url,'Supplement_Details',supplementFeatures);
}


