// JavaScript Document
var reWhitespace = /^\s+$/

function isEmpty(s)
{  
 return ((s == null) || (s.length == 0))
}


function isWhitespace (s)
{   
// Is s empty?
    return (isEmpty(s) || reWhitespace.test(s));
}
function isWhitespace (s)
{   
// Is s empty?
    return (isEmpty(s) || reWhitespace.test(s));
}

function echeck(str) {

		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
		 }

 		 return true					
	}


function ValidateNo(NumStr, String)
{    
for(var Idx=0; Idx<NumStr.length; Idx++)    
{        
var Char = NumStr.charAt(Idx);        
var Match = false;        
for(var Idx1=0; Idx1<String.length; Idx1++)        
{            
if(Char == String.charAt (Idx1))                
Match = true;        
}       
 if (!Match)            
return false;    
}    
return true;
}

function clear()
{
	document.reg.reset();  
}


function registerForm(){
	if((document.reg.txtName.value == null)||isWhitespace(document.reg.txtName.value))
	 {       
	 alert("Please specify your Name");       
	 document.reg.txtName.focus();       
	 return false;    
	 }
	 
	 if((document.reg.txtDesignation.value == null)||isWhitespace(document.reg.txtDesignation.value))
	 {       
	 alert("Please specify your Designation");       
	 document.reg.txtDesignation.focus();       
	 return false;    
	 }
	 if((document.reg.txtCompany.value == null)||isWhitespace(document.reg.txtCompany.value))
	 {       
	 alert("Please specify your txtCompany");       
	 document.reg.txtCompany.focus();       
	 return false;    
	 }
	 if((document.reg.txtIndustry.value == null)||isWhitespace(document.reg.txtIndustry.value))
	 {       	 alert("Please specify your Industry");       
	 document.reg.txtIndustry.focus();       
	 return false;    
	 }
	 
	  if((document.reg.txtPhone.value == null)||isWhitespace(document.reg.txtPhone.value))
	 {       
	 alert("Please specify phone number");       
	 document.reg.txtPhone.focus();       
	 return false;    
	 }
	 
	 if(!ValidateNo(document.reg.txtPhone.value,"1234567890+- "))    
	 {        
	 alert("Please Enter Only Number");        
	 document.reg.txtPhone.focus();        
	 return false;    
	 }
	 
	var emailID=document.reg.txtEmail
	
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please Enter your Email ID")
		emailID.focus()
		return false
	}
	
	if (echeck(emailID.value)==false){
		emailID.value=""
		emailID.focus()
		return false
	}
		
	if((document.reg.userid.value == null)||isWhitespace(document.reg.userid.value))
	 {       	 
	 alert("Please specify your username");       
	 document.reg.userid.focus();       
	 return false;    
	 }
	 usr=document.reg.userid.value;
	 if ((usr.length < 5) || (usr.length > 10)) {
    alert("Please specify username between 6 to 9 characters.\n");
	document.reg.userid.focus(); 
	return false
	}
	var illegalChars = /\W/;
  // allow only letters, numbers, and underscores
    if (illegalChars.test(usr)) {
    alert("The username contains illegal characters.\n");
    document.reg.userid.focus(); 
	return false
    } 
	
	if((document.reg.pwd.value == null)||isWhitespace(document.reg.pwd.value))
	 {       	 
	 alert("Please specify your Password");       
	 document.reg.pwd.focus();       
	 return false;    
	 }
	 
	 usr=document.reg.pwd.value;
	 var illegalChars = /\W/;
  // allow only letters, numbers, and underscores
	 if ((usr.length < 5) || (usr.length > 10)) {
    alert("Please specify Password between 6 to 9 characters.\n");
	document.reg.pwd.focus(); 
	return false
	}
	else if (illegalChars.test(usr)) {
    alert("The Password contains illegal characters.\n");
    document.reg.pwd.focus(); 
	return false
    } 
	
	return true;
 }
 
//update Registration
 
 
 function clear()
{
	document.reg.reset();  
}


function updateForm(){
	if((document.updatereg.txtName.value == null)||isWhitespace(document.updatereg.txtName.value))
	 {       
	 alert("Please specify your Name");       
	 document.updatereg.txtName.focus();       
	 return false;    
	 }
	 
	 if((document.updatereg.txtDesignation.value == null)||isWhitespace(document.updatereg.txtDesignation.value))
	 {       
	 alert("Please specify your Designation");       
	 document.updatereg.txtDesignation.focus();       
	 return false;    
	 }
	 if((document.updatereg.txtCompany.value == null)||isWhitespace(document.updatereg.txtCompany.value))
	 {       
	 alert("Please specify your txtCompany");       
	 document.updatereg.txtCompany.focus();       
	 return false;    
	 }
	 if((document.updatereg.txtIndustry.value == null)||isWhitespace(document.updatereg.txtIndustry.value))
	 {       	 alert("Please specify your Industry");       
	 document.updatereg.txtIndustry.focus();       
	 return false;    
	 }
	 
	  if((document.updatereg.txtPhone.value == null)||isWhitespace(document.updatereg.txtPhone.value))
	 {       
	 alert("Please specify phone number");       
	 document.updatereg.txtPhone.focus();       
	 return false;    
	 }
	 
	 if(!ValidateNo(document.updatereg.txtPhone.value,"1234567890+- "))    
	 {        
	 alert("Please Enter Only Number");        
	 document.updatereg.txtPhone.focus();        
	 return false;    
	 }
	 
	var emailID=document.updatereg.txtEmail
	
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please Enter your Email ID")
		emailID.focus()
		return false
	}
	
	if (echeck(emailID.value)==false){
		emailID.value=""
		emailID.focus()
		return false
	}
		
	usr=document.updatereg.pwd.value;
	 var illegalChars = /\W/;
  // allow only letters, numbers, and underscores
	 if ((usr.length < 5) || (usr.length > 10)) {
    alert("Please specify Password between 6 to 9 characters.\n");
	document.updatereg.pwd.focus(); 
	return false
	}
	else if (illegalChars.test(usr)) {
    alert("The Password contains illegal characters.\n");
    document.updatereg.pwd.focus(); 
	return false
    } 
	
	return true;
 }
 
 
 function forgetpass()
 {
 
 var emailID=document.forget.email
	
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please Enter your Email ID")
		emailID.focus()
		return false
	}
	
	if (echeck(emailID.value)==false){
		emailID.value=""
		emailID.focus()
		return false
	}
	return true
 }



//Download Registration
 function clear()
{
	document.seminars.reset();  
}


function seminarsForm(){

	
	if((document.seminars.txtName.value == null)||isWhitespace(document.seminars.txtName.value))
	 {       
	 alert("Please specify your Name");       
	 document.seminars.txtName.focus();       
	 return false;    
	 }
	 
	 if((document.seminars.txtDesignation.value == null)||isWhitespace(document.seminars.txtDesignation.value))
	 {       
	 alert("Please specify your Designation");       
	 document.seminars.txtDesignation.focus();       
	 return false;    
	 }
	 if((document.seminars.txtCompany.value == null)||isWhitespace(document.seminars.txtCompany.value))
	 {       
	 alert("Please specify your txtCompany");       
	 document.seminars.txtCompany.focus();       
	 return false;    
	 }
	 if((document.seminars.txtIndustry.value == null)||isWhitespace(document.seminars.txtIndustry.value))
	 {       	 alert("Please specify your Industry");       
	 document.seminars.txtIndustry.focus();       
	 return false;    
	 }
	 
	  if((document.seminars.txtPhone.value == null)||isWhitespace(document.seminars.txtPhone.value))
	 {       
	 alert("Please specify phone number");       
	 document.seminars.txtPhone.focus();       
	 return false;    
	 }
	 
	 if(!ValidateNo(document.seminars.txtPhone.value,"1234567890+- "))    
	 {        
	 alert("Please Enter Only Number");        
	 document.seminars.txtPhone.focus();        
	 return false;    
	 }
	 
	var emailID=document.seminars.txtEmail
	
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please Enter your Email ID")
		emailID.focus()
		return false
	}
	
	if (echeck(emailID.value)==false){
		emailID.value=""
		emailID.focus()
		return false
	}

		
	return true;
 }