
function setBrowserClientHeight() {
    var iWidth = 0, iHeight = 0;
    iWidth = getBrowserWidth();
    iHeight = getBrowserHeight();
    var tdHeaderHeight = getHeader();
    var tdFooterHeight = getFooter();
    var iDivHeight = 0;
    iDivHeight = iHeight - (tdHeaderHeight + tdFooterHeight);
    iHeight = iHeight - 10;
    var objDivMain = document.getElementById('DivContentMain');
    //var tableMain = document.getElementById('tableMain');
    objDivMain.style.minHeight = (iDivHeight) + 'px';
    //alert(objDivMain);
    //alert(tableMain.offsetHeight);
    //alert(iHeight);
    /*if (tableMain.offsetHeight < iHeight) 
    {
    tableMain.height = iHeight + 'px';
    objDivMain.style.height = (iDivHeight) + 'px';
    objDivMain.style.overflow = 'none';
    }*/
}

function getBrowserWidth() {
    var iWidth = 0;
    if (typeof (window.innerWidth) == 'number')
        iWidth = window.innerWidth;
    else if (document.documentElement && (document.documentElement.clientWidth))
        iWidth = document.documentElement.clientWidth;
    else if (document.body && (document.body.clientWidth))
        iWidth = document.body.clientWidth;
    return iWidth;
}

function getBrowserHeight() {
    var iHeight = 0;
    if (typeof (window.innerHeight) == 'number')
        iHeight = window.innerHeight;
    else if (document.documentElement && (document.documentElement.clientHeight))
        iHeight = document.documentElement.clientHeight;
    else if (document.body && (document.body.clientHeight))
        iHeight = document.body.clientHeight;
    return iHeight;
}

function getHeader() {
    var tbHeader = document.getElementById('TableHeader');
    return tbHeader.offsetHeight;
}

function getFooter() {
    var tbFooter = document.getElementById('TableFooter');
    return tbFooter.offsetHeight;
}

function OpenReportWindow(pageurl) {
    window.open(pageurl, "", 'Width=800px;scrollbars=yes;menubar=no;toolbar=no;location=center', "");
}

function OpenHelpWindow(pageurl) {
    window.open(pageurl, "AnchorLiteHelp", 'Width=800px,scrollbars=1,menubar=0,toolbar=0,status=1,resizable=1,location=center,location=0', "");
}

function ConfirmMessageForApprove(alertMessage, lblConfirm) {
    if (document.getElementById(lblConfirm).innerHTML == 'To be confirmed') {
        return confirm(alertMessage);
    }
}

function AttributeDeleteConfirmation() {
    return window.confirm('Are you sure, you want to delete Attribute? ');
}

function AttributeDescriptionDeleteConfirmation() {
    return window.confirm('Are you sure, you want to delete Description? ');
}

function Confirmation() {
    return window.confirm('Are you sure? ');
}

function RejectConfirmation() {
    return window.confirm('Are you sure, you want to Reject? ');
}

function DeleteConfirmation() {
    return window.confirm('Are you sure, you want to Delete? ');
}

function LinkButtonDeleteConfirmation(linkButtonDetails) {
    var obj = document.getElementById(linkButtonDetails);
    if (obj.disabled == true) {
        return false;
    }
    else {
        if (confirm('Are you sure, you want to Delete? ')) {
            return true;
        }
        else {
            return false;
        }
    }
}

function LinkButtonAOPRequestApprovalConfirmation(linkButtonDetails) {
    var obj = document.getElementById(linkButtonDetails);
    if (obj.innerText == 'Request Approval') {
        if (confirm('Are you sure, you want to request for Approval? ')) {
            return true;
        }
        else {
            return false;
        }
    }
    else {
        return true;
    }
}


function RequestApprovalConfirmation() {
    return window.confirm('Are you sure, you want to request for Approval? ');
}

function ApprovedConfirmation() {
    return window.confirm('Are you sure, you want to Approve? ');
}


function ResetPasswordConfirmation() {
    return window.confirm('Are you sure, you want to Reset Password? ');
}

function GenerateNewPasswordConfirmation() {
    return window.confirm('Are you sure, you want to Generate New Password? ');
}

// Request for Task Approval
function RequestTasksApprovalConfirmation(linkButtonDetails) {
    var obj = document.getElementById(linkButtonDetails);
    if (obj.disabled == true) {
        return false;
    }
    else {
        if (confirm('Are you sure, the tasks for this month have been defined? ')) {
            return true;
        }
        else {
            return false;
        }
    }
}



function RequestPEApprovalConfirmation(linkButtonDetails) {
    var obj = document.getElementById(linkButtonDetails);
    if (obj.disabled == true) {
        return false;
    }
    else {
        if (confirm('Are you sure, you want to request for PE Rating Approval? ')) {
            return true;
        }
        else {
            return false;
        }
    }
}

function PEApprovalConfirmation(linkButtonDetails) {
    var obj = document.getElementById(linkButtonDetails);
    if (obj.disabled == true) {
        return false;
    }
    else {
        if (confirm('Are you sure, You want approve PE Tasks? ')) {
            return true;
        }
        else {
            return false;
        }
    }
}

function PEStrengthsApprovalConfirmation(linkButtonDetails) {
    var obj = document.getElementById(linkButtonDetails);
    if (obj.disabled == true) {
        return false;
    }
    else {
        if (confirm('Are you sure, You want to submit Strengths? ')) {
            return true;
        }
        else {
            return false;
        }
    }
}

function PEOFIApprovalConfirmation(linkButtonDetails) {
    var obj = document.getElementById(linkButtonDetails);
    if (obj.disabled == true) {
        return false;
    }
    else {
        if (confirm('Are you sure, you want to approve PE OFI? ')) {
            return true;
        }
        else {
            return false;
        }
    }
}

function SubmitPEConfirmation(linkButtonDetails) {
    var obj = document.getElementById(linkButtonDetails);
    if (obj.disabled == true) {
        return false;
    }
    else {
        if (confirm('Are you sure, you want to Submit PE? ')) {
            return true;
        }
        else {
            return false;
        }
    }
}

function UpdateReviewConfirmation() {
    return window.confirm('Are you sure, you want to Update Review? ');
}

function SubmitReviewConfirmation() {
    return window.confirm('Are you sure, you want to Submit Review? ');
}

function SubmitAssessmentConfirmation(linkButtonDetails) {
    var obj = document.getElementById(linkButtonDetails);
    if (obj.disabled == true) {
        return false;
    }
    else {
        if (confirm('Are you sure, you want to Submit Assessment? ')) {
            return true;
        }
        else {
            return false;
        }
    }
}

function RequestCFTObjectivesApprovalConfirmation(linkButtonDetails) {
    var obj = document.getElementById(linkButtonDetails);
    if (obj.disabled == true) {
        return false;
    }
    else {
        if (confirm('Are you sure, you want to request for CFT Objectives Approval? ')) {
            return true;
        }
        else {
            return false;
        }
    }
}

function RequestCFTRatingApprovalConfirmation(linkButtonDetails) {
    var obj = document.getElementById(linkButtonDetails);
    if (obj.disabled == true) {
        return false;
    }
    else {
        if (confirm('Are you sure, you want to request for GA-Rating Approval? ')) {
            return true;
        }
        else {
            return false;
        }
    }
}

function CFTObjectivesActivationConfirmation(linkButtonDetails) {
    var obj = document.getElementById(linkButtonDetails);
    if (obj.disabled == true) {
        return false;
    }
    else {
        if (confirm('Are you sure, you want to activate CFT Objectives? ')) {
            return true;
        }
        else {
            return false;
        }
    }
}

function KRAActivationConfirmation(linkButtonDetails) {
    var obj = document.getElementById(linkButtonDetails);
    if (obj.disabled == true) {
        return false;
    }
    else {
        if (confirm('Are you sure, you want to activate KRAs? ')) {
            return true;
        }
        else {
            return false;
        }
    }
}

function CFTObjectivesApprovalConfirmation(linkButtonDetails) {
    var obj = document.getElementById(linkButtonDetails);
    if (obj.disabled == true) {
        return false;
    }
    else {
        if (confirm('Are you sure, you want to approve CFT Objectives? ')) {
            return true;
        }
        else {
            return false;
        }
    }
}

function CFTRatingApprovalConfirmation(linkButtonDetails) {
    var obj = document.getElementById(linkButtonDetails);
    if (obj.disabled == true) {
        return false;
    }
    else {
        if (confirm('Are you sure, you want to approve GA-Rating? ')) {
            return true;
        }
        else {
            return false;
        }
    }
}

function AlertMessage() {
    return alert('You cannot delete this project, as it is Configured');
}

function DeleteObjectiveConfirmation() {
    return window.confirm('Are you sure, you want to Delete Objectives and all KPI related to this Objectives? ');
}

function ShowAlertMessage() {
    return alert('Your password has been changed successflly');
}

function CheckLength(text, len) {
    var maxlength = new Number(len);
    if (text.value.length > maxlength) {
        text.value = text.value.substring(0, maxlength);
        alert('Length should not exceed ' + len + ' characters');
    }
}

function AssignValidation(grNetworkDetails) {
    var row1;
    var i = 1;
    var j = 0;
    row1 = document.getElementById(grNetworkDetails).rows;
    for (i = 1; i < row1.length; i++) {
        var cell = row1[i].cells[0];
        var chkChecked = cell.firstChild;
        if (chkChecked.type == "radio" && chkChecked.checked == true) {
            j = j + 1;
        }
    }
    if (j < 1) {
        alert("select atleast one record to delete.");
        return false;
    }
    else {
        if (confirm('Are you sure, you want to delete?')) {
            return true;
        }
        else {
            return false;
        }
    }
}

function WarningForDelete(grNetworkDetails) {
    var row1;
    var i = 1;
    var j = 0;
    row1 = document.getElementById(grNetworkDetails).rows;
    for (i = 1; i < row1.length; i++) {
        var cell = row1[i].cells[0];
        var chkChecked = cell.firstChild;
        if (chkChecked.type == "checkbox" && chkChecked.checked == true) {
            j = j + 1;
        }
    }
    if (j < 1) {
        alert("select atleast one record to delete.");
        return false;
    }
    else {
        if (confirm('Are you sure, you want to delete?')) {
            return true;
        }
        else {
            return false;
        }
    }
}

function RequestForAOPUpdateReviewStatus(linkButtonDetails) {
    var obj = document.getElementById(linkButtonDetails);
    if (obj.disabled == true) {

        return false;
    }
    else {
        if (confirm('Are you sure, you want to update the status? ')) {
            return true;
        }
        else {
            return false;
        }
    }
}

function ClearLabelErrorMessage(idLabelErrorMessage) {
    document.getElementById(idLabelErrorMessage).innerText = '';
}

function CheckRadioButtonSelectionInGridView(gridViewID, IdLabelError, alertMSG) {
    var table = document.getElementById(gridViewID);
    if (table.rows && table.rows.length > 0) {
        var count = 0;
        for (rowCount = 1; rowCount < table.rows.length; rowCount++) {
            var firstrow = table.rows[rowCount];
            var cell = firstrow.cells[0];
            var chkChecked = cell.firstChild;
            while (chkChecked) {
                if (chkChecked.tagName == "INPUT" && chkChecked.type == "radio") {
                    if (chkChecked.checked == true) {
                        count++;
                        break;
                    }
                }
                chkChecked = chkChecked.nextSibling;
            }
            if (count > 1)
                break;
        }
        if (count == 0) {
            //alert(alertMSG);
            document.getElementById(IdLabelError).innerText = alertMSG;
            document.getElementById(IdLabelError).style.color = "red";
            return false;
        }
        else
            return true;
    }
}

function CompareCellValueInGridView(gridViewID, alertMSG, CellNumber, ValueToCompare, TxtBoxID) {
    var table = document.getElementById(gridViewID);
    if (table.rows && table.rows.length > 0) {
        var Total = 0;
        for (rowCount = 1; rowCount < table.rows.length; rowCount++) {
            var firstrow = table.rows[rowCount];
            var cell = firstrow.cells[CellNumber];
            var ObjSpan = cell.firstChild;
            while (ObjSpan) {
                if (ObjSpan.tagName == "SPAN") {
                    Total = Total + parseInt(ObjSpan.innerText);
                }
                ObjSpan = ObjSpan.nextSibling;
            }
        }
        Total = Total + parseInt(document.getElementById(TxtBoxID).value);
        if (Total > ValueToCompare) {
            return window.confirm(alertMSG);
        }
        else
            return true;
    }
}

function DisableAndEnableControls(ControlIDs) {
    var ArrayContolIds = new Array();
    ArrayContolIds = ControlIDs.split(',');
    if (document.getElementById(ArrayContolIds[0]).checked == true) {
        for (var count = 1; count < ArrayContolIds.length; count++) {
            document.getElementById(ArrayContolIds[count]).disabled = false;
        }
    }
    else {
        for (var count = 1; count < ArrayContolIds.length; count++) {
            document.getElementById(ArrayContolIds[count]).disabled = true;
        }
    }
}

function ConfirmationWithErrorLabelMessage(IdLabelError, alertMSG, confirmMSG, gridViewID) {
    if (gridViewID != null)
        var alertStatus = CheckRadioButtonSelectionInGridView(gridViewID, IdLabelError, alertMSG);
    if (alertStatus) {
        return window.confirm(confirmMSG);
    }
    else
        return alertStatus;
}