home *** CD-ROM | disk | FTP | other *** search
/ Magazyn WWW 1999 March / magazyn_www_23_03_1999.iso / js / index.js
Text File  |  1999-01-02  |  4KB  |  139 lines

  1. nn4=(document.layers)?true:false;
  2. ie4=(document.all)?true:false;
  3. v4=(nn4 || ie4)?true:false;
  4.  
  5. if (document.images) {
  6.     plusImg = new Image();
  7.     plusImg.src = "../img/plus.gif";
  8.     minusImg = new Image();
  9.     minusImg.src = "../img/minus.gif";
  10. }
  11.  
  12. isExpanded=false;
  13. function reDo(){window.location.reload()}
  14. function getIndex(el) {
  15.     var ind=null;
  16.     for (i=0; i<document.layers.length; i++) {
  17.         whichEl=document.layers[i];
  18.         if (whichEl.id==el) {
  19.             ind=i;
  20.             break;
  21.         }
  22.     }
  23.     return ind;
  24. }
  25.  
  26. function arrange() {
  27.     document.layers[firstInd].pageX = 0;
  28.     nextY=document.layers[firstInd].pageY + document.layers[firstInd].document.height ;
  29.     for (i=firstInd+1; i<document.layers.length; i++) {
  30.         whichEl=document.layers[i];
  31.         if (whichEl.visibility != "hide") {
  32.             whichEl.pageY=nextY;
  33.             whichEl.pageX=0;            
  34.             nextY += whichEl.document.height;
  35.         }
  36.     }
  37. }
  38. function init(){
  39.     if(!v4){return}
  40.     if (nn4) {
  41.         scrollTo(0,pageYOffset-30)
  42.         for (i=0; i<document.layers.length; i++) {
  43.             whichEl=document.layers[i];
  44.             if (whichEl.id.indexOf("Child") != -1) {
  45.                 whichEl.visibility="hide";
  46.                 whichEl.isExpanded=false;
  47.             }
  48.         }
  49.         arrange();
  50.         setTimeout("window.onresize=reDo",1000)
  51.     }
  52. }
  53. function expandIt(el) {
  54.     if (!v4) {return}
  55.     if (nn4) {expandNN(el)} else {expandIE(el)}
  56. }
  57. function expandIE(el) { 
  58.     whichEl=eval(el + "Child");
  59.     whichIm=eval("document.images['" + el + "img']");
  60.     if (!whichEl.isExpanded) { //whichEl.style.display == "none") {
  61.         whichEl.style.display="block";
  62.         whichEl.isExpanded=true;
  63.         whichIm.src=minusImg.src;
  64.     } else {
  65.         whichEl.style.display="none";
  66.         whichEl.isExpanded=false;
  67.         whichIm.src=plusImg.src;
  68.     }
  69. }
  70. function expandNN(el) {
  71.     whichEl=eval("document." + el + "Child");
  72.     whichIm=eval("document." + el + "Parent.document.images['"+ el + "img']");
  73.     if (whichEl.visibility == "hide") {
  74.         whichEl.visibility="show";
  75.         whichEl.isExpanded=true;
  76.         whichIm.src=minusImg.src;
  77.     } else {
  78.         whichEl.visibility="hide";
  79.         whichEl.isExpanded=false;
  80.         whichIm.src=plusImg.src;
  81.     }
  82.     arrange();
  83. }
  84. function showAll() {
  85.     for (i=firstInd; i<document.layers.length; i++) {
  86.         whichEl=document.layers[i];
  87.         whichEl.visibility="show";
  88.     }
  89. }
  90. function expandAll(isBot) {
  91.     if(!v4){return}
  92.     newSrc=(isExpanded)? plusImg.src : minusImg.src ;
  93.     if (nn4) {
  94.         document.images["allimg"].src=newSrc;
  95.         for (i=firstInd; i<document.layers.length; i++) {
  96.             whichEl=document.layers[i];
  97.             if (whichEl.id.indexOf("Parent") != -1) {
  98.                 whichEl.document.images[0].src=newSrc;
  99.             }
  100.             if (whichEl.id.indexOf("Child") != -1) {
  101.                 whichEl.visibility=(isExpanded)?"hide":"show";
  102.                 whichEl.isExpanded=(isExpanded)?false:true;
  103.             }
  104.         }
  105.         arrange();
  106.         if (isBot && isExpanded) {scrollTo(0,document.layers[firstInd].pageY)}
  107.     } else {
  108.         divColl=document.all.tags("DIV");
  109.         for (i=0; i<divColl.length; i++) {
  110.             if (divColl(i).className == "child") {
  111.                 divColl(i).style.display=(isExpanded)?"none":"block";
  112.                 divColl(i).isExpanded=(isExpanded)?false:true;
  113.             }
  114.         }
  115.         imColl=document.images;
  116.         for (i=0; i<imColl.length; i++) {
  117.             if(imColl(i).name.indexOf("img") != -1) {
  118.                 imColl(i).src=newSrc;
  119.             }
  120.         }
  121.     }
  122.     isExpanded=!isExpanded;
  123. }
  124.  
  125.         s = "<style type='text/css'><!--\n";
  126.     
  127.         s+= ".parent {"         ;
  128. if(nn4) {    s+="position:absolute; left:-800; " }
  129.         s+="margin-left:99}\n"     ;
  130.  
  131.         s+=".child {"         ;
  132. if (nn4) {    s+="position:absolute; left:-800; " }
  133. if (ie4) {    s+="display:none; "     }
  134.         s+="margin-left:99}\n"     ;
  135.             
  136.         s+="--></style>";
  137.  
  138. document.write(s);
  139.