	


function fun_onblurIPName(obj)
{
	
	var objName=obj.name;
	if(objName=='rocode') 
	{
		var rocode=document.rcdtl.rocode.value;
		if(rocode == "")
		{
		alert("Region Code Can Not Left Empty .");
		//document.rcdtl.rocode.focus();   
		objName.focus();
		return false;
		}
	
		//return true;
		 
	}
/*	else
	if(objName=='ecode')   
	{
		var ecode=document.rcdtl.ecode.value;
		/*if(ecode.length>6)
		{
		alert("Employer Code Should not be greater than 6");
		document.rcdtl.ecode.focus();
		return false;
		}
		if(ecode == "")
		{
		alert("Employer Code Can Not Left Empty");
		document.rcdtl.ecode.focus();
		return false;
		}
		//return true;
	}*/
	
	else
	if(objName=='WageDays') 
	{
		var WageDays=document.rcdtl.WageDays.value;
		if(document.rcdtl.WageDays.value=="")
		{
		alert("You need to enter information for Number of days for which wages paid:");
		document.rcdtl.WageDays.focus(); 
		return false;
		}	
		 if(WageDays>183)
		  {
	  	alert("Number of days for which wages paid should not be greater than 183 Days");		
	    document.rcdtl.WageDays.focus(); 
		return false;
	  	}
		if(WageDays!=parseInt(WageDays))
		{
		alert("Number of days Format is not correct");
		document.rcdtl.WageDays.focus(); 
		return false;
		}
		//return true;
	}
	else
	if(objName=='Wages')	
	{
		Wages=document.rcdtl.Wages.value;
		if(Wages=="")
		{
		alert("You need to enter information for wages:");
		document.rcdtl.WageDays.focus();
		return false;
		}
		if(Wages.length>8)
		{
		alert("Wages paid information should not be greater than the 6");
		document.rcdtl.Wagedays.focus();
		return false;
		}
		
		//return true;
	}
	else
	if(objName=='IPContribution')  
	{
		//alert("start");
 	var IPContribution=document.getElementById('IPContribution');
				 
		if(IPContribution.value =="")
		 {
		 	alert("You need to enter information for IPContribution:");
			document.rcdtl.Wages.focus();
			 return false;
		 }
		
	}
	

}	



function checkEmployer(frm)
{
	 
	if(frm.ecode.value == "")
	{
		alert("Employer Code Can Not Left Empty");
		frm.ecode.focus();
		return false;
	}
	else{
		frm.action="EmpVerification.php";
	 	frm.submit();
		return false;
	}
	return true;
}








function fun_IPNameVerification()
	{
	//alert("ok");
		
		var ipcode=document.rcdtl.ipcode.value;
		if(ipcode == "")
		{
		alert("You need to enter information for Insurance No::");
		document.rcdtl.ipcode.focus();
		return false;
		}
		else
		{
			if(ipcode.length>8)
			{
			alert("Insurance No Field Length Should not be greater than 8");
			document.rcdtl.iprocode.focus();
			return false;
			}
			else
			{
			document.rcdtl.action="IPNameVerification.php";
	 		document.rcdtl.submit();
			document.rcdtl.WageDays.focus();
			return false;	
			}
		}	
 
	}	
	
	
	function fun_onchangeipcontribution()
	{
 		 
		var wageVal=Wages;
		var IPContribution=document.getElementById('IPContribution');
		//document.write("IPC"+IPContribution.value);
		var mipContributionVal1=parseInt(0.0175*parseInt(wageVal));
		 
		var mipContributionVal2=parseInt(0.0178*parseInt(wageVal));
		 
	
		if ( (IPContribution.value) < (mipContributionVal1) )
		{	
		  	alert("IP's Contribution can not be less than 1.75% of wages  Rs: "+ (mipContributionVal1));
			document.getElementById('IPContribution').focus();
			return false;
			 
		}
		else
		if((IPContribution.value) > (mipContributionVal2))
		{
			alert("IP's Contribution can not be more than 1.78% of wages  Rs: "+ (mipContributionVal2));
			document.getElementById('IPContribution').focus();
			return false;
		}
		
	/*	if(!(IPContribution.value>=mipContributionVal1)&&(IPContribution.value<=mipContributionVal2))
		{
				alert("IP's Contribution must be lies between  :"+mipContributionVal1+ " And "mipContributionVal2);
				document.rcdtl.IPContribution.focus();
				return false;
		}*/	 
		
	}
	
	// To clear the elements of the Form
	function fun_clear()
	{
		 
		document.rcdtl.ipcode.value="";
		document.rcdtl.WageDays.value="";
		document.rcdtl.Wages.value="";
		document.rcdtl.IPContribution.value=""; 
		document.rcdtl.remarks.value=""; 
		document.rcdtl.DateLeaving.value="";
		document.rcdtl.DateJoining.value="";
		 
	/*	var divip=document.getElementById('divip');	
		divip.style.display="block";
		divip.s*/
		// document.getElementById('divcp').innerHTML="select-cp";	
		//divcp.display="select-cp";
		
		document.getElementById('divip').style.display="none";
				
		return false;
	}	
	
	function f1()
	{
	//alert('f1');
 	javascript:document.rcdtl.DateLeaving.disabled=true;
    var div0=document.getElementById('div0');
	div0.style.display="none";
	}

	function f2()
	{
	//alert('f2');
	javascript:document.rcdtl.DateLeaving.disabled=false;
	var div0=document.getElementById('div0');
	div0.style.display="block";	
	 
	}
	function fun_onSubmit()
	{
		 var frm=document.rcdtl; 		   
		 var rocode=frm.rocode.value;
		if(rocode=="" || rocode==0)
		{
			alert("Plz enter Region code .");
			frm.rocode.focus();
			return false;
		}
		if(frm.ecode.value=="")
		{
			alert("Plz enter Employer Code .");
			frm.ecode.focus();
			return false;
		}
		if(frm.ipcode.value=="")
		{
			alert("Plz enter for Insurance No. .");
			frm.ipcode.focus();
			return false;
		}
		if(frm.WageDays.value=="")
		{
			alert("Plz enter information for Number of days for which wages paid .");
			frm.WageDays.focus();
			return false;
		}	
		if(frm.Wages.value=="")
		{
			alert("Plz enter information for Wages .");
			frm.Wages.focus();
			return false;
		}
		if(frm.IPContribution.value=="")
		{
			alert("Plz enter information for IPContribution .");
			frm.rocode.focus();
			return false;
		}
		
		//var cp=document.getElementById('cp');
 		if(frm.cp.value == "0")
		{
			alert("Plz select the Contibution Period .");
			frm.cp.focus();		 
			return false;
		} 
	/*	var cp=document.getElementById('cp');
		if(cp.value=='0')
		{
			alert("Plz select the Contibution Period .");
			document.getElementById('cp').focus();		 
			return false;
		}*/
	 
	} 
	
/*	function fun_onblurCP()
	{
		//alert("cp");
        var cp=document.getElementById('cp');	   
		
 		if(cp.value == '0')
		{
			alert("Plz select the Contibution Period .");
			document.getElementById('cp').focus();		 
			return false;
		} 
		
	}*/
	 
	 
function fun_onClickAllDis()
{
	
	//javascript:document.RCLiveListViewForm.IPROCode.disabled=true;	
	javascript:document.RCLiveListViewForm.IPCode.disabled=true;	
	javascript:document.RCLiveListViewForm.dispensery.disabled=true;
	javascript:document.RCLiveListViewForm.branch.disabled=true;	
	javascript:document.RCLiveListViewForm.cp.disabled=false;
	//javascript:document.RCLiveListViewForm.status.disabled=false;
	return true;
}
 
 
function fun_onClickDisp()
{
	//javascript:document.RCLiveListViewForm.IPROCode.disabled=true;
	javascript:document.RCLiveListViewForm.IPCode.disabled=true;
	javascript:document.RCLiveListViewForm.dispensery.disabled=false;
	javascript:document.RCLiveListViewForm.cp.disabled=false;	
	javascript:document.RCLiveListViewForm.branch.disabled=true;
	//javascript:document.RCLiveListViewForm.status.disabled=false;
	
	return true;

}
 
 
function fun_onClickBO()
{
	//javascript:document.RCLiveListViewForm.IPROCode.disabled=true;
	javascript:document.RCLiveListViewForm.IPCode.disabled=true;
	javascript:document.RCLiveListViewForm.dispensery.disabled=true;
	javascript:document.RCLiveListViewForm.cp.disabled=false;
	javascript:document.RCLiveListViewForm.branch.disabled=false;	
	//javascript:document.RCLiveListViewForm.status.disabled=true;
	return true;
		
}
function onClickIP()
{
 
	//javascript:document.RCLiveListViewForm.IPROCode.disabled=false;
	javascript:document.RCLiveListViewForm.ipcode.disabled=false;
	//javascript:document.RCLiveListViewForm.dispensery.disabled=true;	
	javascript:document.RCLiveListViewForm.RCode.disabled=true;
	javascript:document.RCLiveListViewForm.ECode.disabled=true;
	javascript:document.RCLiveListViewForm.cp.disabled=false; 
	//javascript:document.RCLiveListViewForm.branch.disabled=true;
	//javascript:document.RCLiveListViewForm.status.disabled=true;
	return true;	
}
function onClickECode()
{
	javascript:document.RCLiveListViewForm.ipcode.disabled=true;
		javascript:document.RCLiveListViewForm.RCode.disabled=false;
	javascript:document.RCLiveListViewForm.ECode.disabled=false;
	javascript:document.RCLiveListViewForm.cp.disabled=true;
	return true;
}
 
function fun_onclick()
{
	if(document.getElementById("All Dispensaries").checked==true||document.getElementById("Dispensary").checked==true)
	{
		if(document.RCLiveListViewForm.cp.selectedIndex==0)
    	{
			alert("Please Select a Contribution Period");
			return(false);
		}
		else
		{
			document.RCLiveListForm.hdsubmit.value="search";
		}
	}	
}	 
	
	
function DateValid(dateValue)
{
   var len, mark1, mark2, res, res1, res4, monthVal, dayVal, yearVal,flag;
  ret=true;
  len =0;
  flag=0;
    flag1=0;
  len = dateValue.value.length; 
if(len)
{
mark1=dateValue.value.indexOf('-'); 
if(len!=10)
{
	alert("Date Format is DD-MM-YYYY, please Check!");
	dateValue.focus();
    dateValue.value='';
	ret = false;
	flag==1;
	//flag1=1;
	 return false;
}
}
  
        if (mark1 > -1) 
        {
	
             mark2 = dateValue.value.indexOf('-', mark1+1);
	     
                if (mark2 > -1) 
                {
		     dayVal = dateValue.value.substring(0, mark1);
		     monthVal = dateValue.value.substring(mark1+1, mark2);
		     yearVal = dateValue.value.substring(mark2+1, 10);


                 if (yearVal < 1111 || yearVal > 9999) 
                        {
			   
                           alert("Year cannot be more then 9999 or less then 1111, please check!");
			   dateValue.focus();
		           dateValue.value='';
			   ret= false;
			    return false;
		       }
			   
		        if (dayVal < 1 || dayVal > 31) 
                        {
			   
                           alert("Days cannot be more then 31 or less then 1, please check!");
			   dateValue.focus();
		           dateValue.value='';
			   ret= false;
			    return false;
		       }
		
	              if (monthVal < 1 || monthVal > 12) 
                      {
			 
			  alert("Error in Month part, please check!");
			  dateValue.focus();
		  	  dateValue.value='';
			  ret= false;
			   return false;
		     }
 
		    else 
                    {
			if (monthVal == 4 || monthVal == 6 || monthVal == 9 || monthVal == 11) 
                        {
				if (dayVal < 1 || dayVal > 30) 
                                {
					alert("Error in day cannot be more then 30 or less then 1, please check");
					dateValue.focus();
		                        dateValue.value='';
					ret= false;
					 return false;
				}
			}
 
			else if (monthVal == 2) 
                        {
				//Check Leap year
				res = yearVal%4;
				res1 = yearVal%100;
				res4 = yearVal%400;
        		        
                               if ((res==0 && res1 != 0) || res4 == 0) 
                              {
					if (dayVal > 29)
                                       {
						alert("Feb month is of leap year, day should not exceed 29");
						dateValue.focus();
		                                dateValue.value='';
						ret= false;
						 return false;
				       }
				}

				else {
						if (dayVal > 28)
                        {
						     alert("Feb month is not of leap year, day should not exceed 28");
						     dateValue.focus();
		                     dateValue.value='';
						     ret= false;
							  return false;
					    }
				    }	
        		
		    }
					
		}
		
	var currentTime = new Date()
	var month1 = currentTime.getMonth() + 1
	var day1 = currentTime.getDate()
	var day=( day1< 10 ) ? '0' + day1: day1;
	var month =( month1< 10 ) ? '0' + month1: month1;
	var year = currentTime.getFullYear()
	
if(yearVal>year)
{
alert("future date is not allowed")
dateValue.focus();
dateValue.value='';
ret= false;
 return false;
}

else if(monthVal>month && yearVal==year)
{
alert("future date is not allowed")
dateValue.focus();
dateValue.value='';
ret= false;
 return false;
}

else if(monthVal==month && dayVal>day && yearVal==year)
{
alert("future date is not allowed")
dateValue.focus();
dateValue.value='';
ret= false;
 return false;
 }
	}
	else if (mark2 == -1 ) {
	alert("Date Format is DD-MM-YYYY, please Check!");
	dateValue.focus();
    dateValue.value='';
	ret= false;
	 return false;
	

}
}
else if (mark1 == -1 && flag == 0) {
	alert("Date Format is DD-MM-YYYY, please Check!");
	dateValue.focus();
    dateValue.value='';
	ret = false;
	 return false;
}

return(ret);
} 



// js for the Rc Defaulters Report

function fun_fecthInfoEmployer(objRO,objEC,periodVal)
 {
	 
	 if(objRO.value=="")
	 {
		 alert("Region code can not be left empty .");
		objRO.focus(); 
		return false;
	 }
	 else
	 if(objEC.value=="")
	 {
		alert("Employer code can not be left empty .");
		objEC.focus(); 
		return false;
	 }
	 else
	 {
		  
//		 document.rcdtl.action="IPNameVerification.php";
		 document.frmRcDefaulters.action="FetchEmployerInfo.php?cp="+periodVal;
		 document.frmRcDefaulters.submit();
		 return false;
	 }
	 	
	 
 }
 function fun_callSame()
 {
	 	document.frmRcDefaulters.action="RCReceipt.php";
		 document.frmRcDefaulters.submit();
		 return false;
	 
 }
 function fun_maxLength(objDate)
 {
	 
		 	if(objDate.value.length>2)
			{
				alert("Length should not be greater than 2 !\n\n Plz. Enter two digit number .");
				document.frmRcDefaulters.txtDD.focus();
				return false;
			}
 }
 function fun_setYear(objPeriod)
 {
	  	
	if(objPeriod.value=="Sept 08")
	{
		//document.frmRcDefaulters.txtYY.value="2009";
		//document.frmRcDefaulters.txtYY.disabled=true;
		document.frmRcDefaulters.action="RCReceipt.php?cp=Sept 08";
		document.frmRcDefaulters.submit();
		return false;
	}
	if(objPeriod.value=="March 09")
	{
		 
		document.frmRcDefaulters.action="RCReceipt.php?cp=March 09";
		document.frmRcDefaulters.submit();
		return false;
	}
 }
 
 
 function  fun_validation()
 {
	  
	 if(document.frmRcDefaulters.txtRO.value=="")
	 {
		 alert("Region code can not be left blank !");
		 document.frmRcDefaulters.txtRO.focus();
		 return false;
	 }
	 if(document.frmRcDefaulters.txtEC.value=="")
	 {
		 alert("Employer code can not be left blank !");
		 document.frmRcDefaulters.txtEC.focus();
		 return false;
	 }
 }
 function validation()
 {
	 if(document.lgnFrm.txtName.value=="")
	 {
		 alert("User Id can be left blank !");
		 document.lgnFrm.txtName.focus();
		 return false;
	 }
	 if(document.lgnFrm.txtPwd.value=="")
	 {
		 alert("Password can be left blank !");
		 document.lgnFrm.txtPwd.focus();
		 return false;
	 }
 }
 
 
 
 function ipOffFocus(frm)
 {
	 frm.ecode.select();
	 return true;
 }
 
 
function setFocus(val)
{
	
	
	if(val == 'ip')
	 {
	 	document.rcdtl.ipcode.focus();
		return false;
	 }
	 else if(val == 'wage')
	 {
	 	document.rcdtl.WageDays.focus();
		return false;
	 }
	 else{
		 document.rcdtl.rocode.focus();
		 return false;
	 }
		 
	 
	 return true;
}

function liveListSubmit()
{
		 
		
		if(document.RCLiveListViewForm.ipcode.disabled)
		{
				var ecode = document.RCLiveListViewForm.ECode.value;
				var rcode = document.RCLiveListViewForm.RCode.value;
				if(ecode == "")
				{
					alert("Employer Code can not be left blank !");
					document.RCLiveListViewForm.ECode.focus();
					return false;
				}
				if(rcode == "")
				{
					alert("Region Code can not be left blank !");
					document.RCLiveListViewForm.RCode.focus();
					return false;
				}
		}
		else
		{
		
				var ipcode = document.RCLiveListViewForm.ipcode.value;
				var cp = document.RCLiveListViewForm.cp.value;
				if(ipcode == "")
				{
					alert("Insurance number can not be left blank !");
					document.RCLiveListViewForm.ipcode.focus();
					return false;
				}
				if(cp == 'N')
				{
					alert("Select Contribution period !");
					document.RCLiveListViewForm.cp.focus();
					return false;	
				}
				
		}
		return true;
}

