// JavaScript Document


//script for login validation 
function login_validation()
{
	 if (document.Login.txtUsername.value== "" )
	 { 
		 alert ("Please enter the Username");
		 document.Login.txtUsername.focus();
		 return false;
	 }

	 if (document.Login.txtPassword.value== "" )
	 { 
		 alert ("Please enter the Password");
		 document.Login.txtPassword.focus();
		 return false;
	 }
}

function pass_validate()
{
	 if (document.frmChangePass.txtOldPassword.value== "" )
	 { 
		 alert ("Please enter the old Password");
		 document.frmChangePass.txtOldPassword.focus();
		 return false;
	 }
	 if (document.frmChangePass.txtNewPassword.value== "" )
	 { 
		 alert ("Please enter the new Password");
		 document.frmChangePass.txtNewPassword.focus();
		 return false;
	 }
	 if (document.frmChangePass.txtNewPassword.value != document.frmChangePass.txtConfirmPassword.value )
	 { 
		 alert ("New Password & confirm password should be same");
		 document.frmChangePass.txtConfirmPassword.focus();
		 return false;
	 }	 

}

// Script for confirm user before delete.
function calldel(m)
{
	if(!confirm(m))
	{
		return false;
	}
	else
	{
		return true;
	}
}


//script for settnigs validation
function account_validate()
{
	 var  txtCompany= document.frm_accountinfo.txtCompany.value;
	 if ( txtCompany== "" )
	 { 
		 alert ("Please enter Name of the Company");
		 document.frm_accountinfo.txtCompany.focus();
		 return false;
	 }
	 var txtContact= document.frm_accountinfo.txtContact.value;
	 if (txtContact == "" )
	 { 
		 alert ("Please enter Contact Person");
		 document.frm_accountinfo.txtContact.focus();
		 return false;
	 }
	 var txtEmail= document.frm_accountinfo.txtEmail.value;
	 if (txtEmail== "" )
	 { 
		 alert ("Please enter the Email Address");
		 document.frm_accountinfo.txtEmail.focus();
		 return false;
	 }
	 if (!validateEmail(document.frm_accountinfo.txtEmail.value,1,1)) 
	 {
	 document.frm_accountinfo.txtEmail.focus();
	 return false;
	 }
	 var intRows= document.frm_accountinfo.intRows.value;
	 if (intRows== "" )
	 { 
		 alert ("Please enter No of Rows Displayed per page");
		 document.frm_accountinfo.intRows.focus();
		 return false;
	 }
	 if (isNaN(document.frm_accountinfo.intRows.value))
	 { 
		 alert ("No of Rows must be Numeric");
		 document.frm_accountinfo.intRows.focus();
		 return false;
	 }
	 var txtadminpage= document.frm_accountinfo.txtadminpage.value;
	 if (txtadminpage== "" )
	 { 
		 alert ("Please enter Admin Page Title");
		 document.frm_accountinfo.txtadminpage.focus();
		 return false;
	 }
	 var txthomepage= document.frm_accountinfo.txthomepage.value;
	 if (txthomepage== "" )
	 { 
		 alert ("Please enter Home Page Title");
		 document.frm_accountinfo.txthomepage.focus();
		 return false;
	 }
}


//script for Page validation 
function page_validate()
{
	 if (document.frm_page.pagename.value== "" )
	 { 
		 alert ("Please enter the Page Name");
		 document.frm_page.pagename.focus();
		 return false;
	 }

	 if (document.frm_page.pagetitle.value== "" )
	 { 
		 alert ("Please enter the Title");
		 document.frm_page.pagetitle.focus();
		 return false;
	 }
}

//script for Page validation 
function news_validate()
{
	 if (document.frm_news.NewsTitle.value== "" )
	 { 
		 alert ("Please enter the News title");
		 document.frm_news.NewsTitle.focus();
		 return false;
	 }

}



function member_validate()
{
	 if (document.frm_member.FirstName.value== "" )
	 { 
		 alert ("Please enter the First Name");
		 document.frm_member.FirstName.focus();
		 return false;
	 }
	 if (document.frm_member.LastName.value== "" )
	 { 
		 alert ("Please enter the Last Name");
		 document.frm_member.LastName.focus();
		 return false;
	 }
	 if (document.frm_member.Email.value== "" )
	 { 
		 alert ("Please enter the Email");
		 document.frm_member.Email.focus();
		 return false;
	 }
	 if (document.frm_member.Username.value== "" )
	 { 
		 alert ("Please enter the Username");
		 document.frm_member.Username.focus();
		 return false;
	 }
	 if (document.frm_member.Password.value== "" )
	 { 
		 alert ("Please enter the Password");
		 document.frm_member.Password.focus();
		 return false;
	 }	 
}

function member_edit_validate()
{
	 if (document.frm_member.FirstName.value== "" )
	 { 
		 alert ("Please enter the First Name");
		 document.frm_member.FirstName.focus();
		 return false;
	 }
	 if (document.frm_member.LastName.value== "" )
	 { 
		 alert ("Please enter the Last Name");
		 document.frm_member.LastName.focus();
		 return false;
	 }
	 if (document.frm_member.Email.value== "" )
	 { 
		 alert ("Please enter the Email");
		 document.frm_member.Email.focus();
		 return false;
	 }

}


// Valid Email Script
function validateEmail(addr,man,db) {
	if (addr == '' && man) {
	   if (db) alert('Email address is mandatory');
	   return false;
	}
	var invalidChars = '\/\'\\ ";:?!()[]\{\}^|';
	for (i=0; i<invalidChars.length; i++) {
	   if (addr.indexOf(invalidChars.charAt(i),0) > -1) {
		  if (db) alert('Email address contains invalid characters');
		  return false;
	   }
	}
	for (i=0; i<addr.length; i++) {
	   if (addr.charCodeAt(i)>127) {
		  if (db) alert("Email address contains non ascii characters.");
		  return false;
	   }
	}
	var atPos = addr.indexOf('@',0);
	if (atPos == -1) {
	   if (db) alert('Email address must contain an @');
	   return false;
	}
	if (atPos == 0) {
	   if (db) alert('Email address must not start with @');
	   return false;
	}
	if (addr.indexOf('@', atPos + 1) > - 1) {
	   if (db) alert('Email address must contain only one @');
	   return false;
	}
	if (addr.indexOf('.', atPos) == -1) {
	   if (db) alert('Email address must contain a period in the domain name');
	   return false;
	}
	if (addr.indexOf('@.',0) != -1) {
	   if (db) alert('period must not immediately follow @ in email address');
	   return false;
	}
	if (addr.indexOf('.@',0) != -1){
	   if (db) alert('period must not immediately precede @ in email address');
	   return false;
	}
	if (addr.indexOf('..',0) != -1) {
	   if (db) alert('two periods must not be adjacent in email address');
	   return false;
	}
	var suffix = addr.substring(addr.lastIndexOf('.')+1);
	if (suffix.length != 2 && suffix != 'com' && suffix != 'net' && suffix != 'org' && suffix != 'edu' && suffix != 'int' && suffix != 'mil' && suffix != 'gov' & suffix != 'arpa' && suffix != 'biz' && suffix != 'aero' && suffix != 'name' && suffix != 'coop' && suffix != 'info' && suffix != 'pro' && suffix != 'museum') {
	   if (db) alert('invalid primary domain in email address');
	   return false;
	}
return true;
}


//==========================================
// Check all or uncheck all?
//==========================================
<!-- Begin
function Check(chk)
{
	if(document.frmView.chkAll.checked==true)
	{
		for (i = 0; i < chk.length; i++)
			chk[i].checked = true ;
	}
	else
	{
		
		for (i = 0; i < chk.length; i++)
			chk[i].checked = false ;
	}
}

// End -->