home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 January / chipcd20010102.iso / software / internet / thirdvoice / setup3v.exe / %MAINDIR% / htm / ext / AnnInsCt.js next >
Encoding:
JavaScript  |  2000-11-26  |  72.9 KB  |  2,294 lines

  1. ////////////////// ANNOTATION INSERT CONTROL ///////////////////////
  2. //
  3. // ported from AnnotInsertCtl.vb
  4. // dated on 20th December 1998
  5. //
  6. // NOTE : have to call initProperties
  7. ////////////////////////////////////////////////////////////////////
  8.  
  9. //////////////////// GLOBAL VARIABLES ///////////////////
  10. var TV__TVP           = "<tvp>";
  11. var TV__IE_MODULEID   = 10000;
  12. var TV__IE_CLIENT_HDR = "AweAnnotMsg" + TV__TVP + TV__IE_MODULEID;  
  13.  
  14. var TV__TVM_REPLY_ANNOT     = TV__IE_MODULEID + 20;
  15. var TV__TVM_SELECT_URL      = TV__IE_MODULEID + 30;
  16. var TV__TVM_ACTIVATE_ANNOT  = TV__IE_MODULEID + 60;
  17. var TV__TVM_UPDATE_ANNOT    = TV__IE_MODULEID + 70;
  18. var TV__TVM_HIDE_ANNOT      = TV__IE_MODULEID + 80;
  19. var TV__TVM_VOTE            = TV__IE_MODULEID + 100;
  20. var TV__TVM_JOIN_PUBLIC_GRP = TV__IE_MODULEID + 110;
  21. var TV__TVM_MAIL_ANNOT      = TV__IE_MODULEID + 130;
  22. var TV__TVM_SUBMENU_NOTES   = TV__IE_MODULEID + 140;
  23. var TV__TVM_PAGELEVEL_MENU  = TV__IE_MODULEID + 170;
  24. var TV__TVM_SHOW_NOTETUT_DLG= TV__IE_MODULEID + 180;
  25.  
  26. var TV__TVM_SUBMIT_BUG      = TV__IE_MODULEID + 500;
  27.  
  28. var TV__PERSONAL_NOTE     = 0x200;
  29. var TV__PAGELEVEL_NOTE    = 0x20;
  30. var TV__UNATTACHED_NOTE   = 0x80;
  31. var TV__RECOMMENDED_NOTE  = 0x100;
  32. var TV__DEFAULT_NOTETYPE  = 0x400;
  33.  
  34. var TV__NOTETYPE_DISBALED = 0x80;
  35. var TV__MAX_PEERRATING    = 32767;
  36.  
  37. var TV__sSelectURLMsg = TV__IE_CLIENT_HDR + TV__TVP + TV__TVM_SELECT_URL;
  38.  
  39. var TV__HighlightPrefix    = "AweHighlight";
  40. var TV__HighlightBgColor   = "yellow";
  41. var TV__HighlightTextColor = "darkblue";
  42.  
  43. var TV__bShowMailText = false;
  44. var TV__bStartMove    = false;
  45. var TV__objFocus      = null;
  46. var TV__bHideLine     = false;
  47. var TV__mouseTrackY   = 0;
  48. var TV__mouseTrackX   = 0;
  49. var TV__objSelRange   = null;
  50. var TV__keyDownImg    = false;
  51. var TV__replacedMouseMoveFn = false;
  52.  
  53. var TV__joingrpspan      = "joingrpspan";
  54. var TV__jgrpspan         = "grpspan";
  55. var TV__grpurl           = "mygroup/mygroupnotes.asp?groupid=";
  56. var TV__annotMarkTag     = "AweAnnotMarker";
  57. var TV__annotAggMarkTag  = "AweAnnotAggMarker";
  58. var TV__annotRootID      = "AweAnnotRootID";
  59. var TV__inactiveAnnot    = "AweInactiveAnnot";
  60. var TV__refStrEnd        = "AweRefTextEnd";
  61. var TV__refStrStart      = "AweRefTextStart";
  62. ////////////////// annotation template ///////////////////////////
  63. var TV__annotTemplate = "<div id=annot onmouseup='TV__outOfNote(this);' onmousedown='TV__onmousedown(this);'>";
  64. TV__annotTemplate    += "  <div id=annotHeader annotID='%TV__annotid%' annotType='%TV__annottype%' prevAnnotID='%TV__previd%' nextAnnotID='%TV__nextid%' rootAnnotID='%TV__rootid%' markerStatus='nothing'></div>";
  65. TV__annotTemplate    += "  <div id=annotShadowBottom style='top:157' onselectstart='return false;'></div>";
  66. TV__annotTemplate    += "  <div id=annotShadowRight  onselectstart='return false;'></div>";
  67. TV__annotTemplate    += "  <a id=annotSnapTo onclick=\"TV__handleRefTextIconClick('%TV__rootid%');\" >";
  68. TV__annotTemplate    += "  <img border=0 id=snapimg src='%TV__AppDir%/htm/images/snap.gif' title='snap this note to its reference text'>";
  69. TV__annotTemplate    += "  </a>";
  70. TV__annotTemplate    += "  <div id=AweAnnotRootID%TV__rootid% class=AweActiveBasicAnnot>";
  71. TV__annotTemplate    += "  <span id=annotTitle class=annotTitle onselectstart='return false;'>%TV__title%</span><br>";
  72. TV__annotTemplate    += "  <span id=annotAuthor class=annotAuthor onselectstart='return false;'>by %TV__author%</span><br>";
  73. TV__annotTemplate    += "  <a href='' onclick='return false;' onkeydown='TV__keydownImg();' onkeyup='TV__keyupImg();' onkeypress='TV__keypressImg();' style='cursor:move'><img id=annotIcon border=0 src=''></a>";
  74. TV__annotTemplate    += "  <div id=voteStatus></div>";
  75. TV__annotTemplate    += "<div id=annotContent class=annotContent>%TV__content%</div>";
  76. TV__annotTemplate    += "  </div>";
  77. TV__annotTemplate    += "  <div id=awedogearbase onselectstart='return false;'></div> ";
  78. TV__annotTemplate    += "  <img border=0 id=awedogear src='%TV__AppDir%/htm/images/dogear.gif'>";
  79. TV__annotTemplate    += "  <div id=annotToolbar onselectstart='return false;'>";
  80. TV__annotTemplate    += "<img border=0 id=annotCloseHandle    class=annotToolBtn disable=0 dis='%TV__AppDir%/htm/images/d_close.gif' onmouseover=\"TV__noteToolbarMove(this, '%TV__AppDir%/htm/images/i_close.gif');\" onmouseout=\"TV__noteToolbarMove(this, '%TV__AppDir%/htm/images/o_close.gif');\" src='%TV__AppDir%/htm/images/o_close.gif' title='close this note'                                              onclick=\"TV__handleCloseAnnotIconClick('%TV__rootid%');\">";
  81. TV__annotTemplate    += "<img border=0 id=annotReplyHandle    class=annotToolBtn disable=0 dis='%TV__AppDir%/htm/images/d_reply.gif' enb='%TV__AppDir%/htm/images/o_reply.gif' onmouseover=\"TV__noteToolbarMove(this, '%TV__AppDir%/htm/images/i_reply.gif');\" onmouseout=\"TV__noteToolbarMove(this, '%TV__AppDir%/htm/images/o_reply.gif');\" src='%TV__AppDir%/htm/images/o_reply.gif' title='reply to this note' onclick=\"TV__handleReplyIconClick('%TV__rootid%', this);\">";
  82. TV__annotTemplate    += "<img border=0 id=annotMailHandle     class=annotToolBtn disable=0 dis='%TV__AppDir%/htm/images/d_mail.gif'  enb='%TV__AppDir%/htm/images/o_mail.gif'  onmouseover=\"TV__noteToolbarMove(this, '%TV__AppDir%/htm/images/i_mail.gif');\"  onmouseout=\"TV__noteToolbarMove(this, '%TV__AppDir%/htm/images/o_mail.gif');\"  src='%TV__AppDir%/htm/images/o_mail.gif'  title='mail this note'     onclick=\"TV__handleMailIconClick('%TV__rootid%', this);\">";
  83. TV__annotTemplate    += "<img border=0 id=annotVoteHandle     class=annotToolBtn disable=0 dis='%TV__AppDir%/htm/images/d_vote.gif'  enb='%TV__AppDir%/htm/images/o_vote.gif'  onmouseover=\"TV__noteToolbarMove(this, '%TV__AppDir%/htm/images/i_vote.gif');\"  onmouseout=\"TV__noteToolbarMove(this, '%TV__AppDir%/htm/images/o_vote.gif');\"  src='%TV__AppDir%/htm/images/o_vote.gif'  title='vote this note'     onclick=\"TV__handleVoteClick('%TV__rootid%', this);\">";
  84. TV__annotTemplate    += "  <span id=annotMailTxt><img border=0 src='%TV__AppDir%/htm/images/mailthis.gif'>Vote Now!</span>";
  85. TV__annotTemplate    += "  </div>";
  86. TV__annotTemplate    += "  <div id=annotNavigate onselectstart='return false;'>";
  87. TV__annotTemplate    += "  <img border=0 id=annotPrevHandle     class=annotToolBtn disable=0 dis='%TV__AppDir%/htm/images/prevdis.gif'  onmouseover=\"TV__noteToolbarMove(this, '%TV__AppDir%/htm/images/previn.gif');\"  onmouseout=\"TV__noteToolbarMove(this, '%TV__AppDir%/htm/images/prevout.gif');\"  src='%TV__AppDir%/htm/images/prevout.gif'  style='visibility: %TV__prevVisible%' title='show previous notes' onclick=\"TV__handlePrevReplyIconClick('%TV__rootid%');\">";
  88. TV__annotTemplate    += "  <img border=0 id=annotNextHandle     class=annotToolBtn disable=0 dis='%TV__AppDir%/htm/images/nextdis.gif'  onmouseover=\"TV__noteToolbarMove(this, '%TV__AppDir%/htm/images/i_next.gif');\"  onmouseout=\"TV__noteToolbarMove(this, '%TV__AppDir%/htm/images/o_next.gif');\"  src='%TV__AppDir%/htm/images/o_next.gif'  style='visibility: %TV__nextVisible%' title='show next notes'     onclick=\"TV__handleNextIconClick('%TV__rootid%');\">";
  89. TV__annotTemplate    += "  </div>";
  90. TV__annotTemplate    += "  <div id=vote style='height:54' class=aweVotepanel><center>";
  91. TV__annotTemplate    += "    <div id=votehdr>Vote Now</div>";
  92. TV__annotTemplate    += "    <div class=voteItem onmousedown='event.cancelBubble=true;' onclick=\"TV__voteNote('%TV__rootid%', 1);\"   onmouseover='return TV__VoteMouseOver(this);' onmouseout='return TV__VoteMouseOut(this);'><center><img border=0 src='%TV__AppDir%/htm/images/v_star.gif'> <span class=voteItem>Great Note!</span></center></div>";
  93. TV__annotTemplate    += "    <div class=voteItem onmousedown='event.cancelBubble=true;' onclick=\"TV__voteNote('%TV__rootid%', 0);\"   onmouseover='return TV__VoteMouseOver(this);' onmouseout='return TV__VoteMouseOut(this);'><center><img border=0 src='%TV__AppDir%/htm/images/v_trash.gif'> <span class=voteItem>Spam/Junk</span></center></div>";
  94. TV__annotTemplate    += "   </center><img class=aweVotebase src='%TV__AppDir%/htm/images/votebase.gif'>";
  95. TV__annotTemplate    += "   </div>";
  96. TV__annotTemplate    += "</div>";
  97. TV__annotTemplate    += "<hr id=annotVertHr%TV__rootid% class=AweActiveVertHrLine style='display:none'>";
  98. TV__annotTemplate    += "<div id=annotVertDiv%TV__rootid% class=AweActiveVertDivLine style='display:none'></div>";
  99. TV__annotTemplate    += "<hr id=annotHori%TV__rootid% class=AweActiveHoriLine style='display:none'>";
  100.  
  101. var TV__signature = "<br><br><hr noshade style='border:0; color:lightgrey'><font class=signature>Like this note? <span class=signClick onclick=\"TV__handleMailIconClick('%TV__rootid%');\">Email</span> it to a friend.</font>";
  102. var TV__helpVote  = "<font class=signature>Voice your opinion! <span class=signClick onclick='CreateWin(\"%TV__strWebSite%help/helpvote.htm\", \"VoteHelp\", 470, 420, 0, 1, 0);'>Vote</span> on this note.</font>";
  103.   
  104. var TV__star      = "<img border=0 src='%TV__AppDir%/htm/images/star.gif'>";
  105. var TV__starme    = "<img border=0 src='%TV__AppDir%/htm/images/starme.gif'>";
  106. var TV__trash     = "<img border=0 src='%TV__AppDir%/htm/images/trash.gif'>";
  107. var TV__trashme   = "<img border=0 src='%TV__AppDir%/htm/images/trashme.gif'>";
  108.  
  109. var TV__recomImg  = "<img border=0 src='%TV__AppDir%/htm/images/recom.gif'> ";
  110.  
  111. //////////////////// REFSTRING TAG ///////////////////////////////
  112. var TV__ghostFrontIDSelText  = "ghostFrontIDSelText";
  113. var TV__ghostEndIDSelText    = "ghostEndIDSelText";
  114. var TV__ghostFrontTagSelText = "<span style='display:none;' id=" + TV__ghostFrontIDSelText + ">current</span>";
  115. var TV__ghostEndTagSelText   = "<span style='display:none;' id=" + TV__ghostEndIDSelText + ">current</span>";
  116.  
  117. //////////////////// EVENT SINKS ///////////////////////////////
  118. document.ondblclick    = TV__ondblclick;
  119. document.onselectstart = TV__onselectstart;
  120. window.onresize        = TV__onresize;
  121.  
  122. var TV__aggMarkerArray  = new Array;
  123. var TV__bAggregated     = false;
  124. var TV__raisedIndex     = 10;
  125. var TV__topIndex        = 8;
  126. var TV__bottomIndex     = 5;
  127.  
  128. ///////////////////////// MOUSE HANDLER ////////////////////////////
  129. function TV__ondblclick()
  130. {
  131.   if (document.selection.createRange.Text != "")
  132.   {
  133.     TV__sendMsg2Client(TV__sSelectURLMsg + TV__TVP + document.parentWindow.location.href);
  134.   }
  135. }
  136.  
  137. function TV__onmousedown(TV__obj)
  138. {
  139.   // The left mouse button is clicked
  140.   if (event.button == 1)
  141.   {
  142.     var esrc = event.srcElement;
  143.     hideVoteDiv(TV__getAnnotAttribute(TV__obj, "rootAnnotID"));
  144.  
  145.     // don't not remove this if block, it will cause IE5 to crash when user tries to scroll on note
  146.     if (TV__objFocus != TV__obj)
  147.     {
  148.       TV__objFocus = TV__obj;
  149.       TV__sendActivateAnnotEvent(TV__getAnnotAttribute(TV__objFocus, "annotID"), window.location.href);
  150.       TV__RaiseAnnot(TV__objFocus, true, true); // raise this annotation for dragging
  151.     }
  152.  
  153.     if ( (esrc.id != 'annotContent') && (esrc.className != "annotToolBtn") )
  154.     {
  155.       TV__bStartMove = true;
  156.       TV__bHideLine = true;
  157.  
  158.       TV__mouseTrackX = event.clientX; 
  159.       TV__mouseTrackY = event.clientY;
  160.  
  161.       if (document.onmousemove == null)
  162.       {
  163.         document.onmousemove = TV__onmousemove;
  164.         TV__replacedMouseMoveFn = true;
  165.       }
  166.       else
  167.       {
  168.         TV__objFocus.onmousemove = TV__onmousemove;
  169.       }
  170.     }
  171.   }
  172. }
  173.  
  174.  
  175. function TV__outOfNote(TV__DragObj)
  176. {
  177.   if (TV__bStartMove == true) 
  178.   {
  179.     var TV__sRootID   = TV__getAnnotAttribute(TV__DragObj, "rootAnnotID");
  180.     var TV__objMarker = TV__GetNonAggMarker(TV__sRootID);
  181.  
  182.     // Draw line joining the reference text and the annotation
  183.     if (TV__objMarker != null)
  184.       TV__DrawLine(TV__sRootID, TV__GetAbsOffsetLeft(TV__objMarker), TV__GetAbsOffsetTop(TV__objMarker), TV__DragObj.offsetLeft, TV__DragObj.offsetTop, TV__objMarker, true);
  185.  
  186.     // Lower stickies back to the normal z-index setting for an active annotation
  187.     TV__RaiseAnnot(TV__DragObj, false, false);
  188.     TV__bStartMove = false;
  189.  
  190.     if (TV__replacedMouseMoveFn == true)
  191.     {
  192.       document.onmousemove = null;
  193.       TV__replacedMouseMoveFn = false;
  194.     }
  195.   }
  196. }
  197.  
  198.  
  199. function TV__onmousemove()
  200. {
  201.   if ( (event.button == 1) && (TV__objFocus != null) && (TV__bStartMove == true) )
  202.   {
  203.     // Hide the line if the line is still not hidden
  204.     if (TV__bHideLine == true)
  205.     {
  206.       var TV__rootID = TV__getAnnotAttribute(TV__objFocus, "rootAnnotID");
  207.       TV__HideLine(TV__rootID);       // Hide the line joining the annotation marker to the annotation
  208.       TV__bHideLine = false;
  209.     }
  210.     
  211.     // move the element and save mouse's position
  212.     var TV__iTop  = event.clientY;
  213.     var TV__iLeft = event.clientX;
  214.  
  215.     // Move the annotation to the new position
  216.     TV__objFocus.style.pixelLeft += TV__iLeft - TV__mouseTrackX;
  217.     TV__objFocus.style.pixelTop  += TV__iTop  - TV__mouseTrackY;
  218.  
  219.     TV__mouseTrackX = TV__iLeft;
  220.     TV__mouseTrackY = TV__iTop;
  221.     event.cancelBubble = true;
  222.   }
  223. }
  224.  
  225. function TV__onselectstart()
  226. {
  227.   TV__sendMsg2Client(TV__sSelectURLMsg + TV__TVP + window.location.href);
  228.   if ((TV__objFocus != null) && (TV__bStartMove == true))
  229.   {
  230.     return false;
  231.   }
  232. }
  233.  
  234.  
  235.  
  236.  
  237. ///////////////////////// WINDOW HANDLER ////////////////////////////
  238.  
  239. function TV__onresize()
  240. {
  241.   if (document.all != null)
  242.   {
  243.     RedrawLines();
  244.   }
  245. }
  246.  
  247.  
  248. ///////////////////////// MOUSE CLICK HANDLER ////////////////////////////
  249.  
  250. function TV__handleVoteClick(TV__rootid, TV__Obj)
  251. {
  252.   if ((TV__Obj != null) && (TV__Obj.disable == 1))
  253.     return;
  254.  
  255.   var TV__annotPad = TV__getAnnotPadFromRootID(TV__rootid);
  256.  
  257.   if (TV__annotPad != null)
  258.     TV__ShowVoteDiv(TV__annotPad);
  259.  
  260.   event.cancelBubble = true;
  261. }
  262.  
  263. function TV__handleRefTextIconClick(TV__rootid)
  264. {
  265.   if (event.srcElement.disable == 1)
  266.     return;
  267.  
  268.   var TV__annotPad = TV__getAnnotPadFromRootID(TV__rootid);
  269.  
  270.   if (TV__annotPad != null)
  271.   {
  272.     TV__AttachAnnot2Ref(TV__annotPad);
  273.     TV__sendActivateAnnotEvent(TV__getAnnotAttribute(TV__annotPad, "annotID"), window.location.href);
  274.   }
  275.   event.cancelBubble = true;
  276. }
  277.  
  278. function handleAnnotMarkClick(TV__sID)
  279. {
  280.   event.cancelBubble = true;
  281.   var TV__objAnnotID = document.all[TV__annotRootID + TV__sID];
  282.  
  283.   if (TV__objAnnotID != null)
  284.   {
  285.     var TV__objAnnot = TV__objAnnotID.parentElement;
  286.  
  287.     if (TV__objAnnot.style.display == "none")
  288.       TV__sendUpdateAnnotEvent(TV__sID, window.location.href);    // open  annote
  289.     else
  290.       TV__sendActivateAnnotEvent(TV__getAnnotAttribute(TV__objAnnot, "annotID"), window.location.href);
  291.   }
  292.   else
  293.   {
  294.     TV__sendUpdateAnnotEvent(TV__sID, window.location.href);
  295.   }
  296. }
  297.  
  298. function TV__handleCloseAnnotIconClick(TV__rootid)
  299. {
  300.   var TV__annotPad = TV__getAnnotPadFromRootID(TV__rootid);
  301.  
  302.   if (TV__annotPad != null)
  303.     TV__sendMsg2Client(TV__IE_CLIENT_HDR + TV__TVP + TV__TVM_HIDE_ANNOT + TV__TVP + window.location.href + TV__TVP + TV__getAnnotAttribute(TV__annotPad, "annotID"));
  304.  
  305.   event.cancelBubble = true;
  306. }
  307.  
  308. function TV__handleNextIconClick(TV__rootid)
  309. {
  310.   var TV__annotPad = TV__getAnnotPadFromRootID(TV__rootid);
  311.  
  312.   if (TV__annotPad != null)
  313.     TV__sendUpdateAnnotEvent(TV__getAnnotAttribute(TV__annotPad, "nextAnnotID"), window.location.href);
  314.  
  315.   event.cancelBubble = true;
  316. }
  317.  
  318. function TV__handlePrevReplyIconClick(TV__rootid)
  319. {
  320.   var TV__annotPad = TV__getAnnotPadFromRootID(TV__rootid);
  321.  
  322.   if (TV__annotPad != null)
  323.     TV__sendUpdateAnnotEvent(TV__getAnnotAttribute(TV__annotPad, "prevAnnotID"), window.location.href);
  324.  
  325.   event.cancelBubble = true;
  326. }
  327.  
  328. function TV__handleReplyIconClick(TV__rootid, TV__Obj)
  329. {
  330.   if ((TV__Obj != null) && (TV__Obj.disable == 1))
  331.     return;
  332.  
  333.   var TV__annotPad = TV__getAnnotPadFromRootID(TV__rootid);
  334.  
  335.   if (TV__annotPad != null)
  336.   {
  337.     var TV__sID = TV__getAnnotAttribute(TV__annotPad, "annotID");
  338.     TV__sendMsg2Client(TV__IE_CLIENT_HDR + TV__TVP + TV__TVM_REPLY_ANNOT + TV__TVP + window.location.href + TV__TVP + TV__sID + TV__TVP + TV__getAnnotTitle(TV__annotPad));
  339.     TV__sendActivateAnnotEvent(TV__sID, window.location.href);
  340.   }
  341.   event.cancelBubble = true;
  342. }
  343.  
  344. function TV__handleMailIconClick(TV__rootid, TV__Obj)
  345. {
  346.   if ((TV__Obj != null) && (TV__Obj.disable == 1))
  347.     return;
  348.  
  349.   var TV__annotPad = TV__getAnnotPadFromRootID(TV__rootid);
  350.  
  351.   if (TV__annotPad != null)
  352.   {
  353.     var TV__sID = TV__getAnnotAttribute(TV__annotPad, "annotID");
  354.     TV__sendMsg2Client(TV__IE_CLIENT_HDR + TV__TVP + TV__TVM_MAIL_ANNOT + TV__TVP + window.location.href + TV__TVP + TV__sID);
  355.     TV__sendActivateAnnotEvent(TV__sID, window.location.href);
  356.   }
  357.   event.cancelBubble = true;
  358. }
  359.  
  360. function TV__AttachAnnot2Ref(TV__objAnnot, bPageLevelNote)
  361. {
  362.   var TV__sRootID    = TV__getAnnotAttribute(TV__objAnnot, "rootAnnotID");
  363.   var TV__sEndID     = TV__refStrEnd + TV__sRootID;
  364.   var TV__objRefText = document.all[TV__sEndID];
  365.  
  366.   if (TV__objRefText != null)
  367.   {
  368.     // get the absolute top coordinate of the reference text
  369.     // and update the top coordinate of the annotation
  370.     var TV__iNewTop = TV__objRefText.offsetHeight + TV__GetAbsOffsetTop(TV__objRefText);
  371.     TV__objAnnot.style.pixelTop = TV__iNewTop;
  372.  
  373.     // Drawing the line after the annot has been attached to the reference text
  374.     var TV__objMarker = TV__GetNonAggMarker(TV__sRootID);
  375.     
  376.     // get the absoluate left coordinate of the reference text
  377.     // update the left coordinate of the annotation
  378.     var TV__iAbsLeft = TV__GetAbsOffsetLeft(TV__objMarker);
  379.  
  380.     // make the left edge of note flush with the refstring
  381.     var TV__startRef = document.all['AweRefTextStart' + TV__getAnnotAttribute(TV__objAnnot, "rootAnnotID")];
  382.     var TV__iPadLeft = TV__GetAbsOffsetLeft(TV__startRef);
  383.     TV__objAnnot.style.pixelLeft = TV__iPadLeft;
  384.     
  385.     var TV__iAbsTop = TV__GetAbsOffsetTop(TV__objMarker);
  386.  
  387.     // Hide the previous line joining the annotation and marker
  388.     TV__HideLine(TV__sRootID);
  389.  
  390.     // Draw the new line joining the annotation and marker
  391.     TV__DrawLine(TV__sRootID, TV__iAbsLeft, TV__iAbsTop, TV__iPadLeft, TV__iNewTop, TV__objMarker, true);
  392.   }
  393.   else
  394.   {
  395.     var xOffset = 0;
  396.     var yOffset = 0;
  397.  
  398.     if (bPageLevelNote == true)
  399.     {
  400.       xOffset = 20;
  401.       yOffset = 20;
  402.     }
  403.  
  404.     TV__PosToRHSBottom(TV__objAnnot, xOffset, yOffset);
  405.   }
  406. }
  407.  
  408.  
  409.  
  410. ///////////////////////// ANNOT LINES HANDLER ////////////////////////////
  411. function RedrawLines()
  412. {
  413.   var TV__obj = document.all.annot;
  414.  
  415.   if (TV__obj != null)
  416.   {
  417.     if (TV__obj.length == null)  // one annotation
  418.       TV__RedrawLinesForAnnot(TV__obj);
  419.     else
  420.       for (var i = 0; i < TV__obj.length; i++)
  421.         TV__RedrawLinesForAnnot(TV__obj[i]);
  422.   }
  423. }
  424.  
  425. function TV__RedrawLinesForAnnot(TV__obj)
  426. {
  427.   if (TV__obj != null)
  428.   {
  429.     var TV__strRootID = TV__getAnnotAttribute(TV__obj, "rootAnnotID"); 
  430.     var TV__objMarker = TV__GetNonAggMarker(TV__strRootID);
  431.  
  432.     // Draw line joining the reference text and the annotation post-it
  433.     if (TV__objMarker != null)
  434.       TV__DrawLine(TV__strRootID, TV__GetAbsOffsetLeft(TV__objMarker), TV__GetAbsOffsetTop(TV__objMarker), TV__obj.offsetLeft, TV__obj.offsetTop, TV__objMarker, false);
  435.   }
  436. }
  437.  
  438. function TV__DrawLine(TV__sRootID, TV__fromX, TV__fromY, TV__toX, TV__toY, TV__objImage, TV__bVisible)
  439. {
  440.   if ( (TV__fromX >= TV__toX) && (TV__fromY >= TV__toY) )          
  441.     TV__DrawLineQuad2(TV__sRootID, TV__fromX, TV__fromY, TV__toX, TV__toY, TV__objImage, TV__bVisible);
  442.   else if ( (TV__toX > TV__fromX) && (TV__fromY >= TV__toY) )      
  443.     TV__DrawLineQuad1(TV__sRootID, TV__fromX, TV__fromY, TV__toX, TV__toY, TV__objImage, TV__bVisible);
  444.   else if ( (TV__fromX >= TV__toX) && (TV__toY > TV__fromY) )      
  445.     TV__DrawLineQuad3(TV__sRootID, TV__fromX, TV__fromY, TV__toX, TV__toY, TV__objImage, TV__bVisible);
  446.   else      
  447.     TV__DrawLineQuad4(TV__sRootID, TV__fromX, TV__fromY, TV__toX, TV__toY, TV__objImage, TV__bVisible);
  448. }
  449.  
  450. function TV__GetHoriLine(TV__sRootID)
  451. {
  452.   var TV__sHoriID = "annotHori" + TV__sRootID;
  453.   var TV__objHLine = document.all[TV__sHoriID];
  454.  
  455.   if (TV__objHLine == null)
  456.   {
  457.     alert("TV__DrawLine: Error...cannot find horizontal line for annotID = " + TV__sHoriID);
  458.     return null;
  459.   }
  460.   return TV__objHLine;
  461. }
  462.  
  463. function TV__GetVertLine(TV__sRootID, TV__height)
  464. {
  465.   var TV__sVertHrID  = "annotVertHr" + TV__sRootID;
  466.   var TV__sVertDivID = "annotVertDiv" + TV__sRootID;
  467.  
  468.   var TV__objVHrLine  = document.all[TV__sVertHrID];
  469.   var TV__objVDivLine = document.all[TV__sVertDivID];
  470.  
  471.   if ( (TV__objVHrLine == null) || (TV__objVDivLine == null) )
  472.   {
  473.     alert("TV__DrawLine: Error...cannot find vertical line for annotID = " + TV__sVertID);
  474.     return null;
  475.   }
  476.  
  477.   var TV__objVLine = null;
  478.   if (TV__height > 20)
  479.   {
  480.     TV__objVLine = TV__objVDivLine;
  481.     TV__objVHrLine.style.display = "none";
  482.   }
  483.   else
  484.   {
  485.     TV__objVLine = TV__objVHrLine;
  486.     TV__objVDivLine.style.display = "none";
  487.   }
  488.  
  489.   return TV__objVLine;
  490. }
  491.  
  492. function TV__DrawLineQuad1(TV__sRootID, TV__fromX, TV__fromY, TV__toX, TV__toY, TV__objImage, TV__bVisible)
  493. {
  494.   var TV__imgWidth  = TV__objImage.offsetWidth * 0.5;
  495.   var TV__imgHeight = TV__objImage.offsetHeight * 0.5;
  496.  
  497.   var TV__diffX = TV__toX - TV__fromX + TV__imgWidth;
  498.   var TV__diffY = TV__fromY - TV__toY + TV__imgHeight;
  499.   
  500.   var TV__objVLine = TV__GetVertLine(TV__sRootID, TV__diffY);
  501.   var TV__objHLine = TV__GetHoriLine(TV__sRootID);
  502.  
  503.   if ( (TV__objVLine == null) || (TV__objHLine == null) )
  504.     return;
  505.  
  506.   TV__objHLine.style.width     = (TV__diffX > 0) ? TV__diffX : 0;
  507.   TV__objVLine.style.height    = (TV__diffY > 0) ? TV__diffY : 0;
  508.   TV__objHLine.style.pixelLeft = TV__fromX + TV__imgWidth;
  509.   TV__objHLine.style.pixelTop  = TV__toY;
  510.   TV__objVLine.style.pixelLeft = TV__fromX + TV__imgWidth;
  511.   TV__objVLine.style.pixelTop  = TV__toY;
  512.  
  513.   if (TV__bVisible)
  514.   {
  515.     TV__objVLine.style.display = "";
  516.     TV__objHLine.style.display = "";
  517.   }
  518. }
  519.  
  520. function TV__DrawLineQuad2(TV__sRootID, TV__fromX, TV__fromY, TV__toX, TV__toY, TV__objImage, TV__bVisible)
  521. {
  522.   var TV__imgWidth  = TV__objImage.offsetWidth * 0.5;
  523.   var TV__imgHeight = TV__objImage.offsetHeight * 0.5;
  524.  
  525.   var TV__diffX = TV__fromX - TV__toX + TV__imgWidth;
  526.   var TV__diffY = TV__fromY - TV__toY + TV__imgHeight;
  527.  
  528.   var TV__objVLine = TV__GetVertLine(TV__sRootID, TV__diffY);
  529.   var TV__objHLine = TV__GetHoriLine(TV__sRootID);
  530.  
  531.   if ( (TV__objVLine == null) || (TV__objHLine == null) )
  532.     return;
  533.  
  534.   TV__objHLine.style.width     = (TV__diffX > 0) ? TV__diffX : 0;
  535.   TV__objVLine.style.height    = (TV__diffY > 0) ? TV__diffY : 0;
  536.   TV__objHLine.style.pixelLeft = TV__toX;
  537.   TV__objHLine.style.pixelTop  = TV__fromY + TV__imgHeight;
  538.   TV__objVLine.style.pixelLeft = TV__toX;
  539.   TV__objVLine.style.pixelTop  = TV__toY
  540.  
  541.   if (TV__bVisible)
  542.   {
  543.     TV__objVLine.style.display = "";
  544.     TV__objHLine.style.display = "";
  545.   }
  546. }
  547.  
  548. function TV__DrawLineQuad3(TV__sRootID, TV__fromX, TV__fromY, TV__toX, TV__toY, TV__objImage, TV__bVisible)
  549. {
  550.   var TV__imgWidth  = TV__objImage.offsetWidth * 0.5;
  551.   var TV__imgHeight = TV__objImage.offsetHeight * 0.5;
  552.  
  553.   var TV__diffX = TV__fromX - TV__toX + TV__imgWidth;
  554.   var TV__diffY = TV__toY - TV__fromY + TV__imgHeight +1; // +1 to compensation rounding error
  555.  
  556.   var TV__objVLine = TV__GetVertLine(TV__sRootID, TV__diffY);
  557.   var TV__objHLine = TV__GetHoriLine(TV__sRootID);
  558.  
  559.   if ( (TV__objVLine == null) || (TV__objHLine == null) )
  560.     return;
  561.  
  562.   TV__objHLine.style.width     = (TV__diffX > 0) ? TV__diffX : 0;
  563.   TV__objVLine.style.height    = (TV__diffY > 0) ? TV__diffY : 0;
  564.   TV__objHLine.style.pixelLeft = TV__toX;
  565.   TV__objHLine.style.pixelTop  = TV__fromY + TV__imgHeight;
  566.   TV__objVLine.style.pixelLeft = TV__toX;
  567.   TV__objVLine.style.pixelTop  = TV__fromY + TV__imgHeight;
  568.  
  569.   if (TV__bVisible)
  570.   {
  571.     TV__objVLine.style.display = "";
  572.     TV__objHLine.style.display = "";
  573.   }
  574. }
  575.  
  576. function TV__DrawLineQuad4(TV__sRootID, TV__fromX, TV__fromY, TV__toX, TV__toY, TV__objImage, TV__bVisible)
  577. {
  578.   var TV__imgWidth  = TV__objImage.offsetWidth * 0.5;
  579.   var TV__imgHeight = TV__objImage.offsetHeight * 0.5;
  580.  
  581.   var TV__diffX = TV__toX - TV__fromX + TV__imgWidth;
  582.   var TV__diffY = TV__toY - TV__fromY - TV__imgHeight +1;  // +1 to compensation rounding error
  583.  
  584.   var TV__objVLine = TV__GetVertLine(TV__sRootID, TV__diffY);
  585.   var TV__objHLine = TV__GetHoriLine(TV__sRootID);
  586.  
  587.   if ( (TV__objVLine == null) || (TV__objHLine == null) )
  588.     return;
  589.  
  590.   TV__objHLine.style.width     = (TV__diffX > 0) ? TV__diffX : 0;
  591.   TV__objVLine.style.height    = (TV__diffY > 0) ? TV__diffY : 0;
  592.   TV__objHLine.style.pixelLeft = TV__fromX + TV__imgWidth;
  593.   TV__objHLine.style.pixelTop  = TV__toY;
  594.   TV__objVLine.style.pixelLeft = TV__fromX + TV__imgWidth;
  595.   TV__objVLine.style.pixelTop  = TV__fromY + TV__imgHeight;
  596.  
  597.   if (TV__bVisible)
  598.   {
  599.     TV__objVLine.style.display = "";
  600.     TV__objHLine.style.display = "";
  601.   }
  602. }
  603.  
  604.  
  605. function TV__HideLine(TV__sRootID)
  606. {
  607.   var TV__sVertHrID  = "annotVertHr"  + TV__sRootID;
  608.   var TV__sVertDivID = "annotVertDiv" + TV__sRootID;
  609.  
  610.   var TV__sHoriID = "annotHori" + TV__sRootID;
  611.  
  612.   var TV__objVHrLine  = document.all[TV__sVertHrID];
  613.   var TV__objVDivLine = document.all[TV__sVertDivID];
  614.   
  615.   if (TV__objVHrLine.length == null)  // confirm one vertical line
  616.   {
  617.     TV__objVHrLine.style.display = "none";
  618.   }
  619.  
  620.   if (TV__objVDivLine.length == null)  // confirm one vertical line
  621.   {
  622.     TV__objVDivLine.style.display = "none";
  623.   }
  624.  
  625.   var TV__objHLine = document.all[TV__sHoriID];
  626.  
  627.   if (TV__objHLine.length == null)  // confirm one horizontal line
  628.     TV__objHLine.style.display = "none";
  629. }
  630.  
  631.  
  632.  
  633.  
  634. ///////////////////////// MISCELANEOUS ////////////////////////////
  635.  
  636. function TV__sendMsg2Client(TV__msg)
  637. {
  638.   window.status = TV__msg;
  639.   window.status = "";
  640. }
  641.  
  642. function TV__sendActivateAnnotEvent(TV__sID, href)
  643. {
  644.   TV__sendMsg2Client(TV__IE_CLIENT_HDR + TV__TVP + TV__TVM_ACTIVATE_ANNOT + TV__TVP + href + TV__TVP + TV__sID);
  645. }
  646.  
  647. function TV__sendUpdateAnnotEvent(TV__sID, href)
  648. {
  649.   TV__sendMsg2Client(TV__IE_CLIENT_HDR + TV__TVP + TV__TVM_UPDATE_ANNOT + TV__TVP + href + TV__TVP + TV__sID);
  650. }
  651.  
  652. function TV__GetAbsOffsetLeft(TV__obj)
  653. {
  654.   if (TV__obj == null)
  655.     return 0;
  656.  
  657.   var TV__iAbsLeft = TV__obj.offsetLeft;
  658.   var TV__objLocal = TV__obj.offsetParent;      // Get the offset parent for this object
  659.  
  660.   if (TV__objLocal == null)
  661.     return TV__iAbsLeft;
  662.  
  663.   // Update the absolute left coordinate for the current object taking into account the parent offset
  664.   while ( (TV__objLocal != null) && (TV__objLocal.tagName != "BODY") )
  665.   {
  666.     TV__iAbsLeft += TV__objLocal.offsetLeft;
  667.     TV__objLocal = TV__objLocal.offsetParent;
  668.   }
  669.   return TV__iAbsLeft;
  670. }
  671.  
  672. function TV__GetAbsOffsetTop(TV__obj)
  673. {
  674.   if (TV__obj == null)
  675.     return 0;
  676.  
  677.   var TV__iAbsTop  = TV__obj.offsetTop;
  678.   var TV__objLocal = TV__obj.offsetParent;
  679.  
  680.   if (TV__objLocal == null)
  681.     return TV__iAbsTop;
  682.  
  683.   // Update the absolute top coordinate for the current object taking into account the parent offset
  684.   while ( (TV__objLocal != null) && (TV__objLocal.tagName != "BODY") )
  685.   {
  686.     TV__iAbsTop += TV__objLocal.offsetTop;
  687.     TV__objLocal = TV__objLocal.offsetParent;
  688.   }
  689.   return TV__iAbsTop;
  690. }
  691.  
  692. /** Raise/Lower the annotation post-it **/
  693. function TV__RaiseAnnot(TV__objAnnot, TV__bRaise, TV__bDrag)
  694. {
  695.   if (TV__objAnnot == null)
  696.     return;
  697.  
  698.   var TV__zIndex;
  699.   
  700.   if (TV__bDrag != null)
  701.   {
  702.     TV__zIndex = (TV__bDrag) ? TV__raisedIndex : TV__topIndex;
  703.     TV__bRaise = true;
  704.   }
  705.   else
  706.   {
  707.     TV__zIndex = (TV__bRaise) ? TV__topIndex : TV__bottomIndex;
  708.   }
  709.  
  710.   TV__chgUIWhenRaiseAnnot(TV__objAnnot, TV__bRaise, TV__zIndex)
  711.   var TV__sAnnotID = TV__getAnnotAttribute(TV__objAnnot, "rootAnnotID");
  712.   TV__DrawLineWhenRaiseAnnot(TV__sAnnotID, TV__bRaise, TV__zIndex)
  713. }
  714.  
  715. function TV__chgUIWhenRaiseAnnot(TV__objAnnot, TV__bRaise, TV__zIndex)
  716. {
  717.   var TV__pad = TV__getAnnotPad(TV__objAnnot);
  718.   
  719.   if (TV__bRaise == true)
  720.   {
  721.     TV__pad.className = TV__objAnnot.getAttribute("AnnotType");
  722.  
  723.     if ( (TV__getAnnotAttribute(TV__objAnnot, "annotType") & TV__PERSONAL_NOTE) == 0)
  724.     {
  725.       TV__objAnnot.all.annotTitle.className   = "annotTitle";
  726.       TV__objAnnot.all.annotAuthor.className  = "annotAuthor";
  727.       TV__objAnnot.all.annotContent.className = "annotContent";
  728.     }
  729.     else
  730.     {
  731.       TV__objAnnot.all.annotTitle.className   = "psnannotTitle";
  732.       TV__objAnnot.all.annotAuthor.className  = "psnannotAuthor";
  733.       TV__objAnnot.all.annotContent.className = "psnannotContent";
  734.     }
  735.   }
  736.   else
  737.   {
  738.     TV__pad.className = TV__inactiveAnnot;
  739.     TV__objAnnot.all.annotTitle.className   = "inactiveannotTitle";
  740.     TV__objAnnot.all.annotAuthor.className  = "inactiveannotAuthor";
  741.     TV__objAnnot.all.annotContent.className = "inactiveannotContent";
  742.   }
  743.  
  744.   TV__objAnnot.style.display = "";
  745.   TV__objAnnot.style.zIndex  = TV__zIndex;
  746. }
  747.  
  748. function TV__DrawLineWhenRaiseAnnot(TV__sAnnotID, TV__bRaise, TV__zIndex)
  749. {
  750.   if (TV__sAnnotID != null)
  751.   {
  752.     var TV__objRefMarker = TV__GetAnnotMarker(TV__sAnnotID);
  753.  
  754.     if (TV__objRefMarker)
  755.     {
  756.       var TV__vertLine = document.all["annotVertHr" + TV__sAnnotID];
  757.       var TV__sVertZIndex = (TV__bRaise) ? "AweActiveVertHrLine" : "AweInactiveVertHrLine";
  758.       
  759.       if (TV__vertLine.style.display == "none")
  760.       {
  761.         TV__vertLine = document.all["annotVertDiv" + TV__sAnnotID];
  762.         TV__sVertZIndex = (TV__bRaise) ? "AweActiveVertDivLine" : "AweInactiveVertDivLine";
  763.       }
  764.       
  765.       var TV__horiLine = document.all["annotHori" + TV__sAnnotID];
  766.       var TV__sHoriZIndex = (TV__bRaise) ? "AweActiveHoriLine" : "AweInactiveHoriLine";
  767.       
  768.       TV__vertLine.className = TV__sVertZIndex;
  769.       TV__horiLine.className = TV__sHoriZIndex;
  770.       TV__vertLine.style.zIndex = TV__zIndex-1;
  771.       TV__horiLine.style.zIndex = TV__zIndex-1;
  772.     }
  773.   }
  774. }
  775.  
  776. ////////////////////// GLOBAL VARIABLE //////////////////////////
  777. var TV__AppDir          = null;
  778. var TV__strAweBaseSrc   = null;
  779. var TV__websiteURL      = null;
  780. var TV__AnnotTypesArray = new Array;
  781.  
  782.  
  783. //////////////////////// OBJECT DEFINITION ///////////////////////
  784.  
  785. function TV__Annotation(TV__annotid, TV__rootid, TV__previd, TV__nextid, TV__url, TV__title, TV__author, TV__content, TV__reference, TV__type, TV__svrType, TV__sGroupid, TV__sGroupName, TV__bMember, TV__bUnattached, TV__selfRate, TV__rating, TV__rateYes, TV__rateNo, TV__nonmbrInPdtGrp)
  786. {
  787.   this.TV__annotid   = TV__annotid;
  788.   this.TV__rootid    = TV__rootid;
  789.   this.TV__previd    = TV__previd;
  790.   this.TV__nextid    = TV__nextid;
  791.   this.TV__url       = TV__url;
  792.   this.TV__title     = TV__replaceAmpersand(TV__title);
  793.   this.TV__author    = TV__author;
  794.   this.TV__content   = TV__replaceAmpersand(TV__content);
  795.   this.TV__reference = TV__reference;
  796.   this.TV__type      = TV__type & (~TV__NOTETYPE_DISBALED);
  797.   this.TV__svrType   = TV__svrType;
  798.   this.TV__sGroupid  = TV__sGroupid;
  799.   this.TV__sGroupName= TV__sGroupName;
  800.   this.TV__bMember   = TV__bMember;
  801.   this.TV__unattached= TV__bUnattached; 
  802.  
  803.   this.TV__pageLevel = ( (TV__type & TV__PAGELEVEL_NOTE) == TV__PAGELEVEL_NOTE);
  804.   this.TV__type &= (~TV__PAGELEVEL_NOTE);
  805.  
  806.   this.TV__recommended = ( (TV__type & TV__RECOMMENDED_NOTE) == TV__RECOMMENDED_NOTE);
  807.   this.TV__type &= (~TV__RECOMMENDED_NOTE);
  808.  
  809.   this.TV__selfRate  = TV__selfRate;
  810.   this.TV__rating    = TV__rating;
  811.   this.TV__rateYes   = TV__rateYes;
  812.   this.TV__rateNo    = TV__rateNo;
  813.   this.TV__disabled  = ((TV__type & TV__NOTETYPE_DISBALED) == TV__NOTETYPE_DISBALED);
  814.   this.TV__nonmbrInPdtGrp = (TV__nonmbrInPdtGrp == "1") ? true : false;
  815.  
  816.   this.TV__sPrevVisible = (this.TV__previd == "") ? "hidden" : "visible";
  817.   this.TV__sNextVisible = (this.TV__nextid == "") ? "hidden" : "visible";
  818.  
  819.   this.TV__title = TV__findReplace(this.TV__title, /</, "<");
  820.   this.TV__title = TV__findReplace(this.TV__title, />/, ">");
  821.  
  822.   this.TV__markup = TV__annotMarkup;
  823.   this.TV__markupForContent = TV__markupForContent;
  824. }
  825.  
  826. function TV__annotMarkup()
  827. {
  828.   var TV__sAnnot = TV__annotTemplate;
  829.  
  830.   TV__sAnnot = TV__findReplace(TV__sAnnot, /%TV__annotid%/,     this.TV__annotid);
  831.   TV__sAnnot = TV__findReplace(TV__sAnnot, /%TV__rootid%/,      this.TV__rootid);
  832.   TV__sAnnot = TV__findReplace(TV__sAnnot, /%TV__annottype%/,   this.TV__type);
  833.   TV__sAnnot = TV__findReplace(TV__sAnnot, /%TV__previd%/,      this.TV__previd);
  834.   TV__sAnnot = TV__findReplace(TV__sAnnot, /%TV__nextid%/,      this.TV__nextid);
  835.  
  836.   if (this.TV__recommended == true)
  837.     TV__sAnnot = TV__findReplace(TV__sAnnot, /%TV__title%/, TV__recomImg + this.TV__title);
  838.   else
  839.     TV__sAnnot = TV__findReplace(TV__sAnnot, /%TV__title%/, this.TV__title);
  840.  
  841.   TV__sAnnot = TV__findReplace(TV__sAnnot, /%TV__author%/,      this.TV__author);
  842.   TV__sAnnot = TV__findReplace(TV__sAnnot, /%TV__content%/,     this.TV__markupForContent());
  843.   TV__sAnnot = TV__findReplace(TV__sAnnot, /%TV__nextVisible%/, this.TV__sNextVisible);
  844.   TV__sAnnot = TV__findReplace(TV__sAnnot, /%TV__prevVisible%/, this.TV__sPrevVisible);
  845.   
  846.   return TV__sAnnot;
  847. }
  848.  
  849. function TV__markupForContent()
  850. {
  851.   var TV__sJoin = "";
  852.  
  853.   if ( (this.TV__svrType != "public") && (this.TV__bMember == false) && (this.TV__nonmbrInPdtGrp == false))
  854.     TV__sJoin = "<span id=" + TV__joingrpspan + this.TV__sGroupid + " style='cursor:hand' onclick=\"TV__JoinPublicGrp('" + this.TV__url + "', '" + this.TV__sGroupid + "')\"><u>JOIN</u></span>";
  855.  
  856.   if (this.TV__sGroupName == '')
  857.     return this.TV__content;
  858.  
  859.   var TV__sGroupName = this.TV__sGroupName;
  860.  
  861.   //
  862.   // not for public:public group and for non-member
  863.   //
  864.   if (this.TV__bMember == true)
  865.     TV__sGroupName = "<a style='color:blue' name=TV__grptitle href=\"javascript:TV__gotoGroupPage('" + this.TV__sGroupid + "')\">" + this.TV__sGroupName + "</a>";
  866.  
  867.   return "<span id=" + TV__jgrpspan + this.TV__sGroupid + "><font color=blue>Group: <span id=TV__grptitle>"+ TV__sGroupName + "</span> " + TV__sJoin + "</font></span><br><br>" + this.TV__content;
  868. }
  869.  
  870. function TV__AnnotType(TV__id, TV__classname, TV__baseclassname, TV__bsbdrclassname, TV__marker, TV__readMarker, TV__visitMarker, TV__icon, TV__replyTo, TV__mailTo, TV__vote)
  871. {
  872.   this.TV__id          = TV__id;
  873.   this.TV__classname   = TV__classname;
  874.   this.TV__bsclassname = TV__baseclassname;
  875.   this.TV__bsbdrclassname = TV__bsbdrclassname;
  876.   this.TV__marker      = TV__marker;
  877.   this.TV__readMarker  = TV__readMarker;
  878.   this.TV__visitMarker = TV__visitMarker;
  879.   this.TV__icon        = TV__icon;
  880.   this.TV__replyTo     = TV__replyTo;
  881.   this.TV__mailTo      = TV__mailTo;
  882.   this.TV__vote        = TV__vote;
  883. }
  884.  
  885. function AddAnnotType(TV__id, TV__classname, TV__baseclassname, TV__bsbdrclassname, TV__marker, TV__readMarker, TV__visitMarker, TV__icon, TV__bReplyTo, TV__bMailTo, TV__bVote)
  886. {
  887.   TV__AnnotTypesArray[TV__AnnotTypesArray.length] = new TV__AnnotType(TV__id, TV__classname, TV__baseclassname, TV__bsbdrclassname, TV__marker, TV__readMarker, TV__visitMarker, TV__icon, TV__bReplyTo, TV__bMailTo, TV__bVote);
  888. }
  889.  
  890.  
  891. function AnnotMarker(TV__id, TV__refString, TV__author, TV__date, TV__type, TV__index)
  892. {
  893.   this.TV__id         = TV__id;
  894.   this.TV__refString  = TV__refString;
  895.   this.TV__author     = TV__author;
  896.   this.TV__date       = TV__date;
  897.   this.TV__type       = TV__type;
  898.   this.TV__index      = TV__index;
  899. }
  900.  
  901. function TV__GetAnnotTypeAt(TV__id)
  902. {
  903.   for (var i = 0; i < TV__AnnotTypesArray.length; i++)
  904.   {
  905.     if ( (TV__AnnotTypesArray[i]) && (TV__AnnotTypesArray[i].TV__id == TV__id) )
  906.       return TV__AnnotTypesArray[i];
  907.   }
  908.   return null;
  909. }
  910.  
  911. function RemoveAnnotType(TV__id)
  912. {
  913.   for (var i = 0; i < TV__AnnotTypesArray.length; i++)
  914.   {
  915.     if (TV__AnnotTypesArray[i].TV__id == TV__id)
  916.       TV__AnnotTypesArray[i] = null;
  917.   }
  918. }
  919.  
  920. function RemoveAllAnnotTypes()
  921. {
  922.   TV__AnnotTypesArray = new Array;
  923.   return true;
  924. }
  925.  
  926.  
  927.  
  928. ////////////////////////// INITIALIZATION ////////////////////////////
  929. function Initialize(TV__appDir, TV__aweBaseSrc, TV__domain, TV__bMailText)
  930. {
  931.   TV__AppDir        = TV__appDir;
  932.   TV__strAweBaseSrc = TV__aweBaseSrc;
  933.   TV__websiteURL    = TV__domain;
  934.   TV__bShowMailText = (TV__bMailText == '1');
  935.   
  936.   TV__aweUpdateTemplate();
  937.   return true;
  938. }
  939.  
  940. function TV__aweUpdateTemplate()
  941. {
  942.   var TV__reg = /%TV__strAweBaseSrc%/;
  943.   while (TV__reg.test(TV__annotTemplate))
  944.     TV__annotTemplate = TV__annotTemplate.replace(TV__reg, TV__strAweBaseSrc);
  945.  
  946.   TV__reg = /%TV__strWebSite%/;
  947.   while (TV__reg.test(TV__helpVote))
  948.     TV__helpVote = TV__helpVote.replace(TV__reg, TV__websiteURL);
  949.  
  950.   TV__reg = /%TV__AppDir%/;
  951.  
  952.   while (TV__reg.test(TV__annotTemplate))
  953.     TV__annotTemplate = TV__annotTemplate.replace(TV__reg, TV__AppDir);
  954.  
  955.   while (TV__reg.test(TV__star))
  956.     TV__star = TV__star.replace(TV__reg, TV__AppDir);
  957.  
  958.   while (TV__reg.test(TV__starme))
  959.     TV__starme = TV__starme.replace(TV__reg, TV__AppDir);
  960.  
  961.   while (TV__reg.test(TV__trash))
  962.     TV__trash = TV__trash.replace(TV__reg, TV__AppDir);
  963.  
  964.   while (TV__reg.test(TV__trashme))
  965.     TV__trashme = TV__trashme.replace(TV__reg, TV__AppDir);
  966.  
  967.   while (TV__reg.test(TV__recomImg))
  968.     TV__recomImg = TV__recomImg.replace(TV__reg, TV__AppDir);
  969. }
  970.  
  971. function AddNewAnnotation(TV__sURL, TV__sTitle, TV__sAuthor, TV__sContent, TV__sRefString, TV__iAnnotType, TV__sAnnotID, TV__sRootID, TV__sPrevAnnotID, TV__sNextAnnotID, TV__svrType, TV__sGroupid, TV__sGroupName, TV__bMember, TV__bUnattached, TV__bMarkAsRead, TV__selfRate, TV__rating, TV__rateYes, TV__rateNo, TV__nonmbrInPdtGrp)
  972. {
  973.   if (TV__sRootID == "")
  974.     return false;
  975.  
  976.   // The annotation post-it container is not already inserted into the page
  977.   var TV__objAnnot = document.all[TV__annotRootID + TV__sRootID];
  978.   var TV__annote = new TV__Annotation(TV__sAnnotID, TV__sRootID, TV__sPrevAnnotID, TV__sNextAnnotID, TV__sURL, TV__sTitle, TV__sAuthor, TV__sContent, TV__sRefString, TV__iAnnotType, TV__svrType, TV__sGroupid, TV__sGroupName, TV__bMember, TV__bUnattached, TV__selfRate, TV__rating, TV__rateYes, TV__rateNo, TV__nonmbrInPdtGrp);
  979.  
  980.   if (TV__objAnnot == null)
  981.     TV__handleNewAnnot(TV__annote, TV__bMarkAsRead);
  982.   else
  983.     TV__handleExistAnnot(TV__annote, TV__bMarkAsRead);
  984.   return true;
  985. }
  986.  
  987. function TV__handleExistAnnot(TV__annote, TV__bMarkAsRead)
  988. {
  989.   var TV__objAnnotID = document.all[TV__annotRootID + TV__annote.TV__rootid];
  990.   var TV__objAnnot   = TV__setAnnotUI(TV__annote, TV__objAnnotID, false);
  991.  
  992.   TV__setAnnotAttribute(TV__objAnnot, "annotID",     TV__annote.TV__annotid);
  993.   TV__setAnnotAttribute(TV__objAnnot, "prevAnnotID", TV__annote.TV__previd);
  994.   TV__setAnnotAttribute(TV__objAnnot, "nextAnnotID", TV__annote.TV__nextid);
  995.   
  996.   if (TV__annote.TV__recommended == true)
  997.     TV__objAnnot.all.annotTitle.innerHTML  = TV__recomImg + TV__annote.TV__title;
  998.   else
  999.     TV__objAnnot.all.annotTitle.innerHTML  = TV__annote.TV__title;
  1000.  
  1001.   TV__objAnnot.all.annotAuthor.innerHTML = (TV__annote.TV__author == "") ? "" : "by " + TV__annote.TV__author;
  1002.  
  1003.   if (TV__annote.TV__content != "")
  1004.   {
  1005.     var TV__sign = '';
  1006.     
  1007.     if (TV__objAnnot.all.annotMailHandle.disable == 0) 
  1008.       TV__sign = TV__findReplace(TV__signature, /%TV__rootid%/, TV__annote.TV__rootid);
  1009.  
  1010.     if (TV__objAnnot.all.annotVoteHandle.disable == false) 
  1011.     {
  1012.       if (TV__sign == "")
  1013.         TV__sign = "<br><br><hr noshade style='border:0; color:lightgrey'>";
  1014.       else
  1015.         TV__sign += "<br>";
  1016.  
  1017.       TV__sign += TV__helpVote;
  1018.     }
  1019.  
  1020.     var TV__content = TV__annote.TV__markupForContent() + TV__sign;
  1021.     TV__objAnnot.all.annotContent.innerHTML = TV__content;
  1022.   }
  1023.   else
  1024.   {
  1025.     TV__objAnnot.all.annotContent.innerHTML = "";
  1026.   }
  1027.  
  1028.   TV__objAnnot.all.annotNextHandle.style.visibility = TV__annote.TV__sNextVisible;
  1029.   TV__objAnnot.all.annotPrevHandle.style.visibility = TV__annote.TV__sPrevVisible;
  1030.  
  1031.   TV__updateVotingImg(TV__annote.TV__selfRate, TV__annote.TV__rating, TV__annote.TV__rateYes, TV__annote.TV__rateNo, TV__objAnnot);
  1032.   
  1033.   var TV__objRefText = document.all[TV__refStrEnd + TV__annote.TV__rootid];
  1034.  
  1035.   if (TV__objRefText != null)
  1036.   {
  1037.     var TV__objMarker = TV__GetNonAggMarker(TV__annote.TV__rootid);
  1038.  
  1039.     if (TV__objRefText)
  1040.     {
  1041.       var TV__iAbsLeft = TV__GetAbsOffsetLeft(TV__objMarker);
  1042.       var TV__iAbsTop  = TV__GetAbsOffsetTop(TV__objMarker);
  1043.       var TV__iLeft    = TV__objAnnot.offsetLeft;
  1044.       var TV__iTop     = TV__objAnnot.offsetTop;
  1045.       TV__DrawLine(TV__annote.TV__rootid, TV__iAbsLeft, TV__iAbsTop, TV__iLeft, TV__iTop, TV__objMarker, true);
  1046.     }
  1047.   }
  1048.  
  1049.   var TV__markerStatus = (TV__bMarkAsRead == true) ? "read" : "visit";
  1050.   TV__ChangeNoteMark(TV__objAnnot, TV__annote, TV__markerStatus);
  1051.  
  1052.   TV__RaiseAnnot(TV__objAnnot, true);
  1053.   TV__highlightAssocRefText(TV__annote.TV__rootid, true);
  1054. }
  1055.  
  1056. function TV__updateVotingImg(TV__selfRate, TV__rating, TV__rateYes, TV__rateNo, TV__objAnnot)
  1057. {
  1058.   var TV__vMarkup = TV__getVotingMarkup(TV__selfRate, TV__rateYes, TV__rateNo);
  1059.   var TV__voteImg = TV__objAnnot.all.voteStatus;
  1060.  
  1061.   if (TV__voteImg != null)
  1062.   {
  1063.     disableVoteBtn(TV__selfRate, TV__objAnnot);
  1064.  
  1065.     TV__voteImg.innerHTML = TV__vMarkup;
  1066.   }
  1067. }
  1068.  
  1069. function disableVoteBtn(TV__selfRate, TV__objAnnot)
  1070. {
  1071.   var TV__bDisabled = ( (TV__selfRate == 1) || (TV__selfRate == -1) )
  1072.   var TV__btn = TV__objAnnot.all.annotVoteHandle;
  1073.  
  1074.   if (TV__btn.disable == false)
  1075.   {
  1076.     if (TV__bDisabled == true)
  1077.     {
  1078.       var TV__disableBtn = TV__btn.getAttribute("dis");
  1079.       TV__btn.setAttribute("disable", 1);
  1080.       TV__btn.src = TV__disableBtn;
  1081.       TV__btn.style.cursor = "auto"; 
  1082.     }
  1083.     else
  1084.     {
  1085.       var TV__Btn = TV__btn.getAttribute("enb");
  1086.       TV__btn.setAttribute("disable", 0);
  1087.       TV__btn.src = TV__Btn;
  1088.       TV__btn.style.cursor = "hand";
  1089.     }
  1090.   }
  1091. }
  1092.  
  1093. // turn marker to grey after note shown 
  1094. function TV__ChangeNoteMark(TV__objAnnot, TV__annote, TV__status)
  1095. {
  1096.   if (TV__bAggregated == true)
  1097.     return;
  1098.  
  1099.   var TV__bSet = TV__getAnnotAttribute(TV__objAnnot, 'markerStatus');
  1100.  
  1101.   if (TV__bSet != TV__status)
  1102.   {
  1103.     var TV__objType = TV__GetAnnotTypeAt(TV__annote.TV__type);
  1104.     var TV__marker = TV__GetAnnotMarker(TV__annote.TV__rootid);
  1105.  
  1106.     if ( (TV__objType != null) && (TV__marker != null) )
  1107.     {
  1108.       TV__src = (TV__status == "read") ? TV__objType.TV__readMarker : TV__objType.TV__visitMarker;
  1109.       TV__marker.src = TV__src;
  1110.     }
  1111.  
  1112.     TV__setAnnotAttribute(TV__objAnnot, 'markerStatus', TV__status);
  1113.   }
  1114. }
  1115.  
  1116. function TV__handleNewAnnot(TV__annot, TV__bMarkAsRead)
  1117. {
  1118.   document.body.insertAdjacentHTML("afterBegin", TV__annot.TV__markup());
  1119.   var TV__objAnnotID = document.all[TV__annotRootID + TV__annot.TV__rootid];
  1120.  
  1121.   if (TV__objAnnotID != null)
  1122.   {
  1123.     var TV__objAnnot = TV__setAnnotUI(TV__annot, TV__objAnnotID, true);
  1124.     TV__chgClassname4ItemsInPsnNote(TV__annot, TV__objAnnotID);
  1125.     TV__AttachAnnot2Ref(TV__objAnnot, TV__annot.TV__pageLevel);
  1126.     TV__highlightAssocRefText(TV__annot.TV__rootid, true);
  1127.     TV__RaiseAnnot(TV__objAnnot, true);
  1128.  
  1129.     var TV__markerStatus = (TV__bMarkAsRead == true) ? "read" : "visit";
  1130.     TV__ChangeNoteMark(TV__objAnnot, TV__annot, TV__markerStatus);
  1131.     TV__RedrawLinesForAnnot(TV__objAnnot);
  1132.     TV__objFocus = TV__objAnnot;
  1133.   }
  1134. }
  1135.  
  1136. function TV__chgClassname4ItemsInPsnNote(TV__annot, TV__objAnnotID)
  1137. {
  1138.   if ((TV__annot.TV__type & TV__PERSONAL_NOTE) == TV__PERSONAL_NOTE) // rememeber note maybe unattached
  1139.   {
  1140.     TV__objAnnotID.all.annotTitle.className   = "psnannotTitle";
  1141.     TV__objAnnotID.all.annotAuthor.className  = "psnannotAuthor";
  1142.     TV__objAnnotID.all.annotContent.className = "psnannotContent";
  1143.   }
  1144. }
  1145.  
  1146. // this function set the look of notes and return the note object ptr
  1147. function TV__setAnnotUI(TV__annot, TV__objAnnotID, bAddVoteStatus)
  1148. {
  1149.   var TV__objAnnot = TV__objAnnotID.parentElement;
  1150.  
  1151.   if (bAddVoteStatus == true)
  1152.     TV__updateVotingImg(TV__annot.TV__selfRate, TV__annot.TV__rating, TV__annot.TV__rateYes, TV__annot.TV__rateNo, TV__objAnnot);
  1153.  
  1154.   var TV__arSettings = TV__getAnnotUISettings(TV__annot);
  1155.  
  1156.   if (TV__objAnnot.className != TV__arSettings["TV__bsbdrclassname"])
  1157.     TV__objAnnot.className  = TV__arSettings["TV__bsbdrclassname"];
  1158.  
  1159.   //TV__objAnnot.className  = TV__arSettings["TV__bsbdrclassname"];
  1160.   TV__objAnnot.all.awedogearbase.className = TV__arSettings["TV__bsclassname"];
  1161.  
  1162.   var TV__pad = TV__getAnnotPad(TV__objAnnot);
  1163.  
  1164.   if (TV__pad.className != TV__arSettings["TV__classname"])
  1165.     TV__pad.className = TV__arSettings["TV__classname"];
  1166.   
  1167.   //TV__pad.className = TV__arSettings["TV__classname"];
  1168.   TV__objAnnot.setAttribute("AnnotType", TV__arSettings["TV__classname"]);
  1169.  
  1170.   TV__disableButton(TV__objAnnot.all.annotReplyHandle, TV__annot.TV__disabled || TV__annot.TV__nonmbrInPdtGrp || (TV__arSettings["TV__replyTo"] == 0));
  1171.   TV__disableButton(TV__objAnnot.all.annotMailHandle,  TV__annot.TV__disabled || (TV__arSettings["TV__mailTo"] == 0));
  1172.   TV__disableButton(TV__objAnnot.all.annotVoteHandle,  TV__annot.TV__disabled || TV__annot.TV__nonmbrInPdtGrp || (TV__arSettings["TV__vote"] == 0) || (TV__annot.TV__selfRate != 0) );
  1173.  
  1174.   if (TV__annot.TV__disabled == true)
  1175.   {
  1176.     TV__objAnnot.all.annotMailTxt.style.display = "none";
  1177.   }
  1178.   else
  1179.   {
  1180.     TV__objAnnot.all.annotMailTxt.style.display = (TV__bShowMailText && (TV__arSettings["TV__vote"] == true))  ? "" : "none";
  1181.   }
  1182.  
  1183.   if (TV__arSettings["TV__snapTo"] == false)
  1184.   {
  1185.     var TV__snapTo = TV__objAnnot.all.annotSnapTo;
  1186.     if (TV__snapTo != null)
  1187.       TV__snapTo.outerHTML = "";
  1188.   }
  1189.  
  1190.   var TV__voteImg = TV__objAnnot.all.voteStatus;
  1191.  
  1192.   if (TV__voteImg != null)
  1193.     TV__voteImg.style.visibility = (TV__arSettings["TV__vote"] == false) ? "hidden" : "visible";
  1194.  
  1195.   TV__objAnnotID.all.annotIcon.src = TV__arSettings["TV__icon"];
  1196.   return TV__objAnnot;
  1197. }
  1198.  
  1199. function TV__disableButton(TV__btn, TV__disable)
  1200. {
  1201.   if (TV__disable == true)
  1202.   {
  1203.     TV__btn.disable      = 1;
  1204.     TV__btn.src          = TV__btn.dis;
  1205.     TV__btn.style.cursor = "auto";
  1206.   }
  1207.   else
  1208.   {
  1209.     TV__btn.disable      = 0;
  1210.     TV__btn.src          = TV__btn.enb;
  1211.     TV__btn.style.cursor = "hand";
  1212.   }
  1213. }
  1214.  
  1215. /** classname of note, get note icon, color of annotation **/
  1216. function TV__getAnnotUISettings(TV__annot)
  1217. {
  1218.   var TV__arSettings = new Array();
  1219.  
  1220.   var TV__classname_objType    = null;
  1221.   var TV__othersetting_objType = TV__GetAnnotTypeAt(TV__annot.TV__type);
  1222.  
  1223.   // handle unattached note
  1224.   if (TV__annot.TV__unattached == true)
  1225.   {
  1226.     TV__classname_objType = TV__GetAnnotTypeAt(TV__UNATTACHED_NOTE);
  1227.     TV__arSettings["TV__snapTo"] = false;
  1228.   }
  1229.   else if (TV__annot.TV__pageLevel == true)
  1230.   {
  1231.     TV__classname_objType = TV__GetAnnotTypeAt(TV__PAGELEVEL_NOTE);
  1232.     TV__arSettings["TV__snapTo"] = false;
  1233.   }
  1234.   else if (TV__annot.TV__recommended == true)
  1235.   {
  1236.     TV__classname_objType = TV__GetAnnotTypeAt(TV__RECOMMENDED_NOTE);
  1237.     TV__arSettings["TV__snapTo"] = true;
  1238.   }
  1239.   else
  1240.   {
  1241.     TV__classname_objType =  TV__othersetting_objType;
  1242.     TV__arSettings["TV__snapTo"] = true;
  1243.   }
  1244.  
  1245.   if (TV__othersetting_objType == null)
  1246.     TV__othersetting_objType = TV__GetAnnotTypeAt(TV__DEFAULT_NOTETYPE);
  1247.   
  1248.   if (TV__classname_objType == null)
  1249.     TV__classname_objType = TV__GetAnnotTypeAt(TV__DEFAULT_NOTETYPE);
  1250.  
  1251.   if ( (TV__classname_objType != null) && (TV__othersetting_objType != null))
  1252.   {
  1253.     TV__arSettings["TV__bsclassname"] = TV__classname_objType.TV__bsclassname;
  1254.     TV__arSettings["TV__bsbdrclassname"] = TV__classname_objType.TV__bsbdrclassname;
  1255.     TV__arSettings["TV__classname"]   = TV__classname_objType.TV__classname;
  1256.     TV__arSettings["TV__replyTo"]     = TV__othersetting_objType.TV__replyTo;
  1257.     TV__arSettings["TV__mailTo"]      = TV__othersetting_objType.TV__mailTo;
  1258.     TV__arSettings["TV__vote"]        = TV__othersetting_objType.TV__vote;
  1259.     TV__arSettings["TV__icon"]        = TV__othersetting_objType.TV__icon;
  1260.   }
  1261.   return TV__arSettings;
  1262. }
  1263.  
  1264. /** Activate the annotation **/
  1265. function TurnOnAnnotation(TV__annotid)
  1266. {
  1267.   var TV__Annot = TV__getAnnotElement(TV__annotid);
  1268.  
  1269.   if (TV__Annot == null)
  1270.     return false;
  1271.  
  1272.   TV__objFocus = TV__Annot;
  1273.  
  1274.   var TV__sRootID    = TV__getAnnotAttribute(TV__Annot, "rootAnnotID");
  1275.   var TV__objRefSpan = document.all[TV__refStrStart + TV__sRootID];
  1276.  
  1277.   if  ( (TV__objRefSpan != null) && (TV__objRefSpan.style.display != "") )
  1278.   {
  1279.     TV__objRefSpan.style.display = "";
  1280.     TV__objRefSpan = document.all[TV__refStrEnd + TV__sRootID];
  1281.  
  1282.     if (TV__objRefSpan != null)
  1283.       TV__objRefSpan.style.display = "";
  1284.  
  1285.     TV__highlightAssocRefText(TV__sRootID, true);
  1286.   }
  1287.  
  1288.   TV__RaiseAnnot(TV__Annot, true);
  1289.   return true;
  1290. }
  1291.  
  1292.  
  1293. /** Deactivate the annotation **/
  1294. function DeactivateAnnotation(TV__annotid)
  1295. {
  1296.   var TV__Annot = TV__getAnnotElement(TV__annotid);
  1297.  
  1298.   if (TV__Annot == null)
  1299.     return false;
  1300.  
  1301.   var TV__sRootID    = TV__getAnnotAttribute(TV__Annot, "rootAnnotID");
  1302.   var TV__objRefSpan = document.all[TV__refStrStart + TV__sRootID];
  1303.  
  1304.   if ( (TV__objRefSpan != null) && (TV__objRefSpan.style.display == "") )
  1305.   {
  1306.     TV__objRefSpan.style.display = "none";
  1307.     TV__objRefSpan = document.all[TV__refStrEnd + TV__sRootID];
  1308.  
  1309.     if (TV__objRefSpan != null)
  1310.       TV__objRefSpan.style.display = "none";
  1311.   }
  1312.  
  1313.   TV__objFocus = null
  1314.   TV__RaiseAnnot(TV__Annot, false);
  1315.   TV__highlightAssocRefText(TV__sRootID, false);
  1316.   return true;
  1317. }
  1318.  
  1319. // Highlight/Unhighlight the reference text associated with the root annotation
  1320. function TV__highlightAssocRefText(TV__sRootID, TV__bHighlight)
  1321. {
  1322.   var TV__obj = document.all[TV__HighlightPrefix + TV__sRootID];
  1323.   if (TV__obj == null)
  1324.     return;
  1325.  
  1326.   if (TV__obj.length == null)  // one note
  1327.   {
  1328.      if (TV__bHighlight == true)
  1329.        TV__highlightRefString(TV__obj);
  1330.      else
  1331.        TV__unhighlightRefString(TV__obj);
  1332.  
  1333.     return;
  1334.   }
  1335.  
  1336.   for (var i = 0; i < TV__obj.length; i++)
  1337.   {
  1338.    if (TV__bHighlight == true)
  1339.      TV__highlightRefString(TV__obj[i]);
  1340.    else
  1341.      TV__unhighlightRefString(TV__obj[i]);
  1342.   }
  1343. }
  1344.  
  1345. function TV__highlightRefString(TV__obj)
  1346. {
  1347.   TV__backupStyleAttrib(TV__obj, "origColor",   TV__obj.style.color);
  1348.   TV__backupStyleAttrib(TV__obj, "origBgColor", TV__obj.style.backgroundColor);
  1349.  
  1350.   TV__obj.style.color = TV__HighlightTextColor;
  1351.   TV__obj.style.backgroundColor = TV__HighlightBgColor;
  1352. }
  1353.  
  1354. function TV__backupStyleAttrib(TV__obj, TV__attrib, TV__style)
  1355. {
  1356.   if (TV__obj.getAttribute(TV__attrib) == null)
  1357.   {
  1358.     if (TV__style == null)
  1359.       TV__style = "";
  1360.  
  1361.     TV__obj.setAttribute(TV__attrib, TV__style);
  1362.   }
  1363. }
  1364.  
  1365. function TV__unhighlightRefString(TV__obj)
  1366. {
  1367.   var TV__origColor = TV__obj.getAttribute("origColor");
  1368.   TV__obj.style.color = TV__origColor;
  1369.  
  1370.   var TV__origBgColor = TV__obj.getAttribute("origBgColor");
  1371.   TV__obj.style.backgroundColor = TV__origBgColor;
  1372. }
  1373.  
  1374. /** Scroll the html page to the location of the reference text associated with the annotation 
  1375.  *
  1376.  * return true if successful, return false otherwises
  1377. **/
  1378. function ScrollIntoView(TV__annotid)
  1379. {
  1380.   var TV__Annot = TV__getAnnotElement(TV__annotid);
  1381.  
  1382.   if (TV__Annot == null)
  1383.     return false;
  1384.  
  1385.   return TV__ScrollAnnotIntoView(TV__Annot);
  1386. }
  1387.  
  1388. function TV__ScrollAnnotIntoView(TV__objAnnot)
  1389. {
  1390.   if (TV__objAnnot != null)
  1391.   {
  1392.     if (!TV__inClient(TV__objAnnot))
  1393.       TV__objAnnot.scrollIntoView(false);
  1394.  
  1395.     return true;
  1396.   }
  1397.   return false;;
  1398. }
  1399.  
  1400.  
  1401. /** Hide the annotation **/
  1402. function TV__HideAnnot(TV__objAnnot)
  1403. {
  1404.   TV__objAnnot.style.display = "none";
  1405. }
  1406.  
  1407. function MarkAnnotatedHref(TV__strHref)
  1408. {
  1409.   if (TV__strHref == "")
  1410.     return;
  1411.   
  1412.   var TV__obj = document.all[TV__strHref];
  1413.   if (TV__obj == null)
  1414.     return;
  1415.  
  1416.   var TV__colLinks = document.links;
  1417.  
  1418.   if (TV__colLinks == null)
  1419.     return;
  1420.  
  1421.   for (var i = 0; i < TV__colLinks.length; i++)
  1422.   {
  1423.     if (TV__colLinks[i].href == TV__strHref)
  1424.       TV__colLinks[i].insertAdjacentHTML("AfterEnd", "<sup id='AweAnnotatedMarker'><img src='" + TV__strAweBaseSrc + "/htm/images/annlink.gif'></sup>");
  1425.   }
  1426. }
  1427.  
  1428.  
  1429. function UpdateVoteOnNote(TV__sAnnotID, TV__selfRate, TV__rating, TV__rateYes, TV__rateNo)
  1430. {
  1431.   if (TV__sAnnotID == "")
  1432.     return false;
  1433.  
  1434.   var TV__objAnnot = TV__getAnnotElement(TV__sAnnotID);
  1435.  
  1436.   if (TV__objAnnot != null)
  1437.   {
  1438.     TV__updateVotingImg(TV__selfRate, TV__rating, TV__rateYes, TV__rateNo, TV__objAnnot);
  1439.     return true;
  1440.   }
  1441.  
  1442.   return false;
  1443. }
  1444.  
  1445. function CloseAnnotation(TV__sAnnotID)
  1446. {
  1447.   if (TV__sAnnotID == "")
  1448.     return false;
  1449.  
  1450.   var TV__objAnnot = TV__getAnnotElement(TV__sAnnotID);
  1451.  
  1452.   if (TV__objAnnot != null)
  1453.   {
  1454.     TV__CloseNote(TV__objAnnot);
  1455.     return true;
  1456.   }
  1457.   return false; 
  1458. }
  1459.  
  1460. function TV__CloseNote(TV__objAnnot)
  1461. {
  1462.   var TV__sRootID = TV__getAnnotAttribute(TV__objAnnot, "rootAnnotID");
  1463.  
  1464.   var TV__objRefSpan = document.all[TV__refStrStart + TV__sRootID];
  1465.   if (TV__objRefSpan != null)
  1466.     TV__objRefSpan.style.display = "none";
  1467.  
  1468.   TV__objRefSpan = document.all[TV__refStrEnd + TV__sRootID];
  1469.   if (TV__objRefSpan != null)
  1470.     TV__objRefSpan.style.display = "none";
  1471.  
  1472.   // UnHighlight the reference text associated with the root annotation
  1473.   TV__highlightAssocRefText(TV__sRootID, false);
  1474.   TV__HideLine(TV__sRootID);
  1475.   TV__HideAnnot(TV__objAnnot);
  1476.   
  1477.   var TV__objDynaMarker = document.all["AweDynaMarker" + TV__sRootID];
  1478.   if (TV__objDynaMarker != null)
  1479.   {
  1480.     TV__objDynaMarker.style.display = "none";
  1481.   }
  1482. }
  1483.  
  1484. function CloseAllNotes()
  1485. {
  1486.   var allNotes = document.all.annot;
  1487.   if (allNotes == null)
  1488.     return false;
  1489.  
  1490.   if (allNotes.length == null)  // one annotation
  1491.      TV__CloseNote(allNotes);
  1492.   else
  1493.   {
  1494.     for (var i = 0; i < allNotes.length; i++)
  1495.       TV__CloseNote(allNotes[i]);
  1496.   }
  1497.  
  1498.   return true;
  1499. }
  1500.  
  1501. function TV__GetAnnotMarker(TV__sRootID)
  1502. {
  1503.   var TV__objMarker = document.all[TV__annotMarkTag + TV__sRootID];
  1504.  
  1505.   if (TV__objMarker == null)
  1506.   {
  1507.     TV__objMarker = TV__aggMarkerArray[TV__sRootID];
  1508.   }
  1509.  
  1510.   return TV__objMarker;
  1511. }
  1512.  
  1513. function TV__GetNonAggMarker(TV__sRootID)
  1514. {
  1515.   var TV__objMarker = document.all[TV__annotMarkTag + TV__sRootID];
  1516.  
  1517.   if (TV__objMarker == null)
  1518.   {
  1519.     TV__objMarker = document.all["AweRefTextStart" + TV__sRootID];
  1520.     if (TV__objMarker != null)
  1521.     {
  1522.       var TV__dynaMarker = document.all["AweDynaMarker" + TV__sRootID];
  1523.       if (TV__dynaMarker == null)
  1524.       {
  1525.         TV__objMarker.insertAdjacentHTML("AfterEnd", "<img id='AweDynaMarker" + TV__sRootID + "' src='" + TV__AppDir + "\\htm\\images\\clear.gif' width=3 border=0 style='border: 1 solid red;'>");
  1526.         TV__objMarker = document.all["AweDynaMarker" + TV__sRootID];
  1527.       }
  1528.       else
  1529.       {
  1530.         TV__objMarker = TV__dynaMarker;
  1531.         TV__objMarker.style.display = "";
  1532.       }
  1533.     }
  1534.   }
  1535.  
  1536.   return TV__objMarker;
  1537. }
  1538.  
  1539. /////////////////// AGGREGRATION OF MARKERS ///////////////////////////
  1540. function InsertAggregMarkers()
  1541. {
  1542.   var TV__arMarkers = document.all[TV__annotAggMarkTag];
  1543.  
  1544.   if (TV__arMarkers != null)
  1545.   {
  1546.     var TV__len = TV__arMarkers.length;
  1547.     if (TV__len == null)
  1548.     {
  1549.       TV__regAggNotesID(TV__arMarkers);
  1550.     }
  1551.     else
  1552.     {
  1553.       for (var i = 0; i < TV__len; i++)
  1554.         TV__regAggNotesID(TV__arMarkers[i]);
  1555.     }
  1556.   }
  1557.   return true;
  1558. }
  1559.  
  1560. function TV__regAggNotesID(TV__marker)
  1561. {
  1562.   var TV__annotids = TV__marker.getAttribute("annotids");
  1563.  
  1564.   if (TV__annotids != null)
  1565.   {
  1566.     var arIDs = TV__annotids.split(",");
  1567.  
  1568.     for (var i = 0; i < arIDs.length; i++)
  1569.     {
  1570.       TV__aggMarkerArray[arIDs[i]] = TV__marker;
  1571.     }
  1572.     TV__bAggregated = true;
  1573.   }
  1574. }
  1575.  
  1576. function showAnnotList(elm, e)
  1577. {
  1578.   var ids = elm.getAttribute("annotids");
  1579.   //TV__sendMsg2Client(TV__IE_CLIENT_HDR + TV__TVP + TV__TVM_SUBMENU_NOTES + TV__TVP + window.location.href + TV__TVP + ids + TV__TVP + e.screenX + TV__TVP + e.screenY);
  1580.   window.external.ShowAnnotMarkersSubMenu(window.location.href, ids, e.screenX, e.screenY);
  1581. }
  1582.  
  1583. /** Locate app specific style sheet for given HTML **/
  1584. function TV__LocateCSS()
  1585. {
  1586.   var TV__css   = document.styleSheets;
  1587.   var TV__intSS = TV__css.length;
  1588.  
  1589.   for (var i = 0; i < TV__intSS; i++)
  1590.   {
  1591.     var TV__rules = TV__css[i].rules;
  1592.     if ( (TV__rules != null) && (TV__rules.length > 0) && (TV__rules[0].selectorText == "#AweStyles") )
  1593.       return TV__css[i];
  1594.   }
  1595.   return null;
  1596. }
  1597.  
  1598. function IsAnnotInserted(TV__sAnnotID)
  1599. {
  1600.   if (TV__GetAnnotMarker(TV__sAnnotID) != null)
  1601.     return true;
  1602.  
  1603.   return false;
  1604. }
  1605.  
  1606. function IsCtlInsertedInFrame()
  1607. {
  1608.   return true;
  1609. }
  1610.  
  1611. /** substitute ampersand */
  1612. function TV__replaceAmpersand(TV__str)
  1613. {
  1614.   var TV__idx = TV__str.indexOf("&", 0);
  1615.   while (TV__idx != -1)
  1616.   {
  1617.     if ( (TV__str.substring(TV__idx, 4) == "&") && (TV__str.substring(TV__idx+4, 1) != ";"))
  1618.     {
  1619.       TV__str = TV__str.substring(0, TV__idx) + "&" + TV__str.substring(TV__idx +4);
  1620.       TV__idx = TV__str.indexOf("&", TV__idx +5);
  1621.     }
  1622.     else
  1623.     {
  1624.       TV__idx = TV__str.indexOf("&", TV__idx +1);
  1625.     }
  1626.   }
  1627.   return TV__str;
  1628. }
  1629.  
  1630.  
  1631. /** check if the selected text is include annotation **/
  1632.  
  1633. function SelTextIncludeAnnot()
  1634. {
  1635.   if (document.selection.type == "Text")
  1636.   {
  1637.     var TV__trFront = document.selection.createRange();
  1638.     var TV__trEnd   = TV__trFront.duplicate();
  1639.     TV__trEnd.collapse(false);
  1640.     TV__trFront.collapse();
  1641.     if (TV__inAnnotDiv(TV__trFront) || TV__inAnnotDiv(TV__trEnd) )
  1642.       return true;
  1643.   }
  1644.   
  1645.   return false;
  1646. }
  1647.  
  1648. function TV__inAnnotDiv(TV__tr)
  1649. {
  1650.   var TV__parent = TV__tr.parentElement();
  1651.  
  1652.   while ((TV__parent != null) && (TV__parent.tagName != 'BODY'))
  1653.   {
  1654.     if (TV__parent.id == 'annot')
  1655.       return true;
  1656.  
  1657.     TV__parent = TV__parent.parentElement;
  1658.   }
  1659.   return false;
  1660. }
  1661.  
  1662.  
  1663. ///////////////////////// new functions /////////////////////
  1664. function TV__getAnnotAttribute(TV__annotObj, TV__attrib)
  1665. {
  1666.   var TV__header = TV__annotObj.all.annotHeader;
  1667.  
  1668.   if (TV__header == null)
  1669.     return null;
  1670.  
  1671.   return TV__header.getAttribute(TV__attrib);
  1672. }
  1673.  
  1674. function TV__setAnnotAttribute(TV__annotObj, TV__attrib, TV__val)
  1675. {
  1676.   var TV__header = TV__annotObj.all.annotHeader;
  1677.  
  1678.   if (TV__header != null)
  1679.     TV__header.setAttribute(TV__attrib, TV__val);
  1680. }
  1681.  
  1682. function TV__getAnnotPad(TV__annotObj)
  1683. {
  1684.   var TV__title = TV__annotObj.all.annotTitle;
  1685.   return TV__title.parentElement;
  1686. }
  1687.  
  1688. function TV__getAnnotPadFromRootID(TV__rootid)
  1689. {
  1690.   var TV__pad = document.all[TV__annotRootID + TV__rootid];
  1691.   if (TV__pad != null)
  1692.     return TV__pad.parentElement;
  1693.  
  1694.   return null;
  1695. }
  1696.  
  1697. function TV__getAnnotTitle(TV__annotObj)
  1698. {
  1699.   var TV__titleObj = TV__annotObj.all.annotTitle;
  1700.   return TV__titleObj.innerHTML;
  1701. }
  1702.  
  1703. function TV__getAnnotElement(TV__annotid)
  1704. {
  1705.   var TV__notes = document.all.annot;
  1706.  
  1707.   if (TV__notes == null)
  1708.     return null;
  1709.  
  1710.   if (TV__notes.length == null)
  1711.   {
  1712.     if (TV__isTheRightNotes(TV__notes, TV__annotid))
  1713.       return TV__notes;
  1714.   }
  1715.   else
  1716.   {
  1717.     for (var i = 0; i < TV__notes.length; i++)
  1718.     {
  1719.       if (TV__isTheRightNotes(TV__notes[i], TV__annotid))
  1720.         return TV__notes[i];
  1721.     }
  1722.   }
  1723.   return null;
  1724. }
  1725.  
  1726. function TV__isTheRightNotes(TV__holder, TV__annotid)
  1727. {
  1728.   var TV__header = TV__holder.all.annotHeader;
  1729.  
  1730.   if (TV__header.getAttribute("annotID") == TV__annotid)
  1731.     return true;
  1732.  
  1733.   return false;
  1734. }
  1735.  
  1736. function GetSelTextRect()
  1737. {
  1738.   if (document.selection.type == "Text")
  1739.   {
  1740.     var TV__trFront = document.selection.createRange();
  1741.     var TV__trEnd   = TV__trFront.duplicate();
  1742.  
  1743.     TV__trFront.collapse();
  1744.     TV__trFront.moveStart("word", 1);
  1745.  
  1746.     TV__trEnd.collapse(false);
  1747.     TV__trEnd.moveEnd("word", -1);
  1748.  
  1749.     var TV__htmlTxt = TV__trFront.htmlText;
  1750.     TV__htmlTxt = TV__ghostFrontTagSelText + TV__htmlTxt;
  1751.     TV__trFront.pasteHTML(TV__htmlTxt);
  1752.     
  1753.     TV__htmlTxt = TV__trEnd.htmlText;
  1754.     TV__htmlTxt += TV__ghostEndTagSelText;
  1755.     TV__trEnd.pasteHTML(TV__htmlTxt);
  1756.  
  1757.     var TV__ghostFront = document.all[TV__ghostFrontIDSelText];
  1758.     var TV__ghostEnd = document.all[TV__ghostEndIDSelText];
  1759.  
  1760.     if ( (TV__ghostFront != null) && (TV__ghostEnd != null) )
  1761.     {
  1762.       TV__ghostFront = TV__getGhostMarker(TV__ghostFront);
  1763.       TV__ghostEnd   = TV__getGhostMarker(TV__ghostEnd);
  1764.  
  1765.       var TV__left   = 0;
  1766.       var TV__top    = 0;
  1767.       var TV__right  = 0;
  1768.       var TV__bottom = 0;
  1769.  
  1770.       if (TV__inClient(TV__ghostFront) && TV__inClient(TV__ghostEnd))
  1771.       {
  1772.         TV__left   = TV__GetAbsOffsetLeft(TV__ghostFront) - document.body.scrollLeft;
  1773.         TV__top    = TV__GetAbsOffsetTop(TV__ghostFront)  - document.body.scrollTop;
  1774.         TV__right  = TV__GetAbsOffsetLeft(TV__ghostEnd)   - document.body.scrollLeft;
  1775.         TV__bottom = TV__GetAbsOffsetTop(TV__ghostEnd)    - document.body.scrollTop;
  1776.       }
  1777.  
  1778.       TV__ghostFront.innerHTML = "";
  1779.       TV__ghostEnd.innerHTML = "";
  1780.       return "" + TV__left + "," + TV__top + "," + TV__right + "," + TV__bottom;
  1781.     }
  1782.   }
  1783.   return "0,0,0,0";
  1784. }
  1785.  
  1786. function TV__getGhostMarker(TV__ghost)
  1787. {
  1788.   if (TV__ghost.length == null)
  1789.     return TV__ghost;
  1790.  
  1791.   for (var i = 0; i < TV__ghost.length; i++)
  1792.   {
  1793.     if (TV__ghost[i].innerHTML == "current")
  1794.       return TV__ghost[i];
  1795.   }
  1796.   return null;
  1797. }
  1798.  
  1799. ////////////////////// HELPER FUNCTION ////////////////////////////
  1800.  
  1801. function TV__findReplace(TV__str, TV__reg, TV__val)
  1802. {
  1803.   while (TV__reg.test(TV__str))
  1804.     TV__str = TV__str.replace(TV__reg, TV__val);
  1805.  
  1806.   return TV__str;
  1807. }
  1808.  
  1809. function TV__noteToolbarMove(btn, src)
  1810. {
  1811.   if (btn.disable == '0')
  1812.     btn.src =src;
  1813. }
  1814.  
  1815. function TV__inClient(TV__obj)
  1816. {
  1817.   var TV__parent = TV__obj.offsetParent;
  1818.   if (TV__parent == null)   // not visible
  1819.     return true;
  1820.  
  1821.   var TV__rClient = TV__getClientRect();
  1822.   var TV__oClient = TV__getObjRect(TV__obj);
  1823.  
  1824.   return TV__oClient.TV__inRect(TV__rClient);
  1825. }
  1826.  
  1827. function TV__getClientRect()
  1828. {
  1829.   var TV__left   = document.body.scrollLeft;
  1830.   var TV__right  = TV__left + document.body.clientWidth;
  1831.   var TV__top    = document.body.scrollTop;
  1832.   var TV__bottom = TV__top  + document.body.clientHeight;
  1833.   
  1834.   return new TV__rect(TV__left, TV__top, TV__right, TV__bottom);
  1835. }
  1836.  
  1837. function TV__getObjRect(TV__obj)
  1838. {
  1839.   var TV__left   = TV__obj.offsetLeft
  1840.   var TV__top    = TV__obj.offsetTop;
  1841.   var TV__parent = TV__obj.offsetParent;
  1842.  
  1843.   while (TV__parent != null)
  1844.   {
  1845.     TV__left += TV__parent.offsetLeft;
  1846.     TV__top  += TV__parent.offsetTop;
  1847.     TV__parent = TV__parent.offsetParent;
  1848.   }
  1849.  
  1850.   var TV__right  = TV__left + TV__obj.offsetWidth;
  1851.   var TV__bottom = TV__top + TV__obj.style.pixelHeight;
  1852.   return new TV__rect(TV__left, TV__top, TV__right, TV__bottom);
  1853. }
  1854.  
  1855.  
  1856. /** check of html object is in client **/
  1857. function TV__rect(TV__left, TV__top, TV__right, TV__bottom)
  1858. {
  1859.   this.TV__left   = TV__left;
  1860.   this.TV__top    = TV__top;
  1861.   this.TV__right  = TV__right;
  1862.   this.TV__bottom = TV__bottom;
  1863.   this.TV__width  = TV__rectWidth;
  1864.   this.TV__height = TV__rectHeight;
  1865.  
  1866.   this.TV__inRect = TV__rect_inRect;
  1867. }
  1868.  
  1869. /** check if this rect is in a given rect**/
  1870. function TV__rect_inRect(TV__r)
  1871. {
  1872.   if (TV__ptInRect(this.TV__left, this.TV__top, TV__r) && TV__ptInRect(this.TV__right, this.TV__bottom, TV__r))
  1873.     return true;
  1874.   else
  1875.     return false;
  1876. }
  1877.  
  1878. function TV__ptInRect(TV__x, TV__y, TV__r)
  1879. {
  1880.   if (TV__x >= TV__r.TV__left && TV__x <= TV__r.TV__right && TV__y >= TV__r.TV__top && TV__y <= TV__r.TV__bottom)
  1881.     return true;
  1882.   else
  1883.     return false;
  1884. }
  1885.  
  1886. function TV__rectWidth()
  1887. {
  1888.   return this.TV__right - this.TV__left;
  1889. }
  1890.  
  1891. function TV__rectHeight()
  1892. {
  1893.   return this.TV__bottom - this.TV__top;
  1894. }
  1895.  
  1896. function TV__PosToRHSBottom(TV__obj, xOffset, yOffset)
  1897. {
  1898.   var TV__rClient = TV__getClientRect();
  1899.   var TV__oClient = TV__getObjRect(TV__obj);
  1900.  
  1901.   TV__obj.style.pixelLeft = TV__rClient.TV__right  - TV__oClient.TV__width() -10 - xOffset;
  1902.   TV__obj.style.pixelTop  = TV__rClient.TV__top + 10 + yOffset;
  1903. }
  1904.  
  1905. function TV__keydownImg()
  1906. {
  1907.   TV__keyDownImg = event.ctrlKey;
  1908. }
  1909.  
  1910. function TV__keyupImg()
  1911. {
  1912.   TV__keyDownImg = false;;
  1913. }
  1914.  
  1915. function TV__keypressImg()
  1916. {
  1917.   if (TV__keyDownImg == true)
  1918.   {
  1919.     if (event.keyCode == 10)
  1920.       TV__toggleAnnotIDToContent();
  1921.   }
  1922. }
  1923.  
  1924. function TV__toggleAnnotIDToContent()
  1925. {
  1926.   var TV__IDTag = 'ANNOTID:';
  1927.   var TV__BRBR  = '<BR><BR>';
  1928.     
  1929.   var TV__el = event.srcElement;
  1930.   var TV__pad = TV__el.parentElement.parentElement;
  1931.  
  1932.   if ( (TV__pad != null) && ( (TV__getAnnotAttribute(TV__pad, "annotType") & TV__PERSONAL_NOTE) == 0) )
  1933.   {
  1934.     var TV__contentObj = TV__pad.all.annotContent;   // content element
  1935.     var TV__content    = TV__contentObj.innerHTML;   // content string
  1936.  
  1937.     if (TV__content.substring(0, TV__IDTag.length) == TV__IDTag)  //check if id is already inserted to content
  1938.     {
  1939.       // strip it
  1940.       var TV__idx = TV__content.indexOf(TV__BRBR);
  1941.       if (TV__idx > -1)
  1942.         TV__contentObj.innerHTML  = TV__content.substring(TV__idx + TV__BRBR.length);
  1943.     }
  1944.     else
  1945.     {
  1946.       TV__contentObj.innerHTML = TV__IDTag + TV__getAnnotAttribute(TV__pad, "annotID") + TV__BRBR + TV__content;
  1947.     }
  1948.   }
  1949. }
  1950.  
  1951.  
  1952. /////////////////// VOTING (PEER RATING ////////////////////////////
  1953.  
  1954. function TV__ShowVoteDiv(TV__pad)
  1955. {
  1956.   var TV__vote = TV__pad.all.vote;
  1957.  
  1958.   if (TV__vote != null)
  1959.     TV__vote.style.display   = 'block';
  1960. }
  1961.  
  1962. function TV__voteNote(TV__rootid, TV__weight)
  1963. {
  1964.   var TV__annotPad = TV__getAnnotPadFromRootID(TV__rootid);
  1965.  
  1966.   if (TV__annotPad != null)
  1967.   {
  1968.     TV__AnnotID = TV__getAnnotAttribute(TV__annotPad, "annotID");
  1969.     TV__sendMsg2Client(TV__IE_CLIENT_HDR + TV__TVP + TV__TVM_VOTE + TV__TVP + TV__AnnotID + TV__TVP + TV__weight);
  1970.   }
  1971.   hideVoteDiv(TV__rootid);
  1972. }
  1973.  
  1974. function hideVoteDiv(TV__rootid)
  1975. {
  1976.   var TV__annotPad = TV__getAnnotPadFromRootID(TV__rootid);
  1977.  
  1978.   if (TV__annotPad != null)
  1979.   {
  1980.     var TV__vote = TV__annotPad.all.vote;
  1981.  
  1982.     // hidden and then visible setting is necessary cos on slow pc
  1983.     // the image that connect voting panel to button has repaint problem
  1984.     if (TV__vote != null)
  1985.     {
  1986.       TV__vote.style.visibility = "hidden";
  1987.       TV__vote.style.display    = "none";
  1988.       TV__vote.style.visibility = "visible";
  1989.     }
  1990.   }
  1991. }
  1992.  
  1993.  
  1994. function TV__VoteMouseOver(TV__obj)
  1995. {
  1996.   TV__obj.style.backgroundColor = 'darkgray';
  1997. }
  1998.  
  1999. function TV__VoteMouseOut(TV__obj)
  2000. {
  2001.   TV__obj.style.backgroundColor = 'transparent';
  2002. }
  2003.  
  2004. function TV__JoinPublicGrp(TV__URL, TV__GroupID)
  2005. {
  2006.   TV__sendMsg2Client(TV__IE_CLIENT_HDR + TV__TVP + TV__TVM_JOIN_PUBLIC_GRP + TV__TVP + TV__URL + TV__TVP + TV__GroupID);
  2007. }
  2008.  
  2009.  
  2010. function ClearJoinGrpSpan(TV__grpid)
  2011. {
  2012.   var TV__obj = document.all[TV__joingrpspan + TV__grpid];
  2013.  
  2014.   if (TV__obj != null)
  2015.   {
  2016.     if (TV__obj.length == null)  // one link
  2017.       TV__obj.outerHTML = "";
  2018.     else
  2019.     {
  2020.       var TV__nSize = TV__obj.length;
  2021.       for (var i = 0; i < TV__nSize; i++)
  2022.         TV__obj[0].outerHTML = "";
  2023.     }
  2024.   }
  2025. }
  2026.  
  2027. function ConnectGroupLink(TV__grpid)
  2028. {
  2029.   var TV__obj = document.all[TV__jgrpspan + TV__grpid];
  2030.  
  2031.   if (TV__obj != null)
  2032.   {
  2033.     if (TV__obj.length == null)  // one link
  2034.     {
  2035.       TV__SetLinkToEachGroupSpan(TV__obj, TV__grpid);
  2036.     }
  2037.     else
  2038.     {
  2039.       for (var i = 0; i < TV__obj.length; i++)
  2040.         TV__SetLinkToEachGroupSpan(TV__obj[i], TV__grpid);
  2041.     }
  2042.   }
  2043. }
  2044.  
  2045. function TV__SetLinkToEachGroupSpan(TV__span, TV__grpid)
  2046. {
  2047.   var TV__grptitle = TV__span.all.TV__grptitle;
  2048.  
  2049.   if (TV__grptitle != null)
  2050.     TV__grptitle.innerHTML = "<a href=\"javascript:TV__gotoGroupPage('" + TV__grpid + "')\">" + TV__grptitle.innerHTML + "</a>";
  2051. }
  2052.  
  2053. function TV__gotoGroupPage(TV__grpid)
  2054. {
  2055.   document.location = TV__websiteURL + TV__grpurl + TV__grpid;
  2056. }
  2057.  
  2058. function OpenWindow(TV__URL)
  2059. {
  2060.   TV__Win = window.open(TV__URL, "OpenGroup", "width=500,height=500,toolbar=0,scrollbars=1,resizable=1,status=1");
  2061. }
  2062.  
  2063. //------------ fix font style sheet definition problem ----------------------
  2064.  
  2065. function FixFontCSSProblem()
  2066. {
  2067.   if (TV__isFontDefined() == false)
  2068.     return;
  2069.  
  2070.   var TV__allFonts = document.all.tags("FONT");
  2071.   if (TV__allFonts == null)
  2072.     return;
  2073.  
  2074.   var TV__nSize = TV__allFonts.length;
  2075.   if (TV__nSize == null)
  2076.   {
  2077.     if (TV__allFonts.id.substring(0, TV__lenPrefix) == TV__HighlightPrefix)
  2078.       TV__inheritParentStyle(TV__allFonts);
  2079.  
  2080.     return;
  2081.   }
  2082.  
  2083.  
  2084.   var TV__lenPrefix = TV__HighlightPrefix.length;
  2085.   for (var i = 0; i < TV__nSize; i++)
  2086.   {
  2087.     var TV__fontTag = TV__allFonts[i];
  2088.  
  2089.     if ( (TV__fontTag != null) && (TV__fontTag.id.substring(0, TV__lenPrefix) == TV__HighlightPrefix))
  2090.       TV__inheritParentStyle(TV__fontTag);
  2091.   }
  2092. }
  2093.  
  2094. function TV__isFontDefined()
  2095. {
  2096.   var TV__css   = document.styleSheets;
  2097.   var TV__nSize = TV__css.length;
  2098.  
  2099.   for (var i = 0; i < TV__nSize; i++)
  2100.   {
  2101.     if (getFontDefined(TV__css[i]) == true)
  2102.       return true;
  2103.   }
  2104.   return false;
  2105. }
  2106.  
  2107. function getFontDefined(TV__css)
  2108. {
  2109.   var TV__nSize = TV__css.rules.length;
  2110.  
  2111.   for (var i = 0; i < TV__nSize; i++)
  2112.   {
  2113.     var TV__rule = TV__css.rules[i].selectorText.toLowerCase();
  2114.     if (TV__rule == "font")
  2115.       return true;
  2116.   }
  2117.   return false;
  2118. }
  2119.  
  2120. function TV__inheritParentStyle(TV__fontTag)
  2121. {
  2122.   var TV__parentTag = TV__fontTag.parentElement;
  2123.  
  2124.   if (TV__parentTag != null)
  2125.   {
  2126.     var TV__parentheaderText = TV__getMarkupHeader(TV__parentTag);
  2127.     
  2128.     TV__newheader = TV__changeTagName(TV__parentheaderText, "FONT");  // parent tag may be any other tagname
  2129.  
  2130.     TV__newheader = TV__stripAttribute(TV__newheader, "id");  // coz, we want to insert the 
  2131.                                                               // highlight font id later
  2132.  
  2133.     if (TV__newheader != "")
  2134.     {
  2135.       var TV__id = TV__fontTag.id;
  2136.       var TV__innnerText = TV__fontTag.innerHTML;
  2137.  
  2138.       var TV__newheader = TV__addAttribute(TV__newheader, "id=" + TV__id);
  2139.  
  2140.       if (TV__newheader != "")
  2141.         TV__fontTag.outerHTML = TV__newheader + TV__innnerText + "</font>";
  2142.     }
  2143.   }
  2144. }
  2145.  
  2146. function TV__getMarkupHeader(TV__Obj)
  2147. {
  2148.   var TV__Text = TV__Obj.outerHTML;
  2149.   var TV__idx = TV__Text.indexOf(">");
  2150.  
  2151.   if (TV__idx == -1)
  2152.     return "";
  2153.  
  2154.   return TV__Text.substring(0, TV__idx+1);
  2155. }
  2156.  
  2157. function TV__changeTagName(TV__Markup, TV__newTag)
  2158. {
  2159.   var TV__idx = TV__Markup.indexOf(" ");
  2160.  
  2161.   if (TV__idx == -1)
  2162.     return "";
  2163.  
  2164.   return "<" + TV__newTag + " " + TV__Markup.substring(TV__idx);
  2165. }
  2166.  
  2167. function TV__stripAttribute(TV__Markup, TV__AttribName)
  2168. {
  2169.   TV__Markup = TV__Markup.toLowerCase();
  2170.  
  2171.   var TV__idx = TV__Markup.indexOf(TV__AttribName);
  2172.  
  2173.   if (TV__idx == -1)
  2174.     return TV__Markup;
  2175.  
  2176.   var TV__endIdx = TV__Markup.indexOf(" ", TV__idx+1);
  2177.   if (TV__endIdx == -1)
  2178.     TV__endIdx = TV__Markup.indexOf(">", TV__idx+1);
  2179.  
  2180.   if (TV__endIdx == -1)
  2181.     return "";
  2182.  
  2183.   return TV__Markup.substring(0, TV__idx) + " " + TV__Markup.substring(TV__endIdx);
  2184. }
  2185.  
  2186. function TV__addAttribute(TV__Markup, TV__Attribute)
  2187. {
  2188.   var TV__idx = TV__Markup.indexOf(">");
  2189.  
  2190.   if (TV__idx == -1)
  2191.     return "";
  2192.  
  2193.   return TV__Markup.substring(0, TV__idx) + " " + TV__Attribute + ">";
  2194. }
  2195.  
  2196. function TV__getVotingMarkup(TV__selfRate, TV__rateYes, TV__rateNo)
  2197. {
  2198.   TV__selfRate = 1 * TV__selfRate;
  2199.  
  2200.   var TV__trashImg = (TV__selfRate == -1)  ? TV__trashme : TV__trash;
  2201.   var TV__starImg  = (TV__selfRate == 1)   ? " " + TV__starme  : TV__star;
  2202.  
  2203.   var TV__vYes = (TV__rateYes > 99) ? ">99" : "" + TV__rateYes;
  2204.   var TV__vNo  = (TV__rateNo  > 99) ? ">99" : "" + TV__rateNo;
  2205.  
  2206.   return TV__trashImg + " " + TV__vNo + TV__starImg + " " + TV__vYes ;
  2207. }
  2208.  
  2209.  
  2210. // support for backend
  2211.  
  2212. function SignatureMailNote(TV__obj)
  2213. {
  2214.   if (TV__obj != null)
  2215.   {
  2216.     var TV__parent = TV__obj.parentElement;
  2217.  
  2218.     while ( (TV__parent != null) && (TV__parent.id != "annot") )
  2219.       TV__parent = TV__parent.parentElement;
  2220.  
  2221.     if (TV__parent != null)
  2222.     {
  2223.       var TV__rootid = TV__getAnnotAttribute(TV__parent, "rootAnnotID");
  2224.       TV__handleMailIconClick(TV__rootid);
  2225.     }
  2226.   }
  2227. }
  2228.  
  2229. function CreateWin(TV__URL, TV__title, TV__width, TV__height, TV__toolbar, TV__scrollbars, TV__status)
  2230. {
  2231.   return window.open(TV__URL, TV__title, "width=" + TV__width + ",height=" + TV__height + ",toolbar=" + TV__toolbar + ",scrollbars=" + TV__scrollbars + ",resizable=1,status=" + TV__status);
  2232. }
  2233.  
  2234.  
  2235. function IsSelectionInTextElement()
  2236. {
  2237.   if (document.selection.type == "Text")
  2238.   {
  2239.     var TV__tr = document.selection.createRange();
  2240.     TV__tr.collapse();
  2241.     
  2242.     var TV__parent = TV__tr.parentElement();
  2243.  
  2244.     return (TV__parent.tagName == "TEXTAREA") || (TV__parent.tagName == "INPUT")
  2245.   }
  2246.   return false;
  2247. }
  2248.  
  2249. function MarkAllMarkerAsRead()
  2250. {
  2251.   var TV__markers = document.all.tags("IMG");
  2252.  
  2253.   if (TV__markers != null)
  2254.   {
  2255.     if (TV__markers.length == null)  // one marker
  2256.     {
  2257.       if (TV__markers.className == "AweAnnotMarker")
  2258.         TV__chgNoteMarkToRead(TV__markers)
  2259.     }
  2260.     else
  2261.     {
  2262.       for (var i = 0; i < TV__markers.length; i++)
  2263.       {
  2264.         if (TV__markers[i].className == "AweAnnotMarker")
  2265.           TV__chgNoteMarkToRead(TV__markers[i]);
  2266.       }
  2267.     }
  2268.   }
  2269. }
  2270.  
  2271. function TV__chgNoteMarkToRead(TV__marker)
  2272. {
  2273.   var TV__readsrc = TV__marker.getAttribute("readsrc");
  2274.   if (TV__readsrc != "")
  2275.     TV__marker.src = TV__readsrc;
  2276. }
  2277.  
  2278. function showPageLevelNotesMenu(evt)
  2279. {
  2280.   TV__sendMsg2Client(TV__IE_CLIENT_HDR + TV__TVP + TV__TVM_PAGELEVEL_MENU + TV__TVP + evt.screenX + TV__TVP + evt.screenY);
  2281. }
  2282.  
  2283. function ShowPostNoteInfoDialog()
  2284. {
  2285.   var TV__showAgain = window.showModalDialog(TV__websiteURL + "help/tutorial/NotePostTut.htm", "again", "dialogWidth:300px; dialogHeight:200px; center:yes");
  2286.   
  2287.   var TV__nShowAgain = (TV__showAgain == true) ? 1 : 0;
  2288.   TV__sendMsg2Client(TV__IE_CLIENT_HDR + TV__TVP + TV__TVM_SHOW_NOTETUT_DLG + TV__TVP + TV__nShowAgain);
  2289. }
  2290.  
  2291.  
  2292. /** Copyright (c) 1999 ThirdVoice Inc. All rights reserved. **/
  2293.  
  2294. // <!-- tvcomplete -->