﻿var ColumnSize = 3;
var PaginationCount = 2;


$(document).ready(function () {  
  $("#nav ul").css({ display: "none" }); // Opera Fix
  $("#nav li").hover(function () {
    $(this).find('ul:first').css({ visibility: "visible", display: "none" }).show(400);
  }, function () {
    $(this).find('ul:first').css({ visibility: "hidden" });
  });
});
    
function AddMessage(TopicID, Body) 
{  
  $.post("/Messages/AddMessage",
    { topicID: TopicID,
      body: escape(Body)
    },
    function (topicID) {           
          window.location.href="/Messages/Index/" + topicID;
    },
    "json"
  )
}


function AddPersonalizedMessage(TopicID, MessageID, Body) {
  $.post("/Messages/AddPersonalizedMessage",
    { topicID: TopicID,
      messageID : MessageID,
      body: escape(Body)
    },
    function (topicID) {
      window.location.href = "/Messages/Index/" + topicID;
    },
    "json"
  )
}


function AddComplaint(TopicID, MessageID, Body) {
  $.post("/Complaint/AddComplaint",
    { topicID: TopicID,
      messageID: MessageID,
      body: escape(Body)
    },
    function (topicID) {
      window.location.href = "../Messages/Index/" + topicID;
    },
    "json"
  )
}


function dateReviver(value) {

        if (typeof value === 'string') {
            return dateFormat(eval(value.replace(/\/Date\((\d+)\)\//gi, "new Date($1)")), "dd mmm yyyy HH:MM:ss", true)
    }
    return "";
}
function dateReviver1(value) {

    if (typeof value === 'string') {
        return dateFormat(eval(value.replace(/\/Date\((\d+)\)\//gi, "new Date($1)")), "dd mmm yyyy", true)
    }
    return "";
}
function htmlEntity(tags,aa) {
  var bb = '';  
  for (i = 0; i < aa.length; i++) {
    if (aa.charCodeAt(i) > 127)
      bb += '&#' + aa.charCodeAt(i) + ';';
    else
      if (tags == 1) {
        if (aa.charAt(i) == '<')
          bb += '&lt;';
        else
          if (aa.charAt(i) == '>')
            bb += '&gt;';
          else
            if (aa.charAt(i) == '&')
              bb += '&amp;';
            else
              bb += aa.charAt(i);
      }
      else
        if (tags == 2) {
          if (aa.charAt(i) == '<')
            bb += '&lt;';
          else
            if (aa.charAt(i) == '>')
              bb += '&gt;';
            else
              bb += aa.charAt(i);
        }
        else
          bb += aa.charAt(i);
  }
  return bb;
}

function tooglerow(rowid,imgid) {
  
  var m_src = ($('#' + imgid + '').attr('src') === '../../Content/Images/img_mnus.gif')
                    ? '../../Content/Images/img_plus.gif'
                    : '../../Content/Images/img_mnus.gif';
  $('#' + imgid + '').attr('src', m_src);
  $('#' + rowid + '').toggle(400);     
  return false;
}
