// JavaScript Document
// ------------- This is Script For Admin Pages----------------------//

// 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;
}


//LIst box script

var lists=new Array();
var lists1=new Array();
var listsxx=new Array();
var listsxx1=new Array();

var centers=new Array();
var emptycenters=new Array();
emptycenters[0]	= new Array('Choose','Choose');

function emptyList(box) 
{
	while (box.options.length) box.options[0] = null;
}

function fillList( box, arr ) 
{
	for ( i = 0; i < arr[0].length; i++ ) 
	{
		opton = new Option( arr[0][i], arr[0][i+1] );
		box.options[box.length] = opton;
		i=i+1;
	}
	box.selectedIndex=0;
}

function contactus_frm()
{
		if(document.contactus.name.value=="")
	{
		alert("Please enter Name");
		document.contactus.name.focus();
		return false;
	}
	
	if(document.contactus.email.value=="")
	{
		alert("Please enter The Email Id");
		document.contactus.email.focus();
		return false;
	}
	if (!validateEmail(document.contactus.email.value,1,1)) 
	 {
	 document.contactus.email.focus();
	 return false;
	 } 
	 
	 if(document.contactus.address.value=="")
	{
		alert("Please enter your Address");
		document.contactus.address.focus();
		return false;
	}
	
	if(document.contactus.phone.value=="")
	{
		alert("Please enter your Contact number");
		document.contactus.phone.focus();
		return false;
	}
	if (isNaN(document.contactus.phone.value))
		 { 
			 alert ("Phone must be Numeric");
			 document.contactus.phone.focus();
			 return false;
		 }
	

}


function contactus()
{
		if((document.contact.name.value=="Name") || (document.contact.name.value==""))
	{
		alert("Please enter Name");
		document.contact.name.focus();
		return false;
	}
	
	if((document.contact.email.value=="E-mail") || (document.contact.email.value==""))
	{
		alert("Please enter The Email Id");
		document.contact.email.focus();
		return false;
	}
	if (!validateEmail(document.contact.email.value,1,1)) 
	 {
	 document.contact.email.focus();
	 return false;
	 } 
	 
	 if((document.contact.require.value=="Requirements") || (document.contact.require.value==""))
	{
		alert("Please enter your Requirements.");
		document.contact.require.focus();
		return false;
	}
	
	
}




function validate_form()
{
		if(document.enquiry.package_name.value=="")
	{
		alert("Please enter Package Name");
		document.enquiry.package_name.focus();
		return false;
	}
		
		if(document.enquiry.name.value=="")
	{
		alert("Please enter Name");
		document.enquiry.name.focus();
		return false;
	}
	if(document.enquiry.email.value=="")
	{
		alert("Please enter The Email Id");
		document.enquiry.email.focus();
		return false;
	}
	if (!validateEmail(document.enquiry.email.value,1,1)) 
	 {
	 document.enquiry.email.focus();
	 return false;
	 } 
	 if(document.enquiry.phone.value=="")
	{
		alert("Please enter the Phone");
		document.enquiry.phone.focus();
		return false;
	}
	if (isNaN(document.enquiry.phone.value))
		 { 
			 alert ("Phone must be Numeric");
			 document.enquiry.phone.focus();
			 return false;
		 }
	
}

