﻿// JScript Files

function checkempty()
{	  
 
    if (isEmpty(document.getElementById('ctl00_cphsharmaTransports_txtemailid'), "UserName can't be empty", document.getElementById('txtemailiderr')))
    {if(isValidEmail(document.getElementById('ctl00_cphsharmaTransports_txtemailid'), "Invalid Email", document.getElementById('txtemailiderr')))
	{if (isEmpty(document.getElementById('ctl00_cphsharmaTransports_txtpassword'), "Password can't be empty", document.getElementById('txtpassworderr')))
    {if (isEmpty(document.getElementById('txtconpassword'), "Confirm password can't be empty.", document.getElementById('txtconpassworderr')))
    {if (validatePwd(document.getElementById('ctl00_cphsharmaTransports_txtpassword'),document.getElementById('txtconpassword'),"Both password and confirm pasword must be same.", document.getElementById('txtconpassworderr')))
    {if (isEmpty(document.getElementById('ctl00_cphsharmaTransports_txtfirstname'), "First Name can't be empty", document.getElementById('txtfirstnameerr')))
    {if (isEmpty(document.getElementById('ctl00_cphsharmaTransports_txtaddress1'), "Address can't be empty", document.getElementById('txtaddress1err')))
    {if (isAddress1(document.getElementById('ctl00_cphsharmaTransports_txtaddress1').value, "Address must be 40 characters only.", document.getElementById('txtaddress1err')))
    {if (isEmpty(document.getElementById('ctl00_cphsharmaTransports_txtcity'), "City can't be Empty", document.getElementById('txtcityerr')))
    {if (isEmpty(document.getElementById('ctl00_cphsharmaTransports_txtpincode'), "Pincode can't be empty", document.getElementById('txtpincodeerr')))            
    {if (isEmpty(document.getElementById('ctl00_cphsharmaTransports_txtphoneno'), "Phone No. can't be empty", document.getElementById('txtphonenoerr')))            
    {if (validatephone(document.getElementById('ctl00_cphsharmaTransports_txtphoneno').value, "Phone No. Must be 10 Digits.", document.getElementById('txtphonenoerr')))            
    {if (isEmpty(document.getElementById('ctl00_cphsharmaTransports_txtmobileno'), "Mobile No. can't be empty.", document.getElementById('txtmobilenoerr')))
    {if (isValidateMobile(document.getElementById('ctl00_cphsharmaTransports_txtmobileno').value, "Mobile No. Must be 10 Digits.", document.getElementById('txtmobilenoerr')))
    {return true;}}}}}}}}}}}}}}
    return false;
}
function getfocus(id)
{
if (id.focus!=true)
{
    id.focus();
    return false;
}
return true;

}
function checkPassword(id)									
{	
    var passwd=	document.getElementById(id).value;
		var intScore   = 0							
		var strVerdict = "weak"							

	    if (passwd.length==0) 		
		{							
			intScore = 0		
		}	
		else if (passwd.length<5)				
		{							
			intScore = (intScore+3)
		}							
		else if (passwd.length>4 && passwd.length<8) 
		{							
			intScore = (intScore+6)
		}							
		else if (passwd.length>7 && passwd.length<16)
		{							
			intScore = (intScore+12)
		}							
		else if (passwd.length>15) 		
		{							
			intScore = (intScore+18)			
		}
					
		if (passwd.match(/[a-z]/))				
		{							
			intScore = (intScore+1)	
		}							
									
		if (passwd.match(/[A-Z]/))
		{							
			intScore = (intScore+5)
		}
		if (passwd.match(/\d+/))
		{							
			intScore = (intScore+5)
		}							
									
		if (passwd.match(/(.*[0-9].*[0-9].*[0-9])/))
		{							
			intScore = (intScore+5)
		}
		if (passwd.match(/.[!,@,#,$,%,^,&,*,?,_,~]/))
		{							
			intScore = (intScore+5)
		}
		if (passwd.match(/(.*[!,@,#,$,%,^,&,*,?,_,~].*[!,@,#,$,%,^,&,*,?,_,~])/))							
		{							
			intScore = (intScore+5)
		}
		if (passwd.match(/([a-z].*[A-Z])|([A-Z].*[a-z])/))
		{							
			intScore = (intScore+2)
		}
		if (passwd.match(/([a-zA-Z])/) && passwd.match(/([0-9])/))
		{							
			intScore = (intScore+2)
		}
		if (passwd.match(/([a-zA-Z0-9].*[!,@,#,$,%,^,&,*,?,_,~])|([!,@,#,$,%,^,&,*,?,_,~].*[a-zA-Z0-9])/))							
		{							
			intScore = (intScore+2)
		}
		var progressBar = document.getElementById("progressBar");
		if(intScore ==0)							
		{			
		   progressBar.style.backgroundColor = "white";				
		   progressBar.innerText = ''							
		}		
		else if(intScore < 16)							
		{			
		   progressBar.style.backgroundColor = "#ffd801";				
		   progressBar.innerText = "weak"							
		}							
		else if (intScore > 15 && intScore < 25)							
		{			
		progressBar.style.backgroundColor = "#ffd801";				
		   progressBar.innerText = "weak"							
		}							
		else if (intScore > 24 && intScore < 35)							
		{					
		progressBar.style.backgroundColor = "orange";		
		   progressBar.innerText = "medium"							
		}							
		else if (intScore > 34 && intScore < 45)							
		{							
		 progressBar.style.backgroundColor = "red";
		   progressBar.innerText = "strong"							
		}									
		else							
		{				
		   progressBar.style.backgroundColor = "#3bce08";			
		   progressBar.innerText = "strong"							
		}
	}