function submitForm(name)
{
	err=false;

	/****************Register**************/
	if(name=="register")
	{
		if(document.register.fname.value=='' && err==false)
		{
			alert("Please Enter Your First Name");
			document.register.fname.focus();
			err=true;			
		}
		if(document.register.lname.value=='' && err==false)
		{
			alert("Please Enter Your Last Name");
			document.register.lname.focus();
			err=true;			
		}
		if(document.register.email.value=='' && err==false)
		{
			alert("Please Enter Your Email");
			document.register.email.focus();
			err=true;			
		}

		if(!validateEmail(document.register.email) && err==false)
		{
			alert("Please Enter Valid Email Address");
			document.register.email.focus();
			err=true;			
		}
		if(document.register.password.value=='' && err==false)
		{
			alert("Please Enter Password");
			document.register.password.focus();
			err=true;			
		}
		if(document.register.password.value!=document.register.password2.value && err==false)
		{
			alert("Please Enter Same Password");
			document.register.password.focus();
			err=true;			
		}
	}
	/****************Register**************/
	
	/****************Login**************/
	
	if(name=="login")
	{
		if(document.login.email.value=='' && err==false)
		{
			alert("Please Enter Your Email");
			document.login.email.focus();
			err=true;			
		}

/*		if(!validateEmail(document.login.email) && err==false)
		{
			alert("Please Enter Valid Email Address");
			document.login.email.focus();
			err=true;			
		}
*/		if(document.login.password.value=='' && err==false)
		{
			alert("Please Enter Your Password");
			document.login.password.focus();
			err=true;			
		}

	}
	/****************Login**************/

	
	/****************password**************/
	
	if(name=="password")
	{
		if(document.password.old.value=='' && err==false)
		{
			alert("Please Enter Your old Password");
			document.password.old.focus();
			err=true;			
		}

		if(document.password.password.value!=document.password.password2.value && err==false)
		{
			alert("Please Enter Same Password");
			document.password.password.focus();
			err=true;			
		}
		if(document.password.password.value=='' && err==false)
		{
			alert("Please Enter Your Password");
			document.password.password.focus();
			err=true;			
		}
		if(document.password.password2.value=='' && err==false)
		{
			alert("Please Enter Confirm Password");
			document.password.password2.focus();
			err=true;			
		}

	}
	/****************password**************/

	/****************Edit Summary**************/
	if(name=="summary")
	{
		if(document.summary.fname.value=='')
		{
			alert("Please Enter Your First Name");
			document.summary.fname.focus();
			err=true;			
		}

		if(document.summary.lname.value=='' && err==false)
		{
			alert("Please Enter Your Last Name");
			document.summary.lname.focus();
			err=true;			
		}
		if(document.getElementById("gender1").checked==false && document.getElementById("gender2").checked==false && err==false)
		{
			alert("Please Select Your Gender");
			document.getElementById("gender1").focus();
			err=true;			
		}
		if(document.summary.country.value==0 && err==false)
		{
			alert("Please Select Country");
			document.summary.country.focus();
			err=true;			
		}
		
	}
	/****************summary**************/
	
	/****************Upload Profile Photo Summary**************/
	if(name=="profile_photo")
	{
		if(document.profile_photo.pic.value=='')
		{
			alert("Please Select Image");
			document.profile_photo.pic.focus();
			err=true;			
		}
		else
		{
		      document.getElementById("photoExplanation").style.display = "none";
		      document.getElementById("photoPleaseWait").style.display = "block";
		        document.getElementById("profile_photo").submit();
			  
		}
	}
	/****************Upload Profile Photo Summary**************/
	
	
	/****************Edit community_edit**************/
	if(name=="community_edit")
	{
		if(document.community_edit.name.value=='')
		{
			alert("Please Enter Community Name");
			document.community_edit.name.focus();
			err=true;			
		}
		if(document.community_edit.category.value=="0" && err==false)
		{
			alert("Please Select Community Category");
			document.community_edit.category.focus();
			err=true;			
		}
		if(document.community_edit.language.value=="0" && err==false)
		{
			alert("Please Select Community Language");
			document.community_edit.language.focus();
			err=true;			
		}
		if(document.community_edit.country.value=="0" && err==false)
		{
			alert("Please Select Community Country");
			document.community_edit.country.focus();
			err=true;			
		}

		if(document.community_edit.description.value=='' && err==false)
		{
			alert("Please Enter Description");
			document.community_edit.description.focus();
			err=true;			
		}
	}
	/****************community_edit**************/
	
	
	/****************Message Post**************/
	if(name=="msg_post")
	{
		if(document.msg_post.tid.value=='' && document.msg_post.topic.value=='' )
		{
			alert("Please Enter Subject of Topic");
			document.msg_post.topic.focus();
			err=true;			
		}
		if(document.msg_post.post.value==''  && err==false)
		{
			alert("Please Enter Your Message");
			document.msg_post.post.focus();
			err=true;			
		}
	}
	/****************Message Post**************/
		
	
	
/*	if(err==false)
	document.getElementById(name).submit();
	else return false;*/
	return !err;
}



	  function validateEmail(objField,cap)
{
	var checkError,firstAt,firstDot;

	if(objField.value=="")
		return true;
	checkError = 0;
	firstAt = 0;
	firstDot = 0;

	firstAt = parseInt(objField.value.indexOf('@',0));
	firstDot = parseInt(objField.value.indexOf('.',0));

	if(parseInt(objField.value.charAt(0))>=0 && parseInt(objField.value.charAt(0))<=9)
	{
		checkError = 1;
	}

	if(firstAt>=0)
	{
		if(objField.value.indexOf('@',firstAt+1)>=0)
		{
			checkError = 1;
		}
		if(!findChar(objField.value,'@',2,firstAt,'.'))
		{
			checkError = 1;
		}
	}

	if(firstDot >= 0)
	{
		for(i=0;i<objField.value.length;i++)
		{
			if(objField.value.charAt(i)=='.')
			{
				if(!findChar(objField.value,'.',2,i,'@'))
				{
					checkError = 1;
				}
			}
		}
	}
	else
		checkError = 1;

	if(checkError == 1)
	{
		objField.focus();
		objField.select();
		return false;
	}
	else
		return true;
}
function findChar(string,chr,noOfChar,startPos,charNotInclude)
{
	pos = parseInt(string.indexOf(chr,startPos));
	if(pos>1)
	{
		remChar = string.length - pos;
		if(remChar>2)
		{
			subStringLeft = string.substring(pos-2,pos);
			subStringRight = string.substring(pos+1,pos+3);
			if(subStringLeft.indexOf(charNotInclude,0)>=0 || subStringRight.indexOf(charNotInclude,0)>=0)
				return false;
			else
				return true;
		}
		else
		{
			return false;
		}
	}
	else
	{
		return false;
	}
}
function display(id)
{
document.getElementById(id).style.display = 'block'	
}
function hide(id)
{
document.getElementById(id).style.display = 'none'	
}