// JavaScript Document
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 Email id.")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid Email id.")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid Email id.")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid Email id.")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid Email id.")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid Email id.")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid Email id.")
		    return false
		 }

 		 return true					
	}


function validity()
	{
		
		//var checkString1 = document.register.name.value;
	/*if(checkString1 == "")
	{
		alert('Please enter your Name.');
		document.register.name.focus();
		return false; 
	}else if (checkString1 != "") 
	{    
	if ( /[^A-Za-z\d]/.test(checkString1))
	{        
	alert("Please enter only letter and numeric characters.");        
	document.register.name.focus();       
	return (false);    
	}
	}*/
	
	var iChars = "!@#$%^&*()+=-[]\\\';,./{}|\":<>?1234567890";
        for (var i = 0; i < document.register.name.value.length; i++) {
                if (iChars.indexOf(document.register.name.value.charAt(i)) != -1) {
                alert ("Special characters and Numericals \nare not allowed.\n");
                return false;
        		}
            }
			if(document.register.name.value=="")
			{
			 alert('Please enter your Name.');
			 document.register.name.focus();
			 return false;
			}
	
		
		var emailID=document.register.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
		}		
		
		if(document.register.phone.value == "")
		{
			alert('Please enter your Phone Number.');
			document.register.phone.focus();
			return false;  
		} 
		
		if(document.register.comments.value == "")
		{
			alert('Please enter Description.');
			document.register.comments.focus();
		return false;  
		}						
	return true;	  
}


function changepassword_validity()
{
						
	var emailID=document.cpassword.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
	}		
	
	if(document.cpassword.password.value == "")
	{
		alert('Please enter your Old Password.');
		document.cpassword.password.focus();
		return false;  
	}
	
	if(document.cpassword.newpw.value == "")
	{
		alert('Please enter your New Password.');
		document.cpassword.newpw.focus();
		return false;  
	} 						
	return true;	  
}
	
	
function requestquote()
{
	/*var checkString3 = document.mailform.name.value;
	if(checkString3 == "")
	{
		alert('Please enter your Name.');
		document.mailform.name.focus();
		return false; 
	}else if (checkString3 != "") 
	{    
	if ( /[^A-Za-z\d]/.test(checkString3))
	{        
	alert("Please enter only letter and numeric characters.");        
	document.mailform.name.focus();       
	return (false);    
	}
	}*/
	
	var iChars = "!@#$%^&*()+=-[]\\\';,./{}|\":<>?1234567890";
        for (var i = 0; i < document.mailform.name.value.length; i++) {
                if (iChars.indexOf(document.mailform.name.value.charAt(i)) != -1) {
                alert ("Special characters and Numericals \nare not allowed.\n");
                return false;
        		}
            }
			if(document.mailform.name.value=="")
			{
			 alert('Please enter your Name.');
			 document.mailform.name.focus();
			 return false;
			}
	
		
		var emailID=document.mailform.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
		}
		
		if(document.mailform.country.selectedIndex==0)
		{
			alert("Please select a Country.");
			document.mailform.country.focus();
			return false;
		}
		
		if(document.mailform.phone.value == "")
		{
			alert('Please enter your Phone Number.');
			document.mailform.phone.focus();
			return false;  
		} 
		
		if(document.mailform.projDes.value == "")
		{
			alert('Please enter Project Description.');
			document.mailform.projDes.focus();
			return false;  
		}
		if(document.mailform.targetDes.value == "")
		{
			alert('Please enter Target Audience.');
			document.mailform.targetDes.focus();
			return false;  
		}
	return true;	  
}


function login_validate()
{	
	
	/*var checkString = document.login.name.value;
	if(checkString == "")
	{
		alert('Please enter your Name.');
		document.login.name.focus();
		return false; 
	}else if (checkString != "") 
	{    
	if ( /[^A-Za-z\d]/.test(checkString))
	{        
	alert("Please enter only Alphabets.");        
	document.login.name.focus();       
	return (false);    
	}
	}*/
	
	var iChars = "!@#$%^&*()+=-[]\\\';,./{}|\":<>?1234567890";
        for (var i = 0; i < document.login.name.value.length; i++) {
                if (iChars.indexOf(document.login.name.value.charAt(i)) != -1) {
                alert ("Special characters and Numericals \nare not allowed.\n");
                return false;
        		}
            }
			if(document.login.name.value=="")
			{
			 alert('Please enter your Name.');
			 document.login.name.focus();
			 return false;
			}
	
	
	var emailID=document.login.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;	
}
	
	
	
function login_validate1()
{
	/*var checkString4 = document.login.name.value;
	if(checkString4 == "")
	{
		alert('Please enter your Name.');
		document.login.name.focus();
		return false; 
	}else if (checkString4 != "") 
	{    
	if ( /[^A-Za-z\d]/.test(checkString4))
	{        
	alert("Please enter only letter.");        
	document.login.name.focus();       
	return (false);    
	}
	}*/
	
	var iChars = "!@#$%^&*()+=-[]\\\';,./{}|\":<>?1234567890";
        for (var i = 0; i < document.login.name.value.length; i++) {
                if (iChars.indexOf(document.login.name.value.charAt(i)) != -1) {
                alert ("Special characters and Numericals \nare not allowed.\n");
                return false;
        		}
            }
			if(document.login.name.value=="")
			{
			 alert('Please enter your Name.');
			 document.login.name.focus();
			 return false;
			}
	
	var emailID=document.login.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;	
}

	
	
function fpvalidty()
{
	var emailID=document.fpassword.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;
}



function pin_number_validty()
{
	if(document.upload_script.article_file_path.value == "")
			{
			alert('Please attach a file.');
			document.upload_script.article_file_path.focus();
			return false;  
			}
}



function textCounter(field,cntfield,maxlimit) {
	//alert("hi")
if (field.value.length > maxlimit)
{// if too long...trim it!
field.value = field.value.substring(0, maxlimit);
// otherwise, update 'characters left' counter
alert("Limit size exceeds 255 Characters.");
}
else
{
cntfield.value = maxlimit - field.value.length;
}
}
	
		
	
function validate_contact(){
		
if(document.contact.first_name.value == "")
{
alert('Please enter your First name.');
document.contact.first_name.focus();
return false;  
}

if(document.contact.phno.value == "")
{
alert('Please enter your Phone Number.');
document.contact.phno.focus();
return false;  
}

var emailID=document.contact.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
	}					    		
	if(document.contact.comments.value == "")
	{
	alert('Please enter a comment or message.');
	document.contact.comments.focus();
	return false;  
	}
return true;			
}



function validate_mail(){
	
if(document.query_mail.subject.value == "")
	{
		alert('Please enter Subject.');
		document.query_mail.subject.focus();
		return false;  
	}

	if(document.query_mail.msg.value == "")
	{
		alert('Please enter Message/Query.');
		document.query_mail.msg.focus();
		return false;  
	}
	return true;
}
	
	

function forgot_password_validty()
	{	
	var emailID=document.forgot_password.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;
}


function product_validity()
{
	/*if(document.productregister.fname.value == "")
	{
		alert('Please enter your First Name.');
		document.productregister.fname.focus();
		return false;  
	} */
	
	var iChars = "!@#$%^&*()+=-[]\\\';,./{}|\":<>?1234567890";
        for (var i = 0; i < document.productregister.fname.value.length; i++) {
                if (iChars.indexOf(document.productregister.fname.value.charAt(i)) != -1) {
                alert ("Special characters and Numericals \nare not allowed.\n");
                return false;
        		}
            }
			if(document.productregister.fname.value=="")
			{
			 alert('Please enter your First Name.');
			 document.productregister.fname.focus();
			 return false;
			}
	
	
						
	var emailID=document.productregister.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
	}		
							
	if(document.productregister.password.value == "")
		{
		alert('Please enter a Password.');
		document.productregister.password.focus();
		return false;   
		}else if(document.productregister.password.value != ""){
		password_lng = document.productregister.password.value;
		if(password_lng.length < 6 )
		{
			alert("Your password should be atleast 6 characters minimum.");
			return false;
		}						
	}
	if(document.productregister.phone.value == "")
		{
			alert('Please enter your Phone Number.');
			document.productregister.phone.focus();
			return false;  
		}
	return true;				
}

function product_validity1(){
	var emailID1=document.olduser.Email1
	if ((emailID1.value==null)||(emailID1.value=="")){
		alert("Please enter your Email id.")
		emailID1.focus()
		return false
	}
	if (echeck(emailID1.value)==false){
		emailID1.value=""
		emailID1.focus()
		return false
	}		

	if(document.olduser.password1.value == ""){
		alert('Please enter your Password.');
		document.olduser.password1.focus();
		return false;   
	}
	return true;				
}


function login_validateindex(){
	var emailID=document.validateindex.userid;
	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.validateindex.password.value == ""){
		alert('Please enter your Password.');
		document.validateindex.password.focus();
		return false;  
	}
	return true;
}	

function validate_requestcourse(){	

	/*var checkString2 = document.requestcourse.name.value;
	if(checkString2 == "")
	{
		alert('Please enter your Name.');
		document.requestcourse.name.focus();
		return false; 
	}else if (checkString2 != "") 
	{    
	if ( /[^A-Za-z\d]/.test(checkString2))
	{        
	alert("Please enter only letter and numeric characters.");        
	document.requestcourse.name.focus();       
	return (false);    
	}
	}*/
	
	var iChars = "!@#$%^&*()+=-[]\\\';,./{}|\":<>?1234567890";
        for (var i = 0; i < document.requestcourse.name.value.length; i++) {
                if (iChars.indexOf(document.requestcourse.name.value.charAt(i)) != -1) {
                alert ("Special characters and Numericals \nare not allowed.\n");
                return false;
        		}
            }
			if(document.requestcourse.name.value=="")
			{
			 alert('Please enter your Name.');
			 document.productregister.fname.focus();
			 return false;
			}
	
		var emailID=document.requestcourse.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
			}					
		if(document.requestcourse.phone.value == "")
			{
			alert('Please enter your Phone Number.');
			document.requestcourse.phone.focus();
			return false;  
			}
		if(document.requestcourse.course.selectedIndex == 0)
			{
			alert('Please select Courses.');
			document.requestcourse.course.focus();
			return false;  
			}	
				
		if(document.requestcourse.numlicence.value == "")
			{
			alert('Please enter No. of License Required.');
			document.requestcourse.numlicence.focus();
			return false;  
			}
		return true;		
}


function clearfields()
{
	name.text = "";	
	Email.text = "";
	company.text = "";
	phone.text = "";
}

function clearfields_users()
{
	fname.text = "";	
	lname.text = "";
	Email.text = "";
	password.text = "";
	compname.text = "";
	phone.text = "";
	address.text = "";
}

function winnew1(){
 var myWin1 = window.open("demoform.html","_self")
}


function addtocart(){
	 var myWin6 = window.open("addtocart.php","_self")
}

function forgotpassword(){
 var myWin1 = window.open("request_password.php","_self")
}
