// JavaScript Document

function val()
{
var txtUsername=document.login.username.value;
	 if(txtUsername == "")
			 {
			 alert("Username is empty");
			 document.login.username.focus();
			 return false;
			 }
var txtPassword=document.login.passwd.value;
	 if(txtPassword == ""){
			 alert("Password is empty");
			 document.login.passwd.focus();
			 return false;
	}
	
document.login.submit();
}



function pass_validate()
{
	     var Old = document.frm_change.Old.value;
		 if (Old == "" )
		 { 
			 alert ("Please enter Your Old Password");
			 document.frm_change.Old.focus();
			 return false;
		 }
		 var Password = document.frm_change.Password.value;
		 if (Password == "" )
		 { 
			 alert ("Please enter Your New Password");
			 document.frm_change.Password.focus();
			 return false;
		 }
		 var Conpassword = document.frm_change.Conpassword2.value;
		 if (Conpassword == "" )
		 { 
			 alert ("Please enter Your Confirm Password");
			 document.frm_change.Conpassword2.focus();
			 return false;
		 }
		 var Conpassword = document.frm_change.Conpassword2.value;
		 if (document.frm_change.Conpassword2.value != document.frm_change.Password.value)
		 { 
			 alert ("Password and Confirm Password must be same");
			 document.frm_change.Conpassword2.focus();
			 return false;
		 }
return true;
}

function myprofile_validate(){



	if (document.form_myprofile.txt_contactperson.value == "") 

		{

			alert ("Please Enter the Contact Person name.");

			document.form_myprofile.txt_contactperson.focus();

			return false;

		}

		if (!validateEmail(document.form_myprofile.txt_email.value,1,1)) 

		{

			document.form_myprofile.txt_email.focus();

			return false;

		}

		if (!validateEmail(document.form_myprofile.txt_email.value,1,1)) 

		{

			document.form_myprofile.txt_email.focus();

			return false;

		}

		if (document.form_myprofile.txt_address1.value == "") 

		{

			alert ("Please Enter the Address.");

			document.form_myprofile.txt_address1.focus();

			return false;

		}

		//if (document.form_myprofile.txt_address2.value == "") 

//		{

//			alert ("Please Enter the Address2.");

//			document.form_myprofile.txt_address2.focus();

//			return false;

//		}

		if (document.form_myprofile.txt_city.value == "") 

		{

			alert ("Please Enter the City.");

			document.form_myprofile.txt_city.focus();

			return false;

		}

		if (document.form_myprofile.txt_state.value == "") 

		{

			alert ("Please Enter the State.");

			document.form_myprofile.txt_state.focus();

			return false;

		}

		recordvalue = document.form_myprofile.txt_postcode.value;

		if( (recordvalue == "")  || (recordvalue == 0) || isNaN(recordvalue) ||  (recordvalue.indexOf("-") >= 0) || (recordvalue.indexOf(".") >= 0) ){

			alert ("Please enter the valid Postcode.");

			document.form_myprofile.txt_postcode.focus();

			return false;

		}

		if (document.form_myprofile.txt_country.value == "") 

		{

			alert ("Please Enter the Country.");

			document.form_myprofile.txt_country.focus();

			return false;

		}

		if (document.form_myprofile.txt_phone.value == "") 

		{

			alert ("Please Enter the Phone Number.");

			document.form_myprofile.txt_phone.focus();

			return false;

		}

		//if (document.form_myprofile.txt_mobile.value == "") 

//		{

//			alert ("Please Enter the Mobile Number.");

//			document.form_myprofile.txt_mobile.focus();

//			return false;

//		}

		//if (document.form_myprofile.txt_fax.value == "") 

//		{

//			alert ("Please Enter the Fax Number.");

//			document.form_myprofile.txt_fax.focus();

//			return false;

//		}

		if (document.form_myprofile.txt_username.value == "") 

		{

			alert ("Please Enter the Username.");

			document.form_myprofile.txt_username.focus();

			return false;

		}

		if (document.form_myprofile.txt_password.value == "") 

		{

			alert ("Please Enter the Password.");

			document.form_myprofile.txt_password.focus();

			return false;

		}

}

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;

}

<!--
var letters='ABCÇDEFGHIJKLMNÑOPQRSTUVWXYZabcçdefghijklmnñopqrstuvwxyzàáÀÁéèÈÉíìÍÌïÏóòÓÒúùÚÙüÜe'
var numbers='1234567890'
var empty=''
var special='.'
var price='x'


function mailsetting_validate()
{
	if (document.form_mail.txt_website.value == "") 
		{
			alert ("Please Enter the Subject");
			document.form_mail.txt_website.focus();
			return false;
		}
		if (document.form_mail.content.value == "") 
		{
			alert ("Please Enter the Mail content");
			document.form_mail.content.focus();
			return false;
		}
		
		
}
function generalsetting_validate()
{
	if (document.form_general.txt_website.value == "") 
		{
			alert ("Please Enter the Website URL.");
			document.form_general.txt_website.focus();
			return false;
		}
		
	if (document.form_general.txt_numrows.value == "") 
		{
			alert ("Please Enter the number of rows displayed per page.");
			document.form_general.txt_numrows.focus();
			return false;
		}
	recordvalue = document.form_general.txt_numrows.value;
		if((recordvalue == "")  || (recordvalue == 0) || isNaN(recordvalue) ||  (recordvalue.indexOf("-") >= 0) || (recordvalue.indexOf(".") >= 0) || (recordvalue > 65535) ){
			alert ("Please enter the valid number of rows per page.");
			document.form_general.txt_numrows.focus();
			return false;
		}
		
		if (document.form_general.txt_numrowsfront.value == "") 
		{
			alert ("Please Enter the number of rows displayed per page.");
			document.form_general.txt_numrowsfront.focus();
			return false;
		}
	recordvalue = document.form_general.txt_numrowsfront.value;
		if((recordvalue == "")  || (recordvalue == 0) || isNaN(recordvalue) ||  (recordvalue.indexOf("-") >= 0) || (recordvalue.indexOf(".") >= 0) || (recordvalue > 65535) ){
			alert ("Please enter the valid number of rows per page.");
			document.form_general.txt_numrowsfront.focus();
			return false;
		}
		
		
	if (document.form_general.txt_admintitle.value == "") 
		{
			alert ("Please Enter the Admin title.");
			document.form_general.txt_admintitle.focus();
			return false;
		}
	if (document.form_general.txt_hometitle.value == "") 
		{
			alert ("Please Enter the Home page title.");
			document.form_general.txt_hometitle.focus();
			return false;
		}
}

function CMS_validate(){
		
var chks = document.getElementsByName('diaplay[]');
var hasChecked = 0;
var imagecode;
var chkval = 0;


for (var i = 0; i < chks.length; i++)
{
if (chks[i].checked)
{
chkval = chkval + chks[i].value;
imagecode = chks[i].value + "," +  imagecode;
hasChecked = 1;
}
}
if (hasChecked == 0)
{
alert("Please select an Display.");
return false;
}


		if (document.frmCMS.titletag.value == "") 
		{
			alert ("Please enter the title");
			document.frmCMS.titletag.focus();
			return false;
		}
		if (document.frmCMS.metakeyword.value == "") 
		{
			alert ("Please enter the meta keyword");
			document.frmCMS.metakeyword.focus();
			return false;
		}
		if (document.frmCMS.metadesc.value == "") 
		{
			alert ("Please enter the meta description ");
			document.frmCMS.metadesc.focus();
			return false;
		}
		
			if (document.frmCMS.short.value == "") 
		{
			alert ("Please enter the Short Content ");
			document.frmCMS.short.focus();
			return false;
		}
			if (document.frmCMS.txtdetails.value == "") 
		{
			alert ("Please enter the Content ");
			document.frmCMS.txtdetails.focus();
			return false;
		}

}

function page_validate(){


var chks = document.getElementsByName('diaplay[]');
var hasChecked = 0;
var imagecode;
var chkval = 0;


for (var i = 0; i < chks.length; i++)
{
if (chks[i].checked)
{
chkval = chkval + chks[i].value;
imagecode = chks[i].value + "," +  imagecode;
hasChecked = 1;
}
}
if (hasChecked == 0)
{
alert("Please select an Display.");
return false;
}

		if (document.frmCMS.heading.value == "") 
		{
			alert ("Please enter the Page Name.");
			document.frmCMS.heading.focus();
			return false;
		}
if (document.frmCMS.titletag.value == "") 
		{
			alert ("Please enter the title");
			document.frmCMS.titletag.focus();
			return false;
		}
		if (document.frmCMS.metakeyword.value == "") 
		{
			alert ("Please enter the meta keyword");
			document.frmCMS.metakeyword.focus();
			return false;
		}
		if (document.frmCMS.metadesc.value == "") 
		{
			alert ("Please enter the meta description ");
			document.frmCMS.metadesc.focus();
			return false;
		}
		
			if (document.frmCMS.short.value == "") 
		{
			alert ("Please enter the Short Content ");
			document.frmCMS.short.focus();
			return false;
		}
			if (document.frmCMS.txtdetails.value == "") 
		{
			alert ("Please enter the Content ");
			document.frmCMS.txtdetails.focus();
			return false;
		}

}

function validate_addcate()
{
		if (document.addcat.cname.value == "") 
		{
			alert ("Please Select the category name");
			document.addcat.cname.focus();
			return false;
		}
		if (document.addcat.title.value == "") 
		{
			alert ("Please enter the title name");
			document.addcat.title.focus();
			return false;
		}
			if (document.addcat.info.value == "") 
		{
			alert ("Please enter the Info");
			document.addcat.info.focus();
			return false;
		}
		

		if (document.addcat.lc.checked == false)
			{
			alert ("Please Select the LC");
			document.addcat.lc.focus();
			return false;
		}
	
				if (document.addcat.leftheading.value == "") 
		{
			alert ("Please enter the left heading");
			document.addcat.leftheading.focus();
			return false;
		}
		if (document.addcat.leftcontant.value == "") 
		{
			alert ("Please enter the left contant");
			document.addcat.leftcontant.focus();
			return false;
		}
		
}

function category_validate()
{

	if (document.addcategory.category.value == "") 
	{
			alert ("Please Category name.");
			document.addcategory.category.focus();
			return false;
	}
		
		if (document.addcategory.short.value == "") 
		{
			alert ("Please Enter Short Notes.");
			document.addcategory.short.focus();
			return false;
		}
		
		if (document.addcategory.long.value == "") 
		{
			alert ("Please Enter Long Notes.");
			document.addcategory.long.focus();
			return false;
		}
}

function mymail_validate(){



	if (document.details.name.value == "") 

		{

			alert ("Please Enter the Contact Person name.");

			document.details.name.focus();

			return false;

		}

		if (!validateEmail(document.details.mail.value,1,1)) 

		{

			document.details.mail.focus();

			return false;

		}

		if (!validateEmail(document.details.mail.value,1,1)) 

		{

			document.details.mail.focus();

			return false;

		}

		if (document.details.phone1.value == "") 
		{
			alert ("Please enter the 1st four digits in contact number");
			document.details.phone1.focus();
			return false;
		}
				
			if (isNaN(document.details.phone1.value))
		{
			alert ("Please enter in Numericvalue");
			document.details.phone1.focus();
			return false;
		}

		 var tst = document.details.phone1.value.length;	
			
		if(tst <= 3)
		{
			alert ("Please enter 4 digits in Phone1");
			document.details.phone1.focus();
			return false;			
		}
			if (document.details.phone2.value == "") 
		{
			alert ("Please enter the 2nd six contact number");
			document.details.phone2.focus();
			return false;
		}
			if (isNaN(document.details.phone2.value))
		{
			alert ("Please enter in Numericvalue");
			document.details.phone2.focus();
			return false;
		}
		 var tstt = document.details.phone2.value.length;	
			
		if(tstt <= 5)
		{
			alert ("Please enter 6 digits in Phone2");
			document.details.phone2.focus();
			return false;			
		}
			if (document.details.send.value == "") 

		{

			alert ("Please Enter the sending option.");

			document.details.send.focus();

			return false;

		}
			if (document.details.inquiry.value == "") 

		{

			alert ("Please Enter the Inquiry.");

			document.details.inquiry.focus();

			return false;

		}


}

function checkmail()
  {
	  
	  if (document.sendreply.subj.value == "") 
		{
			alert ("Please Enter Subject");
			document.sendreply.subj.focus();
			return false;
		}
		if (document.sendreply.short.value == "") 
		{
			alert ("Please Enter the mail content.");
			document.sendreply.short.focus();
			return false;
		}
  var chks = document.sendreply.checkcount.value;
  var hasChecked = 0;
  for (var i = 1; i < chks; i++)
	{
			 var check = document.sendreply['mail'+i].checked;
		if (check==true)
			{
				hasChecked = 1;
			}
	}
		if (hasChecked == 0)
		{
			alert("Please select an Mail Id");
			return false;
		}
  	 confirm("Are you sure to send mail");
  	 document.sendreply.action;
	 document.sendreply.submit();
 }
 
 function checkdelete()
  {
  var chks = document.viewquery.checkcount.value;
  var hasChecked = 0;
  for (var i = 1; i <= chks; i++)
	{
		 var check = document.viewquery['dele'+i].checked;
		if (check==true)
			{
				hasChecked = 1;
				con=confirm("Are you sure do you want to delete it");
			if(con == true)
			{
				return true;
			}
			else
			{
				return false;
			}
			}
	}
		if (hasChecked == 0)
		{
			alert("Please select an query to Delete.");
			return false;
		}
  	 confirm("Are you sure want to delete it");
  	 document.viewquery.action;
	 document.viewquery.submit();
 }
 
  function configuredelete()
  {
  var chks = document.configure.checkcount.value;
  var hasChecked = 0;
  for (var i = 1; i <= chks; i++)
	{
		 var check = document.configure['dele'+i].checked;
		if (check==true)
			{
				hasChecked = 1;
				con=confirm("Are you sure do you want to delete it");
			if(con == true)
			{
				return true;
			}
			else
			{
				return false;
			}
			}
	}
		if (hasChecked == 0)
		{
			alert("Please select an query to Delete.");
			return false;
		}

  	 document.configure.action;
	 document.configure.submit();
 }
