// JScript File
//-----------------------Time Validation Function------------------//

function IsValidTime(value) {

var timePat = /^(\d{1,2}):(\d{2})(:(\d{2}))?(\s?(AM|am|PM|pm))?$/;

var matchArray = value.match(timePat);
if (matchArray == null) {
alert("Enter Time in HH:MM:SS Format");
return false;
}
hour = matchArray[1];
minute = matchArray[2];
second = matchArray[4];
ampm = matchArray[6];

if (second=="") { second = null; }
if (ampm=="") { ampm = null }

if (hour < 0  || hour > 23) {
alert("Hour must be between 1 and 12. (or 0 and 23 for Military Time)");
return false;
}
if (hour <= 12 && ampm == null) {
if (confirm("Please Indicate which Time Format you are using.  OK = Standard Time, CANCEL = Military Time")) {
alert("You must specify AM or PM.");
return false;
   }
}
if  (hour > 12 && ampm != null) {
alert("You can't specify AM or PM for Military Time");
return false;
}
if (minute<0 || minute > 59) {
alert ("Minute must be between 0 and 59.");
return false;
}
if (second != null && (second < 0 || second > 59)) {
alert ("Second must be between 0 and 59.");
return false;
}
return true;
}
//  End -->
//-----------------------End of time function------------------//

//---------------------Date Function----------------------//
function isValidDate_date(value) 
{
   	
    var datePat = /^(\d{2}|\d{4})\-(\d{1,2})\-(\d{1,2})$/;
    var matchArray = value.match(datePat); // is the format ok?
    
    if (matchArray == null) 
    {
    	alert("Enter Date in YYYY-MM-DD Format")
	    return false;
	}
	
	year = matchArray[4];
	month = matchArray[2]; // parse date into variables
	day = matchArray[3];
 
 	if (month<1 || month>12) // check month range
 	{ 
 		alert("Month must be between 1 and 12");
		return false;
	}

	if (day<1 || day>31) 
	{
		alert("Day must be between 1 and 31");
		return false;
	}
 	
 	if ((month==4 || month==6 || month==9 || month==11) && day==31) 
 	{
 		alert("Month "+month+" doesn't have 31 days")
 		return false
	}
	
	if (month == 2) // check for february 29th
	{
 		var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
 	
 	if (day>29 || (day==29 && !isleap)) 
 	{
		alert("February " + year + " doesn't have " + day + " days!");
	 	return false;
 	}
	}
  		return true;  // date is valid
}
//-----------------------------------------------------------------------------//


//-----------------------validate character number-----------------------------//

<!-- Begin
function twdCount(field,cntfield,maxlimit) {
//alert("fsdfsdfs");
if (field.value.length > maxlimit)
field.value = field.value.substring(0, maxlimit);
else
cntfield.value = maxlimit - field.value.length;
}
// End -->


function ismaxlength(obj)
{
var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""
if (obj.getAttribute && obj.value.length>mlength)
obj.value=obj.value.substring(0,mlength)
}

//------------------------End of validate character number-------------------------//



//--------------- E-Mail Validation----------//
function checkEmail(value)
 {
 
 
		
		
		var at="@"
        var bsnl ="@bsnl.co.in"
        var utl ="@utlindia.com"
        var lat=value.indexOf(at)
        var lstr=value.length
 		if(value.substring(lat,lstr)!=bsnl && value.substring(lat,lstr)!=utl) 

		{

            alert("Invalid E-mail Address! Please Re-Enter ")

             return (false);

         }
		
		if (/([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3}$)/.test(value))
		{
			return (true)
		}
		
		else
		{
			alert("Invalid E-mail Address! Please Re-Enter ")
			return (false);
		}
	}
//---------------End E-Mail Validation----------//

//--------------- URL Validation----------//
function checkUrl(value) {
		if (/(^(http:\/\/www.|https:\/\/www.|ftp:\/\/www.|www.){1}[0-9A-Za-z\.\-]*\.[a-z]{2,3}$)/.test(value)){
		return (true)
		}
		alert("Invalid URL! Please Re-Enter ")
		return (false);
	}
//---------------End  URL Validation----------//

//--------------------Number Validation----------------------------//
function checkNumber(value) {
		if (/^[0-9]+$/.test(value)){
		return (true)
		}
		alert("Please Enter Number Only ")
		return (false);
		}
//--------------------End Number Validation----------------------------//

//------------------ Trim Values-----------------------------------//

// Removes leading whitespaces
	function LTrim( value ) 
	{
		var re = /\s*((\S+\s*)*)/;
		return value.replace(re, "$1");
	}
	// Removes ending whitespaces
	function RTrim( value ) 
	{
		var re = /((\s*\S+)*)\s*/;
		return value.replace(re, "$1");
	}
	// Removes leading and ending whitespaces
	function trim( value )
	{
		return LTrim(RTrim(value));
	}

//------------------End Trim Values-----------------------------------//


//-----------For All Popup---------------------//

function printpopup(URL,WIN_NAME)
{

	var HEIGHT=screen.height;
	var POPUP_HEIGHT = HEIGHT-1000;
	var POPUP_WIDTH = 1233;
	var HEIGHT_POP=screen.height;
	HEIGHT_POP=(HEIGHT_POP/2) - (POPUP_HEIGHT/2);
	var WIDTH_POP=screen.width;
	WIDTH_POP=(WIDTH_POP/2) - (POPUP_WIDTH/2);
    window.open(URL,WIN_NAME,'top='+HEIGHT_POP+', left='+WIDTH_POP+', width='+POPUP_WIDTH+',height='+POPUP_HEIGHT+',directories=no,location=no,menubar=no,scrollbars=yes,status=no,toolbar=no,resizable=yes');
	return false;
}


//------------------------------END-----------------------------------------------//








//------------------------------Client Registration Validation------------//
function client_registration_validation(src)
{
	
	

	
	if(trim(src.clientname.value) == "")
	{
		alert("Please enter name")
		src.clientname.focus();			
		return false;	
	}
	
	if(trim(src.clientdesignation.value) == "")
	{
		alert("Please enter designation")
		src.clientdesignation.focus();			
		return false;	
	}
	
	if(trim(src.clientbsnlmailid.value) == "")
	{
		alert("Please enter BSNL mail id")
		src.clientbsnlmailid.focus();			
		return false;	
	}
	if(!checkEmail(src.clientbsnlmailid.value))
   	{
   		   src.clientbsnlmailid.select();
		   return false;
	}
	
	if(trim(src.clientstdcode.value) == "" || trim(src.clientstdcode.value) ==0)
	{
		alert("Please enter STD code")
		src.clientstdcode.focus();			
		return false;	
	}
	if(!checkNumber(src.clientstdcode.value))
   	{
   		   src.clientstdcode.select();
		   return false;
	}
	
	   
	if(trim(src.clientphonenumber.value) == "")
	{
		alert("Please enter phone number")
		src.clientphonenumber.focus();			
		return false;	
	}
	
	var x=src.clientstdcode.value.length;
	var y=src.clientphonenumber.value.length;
	var res1=x+y;
	//alert(res1);
	if(res1!=11)
	{
		alert("your STD code and number should be 11 digit.")
		src.clientphonenumber.focus();			
		return false;	
	}
	
	
	
	if(!checkNumber(src.clientphonenumber.value))
   	{
   		   src.clientphonenumber.select();
		   return false;
	}
	   
	   
	if(trim(src.clientmobilenumber.value) == "")
	{
		alert("Please enter mobile number")
		src.clientmobilenumber.focus();			
		return false;	
	}
	
	if(src.clientmobilenumber.value.length<10)
	{
		alert("your mobile number is less than 10 digit.")
		src.clientmobilenumber.focus();			
		return false;	
	}
	
	if(!checkNumber(src.clientmobilenumber.value))
   	{
   		   src.clientmobilenumber.select();
		   return false;
	}
	
	
	 
	if(trim(src.clientofficeaddress.value) == "")
	{
		alert("Please enter adress")
		src.clientofficeaddress.focus();			
		return false;	
	}
	
	if(src.clientcountryname.selectedIndex==0)
	{
	
		alert("Please select country")
		src.clientcountryname.focus();			
		return false;	
	}
	if(src.clientstatename.selectedIndex==0)
	{
	
		alert("Please select state")
		src.clientstatename.focus();			
		return false;	
	}
	if(src.clientcityname.selectedIndex==0)
	{
	
		alert("Please select city")
		src.clientcityname.focus();			
		return false;	
	}
	
	if(trim(src.clientpincode.value) == "")
	{
		alert("Please enter pin code")
		src.clientpincode.focus();			
		return false;	
	}
	
	if(src.clientpincode.value.length<6)
	{
		alert("your pin code is less than 6 digit.")
		src.clientpincode.focus();			
		return false;	
	}
	
	
	if(!checkNumber(src.clientpincode.value))
   	{
   		   src.clientpincode.select();
		   return false;
	}
	
	
	if(trim(src.clientreportingofficerstdcode.value)!=null || trim(src.clientreportingofficerstdcode.value) ==0)
	{
		if(!checkNumber(src.clientreportingofficerstdcode.value))
   		{
   		   src.clientreportingofficerstdcode.select();
		   return false;
		}
	}
	
	
	if(trim(src.clientreportingofficernumber.value)!="")
	{
		if(!checkNumber(src.clientreportingofficernumber.value))
   		{
   		   src.clientreportingofficernumber.select();
		   return false;
		}
	}
	
	if(trim(src.clientreportingofficermobilenumber.value)!="")
	{
		if(!checkNumber(src.clientreportingofficermobilenumber.value))
   		{
   		   src.clientreportingofficermobilenumber.select();
		   return false;
		}
	}
	
	
	if(trim(src.clientreportingofficerstdcode.value)!="" && trim(src.clientreportingofficernumber.value)!="")
	{
			
		
		
		var x1=src.clientreportingofficerstdcode.value.length;
		var y1=src.clientreportingofficernumber.value.length;
		var res2=x1+y1;
		if(res2!=11)
		{
			alert("your STD code and number should be 11 digit.")
			src.clientreportingofficernumber.focus();			
			return false;
		}	
	}
	
	
	
	
	
	if(confirm("You are about to register yourself"))
	{
		
		return true;
	}
	else
	{
		return false;	
	}
	
}
//---------------------------End of Client Registration Validation----------------//






//------------------------------client_account_validation Validation------------//
function client_account_validation(src)
{
	
	if(trim(src.clientname.value) == "")
	{
		alert("Please enter name")
		src.clientname.focus();			
		return false;	
	}
	
	if(trim(src.clientdesignation.value) == "")
	{
		alert("Please enter designation")
		src.clientdesignation.focus();			
		return false;	
	}
	
	if(trim(src.clientbsnlmailid.value) == "")
	{
		alert("Please enter BSNL mail id")
		src.clientbsnlmailid.focus();			
		return false;	
	}
	if(!checkEmail(src.clientbsnlmailid.value))
   	{
   		   src.clientbsnlmailid.select();
		   return false;
	}
	
	if(trim(src.clientstdcode.value) == "" || trim(src.clientstdcode.value) ==0)
	{
		alert("Please enter STD code")
		src.clientstdcode.focus();			
		return false;	
	}
	
	if(!checkNumber(src.clientstdcode.value))
   	{
   		   src.clientstdcode.select();
		   return false;
	}
	
	   
	if(trim(src.clientphonenumber.value) == "")
	{
		alert("Please enter phone number")
		src.clientphonenumber.focus();			
		return false;	
	}
	if(!checkNumber(src.clientphonenumber.value))
   	{
   		   src.clientphonenumber.select();
		   return false;
	}
	  
	  
	var x1=src.clientstdcode.value.length;
	var y1=src.clientphonenumber.value.length;
	var res11=x1+y1;
	//alert(res1);
	if(res11!=11)
	{
		alert("your STD code and number should be 11 digit.")
		src.clientphonenumber.focus();			
		return false;	
	}  
	  
	   
	
	if(src.clientcountrycode.selectedIndex==0)
	{
	
		alert("Please select country code")
		src.clientcountrycode.focus();			
		return false;	
	}
	
	
	   
	if(trim(src.clientmobilenumber.value) == "")
	{
		alert("Please enter mobile number")
		src.clientmobilenumber.focus();			
		return false;	
	}
	
	if(src.clientmobilenumber.value.length<10)
	{
		alert("your mobile number is less than 10 digit.")
		src.clientmobilenumber.focus();			
		return false;	
	}
	
	
	if(!checkNumber(src.clientmobilenumber.value))
   	{
   		   src.clientmobilenumber.select();
		   return false;
	}
	
	
	 
	 
	if(trim(src.clientofficeaddress.value) == "")
	{
		alert("Please enter adress")
		src.clientofficeaddress.focus();			
		return false;	
	}
	
	if(src.clientcountryname.selectedIndex==0)
	{
	
		alert("Please select country")
		src.clientcountryname.focus();			
		return false;	
	}
	if(src.clientstatename.selectedIndex==0)
	{
	
		alert("Please select state")
		src.clientstatename.focus();			
		return false;	
	}
	if(src.clientcityname.selectedIndex==0)
	{
	
		alert("Please select city")
		src.clientcityname.focus();			
		return false;	
	}
	
	if(trim(src.clientpincode.value) == "")
	{
		alert("Please enter pin code")
		src.clientpincode.focus();			
		return false;	
	}
	
	if(src.clientpincode.value.length<6)
	{
		alert("your pin code is less than 6 digit.")
		src.clientpincode.focus();			
		return false;	
	}
	
	
	if(!checkNumber(src.clientpincode.value))
   	{
   		   src.clientpincode.select();
		   return false;
	}
	
	
	if(trim(src.clientreportingofficerstdcode.value)!=null || trim(src.clientreportingofficerstdcode.value) ==0)
	{
		if(!checkNumber(src.clientreportingofficerstdcode.value))
   		{
   		   src.clientreportingofficerstdcode.select();
		   return false;
		}
	}
	
	
	if(trim(src.clientreportingofficernumber.value)!="")
	{
		if(!checkNumber(src.clientreportingofficernumber.value))
   		{
   		   src.clientreportingofficernumber.select();
		   return false;
		}
	}
	
	if(trim(src.clientreportingofficermobilenumber.value)!="")
	{
		if(!checkNumber(src.clientreportingofficermobilenumber.value))
   		{
   		   src.clientreportingofficermobilenumber.select();
		   return false;
		}
	}
	
	
	
	if(trim(src.clientreportingofficerstdcode.value)!=""  && trim(src.clientreportingofficernumber.value)!="")
	{
			
		
		
		var x2=src.clientreportingofficerstdcode.value.length;
		var y2=src.clientreportingofficernumber.value.length;
		var res22=x2+y2;
		if(res22!=11)
		{
			alert("your STD code and number should be 11 digit.")
			src.clientreportingofficernumber.focus();			
			return false;
		}	
	}
	
	
	
	if(confirm("You are about to edit your account"))
	{
		
		return true;
	}
	else
	{
		return false;	
	}
	
}
//---------------------------End of client_account_validation Validation----------------//









//----------------------validate MAC ID add-------------------------------------//


function validate_macid_add(src)
{
	
	if(trim(src.macid1.value) == "")
	{
		alert("First Box empty")
		src.macid1.focus();			
		return false;	
	}
	
	if(trim(src.macid2.value) == "")
	{
		alert("Second  Box empty")
		src.macid2.focus();			
		return false;	
	}
	if(trim(src.macid3.value) == "")
	{
		alert("Third Box empty")
		src.macid3.focus();			
		return false;	
	}
	if(trim(src.macid4.value) == "")
	{
		alert("Fourth Box empty")
		src.macid4.focus();			
		return false;	
	}
	if(trim(src.macid5.value) == "")
	{
		alert("Fifth Box empty")
		src.macid5.focus();			
		return false;	
	}
	if(trim(src.macid6.value) == "")
	{
		alert("Sixth Box empty")
		src.macid6.focus();			
		return false;	
	}
	
	if(confirm("You are about to add MAC ID for generating license"))
	{
		
		return true;
	}
	else
	{
		return false;	
	}
	
}

//-----------------------End of MAC ID add---------------------------------//


//---------------------Change Password validation----------------------------//

function validate_changepassword(src)
{
	if(trim(src.currentpassword.value) == "")
	{
		alert("Please Enter Current password ")
		src.currentpassword.focus();			
		return false;	
	}
	
	if(trim(src.newpassword.value) == "")
	{
		alert("Please Enter new password")
		src.newpassword.focus();			
		return false;	
	}
	
	
	if(src.newpassword.value.length<6)
	{
		alert("Please Enter new password minimum of 6 Character ")
		src.newpassword.focus();			
		return false;	
	}
	
	if(trim(src.confirmpassword.value) == "")
	{
		alert("Please Enter comfirm password")
		src.confirmpassword.focus();			
		return false;	
	}
	if(src.confirmpassword.value.length<6)
	{
		alert("Please Enter confirm password minimum of 6 Character ")
		src.confirmpassword.focus();			
		return false;	
	}
	
	
	if(trim(src.newpassword.value)!=trim(src.confirmpassword.value))
	{
		alert("New password and confirm password dose  not match")
		src.confirmpassword.focus();			
		return false;	
	}
	
	if(confirm("You are about to change your password"))
	{
		
		return true;
	}
	else
	{
		return false;	
	}
	
}

//---------------------End of change password------------------------------//


//---------------------Client forgotpassword------------------------------//
function validate_forgotpassword(src)
{

	if(trim(src.clientemailid.value) == "")
	{
		alert("Please enter your email id")
		src.clientemailid.focus();			
		return false;	
	}
	if(!checkEmail(src.clientemailid.value))
   	{
   		   src.clientemailid.select();
		   return false;
	}
	
	if(confirm("You are about to submit the form to get password"))
	{
		
		return true;
	}
	else
	{
		return false;	
	}


}

//---------------------End of forgotpassword----------------------------//


//--------------------track Software----------------------------------//
function tracksoftware(clientidpkidPk,foldername,filename,fileTypeName)
{
	if(confirm("You are about to download "+filename+" file."))
	{
		document.getElementById("hidden_clientid").value=clientidpkidPk;
		document.getElementById("flodername_download").value=foldername;
		document.getElementById("hidden_filename").value=filename;
		document.getElementById("type_file").value=fileTypeName;
		document.getElementById("downloadfile").submit();
		return true;
	}
	else
	{
		return false;	
	}
}
//----------------End of Track Software------------------------------//



