// JavaScript Document
function poplinks(url)
{
	newwindow=window.open(url,'ImageDisplay','height=400,width=600,left=0,top=0,resizable=yes,scrollbars=yes');
	if (window.focus) {newwindow.focus()}
}

function confirmMsg(msg){
if(!confirm(msg)){
	return false;

} else {
	return true;

}
}
function partnersignup_validate(){
var firstname=document.frm_partnersignup.firstname;
	 if(firstname.value == "")
		 {
		 alert("Please enter your  first name");
		 firstname.focus();
		 return false;
		 }
var lastname=document.frm_partnersignup.lastname;
	 if(lastname.value == "")
		 {
		 alert("Please enter your  last name");
		 lastname.focus();
		 return false;
		 }		 
var email=document.frm_partnersignup.email;
	 if(email.value == "")
		 {
		 alert("Please enter your  email address");
		 email.focus();
		 return false;
		 }	
	if (!validateEmail(email.value,1,1)) 
	 	{
		 email.focus();
		 return false;
		 }	 
		 
var password=document.frm_partnersignup.password;
	 if(password.value == "")
		 {
		 alert("Please enter the  password");
		 password.focus();
		 return false;
		 }			 
}
function admin_validation(){
var txtUsername=document.Login.txtUsername.value;
	 if(txtUsername == "")
			 {
			 alert("Username is empty");
			 document.Login.txtUsername.focus();
			 return false;
			 }
var txtPassword=document.Login.txtPassword.value;
	 if(txtPassword == "")
			 {
			 alert("Password is empty");
			 document.Login.txtPassword.focus();
			 return false;
			 }
}
function generalsetting_validate(){
	if(document.form_general.txt_website.value=="")
	{
	   alert("Enter the website name");
	   document.form_general.txt_website.focus();
	   return false;
	}
	if(document.form_general.txt_numrows.value=="")
	{
	   alert("Enter the number of rows displayed per page in Admin panel");
	   document.form_general.txt_numrows.focus();
	   return false;
	}
	if(isNaN(document.form_general.txt_numrows.value))
	{
	   alert("Enter the number of rows displayed per page in numeric value");
	   document.form_general.txt_numrows.focus();
	   return false;
	}
	if(document.form_general.txt_frontrows.value=="")
	{
	   alert("Enter the number of rows displayed per page in Front panel");
	   document.form_general.txt_frontrows.focus();
	   return false;
	}
	if(isNaN(document.form_general.txt_frontrows.value))
	{
	   alert("Enter the number of rows displayed per page in numeric value");
	   document.form_general.txt_frontrows.focus();
	   return false;
	}
	if(document.form_general.txt_admintitle.value=="")
	{
	   alert("Enter the admin panel Title");
	   document.form_general.txt_admintitle.focus();
	   return false;
	}
	if(document.form_general.appointdays.value=="")
	{
	   alert("Enter the Appointment Reminder Days");
	   document.form_general.appointdays.focus();
	   return false;
	}
	if(isNaN(document.form_general.appointdays.value))
	{
	   alert("Enter the number of Appointment days in numeric value");
	   document.form_general.appointdays.focus();
	   return false;
	}
	return true;
}

function myprofile_validate()
{
	
	if(document.form_myprofile.company.value == "")
	{
	   alert("Please Enter Company Name");
	   document.form_myprofile.company.focus();
	   return false;
	}
	if(document.form_myprofile.txt_contactperson.value == "")
	{
	   alert("Please Enter Your Name");
	   document.form_myprofile.txt_contactperson.focus();
	   return false;
	}
	if(document.form_myprofile.txt_email.value == "")
	{
	   alert("Please Enter Email Address");
	   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_phone.value == "")
	{
	   alert("Please Enter The Phone Number");
	   document.form_myprofile.txt_phone.focus();
	   return false;
	}
	txt_phone = document.form_myprofile.txt_phone;
	if (checkInternationalPhone(txt_phone.value)==false){
		alert("Please Enter a Valid Phone Number")
		txt_phone.value=""
		txt_phone.focus()
		return false
	}
	if(document.form_myprofile.txt_username.value == "")
	{
	   alert("Please Enter Username");
	   document.form_myprofile.txt_username.focus();
	   return false;
	}
	if(document.form_myprofile.txt_password.value == "")
	{
	   alert("Please Enter Your Password");
	   document.form_myprofile.txt_password.focus();
	   return false;
	}
return true;
}


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;
}
