home *** CD-ROM | disk | FTP | other *** search
/ Magazyn WWW 2001 May / cd49www.iso / full / js / index.js < prev   
Text File  |  2000-04-06  |  4KB  |  156 lines

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