﻿// JScript File

function SaveComments()
{
    if(ValidateAddCommentsForm()==false)
    {
        return(false);
    }
    else
    {
        return(true);
    }   
}


function ValidateAddCommentsForm()
{
    errors = "<ul>";
    
    var status = true;
    mandatoryFieldsErrorFlag=false;
     
    // validating Description field           
    varTemp = document.getElementById("txtCommentDescription");  
    alertName = " Description ";
    isMandatory = 'True'; 
    if(bValidate(varTemp,"",isMandatory , alertName) != true)
        { status = false;   
         
        }
        if(varTemp.value.length > 1025)
        {  errors +="Description cannot exceed 1025 characters.";
          status = false;
        }
   //if validation of any field comes out to be invalid then display error message 
   if(status == false)
   {
       
        var registrationErrorsDiv = document.getElementById("WarningMsgs_RegistrationErrors");

        registrationErrorsDiv.style.display = "block";
        errors +='</ul>';
        registrationErrorsDiv.innerHTML = "";
         document.getElementById("WarningMsgs_divWarningInfo").style.display = "block";
        registrationErrorsDiv.innerHTML = errors; 
       
        return false;   
    }
    else 
    {
        return true;
    }   
}

function DeleteCommentRecordConfirmation(RecordId,btnId)
{
    // return confirm('Would you like to delete this record?');
    document.getElementById("confirmBox_hidButtonId").value=btnId;
    document.getElementById("hidRecordId").value=RecordId;
    ShowConfirmBox('Would you like to delete this record?');
    return false;
}

function OffensiveReviewCommentConfirmation(RecordId,btnId)
{
    //return confirm('Would you like to report this comment on review as offensive?');
    document.getElementById("confirmBox_hidButtonId").value=btnId;
    document.getElementById("hidRecordId").value=RecordId;
    ShowConfirmBox('Would you like to report this comment on review as offensive?');
    return false;
}

function OffensiveEventCommentConfirmation(RecordId,btnId)
{
    //return confirm('Would you like to report this comment on review as offensive?');
    document.getElementById("confirmBox_hidButtonId").value=btnId;
    document.getElementById("hidRecordId").value=RecordId;
    ShowConfirmBox('Would you like to report this comment on Event as offensive?');
    return false;
}

function EditComment(CommentId,CommentText)
{
    document.getElementById("txtCommentDescription").value="";
    document.getElementById("WarningMsgs_RegistrationErrors").innerHTML = "";
    document.getElementById("WarningMsgs_RegistrationErrors").style.display = "none";
    document.getElementById("WarningMsgs_divWarningInfo").style.display = "none"; 
    document.getElementById("txtCommentDescription").value=CommentText;  
    document.getElementById("hidCommentId").value= CommentId;
   
    return false;

}
