﻿
$(document).ready(
  function() {

      var ReplyWatermarkText = $("#Wall_WatermarkTextInCommentField").attr('value');
      var WritePostWatermarkText = $("#Wall_WatermarkTextInWritePostField").attr('value');
      var ReplyTextboxID = "ReplyTextBoxID";

      $("#Wall_UserCommentTextBox_TextBox").focus(function() {
          $(this).addClass('Wall_UserCommentTextBoxSelected');
          if ($(this).attr('value') == WritePostWatermarkText)
              $(this).attr('value', '')
      });

      $("#Wall_UserCommentTextBox_TextBox").blur(function() {
          if ($(this).attr("value") == '') {
              $(this).removeClass('Wall_UserCommentTextBoxSelected');
              $(this).attr('value', WritePostWatermarkText);
          }
      });

      $("span.wall_CommentLabel").click(function() {

          var textbox = FindPrefixID($(this), "wall_UserCommentLinkButton", ReplyTextboxID);
          var ReplyPanel = FindPrefixID($(this), "wall_UserCommentLinkButton", "Wall_GridAndCommentPanel");
          ReplyPanel.addClass('Wall_GridAndCommentPanelSelected');
          textbox.focus();

      });


      $("textarea.Wall_ReplyTextBox").focus(function() {

          $(this).addClass('Wall_ReplyTextBoxSelected');
          var button = FindPrefixID($(this), ReplyTextboxID, "Wall_ReplyButton")
          button.addClass('wall_ReplyLinkButtonSelected');

          if ($(this).attr('value') == ReplyWatermarkText) {
              $(this).attr('value', '');


          }
      });


      $("textarea.Wall_ReplyTextBox").blur(function() {



          if ($(this).attr("value") == '') {

              $(this).attr('value', ReplyWatermarkText);
              $(this).removeClass('Wall_ReplyTextBoxSelected');
              var button = FindPrefixID($(this), ReplyTextboxID, "Wall_ReplyButton")
              button.removeClass('wall_ReplyLinkButtonSelected');

              var ReplyPanel = FindPrefixID($(this), ReplyTextboxID, "Wall_GridAndCommentPanel");
              ReplyPanel.removeClass('Wall_GridAndCommentPanelSelected');
          }
      });

      //             $("input.wall_ReplyLinkButton").click(function(){ 
      //            
      //                    var ReplyPanel = FindPrefixID($(this), "Wall_ReplyButton" ,ReplyTextboxID);
      //                    Count(ReplyPanel,10);
      //            
      //              });
  });


function OpenReplyBox(textBox) {

    textBox.attr('value', '');
    textBox.addClass('Wall_ReplyTextBoxSelected');
    var button = FindPrefixID($(this), "ReplyTextBoxID", "Wall_ReplyButton")
    button.addClass('wall_ReplyLinkButtonSelected');
}

function FindPrefixID(control, oldControlClientID, newControlClientID) {
    var linkID = control.attr('id')
    var NamingID = linkID.replace(oldControlClientID, "");
    var textbox = $("#" + NamingID + newControlClientID);
    return textbox;
}

function Count(text, long) {
    var maxlength = new Number(long); // Change number to your max length.
    if (text.val().length > maxlength) {
        //text.attr('value', text.attr('value').substr(0,maxlength));  
        $("span.Wall_LengthErrorMessage").addClass("Wall_LengthErrorMessageShown");
        alert(" Only " + long + " characters");
    }
}

function CheckLength(val, args) {
    //fire checkbox validator message if the ePay checkbox is not checked
    var cb = document.getElementById('btf_AcceptTermsCheckBox');
    args.IsValid = cb.checked;
}
