function validate()
{
	
		var loginname=document.frmlogin.txtusername;
		var loginpassword=document.frmlogin.txtpassword;
		if(loginname.value=="" || loginname.value==null)
		{
				alert("Please Enter Username or Password");
				return false;
		}
			//return true;
				
		if(loginpassword.value=="" || loginpassword.value==null)
		{
				alert("Please Enter Username or Password");
				return false;
		}
			return true;
				
}
//**********************************************************************
function validate_catdoc()
{
		var val=document.adddocumentcategory.txtcategoryname;
		if(val.value=="" || val.value==null)
		{
				alert("Please Enter the Category Name");
				document.adddocumentcategory.txtcategoryname.focus();
				return false;
		}
		return true;
}
//**********************************************************************
function validate_linkcat()
{
		var val=document.addlinkcategory.txtcategoryname;
		if(val.value=="" || val.value==null)
		{
			alert("Please Enter the Category Name");
			document.addlinkcategory.txtcategoryname.focus();
			return false;
		}
	return true;				
}
//************************************************************************
function validate_addlink()
{
	var i;
	var val=document.addlink;
	if(val.txtlinkname.value=="" || val.txtlinkname.value==null )
	{
		alert("Please Enter the Link Name");
		return false;
	}
	var vv=val.sellinkcategory;
	if(vv.length==0)
	{
		alert("Please select category for link");
		return false;
	}
		
	for(i=0;i<val.isurl.length;i++)
	{
		if(val.isurl[i].checked)
		{
			var yeah=val.isurl[i].value;
			
			if(yeah=="yes")
			{
				if(val.linkurl.value.indexOf("http://",0) == -1) 
				{
					alert("Please Enter a valid URL")
					return false;
				}
			
			}
			else 
			{
				if(val.txtdescription.value=="" || val.txtdescription.value==null)
				{
					alert("Please Enter Text Description");
					return false;
				}
	
			}
		}	
	}
	
	return true;
}
//******************************************************************************
function validate_document()
{
	var val=document.adddocument;
	if(val.txtdocumentname.value=="" || val.txtdocumentname.value==null)
	{
		alert("Please Enter Document Name");
		return false;
	}
	var vv=val.seldocumentcategory;
	if(vv.length==0)
	{
		alert("Please select category for document");
		return false;
	}
	if(val.txtdescription.value=="" || val.txtdescription.value==null)
	{
		alert("Please Write Document Description");
		return false;
	}
	if(val.uploadfile.value=="" || val.uploadfile.value==null)
	{
		alert("Please Browse a file for Uploading");
		return false;
	}
	return true;
}

//******************************************************************************
function validate_user()
{
	var val=document.adduser;
	if(val.txtusername.value=="" || val.txtusername.value==null)
	{
		alert("None of the Field Should be Blank.Please Enter Values");
		return false;
	}
	if(val.txtpassword.value=="" || val.txtpassword.value==null)
	{
		alert("None of the Field Should be Blank.Please Enter Values");
		return false;
	}
	if(val.txtname.value=="" || val.txtname.value==null)
	{
		alert("None of the Field Should be Blank.Please Enter Values");
		return false;
	}
	//*******************************************Validate Email
	
		var str=val.txtemail.value;	
		var at="@";
		var dot=".";
		var lat=str.indexOf(at);
		var lstr=str.length;
		var ldot=str.indexOf(dot);
		if(str.indexOf(at)==-1)
		{
		  alert("Invalid E-mail ID");
		  return false;
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr)
		{
		   alert("Invalid E-mail ID");
		   return false;
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr)
		{
		   alert("Invalid E-mail ID");
		   return false;
		}

		 if (str.indexOf(at,(lat+1))!=-1)
		 {
		   alert("Invalid E-mail ID");
		   return false;
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot)
		 {
		    alert("Invalid E-mail ID");
		    return false;
		 }

		 if (str.indexOf(dot,(lat+2))==-1)
		 {
		   alert("Invalid E-mail ID");
		   return false;
		 }
		
		 if (str.indexOf(" ")!=-1)
		 {
		   alert("Invalid E-mail ID");
		   return false;
		 }
	
	//***************************************************************************
	if(val.txtemail.value=="" || val.txtemail.value==null)
	{
		alert("None of the Field Should be Blank.Please Enter Values");
		return false;
	}
	return true;
}
//*********************************************************************************

function validate_editlink()
{
	var i;
	var val=document.editlink;
	if(val.txtlinkname.value=="" || val.txtlinkname.value==null )
	{
		alert("Please Enter the Link Name");
		return false;
	}
	var vv=val.sellinkcategory;
	if(vv.length==0)
	{
		alert("Please select category for link");
		return false;
	}
	for(i=0;i<val.isurl.length;i++)
	{
		if(val.isurl[i].checked)
		{
			var yeah=val.isurl[i].value;
			
			if(yeah=="yes")
			{
				if(val.linkurl.value.indexOf("http://",0) == -1) 
				{
					alert("Please Enter a valid URL")
					return false;
				}
			
			}
			else 
			{
				if(val.txtdescription.value=="" || val.txtdescription.value==null)
				{
					alert("Please Enter Text Description");
					return false;
				}
			}
		}	
	}
	
	return true;
}
//**************************************************************************

function validate_editdocument()
{
	var val=document.adddocument;
	if(val.txtdocumentname.value=="" || val.txtdocumentname.value==null)
	{
		alert("Please Enter Document Name");
		return false;
	}
	var vv=val.seldocumentcategory;
	if(vv.length==0)
	{
		alert("Please select category for document");
		return false;
	}
	if(val.txtdescription.value=="" || val.txtdescription.value==null)
	{
		alert("Please Enter Document Description");
		return false;
	}
	
	return true;
}
//*****************************************************************************
function validate_addnews()
{
	var val=document.addnews;
	if(val.txtnewsname.value=="" || val.txtnewsname.value==null)
	{
		alert("Please Enter News Name");
		return false;
	}
	
	if(val.txtdescription.value=="" || val.txtdescription.value==null)
	{
		alert("Please Enter News Description");
		return false;
	}
	
	return true;
}
//****************************************************************************

function validate_editnews()
{
	var val=document.editnews;
	if(val.txtnewsname.value=="" || val.txtnewsname.value==null)
	{
		alert("Please Enter News Name");
		return false;
	}
	
	if(val.txtdescription.value=="" || val.txtdescription.value==null)
	{
		alert("Please Enter News Description");
		return false;
	}
	return true;
}

//**************************************************************************

function redirectMe () 
{
		var mm=document.calendar.month;
		var m=mm.options[mm.selectedIndex].value;
		var yy=document.calendar.year;
		var yr=yy.options[yy.selectedIndex].value;
		if(m !="no" && yr !="no")
 		{
 			document.calendar.submit();
 		}
}
//**************************************************************************

function validate_addevent()
{
		var val=document.addevent;
		if(val.txteventname.value == "" || val.txteventname.value==null)
		{
			alert("Please Enter Event Title");
			return false;
		}
		var val=document.addevent;
		if(val.description1.value=="" || val.description1.value==null)
		{
			alert("Please Enter Event description");
			return false;
		}
		return true;
}
function password_recovery()
{
	if(document.passwordrecovery.email.value=="" || document.passwordrecovery.email.value==null)
	{
		alert("Please Enter Email ID");
		return false;
	}
	return true;
}

