/*

@File    : abngen.js
@Author  : Aashish B. Narain
@Creatd : Non 20, 2008
@Info    : General Functions

*/

   var isCSV=true;
   var dateFormat="dd/mm/yyyy";
   
   var abnTarget="abnTarget";
   var abnTarget2Add="adding";
   var abnTarget2Edit="editing";
   var abnTarget2View="view";
   var abnTarget2Approve="approval";
   var abnTarget2Resubmit="resubmit";
   var abnOsrsParam="osrs";
   var abnOsr1="OSR1";
   var abnOsr2="OSR2";
   var abnOsr3="OSR3";
   var abnAgrTypeOsr='OSR';
   var abnAgrTypeIr='IR';
   var abnOsr2a='OSR2A';
   
   var currentTime = new Date(); // VsA181010-1 
   var currentYear = currentTime.getFullYear(); // VsA181010-1 
	   
   function showInBody(url){//fine
	   
      var abnTPPrefix='?';
      if(url.indexOf(abnTPPrefix)!=-1 ){
        abnTPPrefix='&';
      }
      parent.abnbdy.location.href=url+abnTPPrefix+'abnTP='+Math.random();
   }
   function homePage(){
       return "Logout.do";
   }
   function logout(){//fine
      parent.location.href="Logout.do";
   }
   function verifyuser(){
       abnFillHtmlCtrl('iuli','iuli','IULI','resultverifyuser','JsFun');
   }
   function resultverifyuser(rtMsg){
     if(rtMsg[1]!='true'){
       logout();
     }
   }
   function myProfile(userId){//fine
      showInBody('security/userView.do?user_id='+userId);
   }
   function forgetPwd(){//fine
      var url='./security/forgotPassword.jsp';
      window.open(url,'USOF',"location=0,status=0,scrollbars=yes,width=500,height=180,resizable=yes,margin=0:px");
   }
   function changePwd(user_id){
      var url='./security/changePassword.jsp?abnTP='+Math.random();
      var abnPopupPwdWin = window.open(url,'USOF',"directories=no,location=no,menubar=no,resizable=yes,status=no,scrollbars=yes,toolbar=no,copyhistory=no,z-lock=no,width=500,height=180,margin=0:px");
   }
   function adjustHome(root){//fine
      if(parent.frames.length!=0){
         parent.location.href=root+'/'+homePage();
      }
   }
   function adjustMenu(){//fine
      var abnV='12, *';
      if(parent.abnpgm.cols==abnV){
         document.menuarrow.src="images/arrow_lf.png";
         parent.abnpgm.cols='20%, 80%';
      }else{
         document.menuarrow.src="images/arrow_rg.png";
         parent.abnpgm.cols=abnV;
      }
   }
function isValidCharacterSet(fieldValue, withChars){
    var allValid = true;
    for (i = 0;i<fieldValue.length;i++){
        ch = fieldValue.charAt(i);
        for (j = 0;j<withChars.length;j++){
            if (ch == withChars.charAt(j)){
                break;
            }
        }
        if (j == withChars.length) {
            allValid = false;
            break;
        }
    }
    return allValid;
}
//Abn:Login
  function login(jsessionId){//fine
      if(document.loginForm.loginId.value==''){
         alert('Please enter Login Id');
         document.loginForm.loginId.focus();
         return;
      }
       if(!isValidCharacterSet(document.loginForm.loginId.value,"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.-")){//Abn280110-16
         alert('Characters A to Z, a to z, 0 to 9,. and - are allowed for Login Id.');
         document.loginForm.loginId.focus();
         return;
      }
      if(document.loginForm.password.value==''){
         alert('Please enter Password');
         document.loginForm.password.focus();
         return;
      }
     
      document.loginForm.password.value=sha1Hash(document.loginForm.password.value);
      document.loginForm.action="VerifyUser.do?jsessionId="+jsessionId;//Abn280110-15
      document.loginForm.method="post";
      document.loginForm.submit();
      return;
   }
   function loginReset(){
      document.loginForm.loginId.value='';
      document.loginForm.password.value='';
      document.loginForm.loginId.focus();
   }


//Abn:Pending Task
   function searchPendingTask(){//fine
      document.pendingtasksch.rPg.value="";
      submitSchPendingtask();
   }
   function submitSchPendingtask(){//fine
      var srchMsg4Cri='Please select the value for search.';//At least one criteria is required to search.
      var isSearchCri=true;
      var objCcaId = document.getElementById("ccaId");
      if(objCcaId!=null){
        if(objCcaId.options[objCcaId.options.selectedIndex].value==''){
          isSearchCri=false;
          srchMsg4Cri='Please select CCA.';
        }
      }
      var objStateId = document.getElementById("stateId");
      if(objStateId!=null){
        if(objStateId.options[objStateId.options.selectedIndex].value==''){
          isSearchCri=false;
          srchMsg4Cri='Please select State.';
        }
      }
      if(isSearchCri){
        document.pendingtasksch.action="PendingTask.do";
        document.pendingtasksch.method="post";
        document.pendingtasksch.submit();
      }else{
        alert(srchMsg4Cri);
      }
   }
   function selectAllLPendingtask(){//fine
      abnCheckAs(document.pendingtasksch.osrId,document.pendingtasksch.lc.checked);
   }
//Abn:OSR Searching
   function searchOsr(){//fine
      document.osrsch.rPg.value="";
      submitSchOsr();
   }
   
   function submitSchOsr(){//fine
   
   var srchMsg4Cri='At least one criteria is required to search.';
      var isSearchCri=false;
      var objCcaId = document.getElementById("ccaId");
      if(objCcaId!=null){
        if(objCcaId.options[objCcaId.options.selectedIndex].value!=''){
          isSearchCri=true;
        }
      }
      var objStateId = document.getElementById("stateId");
      if(objStateId!=null){
        if(objStateId.options[objStateId.options.selectedIndex].value!=''){
          isSearchCri=true;
        }
      }
      var objAgrId = document.getElementById("agrId");
      if(objAgrId!=null){
        if(objAgrId.options[objAgrId.options.selectedIndex].value!=''){
          isSearchCri=true;
        }
      }
      var objUspId = document.getElementById("uspId");
      if(objUspId!=null){
        if(objUspId.options[objUspId.options.selectedIndex].value!=''){
          isSearchCri=true;
        }
      }
      //var objQeDt = document.getElementById("qeDt");
      //if(objQeDt!=null){
      //  if(objQeDt.value!=''){
      //    isSearchCri=true;
      //  }
      //}
      
      var objReceiptDt = document.getElementById("receiptDt");
      if(objReceiptDt!=null){
        if(objReceiptDt.value!=''){
          isSearchCri=true;
        }
      }
      var objApproveDt = document.getElementById("approveDt");
      if(objApproveDt!=null){
        if(objApproveDt.value!=''){
          isSearchCri=true;
        }
      }
      var objStatus = document.getElementById("status");
      if(objStatus!=null){
        if(objStatus.options[objStatus.options.selectedIndex].value!=''){
          isSearchCri=true;
        }
      }
   
   //VsA181010-1 
   //Validation for new QE control
   var objddmm = document.getElementById("ddmm");
   var objyyyy = document.getElementById("yyyy");
    var currentTime = new Date();
    var year = currentTime.getFullYear();
   if(objddmm!=null && objyyyy!=null){
        if(objddmm.value!='' && objyyyy.value!=''){
          isSearchCri=true;
        }
   }
   
    if(objddmm.value!=""){
        if(objyyyy.value==""){
            alert("Please enter year");
            return false;
        }
    }
    if(objyyyy.value!=""){
        if(objddmm.value==""){
            alert("Please select quarter");
            return false;
        }
    }
    
    if(objyyyy.value!=""){
        if(objyyyy.value.length != 4) {
            alert('Please enter year in YYYY format');
            return false;
        }
    }
    if(objyyyy.value!=""){
        if(objyyyy.value < 2002){
            alert('Please enter year from 2002');
            return false;
        }
    }
    if(objyyyy.value!=""){
        if(objyyyy.value > year){
            alert('Please enter year upto current year');
            return false;
        }
    }
   //VsA181010-1  

      if(isSearchCri){
        document.osrsch.action="OsrSearch.do";
        document.osrsch.method="post";
        document.osrsch.submit();
      }else{
        alert(srchMsg4Cri);
      }

    }
      
     
 
   
   function selectAllLOsr(){
      abnCheckAs(document.osrsch.osrId,document.osrsch.lc.checked);
   }

//Abn:Osr1
function viewAOsr1(){//Abn:fine
  showInBody("Osr1Dets.do?"+abnTarget+"="+abnTarget2Add);
}
function viewAFOsr1(osrSNo){//Abn:fine
  showInBody("Osr1Fetch.do?"+abnTarget+"="+abnTarget2Approve+"&"+abnOsrsParam+"="+abnOsr1+"&osrSNo="+osrSNo);
}
function approveOsr1(osr1Status){//Abn:fine
  if(abnMaxLengthFail(document.osr1det.osr1RevertRemk,"Comments",500)){
    return false;
  }
  var confirmMsg='Are you sure, you want to take this action?';
  if(osr1Status=='R'){
    confirmMsg='Are you sure, you want to revert?';
    if(abnRequiredFail(document.osr1det.osr1RevertRemk,"Comments")){
      return false;
    }
  }else{
    confirmMsg='Are you sure, you want to approve?';
  }
  var istd=confirm(confirmMsg);
  if(istd==true){
    document.osr1det.action="Osr1Approve.do?osr1Status="+osr1Status;
    document.osr1det.method="post";
    document.osr1det.submit();
  }
}
function viewRFOsr1(osrSNo){//Abn:fine
  showInBody("Osr1Fetch.do?"+abnTarget+"="+abnTarget2Resubmit+"&"+abnOsrsParam+"="+abnOsr1+"&osrSNo="+osrSNo);
}
function viewVFOsr1(osrSNo){//Abn:fine
  showInBody("Osr1Fetch.do?"+abnTarget+"="+abnTarget2View+"&"+abnOsrsParam+"="+abnOsr1+"&osrSNo="+osrSNo);
}

function viewEFOsr1(){
  document.osr1det.action="Osr1Fetch.do?"+abnTarget+"="+abnTarget2Edit;
  document.osr1det.method="post";
  document.osr1det.submit();
}
function viewELOsr1(){
  var noClick=abnCountChecked(document.osr1list.osr1No);
  if(noClick==-1){
    return;
  }
  if(noClick>1){
    alert("Please select only one row");
    return false;
  }else if(noClick<1){
    alert("Please select a row");
    return false;
  }else{
    document.osr1list.action="Osr1Fetch.do";
    document.osr1list.method="post";
    document.osr1list.submit();
  }
}
function viewROsr1(){
  var noClick=abnCountChecked(document.osr1list.osr1No);
  if(noClick==-1){
    return;
  }
  if(noClick>1){
    alert("Please select only one row");
    return false;
  }else if(noClick<1){
    alert("Please select a row");
    return false;
  }else{
    document.osr1list.action="Osr1Fetch.do";
    document.osr1list.method="post";
    document.osr1list.submit();
  }
}
function validateOsr1(){//Abn:fine
  if(!isCSV) return true;
  if(abnRequiredFail(document.osr1det.stateId,"State")){
    return false;
  }
  if(abnRequiredFail(document.osr1det.agrId,"Activity")){
    return false;
  }
  if(document.osr1det.agrType.value==abnAgrTypeIr){
    if(abnRequiredFail(document.osr1det.clusterId,"Cluster No")){
      return false;
    }
    if(abnRequiredFail(document.osr1det.clstPart,"Claim for")){
      return false;
    }
    if(abnRequiredFail(document.osr1det.maxSites,"Total No of sites")){
      return false;
    }
  }
  // VsA181010-1 -- Start --
  if(abnRequiredFail(document.osr1det.ddmm,"Quarter End")){
    return false;
  }
  if(abnRequiredFail(document.osr1det.yyyy,"Year")){
    return false;
  }
  
  if(isFormatYear(document.osr1det.yyyy.value,"Year")){
    return false;
  }  

  if(isLessYear(document.osr1det.yyyy.value,"Year")){
    return false;
  }  
  if(isGreaterYear(document.osr1det.yyyy.value,"Year",currentYear)){
    return false;
  }  
  // VsA181010-1 -- End --
  
  if(abnRequiredFail(document.osr1det.uspId,"Service Provider")){
    return false;
  }
  if(abnRequiredFail(document.osr1det.receiptDt,"Date of Receipt")){
    return false;
  }
  if(abnRequiredFail(document.osr1det.claimedNo,"Claimed No")){
    return false;
  }
  if(abnRequiredFail(document.osr1det.claimedAmt,"Claimed Amount")){
    return false;
  }
  if(abnRequiredFail(document.osr1det.osr1SendDt,"Date of sending OSR-1")){
    return false;
  }
 //YK:A220611
  if(isGreaterDate(document.osr1det.ddmm.value+document.osr1det.yyyy.value,document.osr1det.agrClrDt.value,dateFormat)){
	    alert("Quarter End Date should not be greater than Activity Closer Date.");
	    document.osr1det.agrClrDt.focus();
	    return false;
  }
  
  //YK:A150611
   
  if(getDaysDiff(document.osr1det.ddmm.value+document.osr1det.yyyy.value,document.osr1det.receiptDt.value,dateFormat)>=31){
	    if(abnRequiredFail(document.osr1det.osr1DelayReason,"Details of Condonation")){
	       return false;
	    }
	  }
  
    
  /* vs if(getDaysDiff(document.osr1det.qeDt.value,document.osr1det.osr1SendDt.value,dateFormat)>=32){
  //Abn:ToVerify Either document.osr1det.receiptDt.value OR document.osr1det.osr1SendDt.value
  //if(isGreaterDate(document.osr1det.osr1SendDt1MonthBefore.value,document.osr1det.osr1SendDt.value,dateFormat)){
    if(abnRequiredFail(document.osr1det.osr1DelayReason,"Details of Condonation")){
      return false;
    }
  }*/
  if(document.osr1det.agrType.value==abnAgrTypeIr){
    if(abnMaxLengthFail(document.osr1det.clusterId,"Cluster No",10)){
      return false;
    }
    if(abnMaxLengthFail(document.osr1det.clstPart,"Claim for",10)){
      return false;
    }
    if(abnMaxLengthFail(document.osr1det.maxSites,"Total No of sites",10)){
      return false;
    }
  }
 /* vs if(abnMaxLengthFail(document.osr1det.qeDt,"Quarter End",10)){
    return false;
  }*/
  if(abnMaxLengthFail(document.osr1det.receiptDt,"Date of Receipt",10)){
    return false;
  }
  if(abnMaxLengthFail(document.osr1det.claimedNo,"Claimed No",10)){
    return false;
  }
  if(abnMaxLengthFail(document.osr1det.claimedAmt,"Claimed Amount",10)){
    return false;
  }
  if(abnMaxLengthFail(document.osr1det.osr1SendDt,"Date of sending OSR-1",10)){
    return false;
  }
  if(abnMaxLengthFail(document.osr1det.osr1DelayReason,"Details of Condonation",500)){
    return false;
  }
  if(abnMaxLengthFail(document.osr1det.osr1Remk,"Remarks",500)){
    return false;
  }
  if(abnMaxLengthFail(document.osr1det.osr1RevertRemk,"Comments",500)){
    return false;
  }
  /*
  if(abnDateFail(document.osr1det.qeDt,"Quarter End")){
    return false;
  }
  */
  if(document.osr1det.agrType.value==abnAgrTypeIr){
    if(abnIntegerFail(document.osr1det.maxSites,"Total No of sites")){
      return false;
    }
  }
  if(abnIntegerFail(document.osr1det.claimedNo,"Claimed No")){
    return false;
  }
  if(abnIntegerFail(document.osr1det.claimedAmt,"Claimed Amount")){
    return false;
  }
 /* vs if(abnQuaterEndFail(document.osr1det.qeDt,"Quarter End")){
    return false;
  }*/
  //
 /* vs if(isGreaterDate(document.osr1det.qeDt.value,document.osr1det.osr1Addedon.value,dateFormat)){
    alert("Please select the previous Quarter End.");
    document.osr1det.qeDt.focus();
    return false;
  }*/
  //YK:A220611
  if(isGreaterDate(document.osr1det.ddmm.value+document.osr1det.yyyy.value,document.osr1det.osr1Addedon.value,dateFormat)){
	    alert("Please select the previous Quarter End.");
	    document.osr1det.qeDt.focus();
	    return false;
  }
  //end YK:A220611
  if(isGreaterDate(document.osr1det.receiptDt.value,document.osr1det.osr1SendDt.value,dateFormat)){
    alert("Date of Receipt can not be greater than today.");
    document.osr1det.receiptDt.focus();
    return false;
  }
  
  //Abn:ToDo Other validation
  /*
  if(abnDateFail(document.quotdet.confirmationDt,"Customer Ref. Letter Date")){
    return false;
  }
  if(abnPhoneNumberFail(document.custcontdet.phone,"Phone No.")){
    return false;
  }
  if(abnEmailFail(document.custcontdet.email,"Email")){
    return false;
  }
  if(abnPINFail(document.custadddet.pinnum,"PIN")){
    return false;
  }
  */
  
  return true;
}
function addOsr1(){//Abn:fine
  if(validateOsr1()){
    document.osr1det.action="Osr1AddSave.do";
    document.osr1det.method="post";
    document.osr1det.submit();
  }
}
function editOsr1(){
  if(validateOsr1()){
    document.osr1det.action="Osr1EditSave.do";
    document.osr1det.method="post";
    document.osr1det.submit();
  }
}
function saveOsr1(){//Abn:fine
  if(document.osr1det.osr1SNo.value == '' || document.osr1det.osr1SNo.value == null || document.osr1det.osr1SNo.value == '0'){
    addOsr1();
  }else{
    editOsr1();
  }
}
function deleteFOsr1(){
  var istd=confirm("Are you sure, you want to delete?");
  if(istd==true){
    document.osr1det.action="Osr1DeleteSave.do";
    document.osr1det.method="post";
    document.osr1det.submit();
  }
}
function deleteLOsr1(){
  var noClick=abnCountChecked(document.osr1list.osr1No);
  if(noClick==-1){
    return;
  }
  if(noClick<1){
    alert("Please select at least one row");
    return false;
  }else{
    var istd=confirm("Are you sure, you want to delete?");
    if(istd==true){
      document.osr1list.action="Osr1DeleteSave.do";
      document.osr1list.method="post";
      document.osr1list.submit();
    }
  }
}
function getPgOsr1(){
    document.osr1sch.rPg.value=document.osr1list.rPg.value;
    submitSchOsr1();
}
function getPrvPgOsr1(){
    if(document.osr1list.rPg.options.selectedIndex>0){
        document.osr1list.rPg.options.selectedIndex=document.osr1list.rPg.options.selectedIndex-1;
        getPgOsr1();
    }
}
function getNxtPgOsr1(){
    if(document.osr1list.rPg.options.selectedIndex<document.osr1list.rPg.options.length-1){
        document.osr1list.rPg.options.selectedIndex=document.osr1list.rPg.options.selectedIndex+1;
        getPgOsr1();
    }
}
function searchOsr1(){
  document.osr1sch.rPg.value="";
  submitSchOsr1();
}
function submitSchOsr1(){
  document.osr1sch.action="Osr1Search.do";
  document.osr1sch.method="post";
  document.osr1sch.submit();
}
function resetschOsr1(){
  var objCcaId = document.getElementById("ccaId");
  if(objCcaId!=null){
    objCcaId.options.selectedIndex=0;
  }
  var objStateId = document.getElementById("stateId");
  if(objStateId!=null){
    objStateId.options.selectedIndex=0;
  }
  var objAgrId = document.getElementById("agrId");
  if(objAgrId!=null){
    objAgrId.options.selectedIndex=0;
  }
  var objUspId = document.getElementById("uspId");
  if(objUspId!=null){
    objUspId.options.selectedIndex=0;
  }
  
  //VsA181010-1 -- Start---
  /*var objQeDt = document.getElementById("qeDt");
  if(objQeDt!=null){
  objQeDt.value='';
  }*/
  var objddmm = document.getElementById("ddmm");
  if(objddmm!=null){
    objddmm.options.selectedIndex=0;
  }
  var objyyyy = document.getElementById("yyyy");
  if(objyyyy!=null){
    objyyyy.value='';
  }
  //VsA181010-1 -- End ---
  
  var objReceiptDt = document.getElementById("receiptDt");
  if(objReceiptDt!=null){
    objReceiptDt.value='';
  }
  var objApproveDt = document.getElementById("approveDt");
  if(objApproveDt!=null){
    objApproveDt.value='';
  }
  var objStatus = document.getElementById("status");
  if(objStatus!=null){
    objStatus.options.selectedIndex=0;
  }
}
function selectAllLOsr1(){
  abnCheckAs(document.osr1list.osr1No,document.osr1list.lc.checked);
}
function listOsr1(){
  document.location.href = "Osr1List.do";
}



   

//Abn:Osr2
function viewAOsr2(osrSNo){//Abn:fine
  showInBody("Osr2Fetch.do?"+abnTarget+"="+abnTarget2Add+"&osrSNo="+osrSNo);
}
function viewAFOsr2(osrSNo){//Abn:fine
  showInBody("Osr2Fetch.do?"+abnTarget+"="+abnTarget2Approve+"&"+abnOsrsParam+"="+abnOsr2+"&osrSNo="+osrSNo);
}
function approveOsr2(osr2Status){//Abn:fine
  if(abnMaxLengthFail(document.osr2det.osr2SanctionNo,"Sanction No",50)){
    return false;
  }
  if(abnMaxLengthFail(document.osr2det.osr2RevertRemk,"Comments",500)){
    return false;
  }
  var confirmMsg='Are you sure, you want to take this action?';
  if(osr2Status=='R'){
    confirmMsg='Are you sure, you want to revert?';
    if(abnRequiredFail(document.osr2det.osr2RevertRemk,"Comments")){
      return false;
    }
  }else{
    if(abnRequiredFail(document.osr2det.osr2SanctionNo,"Sanction No")){
      return false;
    }
    confirmMsg='Are you sure, you want to approve?';
  }
  var istd=confirm(confirmMsg);
  if(istd==true){
    document.osr2det.action="Osr2Approve.do?osr2Status="+osr2Status;
    document.osr2det.method="post";
    document.osr2det.submit();
  }
}
function viewRFOsr2(osrSNo){//Abn:fine
  showInBody("Osr2Fetch.do?"+abnTarget+"="+abnTarget2Resubmit+"&"+abnOsrsParam+"="+abnOsr2+"&osrSNo="+osrSNo);
}
function viewVFOsr2(osrSNo){//Abn:fine
  showInBody("Osr2Fetch.do?"+abnTarget+"="+abnTarget2View+"&"+abnOsrsParam+"="+abnOsr2+"&osrSNo="+osrSNo);
}

function viewEFOsr2(){
  document.osr2det.action="Osr2Fetch.do?"+abnTarget+"="+abnTarget2Edit;
  document.osr2det.method="post";
  document.osr2det.submit();
}
function viewELOsr2(){
  var noClick=abnCountChecked(document.osr2list.osr2No);
  if(noClick==-1){
    return;
  }
  if(noClick>1){
    alert("Please select only one row");
    return false;
  }else if(noClick<1){
    alert("Please select a row");
    return false;
  }else{
    document.osr2list.action="Osr2Fetch.do";
    document.osr2list.method="post";
    document.osr2list.submit();
  }
}
function viewROsr2(){
  var noClick=abnCountChecked(document.osr2list.osr2No);
  if(noClick==-1){
    return;
  }
  if(noClick>1){
    alert("Please select only one row");
    return false;
  }else if(noClick<1){
    alert("Please select a row");
    return false;
  }else{
    document.osr2list.action="Osr2Fetch.do";
    document.osr2list.method="post";
    document.osr2list.submit();
  }
}
function validateOsr2(){//Abn:fine
  if(document.osr2det.claimedNo.value==''){
    document.osr2det.claimedNo.value='0';
  }
  if(document.osr2det.claimedAmt.value==''){
    document.osr2det.claimedAmt.value='0';
  }
  if(document.osr2det.withheldNo.value==''){
    document.osr2det.withheldNo.value='0';
  }
  if(document.osr2det.withheldAmt.value==''){
    document.osr2det.withheldAmt.value='0';
  }
  if(document.osr2det.disallowedNo.value==''){
    document.osr2det.disallowedNo.value='0';
  }
  if(document.osr2det.disallowedAmt.value==''){
    document.osr2det.disallowedAmt.value='0';
  }
  if(document.osr2det.adjustedAmt.value==''){
    document.osr2det.adjustedAmt.value='0';
  }
  var idz=parseInt(document.getElementById('countOsr2ARow').value);
  for(idx=1;idx<=idz;idx++){
    if(document.getElementById('withheldNo'+idx).value==''){
      document.getElementById('withheldNo'+idx).value='0';
    }
    if(document.getElementById('withheldAmt'+idx).value==''){
      document.getElementById('withheldAmt'+idx).value='0';
    }
    if(document.getElementById('disallowedNo'+idx).value==''){
      document.getElementById('disallowedNo'+idx).value='0';
    }
    if(document.getElementById('disallowedAmt'+idx).value==''){
      document.getElementById('disallowedAmt'+idx).value='0';
    }
    if(document.getElementById('adjustedNo'+idx).value==''){
      document.getElementById('adjustedNo'+idx).value='0';
    }
    if(document.getElementById('adjustedAmt'+idx).value==''){
      document.getElementById('adjustedAmt'+idx).value='0';
    }
    if(document.getElementById('settledNo'+idx).value==''){
      document.getElementById('settledNo'+idx).value='0';
    }
    if(document.getElementById('settledAmt'+idx).value==''){
      document.getElementById('settledAmt'+idx).value='0';
    }
    
  //YK:140611
	  
	  if(document.getElementById('withheldAmt'+idx).value!=''){
	     var tempWithHeldAmt =document.getElementById('withheldAmt'+idx).value;
	     var withheldamtIdx=parseInt(tempWithHeldAmt);//.substring(1,tempWithHeldAmt.length));
	     //var withheldamtIdx=parseInt(tempWithHeldAmt.substring(1,tempWithHeldAmt.length));
	      
	      var forAWO =parseInt(document.getElementById('forAWO'+idx).value);     
	      if((forAWO-(-withheldamtIdx))<0){                        
	      alert('Entered correct Amount'); 
	      document.getElementById('withheldAmt'+idx).focus();
	      return false;                                                 
	      }
	  }
	  
	  if(document.getElementById('disallowedAmt'+idx).value!=''){
		     var tempDisallowedAmt =document.getElementById('disallowedAmt'+idx).value;
		     var withheldamtIdx =parseInt(tempDisallowedAmt);
		     //var withheldamtIdx=parseInt(tempDisallowedAmt.substring(1,tempDisallowedAmt.length));
		      
		      var forADO =parseInt(document.getElementById('forADO'+idx).value);     
		     // alert("withheldamtIdx="+withheldamtIdx+"forAWO="+forAWO);
		      if((forADO-(-withheldamtIdx))<0){                        
		      alert('Entered correct Amount'); 
		      document.getElementById('disallowedAmt'+idx).focus();
		      return false;                                                 
		      }
		  }
	  
    
  }

  if(!isCSV) return true;
  if(abnRequiredFail(document.osr2det.stateId,"State")){
    return false;
  }
  if(abnRequiredFail(document.osr2det.agrId,"Activity")){
    return false;
  }
  if(abnRequiredFail(document.osr2det.uspId,"Service Provider")){
    return false;
  }
  if(abnRequiredFail(document.osr2det.qeDt,"Quarter End")){
    return false;
  }
  if(abnRequiredFail(document.osr2det.osr2ReceiptDt,"Date of Receipt")){
    return false;
  }
  if(abnRequiredFail(document.osr2det.settledNo,"Settled No")){
    return false;
  }
  if(abnRequiredFail(document.osr2det.settledAmt,"Settled Amount")){
    return false;
  }
  if(abnRequiredFail(document.osr2det.requisitionedNo,"Requisitioned No")){
    return false;
  }
  if(abnRequiredFail(document.osr2det.requisitionedAmt,"Requisitioned Amount")){
    return false;
  }
  if(abnRequiredFail(document.osr2det.osr2SendDt,"Date of sending OSR-2")){
    return false;
  }
  
  if(abnMaxLengthFail(document.osr2det.qeDt,"Quarter End",10)){
    return false;
  }
  if(abnMaxLengthFail(document.osr2det.osr2ReceiptDt,"Date of Receipt",10)){
    return false;
  }
  if(abnMaxLengthFail(document.osr2det.osr2SendDt,"Date of sending OSR-2",10)){
    return false;
  }
  if(abnMaxLengthFail(document.osr2det.withheldNo,"Withheld No",10)){
    return false;
  }
  if(abnMaxLengthFail(document.osr2det.withheldAmt,"Withheld Amount",10)){
    return false;
  }
  if(abnMaxLengthFail(document.osr2det.withheldReason,"Reason for withheld",500)){
    return false;
  }
  if(abnMaxLengthFail(document.osr2det.disallowedNo,"Disallowed No",10)){
    return false;
  }
  if(abnMaxLengthFail(document.osr2det.disallowedAmt,"Disallowed Amount",10)){
    return false;
  }
  if(abnMaxLengthFail(document.osr2det.disallowedReason,"Reason for disallowed",500)){
    return false;
  }
  if(abnMaxLengthFail(document.osr2det.settledNo,"Settled No",10)){
    return false;
  }
  if(abnMaxLengthFail(document.osr2det.settledAmt,"Settled Amount",10)){
    return false;
  }
  if(abnMaxLengthFail(document.osr2det.adjustedNo,"Adjusted No",10)){
    return false;
  }
  if(abnMaxLengthFail(document.osr2det.adjustedAmt,"Adjusted Amount",10)){
    return false;
  }
  if(abnMaxLengthFail(document.osr2det.requisitionedNo,"Requisitioned No",10)){
    return false;
  }
  if(abnMaxLengthFail(document.osr2det.requisitionedAmt,"Requisitioned Amount",10)){
    return false;
  }
  if(abnMaxLengthFail(document.osr2det.osr2Remk,"Remarks",500)){
    return false;
  }
  if(abnMaxLengthFail(document.osr2det.osr2RevertRemk,"Comments",500)){
    return false;
  }
  
  if(abnQuaterEndFail(document.osr2det.qeDt,"Quarter End")){
    return false;
  }
  if(abnIntegerFail(document.osr2det.withheldNo,"Withheld No")){
    return false;
  }
  if(abnIntegerFail(document.osr2det.withheldAmt,"Withheld Amount")){
    return false;
  }
  if(abnIntegerFail(document.osr2det.disallowedNo,"Disallowed No")){
    return false;
  }
  if(abnIntegerFail(document.osr2det.disallowedAmt,"Disallowed Amount")){
    return false;
  }
  if(abnIntegerFail(document.osr2det.settledNo,"Settled No")){
    return false;
  }
  if(abnIntegerFail(document.osr2det.settledAmt,"Settled Amount")){
    return false;
  }
  if(abnIntegerFail(document.osr2det.adjustedNo,"Adjusted No")){
    return false;
  }
  if(abnIntegerFail(document.osr2det.adjustedAmt,"Adjusted Amount")){
    return false;
  }
  if(abnIntegerFail(document.osr2det.requisitionedNo,"Requisitioned No")){
    return false;
  }
  if(abnIntegerFail(document.osr2det.requisitionedAmt,"Requisitioned Amount")){
    return false;
  }
  if(isGreaterDate(document.osr2det.osr2ReceiptDt.value,document.osr2det.osr2SendDt.value,dateFormat)){
    alert("Date of Receipt can not be greater than today.");
    document.osr2det.osr2ReceiptDt.focus();
    return false;
  }
  if(document.osr2det.withheldAmt.value!=''){
    if(parseInt(document.osr2det.withheldAmt.value)>0){
      if(abnRequiredFail(document.osr2det.withheldReason,"Reason for Withheld")){
        return false;
      }
    }
  }
  if(document.osr2det.disallowedAmt.value!=''){
    if(parseInt(document.osr2det.disallowedAmt.value)>0){
      if(abnRequiredFail(document.osr2det.disallowedReason,"Reason for Disallowed")){
        return false;
      }
    }
  }
  
  
  if(!validateOsr2Grid()){
    return false;
  }
  
  //Abn:ToDo Other validation
  return true;
}
function validateOsr2Grid(){
  var idz=parseInt(document.getElementById('countOsr2ARow').value);
  var vCalcTotAmtPR=0;
  for(idx=1;idx<=idz;idx++){
    if(document.getElementById('abnGRow'+idx).checked){
        if(isLesserDate(document.osr2det.qeDt.value,document.getElementById('qeDt'+idx).value,dateFormat)){
          alert("Quarter End for row " + idx + " must be less than "+document.osr2det.qeDt.value+".");
          //document.getElementById('qeDt'+idx).focus();
          return false;
        }

        if(abnRequiredFail(document.getElementById('qeDt'+idx),"Quarter End")){
          return false;
        }
        if(abnRequiredFail(document.getElementById('agrId'+idx),"Activity")){
          return false;
        }
        if(abnRequiredFail(document.getElementById('calcAmtPR'+idx),"Amount Payable/Recoverable")){
          return false;
        }
    
        if(abnMaxLengthFail(document.getElementById('qeDt'+idx),"Quarter End",10)){
          return false;
        }
        if(abnMaxLengthFail(document.getElementById('withheldNo'+idx),"Withheld No",10)){
          return false;
        }
        if(abnMaxLengthFail(document.getElementById('withheldAmt'+idx),"Withheld Amount",10)){
          return false;
        }
        if(abnMaxLengthFail(document.getElementById('disallowedNo'+idx),"Disallowed No",10)){
          return false;
        }
        if(abnMaxLengthFail(document.getElementById('disallowedAmt'+idx),"Disallowed Amount",10)){
          return false;
        }
        if(abnMaxLengthFail(document.getElementById('adjustedNo'+idx),"Adjusted No",10)){
          return false;
        }
        if(abnMaxLengthFail(document.getElementById('adjustedAmt'+idx),"Adjusted Amount",10)){
          return false;
        }
        if(abnMaxLengthFail(document.getElementById('adjustedHead'+idx),"Reason for Adjustment",10)){
          return false;
        }
        if(abnMaxLengthFail(document.getElementById('calcAmtPR'+idx),"Amount Payable/Recoverable",10)){
          return false;
        }
    
        if(abnQuaterEndFail(document.getElementById('qeDt'+idx),"Quarter End")){
          return false;
        }
        if(abnIntegerFail(document.getElementById('withheldNo'+idx),"Withheld No")){
          return false;
        }
        if(abnIntegerFail(document.getElementById('withheldAmt'+idx),"Withheld Amount")){
          return false;
        }
        if(abnIntegerFail(document.getElementById('disallowedNo'+idx),"Disallowed No")){
          return false;
        }
        if(abnIntegerFail(document.getElementById('disallowedAmt'+idx),"Disallowed Amount")){
          return false;
        }
        if(abnIntegerFail(document.getElementById('adjustedNo'+idx),"Adjusted No")){
          return false;
        }
        if(abnIntegerFail(document.getElementById('adjustedAmt'+idx),"Adjusted Amount")){
          return false;
        }
        if(abnIntegerFail(document.getElementById('calcAmtPR'+idx),"Amount Payable/Recoverable")){
          return false;
        }
        
    }
  }
  return true;
}


function addOsr2(){//Abn:fine
  if(validateOsr2()){
    document.osr2det.action="Osr2AddSave.do";
    document.osr2det.method="post";
    document.osr2det.submit();
  }
}
function editOsr2(){
  if(validateOsr2()){
    document.osr2det.action="Osr2EditSave.do";
    document.osr2det.method="post";
    document.osr2det.submit();
  }
}
function saveOsr2(){//Abn:fine
  if(document.osr2det.osr2SNo.value == '' || document.osr2det.osr2SNo.value == null || document.osr2det.osr2SNo.value == '0'){
    addOsr2();
  }else{
    editOsr2();
  }
}
function deleteFOsr2(){
  var istd=confirm("Are you sure, you want to delete?");
  if(istd==true){
    document.osr2det.action="Osr2DeleteSave.do";
    document.osr2det.method="post";
    document.osr2det.submit();
  }
}
function deleteLOsr2(){
  var noClick=abnCountChecked(document.osr2list.osr2No);
  if(noClick==-1){
    return;
  }
  if(noClick<1){
    alert("Please select at least one row");
    return false;
  }else{
    var istd=confirm("Are you sure, you want to delete?");
    if(istd==true){
      document.osr2list.action="Osr2DeleteSave.do";
      document.osr2list.method="post";
      document.osr2list.submit();
    }
  }
}
function getPgOsr2(){
    document.osr2sch.rPg.value=document.osr2list.rPg.value;
    submitSchOsr2();
}
function getPrvPgOsr2(){
    if(document.osr2list.rPg.options.selectedIndex>0){
        document.osr2list.rPg.options.selectedIndex=document.osr2list.rPg.options.selectedIndex-1;
        getPgOsr2();
    }
}
function getNxtPgOsr2(){
    if(document.osr2list.rPg.options.selectedIndex<document.osr2list.rPg.options.length-1){
        document.osr2list.rPg.options.selectedIndex=document.osr2list.rPg.options.selectedIndex+1;
        getPgOsr2();
    }
}
function searchOsr2(){
  document.osr2sch.rPg.value="";
  submitSchOsr2();
}
function submitSchOsr2(){
  document.osr2sch.action="Osr2Search.do";
  document.osr2sch.method="post";
  document.osr2sch.submit();
}
function resetschOsr2(){
  //Abn:ToDo document.osr2sch.customerName.value="";
}
function selectAllLOsr2(){
  abnCheckAs(document.osr2list.osr2No,document.osr2list.lc.checked);
}
function listOsr2(){
  document.location.href = "Osr2List.do";
}
function calCOsr2(){
  var cno=0;
  var camt=0.0;
  var withheldno=0;
  var withheldamt=0.0;
  var disallowedno=0;
  var disallowedamt=0.0;
  var settlementno=0;
  var settlementamt=0.0;
  var adjustedamt=0.0;
  var requisitionedamt=0.0;
  if(document.osr2det.claimedNo.value!=''){
    cno=parseInt(document.osr2det.claimedNo.value);
  }
  if(document.osr2det.claimedAmt.value!=''){
    camt=parseInt(document.osr2det.claimedAmt.value);
  }
  //alert(cno + ' : ' + camt); 
  if(document.osr2det.withheldNo.value!=''){
    withheldno=parseInt(document.osr2det.withheldNo.value);
  }
  if(document.osr2det.withheldAmt.value!=''){
    withheldamt=parseInt(document.osr2det.withheldAmt.value);
  }
  //alert(withheldno + ' : ' + withheldamt);
  if(document.osr2det.disallowedNo.value!=''){
    disallowedno=parseInt(document.osr2det.disallowedNo.value);
  }
  if(document.osr2det.disallowedAmt.value!=''){
    disallowedamt=parseInt(document.osr2det.disallowedAmt.value);
  }
  //alert(disallowedno + ' : ' + disallowedamt);
  if(document.osr2det.adjustedAmt.value!=''){
    adjustedamt=parseInt(document.osr2det.adjustedAmt.value);
  }
  //alert("YK:210611"+adjustedamt);
  
   settlementno=cno-withheldno-disallowedno;
  settlementamt=camt-withheldamt-disallowedamt;
  requisitionedamt=settlementamt+adjustedamt;
   
   
  /*
   when requisitionedamnt is wrong
   * settlementno=cno-withheldno-disallowedno;
  
  requisitionedamt=settlementamt+adjustedamt; //YK:C210611
  //YK:A210611
  settlementamt=camt-withheldamt-disallowedamt;
  if(camt=='0'){
	 // alert("abc");
	  requisitionedamt=-adjustedamt
  }else{
  requisitionedamt=settlementamt+adjustedamt;
  }*/
  
  
  document.osr2det.settledNo.value=settlementno;
  document.osr2det.settledAmt.value=settlementamt;
  document.osr2det.requisitionedAmt.value=requisitionedamt;
  //alert("document.osr2det.requisitionedAmt.value="+document.osr2det.requisitionedAmt.value);
  document.osr2det.requisitionedNo.value=settlementno;
  
  document.getElementById("abnDsettledNo").innerText=settlementno;
  document.getElementById("abnDsettledAmt").innerText=settlementamt;
  document.getElementById("abnDrequisitionedAmt").innerText=requisitionedamt;
}
function calCOsr2Grid(){
	
  var idz=parseInt(document.getElementById('countOsr2ARow').value);
  var vCalcTotAmtPR=0;
  var withheldnoIdx=0;
  var withheldamtIdx=0;
  var disallowednoIdx=0;
  var disallowedamtIdx=0;
  var adjustedAmtIdx=0;
  for(idx=1;idx<=idz;idx++){
    withheldnoIdx=0;
    withheldamtIdx=0;
    disallowednoIdx=0;
    disallowedamtIdx=0;
    adjustedAmtIdx=0;
    
    if(document.getElementById('withheldNo'+idx).value!=''){
      withheldnoIdx=document.getElementById('withheldNo'+idx).value;
      
    }
    if(document.getElementById('withheldAmt'+idx).value!=''){
    	
      withheldamtIdx=document.getElementById('withheldAmt'+idx).value;
      
     /* var forAWO =document.getElementById('forAWO'+idx).value;      //YK:A130611
      if(forAWO=='0'&&withheldamtIdx=='-'){                        //YK:A130611
      alert('Withheld amount does not exist');                     //YK:A130611
      return false;                                                //YK:A130611    
      }*/
      
    }
    if(document.getElementById('disallowedNo'+idx).value!=''){
      disallowednoIdx=document.getElementById('disallowedNo'+idx).value;
    }
    if(document.getElementById('disallowedAmt'+idx).value!=''){
      disallowedamtIdx=document.getElementById('disallowedAmt'+idx).value;
      /*var forADO =document.getElementById('forADO'+idx).value;      //YK:A130611
      if(forADO=='0'&&disallowedamtIdx=='-'){                        //YK:A130611
      alert('Disallowed amount does not exist');                     //YK:A130611
      return false;                                                //YK:A130611    
      }*/
    }
    
    if(document.getElementById('adjustedAmt'+idx).value!=''){
      adjustedAmtIdx=document.getElementById('adjustedAmt'+idx).value;
    }
    if(document.getElementById('abnGRow'+idx).checked){
        document.getElementById('adjustedNo'+idx).value=0;
        document.getElementById('settledNo'+idx).value=0-parseInt(withheldnoIdx)-parseInt(disallowednoIdx);
        document.getElementById('settledAmt'+idx).value=0-parseInt(withheldamtIdx)-parseInt(disallowedamtIdx);
        document.getElementById('calcAmtPR'+idx).value=(parseInt(withheldamtIdx)+parseInt(disallowedamtIdx)+parseInt(adjustedAmtIdx));
        document.getElementById('abnDcalcAmtPR'+idx).innerText=document.getElementById('calcAmtPR'+idx).value;//Abn180609
        vCalcTotAmtPR=vCalcTotAmtPR+parseInt(document.getElementById('calcAmtPR'+idx).value);
    }
  }
  
  document.osr2det.calcTotAmtPR.value=vCalcTotAmtPR;
  document.getElementById("abnDcalcTotAmtPR").innerText=document.osr2det.calcTotAmtPR.value;//Abn180609//0-parseInt()

  document.osr2det.adjustedAmt.value=parseInt(0)-parseInt(document.osr2det.calcTotAmtPR.value);
 
  document.getElementById("abnDadjustedAmt").innerText=document.osr2det.adjustedAmt.value;
  
  calCOsr2();

}

var numLinesAdded = 0;

function addOsr2ARow(){
	
    numLinesAdded++;
    /*if(numLinesAdded>1){             //YK:A020611 for preventing entry of multiple OSR2A 
    alert("Please fill up freseh OSR2A for further Entries!");
    return false;
    }*/
    var id='osr2ATable';
    var trVAlign='middle';//valign="middle" 
    var trClass='USOF_Data_row1';
    if(numLinesAdded%2==0){
      trClass='USOF_Data_row2'
    }else{
      trClass='USOF_Data_row1';
    }
    var tdClass='USOF_Data_txt';
    
    
    
    
    var vOsr2ATable = document.getElementById('osr2ATable');
    //var lastRow = vOsr2ATable.rows.length;  
    var vTBody = vOsr2ATable.getElementsByTagName('TBODY')[0];
    var vNewRow = document.createElement("<TR CLASS='"+trClass+"' valign='"+trVAlign+"' >");
    //vNewRow.setAttribute('class',trClass);vNewRow.setAttribute('valign',trVAlign);
    
    
    
    var vTd0 = document.createElement("<TD CLASS='"+tdClass+"'>");
    //vTd0.setAttribute('CLASS',tdClass);
    var vTdCtrl0 = document.createElement("<INPUT type='checkbox' id='abnGRow"+numLinesAdded+"' checked='checked' value='"+numLinesAdded+"'>");
    vTdCtrl0.setAttribute('name','abnGRow'+numLinesAdded);
    //vTdCtrl0.setAttribute('TYPE','TEXT');vTdCtrl0.setAttribute('CLASS','USOF_text_box');vTdCtrl0.setAttribute('STYLE','WIDTH:50px; ');vTdCtrl0.setAttribute('VALUE','0');
    vTd0.appendChild(vTdCtrl0);
    vNewRow.appendChild(vTd0);
    //
    
    var vTd1 = document.createElement("<TD CLASS='"+tdClass+"'>");
    //vTd1.setAttribute('CLASS',tdClass);
    var vTdCtrl1 = document.createElement("<INPUT id='qeDt"+numLinesAdded+"' type='text' class='USOF_text_box' STYLE='WIDTH:75px; ' readonly='readonly' value='' title='Quarter End'  onblur='javascript:getActivitiesOnQe(this,"+numLinesAdded+");'>");
    vTdCtrl1.setAttribute('name','qeDt'+numLinesAdded);
    //vTdCtrl1.setAttribute('TYPE','TEXT');vTdCtrl1.setAttribute('CLASS','USOF_text_box');vTdCtrl1.setAttribute('STYLE','WIDTH:50px; ');vTdCtrl1.setAttribute('VALUE','');
    vTd1.appendChild(vTdCtrl1);
    /**/
    var vTdCtrl1CldrA = document.createElement("<a onclick='javascript:abnToggleCalendar(\"qeDt"+numLinesAdded+"\");'>");
    var vTdCtrl1CldrImg = document.createElement("<img src='images/calendar2.png' alt='Calendar' border='0'/>");
    vTdCtrl1CldrA.appendChild(vTdCtrl1CldrImg);
    vTd1.appendChild(vTdCtrl1CldrA);
    /**/
    vNewRow.appendChild(vTd1);

    var vTd2 = document.createElement("<TD CLASS='"+tdClass+"'>");
    //vTd2.setAttribute('CLASS',tdClass);
    var vTdCtrl2 = document.createElement("<SELECT id='agrId"+numLinesAdded+"' CLASS='USOF_combo_box' STYLE='WIDTH:120px; ' title='Activity' onchange='javascript:getOsr2Details(this,"+numLinesAdded+");'>");
    vTdCtrl2.setAttribute('name','agrId'+numLinesAdded);
   
    //YK:A150611
    var history = document.createElement("<Input type= 'button' value='History' style='width:60px;' onClick='javascript:historyTest(this,"+numLinesAdded+");'>");
    //vTdCtrl2.appendChild(history);
    
    
    //vTdCtrl2.setAttribute('TYPE','TEXT');vTdCtrl2.setAttribute('VALUE','');//vTdCtrl2.setAttribute('CLASS','USOF_combo_box');//vTdCtrl2.setAttribute('STYLE','WIDTH:50px; ');
    /*
    var vTdCtrl2Op = window.document.createElement("OPTION"); vTdCtrl2Op.innerText='--Select--'; vTdCtrl2Op.setAttribute('VALUE',''); vTdCtrl2.appendChild(vTdCtrl2Op);
    */
    /*
    var vAgrId1 = document.getElementById('agrId1');
    for(idx=0;idx<vAgrId1.options.length;idx++){
      var vTdCtrl2Op = window.document.createElement("OPTION");
      vTdCtrl2Op.innerText=vAgrId1.options[idx].text;
      vTdCtrl2Op.setAttribute('value',vAgrId1.options[idx].value);
      //alert(vAgrId1.options[idx].value + " " + vAgrId1.options[idx].text);
      vTdCtrl2.appendChild(vTdCtrl2Op);
    }
    */
    vTd2.appendChild(vTdCtrl2);
    vTd2.appendChild(history)  //YK:A150611
    vNewRow.appendChild(vTd2);

    var vTd3 = document.createElement("<TD CLASS='"+tdClass+"'>");
    //vTd3.setAttribute('CLASS',tdClass);
    var vTdCtrl3 = document.createElement("<INPUT id='forACO"+numLinesAdded+"' type='hidden' class='USOF_text_box' STYLE='WIDTH:50px; ' value='' onkeyup='javascript:calCOsr2Grid();'>");
    vTdCtrl3.setAttribute('name','forACO'+numLinesAdded);
    //vTdCtrl3.setAttribute('TYPE','TEXT');vTdCtrl3.setAttribute('CLASS','USOF_text_box');vTdCtrl3.setAttribute('STYLE','WIDTH:50px; ');vTdCtrl3.setAttribute('VALUE','0');
    vTd3.appendChild(vTdCtrl3);
    var vTdSp3 = document.createElement("<span id='forACODiv"+numLinesAdded+"' class='USOF_Data_txt_hl'>");
    vTd3.appendChild(vTdSp3);
    vNewRow.appendChild(vTd3);

    var vTd4 = document.createElement("<TD CLASS='"+tdClass+"'>");
    //vTd4.setAttribute('CLASS',tdClass);
    var vTdCtrl4 = document.createElement("<INPUT id='forAWO"+numLinesAdded+"' type='hidden' class='USOF_text_box' STYLE='WIDTH:50px; ' value='' onkeyup='javascript:calCOsr2Grid();'>");
    vTdCtrl4.setAttribute('name','forAWO'+numLinesAdded);
    //vTdCtrl4.setAttribute('TYPE','TEXT');vTdCtrl4.setAttribute('CLASS','USOF_text_box');vTdCtrl4.setAttribute('STYLE','WIDTH:50px; ');vTdCtrl4.setAttribute('VALUE','0');
    vTd4.appendChild(vTdCtrl4);
    var vTdSp4 = document.createElement("<span id='forAWODiv"+numLinesAdded+"' class='USOF_Data_txt_hl'>");
    vTd4.appendChild(vTdSp4);
    vNewRow.appendChild(vTd4);

    var vTd5 = document.createElement("<TD CLASS='"+tdClass+"'>");
    //vTd5.setAttribute('CLASS',tdClass);
    var vTdCtrl5 = document.createElement("<INPUT id='forADO"+numLinesAdded+"' type='hidden' class='USOF_text_box' STYLE='WIDTH:50px; ' value='' onkeyup='javascript:calCOsr2Grid();'>");
    vTdCtrl5.setAttribute('name','forADO'+numLinesAdded);
    //vTdCtrl5.setAttribute('TYPE','TEXT');vTdCtrl5.setAttribute('CLASS','USOF_text_box');vTdCtrl5.setAttribute('STYLE','WIDTH:50px; ');vTdCtrl5.setAttribute('VALUE','0');
    vTd5.appendChild(vTdCtrl5);
    var vTdSp5 = document.createElement("<span id='forADODiv"+numLinesAdded+"' class='USOF_Data_txt_hl'>");
    vTd5.appendChild(vTdSp5);
    vNewRow.appendChild(vTd5);

    var vTd6 = document.createElement("<TD CLASS='"+tdClass+"'>");
    //vTd6.setAttribute('CLASS',tdClass);
    var vTdCtrl6 = document.createElement("<INPUT id='withheldNo"+numLinesAdded+"' type='text' title='Withheld No.' class='USOF_text_box' STYLE='WIDTH:75px; ' value='' onkeyup='javascript:calCOsr2Grid();'>");
    vTdCtrl6.setAttribute('name','withheldNo'+numLinesAdded);
    //vTdCtrl6.setAttribute('TYPE','TEXT');vTdCtrl6.setAttribute('CLASS','USOF_text_box');vTdCtrl6.setAttribute('STYLE','WIDTH:75px; ');vTdCtrl6.setAttribute('VALUE','0');
    vTd6.appendChild(vTdCtrl6);
    vNewRow.appendChild(vTd6);

    var vTd7 = document.createElement("<TD CLASS='"+tdClass+"'>");
    //vTd7.setAttribute('CLASS',tdClass);
    var vTdCtrl7 = document.createElement("<INPUT id='withheldAmt"+numLinesAdded+"' type='text' title='Withheld Amount' class='USOF_text_box' STYLE='WIDTH:75px; ' value='' onkeyup='javascript:calCOsr2Grid();'>");
    vTdCtrl7.setAttribute('name','withheldAmt'+numLinesAdded);
    //vTdCtrl7.setAttribute('TYPE','TEXT');
    //vTdCtrl7.setAttribute('CLASS','USOF_text_box');
    //vTdCtrl7.setAttribute('STYLE','WIDTH:50px; ');
    //vTdCtrl7.setAttribute('VALUE','0');
    vTd7.appendChild(vTdCtrl7);
    vNewRow.appendChild(vTd7);
    
    var widthOfNoAmtTextBox="WIDTH:75px;";

    var vTd8 = document.createElement("<TD CLASS='"+tdClass+"'>");
    //vTd8.setAttribute('CLASS',tdClass);
    var vTdCtrl8 = document.createElement("<INPUT id='disallowedNo"+numLinesAdded+"' type='text' title='Disallowed No.' class='USOF_text_box' STYLE='"+widthOfNoAmtTextBox+" ' value='' onkeyup='javascript:calCOsr2Grid();'>");
    vTdCtrl8.setAttribute('name','disallowedNo'+numLinesAdded);
    //vTdCtrl8.setAttribute('TYPE','TEXT');//vTdCtrl8.setAttribute('CLASS','USOF_text_box');//vTdCtrl8.setAttribute('STYLE','WIDTH:75px; ');//vTdCtrl8.setAttribute('VALUE','0');
    vTd8.appendChild(vTdCtrl8);
    vNewRow.appendChild(vTd8);

    var vTd9 = document.createElement("<TD CLASS='"+tdClass+"'>");
    //vTd9.setAttribute('CLASS',tdClass);
    var vTdCtrl9 = document.createElement("<INPUT id='disallowedAmt"+numLinesAdded+"' type='text' title='Disallowed Amount' class='USOF_text_box' STYLE='WIDTH:75px; ' value='' onkeyup='javascript:calCOsr2Grid();'>");
    vTdCtrl9.setAttribute('name','disallowedAmt'+numLinesAdded);
    //vTdCtrl9.setAttribute('TYPE','TEXT');//vTdCtrl9.setAttribute('CLASS','USOF_text_box');//vTdCtrl9.setAttribute('STYLE','WIDTH:75px; ');//vTdCtrl9.setAttribute('VALUE','0');
    vTd9.appendChild(vTdCtrl9);
    vNewRow.appendChild(vTd9);

    var vTd10 = document.createElement("<TD CLASS='"+tdClass+"'>");
    //vTd10.setAttribute('CLASS',tdClass);
    var vTdCtrl10_0 = document.createElement("<INPUT id='adjustedNo"+numLinesAdded+"' type='hidden' class='USOF_text_box' STYLE='WIDTH:75px; ' value='' onkeyup='javascript:calCOsr2Grid();'>");
    vTdCtrl10_0.setAttribute('name','adjustedNo'+numLinesAdded);
    vTd10.appendChild(vTdCtrl10_0);
    var vTdCtrl10 = document.createElement("<INPUT id='adjustedAmt"+numLinesAdded+"' type='text' title='Any Other Adjustment Amount' class='USOF_text_box' STYLE='WIDTH:75px; ' value='' onkeyup='javascript:calCOsr2Grid();'>");
    vTdCtrl10.setAttribute('name','adjustedAmt'+numLinesAdded);
    //vTdCtrl10.setAttribute('TYPE','TEXT');//vTdCtrl10.setAttribute('CLASS','USOF_text_box');//vTdCtrl10.setAttribute('STYLE','WIDTH:75px; ');//vTdCtrl10.setAttribute('VALUE','0');
    vTd10.appendChild(vTdCtrl10);
    vNewRow.appendChild(vTd10);

    var vTd11 = document.createElement("<TD CLASS='"+tdClass+"'>");
    //vTd11.setAttribute('CLASS',tdClass);
    var vTdCtrl11 = document.createElement("<INPUT id='adjustedHead"+numLinesAdded+"' type='text' title='Reason for Adjustment' class='USOF_text_box' STYLE='WIDTH:70px; ' value='' onkeyup='javascript:calCOsr2Grid();'>");
    vTdCtrl11.setAttribute('name','adjustedHead'+numLinesAdded);
    //vTdCtrl11.setAttribute('TYPE','TEXT');//vTdCtrl11.setAttribute('CLASS','USOF_text_box');//vTdCtrl11.setAttribute('STYLE','WIDTH:70px; ');//vTdCtrl11.setAttribute('VALUE','0');
    vTd11.appendChild(vTdCtrl11);
    vNewRow.appendChild(vTd11);

    var vTd12 = document.createElement("<TD CLASS='"+tdClass+"'>");
    //vTd12.setAttribute('CLASS',tdClass);
    var vTdCtrl12 = document.createElement("<INPUT id='calcAmtPR"+numLinesAdded+"' type='hidden' readonly='readonly' class='USOF_text_box' STYLE='WIDTH:80px; ' value='0' onkeyup='javascript:calCOsr2Grid();'>");
    vTdCtrl12.setAttribute('name','calcAmtPR'+numLinesAdded);
    //vTdCtrl12.setAttribute('TYPE','TEXT');//vTdCtrl12.setAttribute('CLASS','USOF_text_box');//vTdCtrl12.setAttribute('STYLE','WIDTH:80px; ');//vTdCtrl12.setAttribute('VALUE','0');
    vTd12.appendChild(vTdCtrl12);
    var vTdSp12 = document.createElement("<span id='abnDcalcAmtPR"+numLinesAdded+"' class='USOF_Data_txt_hl'>");
    vTdSp12.setAttribute('name','abnDcalcAmtPR'+numLinesAdded);
    vTd12.appendChild(vTdSp12);
    var vTdCtrl13 = document.createElement("<INPUT id='settledNo"+numLinesAdded+"' type='hidden' class='USOF_text_box' STYLE='WIDTH:50px; ' value='' onkeyup='javascript:calCOsr2Grid();'>");
    vTdCtrl13.setAttribute('name','settledNo'+numLinesAdded);
    vTd12.appendChild(vTdCtrl13);
    var vTdCtrl14 = document.createElement("<INPUT id='settledAmt"+numLinesAdded+"' type='hidden' class='USOF_text_box' STYLE='WIDTH:50px; ' value='' onkeyup='javascript:calCOsr2Grid();'>");
    vTdCtrl14.setAttribute('name','settledAmt'+numLinesAdded);
    vTd12.appendChild(vTdCtrl14);
    vNewRow.appendChild(vTd12);

    
    vTBody.appendChild(vNewRow);
    var vCountOsr2ARow=document.getElementById('countOsr2ARow');//document.osr2det.countOsr2ARow.value=numLinesAdded;
    vCountOsr2ARow.value=numLinesAdded;
    
}

//YK:A150611
function historyTest(agrId,rowNo){
	var qeDt=document.getElementById('qeDt'+rowNo).value;//agrId
	if(qeDt.length==0){
	alert("First select quarter End");
	return false;
	}
	var stateId=document.osr2det.stateId.value;
	var ccaId=document.osr2det.ccaId.value;
	var upsId=document.osr2det.uspId.value;
	var agrCombo=document.getElementById('agrId'+rowNo);//.value;
	var agrId = agrCombo.options[agrCombo.selectedIndex].value;
	if(agrId==''){
	alert("Before clicking hitory button you must select activity");
	return false;
	}
	//showHistory('OsrHistory4USP.do?qe_dt='+qeDt+'&historyid=null'+'&agrId='+agrId+'&ccaId='+ccaId);
	showHistory('OsrHistory4USP.do?qe_dt='+qeDt+'&agrId='+agrId+'&ccaId='+ccaId+'&upsId='+upsId+"&stateId="+stateId);
}

//end


function abnOSR2A() {
  abnToggleObject("abnOsr2ATable");
  abnToggleObject("abnOsr2ATableSL");
  abnToggleObject("abnOsr2ATableHL");
}
function abnOSR1() {
  abnToggleObject("abnOsr1Table");
  abnToggleObject("abnOsr1TableSL");
  abnToggleObject("abnOsr1TableHL");
}



//Abn:Osr3

 function viewAOsr3(osrSNo){//Abn:fine
	
  showInBody("Osr3Fetch.do?"+abnTarget+"="+abnTarget2Add+"&osrSNo="+osrSNo);
}

/*function viewAOsr3(osrSNo,agrType){///*YK:A1062011
	alert("YK1062011"+osrSNo+agrType);
  showInBody("Osr3Fetch.do?"+abnTarget+"="+abnTarget2Add+"&osrSNo="+osrSNo+"&agrType="+agrType);
}*/


function viewAFOsr3(osrSNo){//Abn:fine
  showInBody("Osr3Fetch.do?"+abnTarget+"="+abnTarget2Approve+"&"+abnOsrsParam+"="+abnOsr3+"&osrSNo="+osrSNo);
}
function approveOsr3(osr3Status){//Abn:fine
  if(abnMaxLengthFail(document.osr3det.osr3RevertRemk,"Comments",500)){
    return false;
  }
  var confirmMsg='Are you sure, you want to take this action?';
  if(osr3Status=='R'){
    confirmMsg='Are you sure, you want to revert?';
    if(abnRequiredFail(document.osr3det.osr3RevertRemk,"Comments")){
      return false;
    }
  }else{
    confirmMsg='Are you sure, you want to approve?';
  }
  var istd=confirm(confirmMsg);
  if(istd==true){
    document.osr3det.action="Osr3Approve.do?osr3Status="+osr3Status;
    document.osr3det.method="post";
    document.osr3det.submit();
  }
}
function viewRFOsr3(osrSNo){//Abn:fine
  showInBody("Osr3Fetch.do?"+abnTarget+"="+abnTarget2Resubmit+"&"+abnOsrsParam+"="+abnOsr3+"&osrSNo="+osrSNo);
}
function viewVFOsr3(osrSNo){//Abn:fine
  showInBody("Osr3Fetch.do?"+abnTarget+"="+abnTarget2View+"&"+abnOsrsParam+"="+abnOsr3+"&osrSNo="+osrSNo);
}

function viewEFOsr3(){
  document.osr3det.action="Osr3Fetch.do?"+abnTarget+"="+abnTarget2Edit;
  document.osr3det.method="post";
  document.osr3det.submit();
}
function viewELOsr3(){
  var noClick=abnCountChecked(document.osr3list.osr3No);
  if(noClick==-1){
    return;
  }
  if(noClick>1){
    alert("Please select only one row");
    return false;
  }else if(noClick<1){
    alert("Please select a row");
    return false;
  }else{
    document.osr3list.action="Osr3Fetch.do";
    document.osr3list.method="post";
    document.osr3list.submit();
  }
}
function viewROsr3(){
  var noClick=abnCountChecked(document.osr3list.osr3No);
  if(noClick==-1){
    return;
  }
  if(noClick>1){
    alert("Please select only one row");
    return false;
  }else if(noClick<1){
    alert("Please select a row");
    return false;
  }else{
    document.osr3list.action="Osr3Fetch.do";
    document.osr3list.method="post";
    document.osr3list.submit();
  }
}
function validateOsr3(){//Abn:fine
  if(!isCSV) return true;
  /*
  if(abnRequiredFail(document.osr3det.stateId,"State")){
    return false;
  }
  if(abnRequiredFail(document.osr3det.agrId,"Activity")){
    return false;
  }
  if(abnRequiredFail(document.osr3det.uspId,"Service Provider")){
    return false;
  }
  if(abnRequiredFail(document.osr3det.qeDt,"Quarter End")){
    return false;
  }
  if(abnRequiredFail(document.osr3det.osr3ReceiptDt,"Date of Receipt")){
    return false;
  }
  if(abnRequiredFail(document.osr3det.settledNo,"Settled No")){
    return false;
  }
  if(abnRequiredFail(document.osr3det.settledAmt,"Settled Amount")){
    return false;
  }
  if(abnRequiredFail(document.osr3det.requisitionedNo,"Requisitioned No")){
    return false;
  }
  if(abnRequiredFail(document.osr3det.requisitionedAmt,"Requisitioned Amount")){
    return false;
  }
  */
  if(document.osr3det.recoveryOtherAmt.value==''){
    document.osr3det.recoveryOtherAmt.value='0';
  }
  
  if(abnRequiredFail(document.osr3det.authorisedNo,"Authorised No")){
    return false;
  }
  if(abnRequiredFail(document.osr3det.authorisedAmt,"Authorised Amount")){
    return false;
  }
  if(abnRequiredFail(document.osr3det.authorisedDt,"Authorised Date")){
    return false;
  }
  if(abnRequiredFail(document.osr3det.recoveryAmt,"Amount Recovered")){
    return false;
  }
  if(abnRequiredFail(document.osr3det.paidAmt,"Paid Amount")){
    return false;
  }
  if(abnRequiredFail(document.osr3det.osr3SanctionNo,"Sanction No")){
    return false;
  }
  if(abnRequiredFail(document.osr3det.osr3SanctionDt,"Sanction Date")){
    return false;
  }
  if(abnRequiredFail(document.osr3det.chequeNo,"Cheque No")){
    return false;
  }
  if(abnRequiredFail(document.osr3det.chequeDt,"Cheque Date")){
    return false;
  }
  if(abnRequiredFail(document.osr3det.osr3SendDt,"Date of intimation regarding payment")){
    return false;
  }
  if(getDaysDiff(document.osr3det.osr3SendDt.value,document.osr3det.authorisedDt.value,dateFormat)>=7){
    if(abnRequiredFail(document.osr3det.osr3Remk,"Remarks")){
      return false;
    }
  }
  /*---yka:180511*/
  if(isGreaterDate(document.osr3det.authorisedDt.value,document.osr3det.osr3SanctionDt.value,dateFormat)){
	   alert("Sanction Date can not be Less than Authorised Date.");
	   document.osr3det.osr3SanctionDt.focus();
       return false;
  }
  if(isGreaterDate(document.osr3det.osr3SanctionDt.value,document.osr3det.chequeDt.value,dateFormat)){
	alert("Cheque Date can not be Less than Saction Date.");
    document.osr3det.chequeDt.focus();
    return false;
  }
  /*------end---Yk---*/
  if(isGreaterDate(document.osr3det.chequeDt.value,document.osr3det.osr3SendDt.value,dateFormat)){
	alert("Cheque Date can not be greater than today.");
    document.osr3det.chequeDt.focus();
    return false;
  }
 
  //-----YK:A150611
  
  if(getDaysDiff(document.osr3det.authorisedDt.value,document.osr3det.chequeDt.value,dateFormat)>=8){
	  var bRt = isBlank(document.osr3det.osr3Remk.value);
	  if(bRt){
		    alert("Give reasons in Remark box for delay in payment ");
		    document.osr3det.osr3Remk.focus();
		    return false;
	  } else{
	  return true;
	  }
 // return true;
  }
  
  

  
  if(abnMaxLengthFail(document.osr3det.authorisedNo,"Authorised No",10)){
    return false;
  }
  if(abnMaxLengthFail(document.osr3det.authorisedAmt,"Authorised Amount",10)){
    return false;
  }
  if(abnMaxLengthFail(document.osr3det.authorisedDt,"Authorised Date",10)){
    return false;
  }
  if(abnMaxLengthFail(document.osr3det.recoveryAmt,"Amount Recovered",10)){
    return false;
  }
  if(abnMaxLengthFail(document.osr3det.paidAmt,"Paid Amount",10)){
    return false;
  }
  if(abnMaxLengthFail(document.osr3det.osr3SanctionNo,"Sanction No",15)){
    return false;
  }
  if(abnMaxLengthFail(document.osr3det.osr3SanctionDt,"Sanction Date",10)){
    return false;
  }
  if(abnMaxLengthFail(document.osr3det.chequeNo,"Cheque No",15)){
    return false;
  }
  if(abnMaxLengthFail(document.osr3det.chequeDt,"Cheque Date",10)){
    return false;
  }
  if(abnMaxLengthFail(document.osr3det.osr3SendDt,"Date of intimation regarding payment",10)){
    return false;
  }
  if(abnMaxLengthFail(document.osr3det.osr3Remk,"Remarks",500)){
    return false;
  }
  if(abnMaxLengthFail(document.osr3det.ldAmt,"LD",10)){
    return false;
  }
  if(abnMaxLengthFail(document.osr3det.interestAmt,"Interest Amount",10)){
    return false;
  }
  if(abnMaxLengthFail(document.osr3det.recoveryOtherAmt,"Any Other Recovery",10)){
    return false;
  }
  if(abnMaxLengthFail(document.osr3det.recoveryReason,"Reason for Recovery",500)){
    return false;
  }
  if(abnMaxLengthFail(document.osr3det.osr3RevertRemk,"Comments",500)){
    return false;
  }
  
  if(abnIntegerFail(document.osr3det.authorisedNo,"Authorised No")){
    return false;
  }
  if(abnIntegerFail(document.osr3det.authorisedAmt,"Authorised Amount")){
    return false;
  }
  if(abnIntegerFail(document.osr3det.recoveryAmt,"Recovery Amount")){
    return false;
  }
  if(abnIntegerFail(document.osr3det.paidAmt,"Paid Amount")){
    return false;
  }
  if(abnChequeNoFail(document.osr3det.chequeNo,"Cheque No")){
    return false;
  }
  if(abnIntegerFail(document.osr3det.ldAmt,"LD")){
    return false;
  }
  if(abnIntegerFail(document.osr3det.interestAmt,"Interest Amount")){
    return false;
  }
  if(abnIntegerFail(document.osr3det.recoveryOtherAmt,"Any Other Recovery")){
    return false;
  }
  if(isGreaterDate(document.osr3det.authorisedDt.value,document.osr3det.osr3SendDt.value,dateFormat)){
    alert("Date of Receipt can not be greater than today.");
    document.osr3det.authorisedDt.focus();
    return false;
  }
  if(document.osr3det.recoveryOtherAmt.value!=''){
    if(parseInt(document.osr3det.recoveryOtherAmt.value)>0){
      if(abnRequiredFail(document.osr3det.recoveryReason,"Reason for Recovery")){
        return false;
      }
    }
  }
  
  //Abn:ToDo Other validation
  return true;
}
function addOsr3(){//Abn:fine
  if(validateOsr3()){
    document.osr3det.action="Osr3AddSave.do";
    document.osr3det.method="post";
    document.osr3det.submit();
  }
}
function editOsr3(){
  if(validateOsr3()){
    document.osr3det.action="Osr3EditSave.do";
    document.osr3det.method="post";
    document.osr3det.submit();
  }
}
function saveOsr3(){//Abn:fine
  if(document.osr3det.osr3SNo.value == '' || document.osr3det.osr3SNo.value == null || document.osr3det.osr3SNo.value == '0'){
    addOsr3();
  }else{
    editOsr3();
  }
}
function deleteFOsr3(){
  var istd=confirm("Are you sure, you want to delete?");
  if(istd==true){
    document.osr3det.action="Osr3DeleteSave.do";
    document.osr3det.method="post";
    document.osr3det.submit();
  }
}
function deleteLOsr3(){
  var noClick=abnCountChecked(document.osr3list.osr3No);
  if(noClick==-1){
    return;
  }
  if(noClick<1){
    alert("Please select at least one row");
    return false;
  }else{
    var istd=confirm("Are you sure, you want to delete?");
    if(istd==true){
      document.osr3list.action="Osr3DeleteSave.do";
      document.osr3list.method="post";
      document.osr3list.submit();
    }
  }
}
function getPgOsr3(){
    document.osr3sch.rPg.value=document.osr3list.rPg.value;
    submitSchOsr3();
}
function getPrvPgOsr3(){
    if(document.osr3list.rPg.options.selectedIndex>0){
        document.osr3list.rPg.options.selectedIndex=document.osr3list.rPg.options.selectedIndex-1;
        getPgOsr3();
    }
}
function getNxtPgOsr3(){
    if(document.osr3list.rPg.options.selectedIndex<document.osr3list.rPg.options.length-1){
        document.osr3list.rPg.options.selectedIndex=document.osr3list.rPg.options.selectedIndex+1;
        getPgOsr3();
    }
}
function searchOsr3(){
  document.osr3sch.rPg.value="";
  submitSchOsr3();
}
function submitSchOsr3(){
  document.osr3sch.action="Osr3Search.do";
  document.osr3sch.method="post";
  document.osr3sch.submit();
}
function resetschOsr3(){
  //Abn:ToDo document.osr3sch.customerName.value="";
}
function selectAllLOsr3(){
  abnCheckAs(document.osr3list.osr3No,document.osr3list.lc.checked);
}
function listOsr3(){
  document.location.href = "Osr3List.do";
}
function calCOsr3(){
      var authamt=0.0;
      var recdamt=0.0;
      var ldamt=0.0;
      var interestamt=0.0;
      var recdotheramt=0.0;
      if(document.osr3det.authorisedAmt.value!=''){
        authamt=parseInt(document.osr3det.authorisedAmt.value);
      }
      if(document.osr3det.recoveryAmt.value!=''){
        recdamt=parseInt(document.osr3det.recoveryAmt.value);
      }
      if(document.osr3det.ldAmt.value!=''){
        ldamt=parseInt(document.osr3det.ldAmt.value);
      }
      if(document.osr3det.interestAmt.value!=''){
        interestamt=parseInt(document.osr3det.interestAmt.value);
      }
      if(document.osr3det.recoveryOtherAmt.value!=''){
        recdotheramt=parseInt(document.osr3det.recoveryOtherAmt.value);
      }
      
      recdamt=parseInt(ldamt)+parseInt(interestamt)+parseInt(recdotheramt);
      document.osr3det.recoveryAmt.value=recdamt;
      document.osr3det.paidAmt.value=parseInt(authamt)-parseInt(recdamt);

      document.getElementById("abnDrecoveryAmt").innerText=document.osr3det.recoveryAmt.value;
      document.getElementById("abnDpaidAmt").innerText=document.osr3det.paidAmt.value;
      
}



//Others
function getActivities(ccaId){
    abnFillHtmlCtrl(ccaId,'lac','LAC','agrId','Combo');
}
function getUsps(agrId,ccaId){
    abnFillHtmlCtrlWithParam3(ccaId,agrId.options[agrId.options.selectedIndex].value,'luca','LUCA','uspId','Combo');
}
function getClusterUsps(clusterPart){
    //abnFillHtmlCtrl(clusterId.value,'luc','LUC','uspId','Combo');
    var clusterIdValue=document.osr1det.clusterId.options[document.osr1det.clusterId.options.selectedIndex].value
    if(clusterIdValue==''){
        alert('Please select Cluster No.');
        return;
    }
    abnFillHtmlCtrlWithParam3(clusterIdValue,clusterPart.value,'luc','LUC','uspId','Combo');
}
function getClusters(ccaId,stateId){
    abnFillHtmlCtrlWithParam3(ccaId,stateId.options[stateId.options.selectedIndex].value,'lccs','LCCS','clusterId','Combo');
}
function getClusterDetails(clusterPart){
    //document.osr1det.clstPart.value='';
    document.osr1det.maxSites.value='';
    var clusterIdValue=document.osr1det.clusterId.options[document.osr1det.clusterId.options.selectedIndex].value
    if(clusterIdValue==''){
        alert('Please select Cluster No.');
        return;
    }
    //abnFillHtmlCtrl(clusterId.value,'ald','ALD','fill4Ir1','JsFun');
    abnFillHtmlCtrlWithParam3(clusterIdValue,clusterPart.value,'ald','ALD','fill4Ir1','JsFun');
}
function fill4Ir1(aClusterDet){
    if(aClusterDet!=null){
        //document.osr1det.clstPart.value=aClusterDet[2];
        document.osr1det.maxSites.value=aClusterDet[3];
    }

}
function getActivitiesOnQe(qeDt,rowNo){
    if(isLesserDate(document.osr2det.qeDt.value,document.getElementById('qeDt'+rowNo).value,dateFormat)){
      alert("Quarter End must be less than "+document.osr2det.qeDt.value+".");
      //document.getElementById('qeDt'+rowNo).focus();
      return false;
    }
    var ccaId=document.osr2det.ccaId.value;
    
    var stateId=document.osr2det.stateId.value;
    var uspId=document.osr2det.uspId.value;
    if(stateId==''){
    alert("First Select State");
    return false;
    }
    if(uspId==''){
    alert("First select Service Provider");
    }
    
    var agrType=document.osr2det.agrType.value;
    var objAgrId = document.getElementById("agrId");
    if(objAgrId !=null){//ABN26052011-1
	    var agrId=objAgrId.value;//ABN26052011-1
	    abnFillHtmlCtrlWithParam7(agrId,agrType,uspId,stateId,ccaId,qeDt.value,'laq','LAQ','agrId'+rowNo,'Combo');//ABN26052011-1
    }else{//ABN26052011-1
    	abnFillHtmlCtrlWithParam6(agrType,uspId,stateId,ccaId,qeDt.value,'laq','LAQ','agrId'+rowNo,'Combo');
    }//ABN26052011-1
}
function getOsr2Details(agrId,rowNo){
	var ccaId=document.osr2det.ccaId.value;
    var stateId=document.osr2det.stateId.value;
    var uspId=document.osr2det.uspId.value;
    var qeDt=document.getElementById('qeDt'+rowNo).value;
    document.getElementById('forACO'+rowNo).value='0';
    document.getElementById('forAWO'+rowNo).value='0';
    document.getElementById('forADO'+rowNo).value='0';
    document.getElementById('forACODiv'+rowNo).innerText=document.getElementById('forACO'+rowNo).value;
    document.getElementById('forAWODiv'+rowNo).innerText=document.getElementById('forAWO'+rowNo).value;
    document.getElementById('forADODiv'+rowNo).innerText=document.getElementById('forADO'+rowNo).value;
    if(agrId.value!=''){
      abnFillHtmlCtrlWithParam7(rowNo,qeDt,uspId,stateId,ccaId,agrId.value,'ao2d','AO2D','fill4Osr2A','JsFun');
    }
}
function fill4Osr2A(aOsr2Det){
    if(aOsr2Det!=null){
        var rowNo=aOsr2Det[0];
        document.getElementById('forACO'+rowNo).value=aOsr2Det[2];
        document.getElementById('forAWO'+rowNo).value=aOsr2Det[4];
        //YK:C270611 document.getElementById('forADO'+rowNo).value=aOsr2Det[7];
        document.getElementById('forADO'+rowNo).value=aOsr2Det[6];
        document.getElementById('forACODiv'+rowNo).innerText=aOsr2Det[1] + ', ' + document.getElementById('forACO'+rowNo).value;
        document.getElementById('forAWODiv'+rowNo).innerText=aOsr2Det[3] + ', ' + document.getElementById('forAWO'+rowNo).value;
        //YK:C270611 document.getElementById('forADODiv'+rowNo).innerText=aOsr2Det[6] + ', ' + document.getElementById('forADO'+rowNo).value;
        document.getElementById('forADODiv'+rowNo).innerText=aOsr2Det[5] + ', ' + document.getElementById('forADO'+rowNo).value;
    }
}
function getActivityDetails(agrId,calling){
	
    var abnActivityDetails='abnActivityDetailsTable';
    document.osr1det.agrEftDt.value='';
    document.osr1det.agrMaxConn.value='';
    document.osr1det.agrClrDt.value='';
    abnHideObject(abnActivityDetails);
    var fill4FormFun='';
    if(abnOsr1==calling){
        fill4FormFun='fill4Osr1';
    }else if(abnOsr2==calling){
        //fill4FormFun='fill4Osr2';
        return ;
    }else if(abnOsr3==calling){
        //fill4FormFun='fill4Osr3';
        return ;
    }else{
        return ;
    }
    if(agrId.value!=''){
    	
      abnFillHtmlCtrl(agrId.value,'aad','AAD',fill4FormFun,'JsFun');
     
      showActivityDetails(abnActivityDetails);
    }
}
function fill4Osr1(aActivityDet){
    document.osr1det.agrEftDt.value=aActivityDet[3];
    document.osr1det.agrMaxConn.value=aActivityDet[7];
    document.osr1det.agrClrDt.value=aActivityDet[4];
}
function showActivityDetails(abnActivityDetails){
    var connectionno="";
    var subsidyupto="";
    if(document.osr1det.agrMaxConn.value==''){
      connectionno="<BR/>Please select activity";
      subsidyupto="";
    }else{
      connectionno="<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0><TR><TD WIDTH='50%'><B>Max. Connection</B>&nbsp;</TD><TD WIDTH='50%'>"+document.osr1det.agrMaxConn.value+"</TD></TR><TR><TD WIDTH='50%'><B>Closure Date</B>&nbsp;</TD><TD WIDTH='50%'>"+document.osr1det.agrClrDt.value+"</TD></TR></TABLE>";
      subsidyupto="";
    }
    document.getElementById(abnActivityDetails).innerHTML=connectionno+subsidyupto;
    abnShowObject(abnActivityDetails);
}

//Abn:Ir1
function viewAIr1(){//Abn:fine
  showInBody("Ir1Dets.do?"+abnTarget+"="+abnTarget2Add);
}




//IR4
function viewVFIr4(ir4SNo){//Abn:fine
  showInBody("osr/ir4/ir4View.do?ir4_id="+ir4SNo);
}
function viewAFIr4(ir4SNo){//Abn:fine
  showInBody("osr/ir4/ir4tPending.do?status=view&ir4No="+ir4SNo);
}




//Abn:Osr2a
function viewAOsr2a(){//Abn:fine
  showInBody("Osr2aDets.do?"+abnTarget+"="+abnTarget2Add);
}
function viewAFOsr2a(osrSNo){//Abn:fine
  showInBody("Osr2aFetch.do?"+abnTarget+"="+abnTarget2Approve+"&"+abnOsrsParam+"="+abnOsr2a+"&osrSNo="+osrSNo);
}
function approveOsr2a(osr2Status){//Abn:fine
  if(abnMaxLengthFail(document.osr2det.osr2SanctionNo,"Sanction No",50)){
    return false;
  }
  if(abnMaxLengthFail(document.osr2det.osr2RevertRemk,"Comments",500)){
    return false;
  }
  var confirmMsg='Are you sure, you want to take this action?';
  if(osr2Status=='R'){
    confirmMsg='Are you sure, you want to revert?';
    if(abnRequiredFail(document.osr2det.osr2RevertRemk,"Comments")){
      return false;
    }
  }else{
    if(abnRequiredFail(document.osr2det.osr2SanctionNo,"Sanction No")){
      return false;
    }
    confirmMsg='Are you sure, you want to approve?';
  }
  var istd=confirm(confirmMsg);
  if(istd==true){
    document.osr2det.action="Osr2aApprove.do?osr2Status="+osr2Status;
    document.osr2det.method="post";
    document.osr2det.submit();
  }
}
function viewRFOsr2a(osrSNo){//Abn:fine
  showInBody("Osr2aFetch.do?"+abnTarget+"="+abnTarget2Resubmit+"&"+abnOsrsParam+"="+abnOsr2a+"&osrSNo="+osrSNo);
}
function viewVFOsr2a(osrSNo){//Abn:fine
  showInBody("Osr2aFetch.do?"+abnTarget+"="+abnTarget2View+"&"+abnOsrsParam+"="+abnOsr2a+"&osrSNo="+osrSNo);
}

function validateOsr2a(){//Abn:fine
  if(document.osr2det.claimedNo.value==''){
    document.osr2det.claimedNo.value='0';
  }
  if(document.osr2det.claimedAmt.value==''){
    document.osr2det.claimedAmt.value='0';
  }
  if(document.osr2det.withheldNo.value==''){
    document.osr2det.withheldNo.value='0';
  }
  if(document.osr2det.withheldAmt.value==''){
    document.osr2det.withheldAmt.value='0';
  }
  if(document.osr2det.disallowedNo.value==''){
    document.osr2det.disallowedNo.value='0';
  }
  if(document.osr2det.disallowedAmt.value==''){
    document.osr2det.disallowedAmt.value='0';
  }
  if(document.osr2det.adjustedAmt.value==''){
    document.osr2det.adjustedAmt.value='0';
  }
  var idz=parseInt(document.getElementById('countOsr2ARow').value);
  var agrId='';//ABN26052011
  for(idx=1;idx<=idz;idx++){
	  
	  //YK:140611
	  
	  if(document.getElementById('withheldAmt'+idx).value!=''){
	     var tempWithHeldAmt =document.getElementById('withheldAmt'+idx).value;
	     var withheldamtIdx=parseInt(tempWithHeldAmt);//.substring(1,tempWithHeldAmt.length));
	     //var withheldamtIdx=parseInt(tempWithHeldAmt.substring(1,tempWithHeldAmt.length));
	      
	      var forAWO =parseInt(document.getElementById('forAWO'+idx).value);     
	      if((forAWO-(-withheldamtIdx))<0){                        
	      alert('Entered correct Amount'); 
	      document.getElementById('withheldAmt'+idx).focus();
	      return false;                                                 
	      }
	  }
	  
	  if(document.getElementById('disallowedAmt'+idx).value!=''){
		     var tempDisallowedAmt =document.getElementById('disallowedAmt'+idx).value;
		     var withheldamtIdx =parseInt(tempDisallowedAmt);
		     //var withheldamtIdx=parseInt(tempDisallowedAmt.substring(1,tempDisallowedAmt.length));
		      
		      var forADO =parseInt(document.getElementById('forADO'+idx).value);     
		     // alert("withheldamtIdx="+withheldamtIdx+"forAWO="+forAWO);
		      if((forADO-(-withheldamtIdx))<0){                        
		      alert('Entered correct Amount'); 
		      document.getElementById('disallowedAmt'+idx).focus();
		      return false;                                                 
		      }
		  }
	  
	  //end
	  
	  
	  
	if(agrId!=''){//ABN26052011
		if(agrId!=document.getElementById('agrId'+idx).value){//ABN26052011
			alert('All activities should be same in a OSR2A.');
			return false;//ABN26052011
		}//ABN26052011
	}//ABN26052011
	agrId=document.getElementById('agrId'+idx).value;//ABN26052011
	
    if(document.getElementById('withheldNo'+idx).value==''){
      document.getElementById('withheldNo'+idx).value='0';
    }
    if(document.getElementById('withheldAmt'+idx).value==''){
      document.getElementById('withheldAmt'+idx).value='0';
    }
    if(document.getElementById('disallowedNo'+idx).value==''){
      document.getElementById('disallowedNo'+idx).value='0';
    }
    if(document.getElementById('disallowedAmt'+idx).value==''){
      document.getElementById('disallowedAmt'+idx).value='0';
    }
    if(document.getElementById('adjustedNo'+idx).value==''){
      document.getElementById('adjustedNo'+idx).value='0';
    }
    if(document.getElementById('adjustedAmt'+idx).value==''){
      document.getElementById('adjustedAmt'+idx).value='0';
    }
    if(document.getElementById('settledNo'+idx).value==''){
      document.getElementById('settledNo'+idx).value='0';
    }
    if(document.getElementById('settledAmt'+idx).value==''){
      document.getElementById('settledAmt'+idx).value='0';
    }
  }

  if(!isCSV) return true;
  if(abnRequiredFail(document.osr2det.stateId,"State")){
    return false;
  }
  /*
  if(abnRequiredFail(document.osr2det.agrId,"Activity")){
    return false;
  }
  */
  if(abnRequiredFail(document.osr2det.uspId,"Service Provider")){
    return false;
  }
  if(abnRequiredFail(document.osr2det.qeDt,"Quarter End")){
    return false;
  }
  if(abnRequiredFail(document.osr2det.osr2ReceiptDt,"Date of Receipt")){
    return false;
  }
  if(abnRequiredFail(document.osr2det.settledNo,"Settled No")){
    return false;
  }
  if(abnRequiredFail(document.osr2det.settledAmt,"Settled Amount")){
    return false;
  }
  if(abnRequiredFail(document.osr2det.requisitionedNo,"Requisitioned No")){
    return false;
  }
  if(abnRequiredFail(document.osr2det.requisitionedAmt,"Requisitioned Amount")){
    return false;
  }
  if(abnRequiredFail(document.osr2det.osr2SendDt,"Date of Adjustment")){
    return false;
  }
  
  if(abnMaxLengthFail(document.osr2det.qeDt,"Quarter End",10)){
    return false;
  }
  if(abnMaxLengthFail(document.osr2det.osr2ReceiptDt,"Date of Receipt",10)){
    return false;
  }
  if(abnMaxLengthFail(document.osr2det.osr2SendDt,"Date of Adjustment",10)){
    return false;
  }
  if(abnMaxLengthFail(document.osr2det.withheldNo,"Withheld No",10)){
    return false;
  }
  if(abnMaxLengthFail(document.osr2det.withheldAmt,"Withheld Amount",10)){
    return false;
  }
  if(abnMaxLengthFail(document.osr2det.withheldReason,"Reason for withheld",500)){
    return false;
  }
  if(abnMaxLengthFail(document.osr2det.disallowedNo,"Disallowed No",10)){
    return false;
  }
  if(abnMaxLengthFail(document.osr2det.disallowedAmt,"Disallowed Amount",10)){
    return false;
  }
  if(abnMaxLengthFail(document.osr2det.disallowedReason,"Reason for disallowed",500)){
    return false;
  }
  if(abnMaxLengthFail(document.osr2det.settledNo,"Settled No",10)){
    return false;
  }
  if(abnMaxLengthFail(document.osr2det.settledAmt,"Settled Amount",10)){
    return false;
  }
  if(abnMaxLengthFail(document.osr2det.adjustedNo,"Adjusted No",10)){
    return false;
  }
  if(abnMaxLengthFail(document.osr2det.adjustedAmt,"Adjusted Amount",10)){
    return false;
  }
  if(abnMaxLengthFail(document.osr2det.requisitionedNo,"Requisitioned No",10)){
    return false;
  }
  if(abnMaxLengthFail(document.osr2det.requisitionedAmt,"Requisitioned Amount",10)){
    return false;
  }
  if(abnMaxLengthFail(document.osr2det.osr2Remk,"Remarks",500)){
    return false;
  }
  if(abnMaxLengthFail(document.osr2det.osr2RevertRemk,"Comments",500)){
    return false;
  }
  /*
  if(abnQuaterEndFail(document.osr2det.qeDt,"Quarter End")){
    return false;
  }
  */
  if(abnIntegerFail(document.osr2det.withheldNo,"Withheld No")){
    return false;
  }
  if(abnIntegerFail(document.osr2det.withheldAmt,"Withheld Amount")){
    return false;
  }
  if(abnIntegerFail(document.osr2det.disallowedNo,"Disallowed No")){
    return false;
  }
  if(abnIntegerFail(document.osr2det.disallowedAmt,"Disallowed Amount")){
    return false;
  }
  if(abnIntegerFail(document.osr2det.settledNo,"Settled No")){
    return false;
  }
  if(abnIntegerFail(document.osr2det.settledAmt,"Settled Amount")){
    return false;
  }
  if(abnIntegerFail(document.osr2det.adjustedNo,"Adjusted No")){
    return false;
  }
  if(abnIntegerFail(document.osr2det.adjustedAmt,"Adjusted Amount")){
    return false;
  }
  if(abnIntegerFail(document.osr2det.requisitionedNo,"Requisitioned No")){
    return false;
  }
  if(abnIntegerFail(document.osr2det.requisitionedAmt,"Requisitioned Amount")){
    return false;
  }
  if(isGreaterDate(document.osr2det.osr2ReceiptDt.value,document.osr2det.osr2SendDt.value,dateFormat)){
    alert("Date of Receipt can not be greater than today.");
    document.osr2det.osr2ReceiptDt.focus();
    return false;
  }
  /*
  if(document.osr2det.withheldAmt.value!=''){
    if(parseInt(document.osr2det.withheldAmt.value)>0){
      if(abnRequiredFail(document.osr2det.withheldReason,"Reason for Withheld")){
        return false;
      }
    }
  }
  if(document.osr2det.disallowedAmt.value!=''){
    if(parseInt(document.osr2det.disallowedAmt.value)>0){
      if(abnRequiredFail(document.osr2det.disallowedReason,"Reason for Disallowed")){
        return false;
      }
    }
  }
  */
  
  
  if(!validateOsr2aGrid()){
    return false;
  }
  
  //Abn:ToDo Other validation
  return true;
}
function validateOsr2aGrid(){//Abn:fine
  if(!validateOsr2Grid()){
    return false;
  }
  return true;
}


function addOsr2a(){//Abn:fine
  if(validateOsr2a()){
    document.osr2det.action="Osr2aAddSave.do";
    document.osr2det.method="post";
    document.osr2det.submit();
  }
}
function saveOsr2a(){//Abn:fine
  if(document.osr2det.osr2SNo.value == '' || document.osr2det.osr2SNo.value == null || document.osr2det.osr2SNo.value == '0'){
    addOsr2a();
  }else{
    //editOsr2a();
  }
}


//---added by yaswant 14.9.11---
function againSearchPendigTask(ccaId){
	document.pendingtasksch.action="PendingTask.do?abnsch=abnsch&abntask4=abn4my&ccaId="+ccaId;
    document.pendingtasksch.method="post";
    document.pendingtasksch.submit();
}
////----- end

function showHistory(url){
	
    window.open(url,'History','width='+((screen.width*3/4)-5)+',height='+((screen.height*2/3)-80)+',resizable=yes,menubar=no,status=yes,location=no,toolbar=no,scrollbars=yes,top=0,left=0,screenX=0,screenY=0');
}

