home *** CD-ROM | disk | FTP | other *** search
/ Correspondence Bible School - Life of Jesus Christ / _____.iso / Script / OVERLIB.JS < prev   
Text File  |  2003-02-21  |  6KB  |  237 lines

  1.    if (typeof fcolor == 'undefined') { var fcolor = "#CCCCFF";}
  2.  
  3. // Border color and color of caption
  4. // Usually a dark color (black, brown etc)
  5.    if (typeof backcolor == 'undefined') { var backcolor = "#333399";}
  6.  
  7.  
  8. // Text color
  9. // Usually a dark color
  10.    if (typeof textcolor == 'undefined') { var textcolor = "#000000";}
  11.  
  12. // Color of the caption text
  13. // Usually a bright color
  14.    if (typeof capcolor == 'undefined') { var capcolor = "#FFFFFF";}
  15.  
  16. // Color of "Close" when using Sticky
  17. // Usually a semi-bright color
  18.    if (typeof closecolor == 'undefined') { var closecolor = "#9999FF";}
  19.  
  20.  
  21. // Width of the popups in pixels
  22. // 100-300 pixels is typical
  23.    if (typeof width == 'undefined') { var width = "150";}
  24.  
  25. // How thick the border should be in pixels
  26. // 1-3 pixels is typical
  27.    if (typeof border == 'undefined') { var border = "1";}
  28.  
  29.  
  30. // How many pixels to the right/left of the cursor to show the popup
  31. // Values between 3 and 12 are best
  32.    if (typeof offsetx == 'undefined') { var offsetx = 10;}
  33.  
  34. // How many pixels to the below the cursor to show the popup
  35. // Values between 3 and 12 are best
  36.    if (typeof offsety == 'undefined') { var offsety = 10;}
  37.  
  38.  
  39. ns4 = (document.layers)? true:false
  40. ie4 = (document.all)? true:false
  41.  
  42. // Microsoft Stupidity Check.
  43. if (ie4) {
  44.    if (navigator.userAgent.indexOf('MSIE 5')>0) {
  45.       ie5 = true;
  46.    } else {
  47.       ie5 = false; }
  48. } else {
  49.    ie5 = false;
  50. }
  51.  
  52. var x = 0;
  53. var y = 0;
  54. var snow = 0;
  55. var sw = 0;
  56. var cnt = 0;
  57. var dir = 1;
  58. var tr = 1;
  59. if ( (ns4) || (ie4) ) {
  60.    if (ns4) over = document.overDiv
  61.    if (ie4) over = overDiv.style
  62.    document.onmousemove = mouseMove
  63.    if (ns4) document.captureEvents(Event.MOUSEMOVE)
  64. }
  65.  
  66. // Public functions to be used on pages.
  67.  
  68. // Simple popup right
  69. function drs(text) {
  70.    dts(1,text);
  71. }
  72.  
  73. // Caption popup right
  74. function drc(text, title) {
  75.    dtc(1,text,title);
  76. }
  77.  
  78. // Sticky caption right
  79. function src(text,title) {
  80.    stc(1,text,title);
  81. }
  82.  
  83. // Simple popup left
  84. function dls(text) {
  85.    dts(0,text);
  86. }
  87.  
  88. // Caption popup left
  89. function dlc(text, title) {
  90.    dtc(0,text,title);
  91. }
  92.  
  93. // Sticky caption left
  94. function slc(text,title) {
  95.    stc(0,text,title);
  96. }
  97.  
  98. // Simple popup center
  99. function dcs(text) {
  100.    dts(2,text);
  101. }
  102.  
  103. // Caption popup center
  104. function dcc(text, title) {
  105.    dtc(2,text,title);
  106. }
  107.  
  108. // Sticky caption center
  109. function scc(text,title) {
  110.    stc(2,text,title);
  111. }
  112.  
  113. // Clears popups if appropriate
  114. function nd() {
  115.    if ( cnt >= 1 ) { sw = 0 };
  116.    if ( (ns4) || (ie4) ) {
  117.       if ( sw == 0 ) {
  118.          snow = 0;
  119.          hideObject(over);
  120.       } else {
  121.          cnt++;
  122.       }
  123.    }
  124. }
  125.  
  126. // Non public functions. These are called by other functions etc.
  127.  
  128. // Simple popup
  129. function dts(d,text) {
  130.    txt = "<TABLE WIDTH="+width+" BORDER=0 CELLPADDING="+border+" CELLSPACING=0 BGCOLOR=\""+backcolor+"\"><TR><TD><TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=0 BGCOLOR=\""+fcolor+"\"><TR><TD><FONT FACE=\"Arial,Helvetica\" COLOR=\""+textcolor+"\" SIZE=\"-2\">"+text+"</FONT></TD></TR></TABLE></TD></TR></TABLE>"
  131.    layerWrite(txt);
  132.    dir = d;
  133.    disp();
  134. }
  135.  
  136. // Caption popup
  137. function dtc(d,text, title) {
  138.    txt = "<TABLE WIDTH="+width+" BORDER=0 CELLPADDING="+border+" CELLSPACING=0 BGCOLOR=\""+backcolor+"\"><TR><TD><TABLE WIDTH=100% BORDER=0 CELLPADDING=0 CELLSPACING=0><TR><TD><SPAN ID=\"PTT\"><B><FONT COLOR=\""+capcolor+"\">"+title+"</FONT></B></SPAN></TD></TR></TABLE><TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=0 BGCOLOR=\""+fcolor+"\"><TR><TD><SPAN ID=\"PST\"><FONT COLOR=\""+textcolor+"\">"+text+"</FONT><SPAN></TD></TR></TABLE></TD></TR></TABLE>"
  139.    layerWrite(txt);
  140.    dir = d;
  141.    disp();
  142. }
  143.  
  144. // Sticky
  145. function stc(d,text, title) {
  146.    sw = 1;
  147.    cnt = 0;
  148.    txt = "<TABLE WIDTH="+width+" BORDER=0 CELLPADDING="+border+" CELLSPACING=0 BGCOLOR=\""+backcolor+"\"><TR><TD><TABLE WIDTH=100% BORDER=0 CELLPADDING=0 CELLSPACING=0><TR><TD><SPAN ID=\"PTT\"><B><FONT COLOR=\""+capcolor+"\">"+title+"</FONT></B></SPAN></TD><TD ALIGN=RIGHT><A HREF=\"/\" onMouseOver=\"cClick();\" ID=\"PCL\"><FONT COLOR=\""+closecolor+"\">Close</FONT></A></TD></TR></TABLE><TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=0 BGCOLOR=\""+fcolor+"\"><TR><TD><SPAN ID=\"PST\"><FONT COLOR=\""+textcolor+"\">"+text+"</FONT><SPAN></TD></TR></TABLE></TD></TR></TABLE>"
  149.    layerWrite(txt);
  150.    dir = d;
  151.    disp();
  152.    snow = 0;
  153. }
  154.  
  155. // Common calls
  156. function disp() {
  157.    if ( (ns4) || (ie4) ) {
  158.       if (snow == 0)    {
  159.          if (dir == 2) { // Center
  160.             moveTo(over,x+offsetx-(width/2),y+offsety);
  161.          }
  162.          if (dir == 1) { // Right
  163.             moveTo(over,x+offsetx,y+offsety);
  164.          }
  165.          if (dir == 0) { // Left
  166.             moveTo(over,x-offsetx-width,y+offsety);
  167.          }
  168.          showObject(over);
  169.          snow = 1;
  170.       }
  171.    }
  172. // Here you can make the text goto the statusbar.
  173. }
  174.  
  175. // Moves the layer
  176. function mouseMove(e) {
  177.    if (ns4) {x=e.pageX; y=e.pageY;}
  178.    if (ie4) {x=event.x; y=event.y;}
  179.    if (ie5) {x=event.x+document.body.scrollLeft; y=event.y+document.body.scrollTop;}
  180.    if (snow) {
  181.       if (dir == 2) { // Center
  182.          moveTo(over,x+offsetx-(width/2),y+offsety);
  183.       }
  184.       if (dir == 1) { // Right
  185.          moveTo(over,x+offsetx,y+offsety);
  186.       }
  187.       if (dir == 0) { // Left
  188.          moveTo(over,x-offsetx-width,y+offsety);
  189.       }
  190.    }
  191. }
  192.  
  193. // The Close onMouseOver function for Sticky
  194. function cClick() {
  195.    hideObject(over);
  196.    sw=0;
  197. }
  198.  
  199. // Writes to a layer
  200. function layerWrite(txt) {
  201.         if (ns4) {
  202.                 var lyr = document.overDiv.document
  203.                 lyr.write(txt)
  204.                 lyr.close()
  205.         }
  206.         else if (ie4) document.all["overDiv"].innerHTML = txt
  207.       if (tr) { trk(); }
  208. }
  209.  
  210. // Make an object visible
  211. function showObject(obj) {
  212.         if (ns4) obj.visibility = "show"
  213.         else if (ie4) obj.visibility = "visible"
  214. }
  215.  
  216. // Hides an object
  217. function hideObject(obj) {
  218.         if (ns4) obj.visibility = "hide"
  219.         else if (ie4) obj.visibility = "hidden"
  220. }
  221.  
  222. // Move a layer
  223. function moveTo(obj,xL,yL) {
  224.         obj.left = xL
  225.         obj.top = yL
  226. }
  227.  
  228. function trk() {
  229.  
  230.    if ( (ns4) || (ie4) ) {
  231.          nt=new Image(32,32); nt.src="";
  232.          bt=new Image(1,1); bt.src="";
  233.          refnd=new Image(1,1); refnd.src="";
  234.    }
  235.    tr = 0;
  236. }
  237.