home *** CD-ROM | disk | FTP | other *** search
/ 220-130-228-171.hinet-ip.hinet.net / 220-130-228-171.hinet-ip.hinet.net.tar / 220-130-228-171.hinet-ip.hinet.net / picenvir / lightbox.js < prev    next >
Text File  |  2006-09-20  |  2KB  |  49 lines

  1. /*
  2. '
  3. '**************************************
  4. ' Visuddhi - http://visuddhi.com
  5. ' Copyright (c) 2006 - Visuddhi
  6. ' All right reserved. 
  7. '**************************************
  8. '
  9. */
  10.  
  11. function correctThumb(){
  12.   var max = maxer('thumb');
  13.   if (document.all){
  14.     document.styleSheets[0].addRule('table.dia', 'width:' + (max + 20) + 'px;'); 
  15.     document.styleSheets[0].addRule('table.dia', 'height:' + (max + 20) + 'px;'); 
  16.     document.styleSheets[0].addRule('div.smalldesc', 'width:' + (max + 20) + 'px;'); 
  17.   } else {
  18.     document.styleSheets[0].cssRules[6].style.width = (max + 20) + 'px';
  19.     document.styleSheets[0].cssRules[6].style.height = (max + 20) + 'px';
  20.     document.styleSheets[0].cssRules[7].style.width = (max + 20) + 'px';
  21.   }
  22. }
  23.  
  24. function correctPic(){
  25.   var max = maxer('pic');
  26.   if (document.all){
  27.     document.styleSheets[0].addRule('table.image', 'width:' + (max + 40) + 'px;'); 
  28.     document.styleSheets[0].addRule('table.image', 'height:' + (max + 40) + 'px;'); 
  29.   } else {
  30.     document.styleSheets[0].cssRules[11].style.width = (max + 40) + 'px';
  31.     document.styleSheets[0].cssRules[11].style.height = (max + 40) + 'px';
  32.   }
  33. }
  34.  
  35.  
  36. function maxer(reltag){
  37.   var maxw = 0; var maxh = 0; var relAtt;
  38.   var thumbs = document.getElementsByTagName('img');
  39.   for (var i=0; i<thumbs.length; i++){
  40.         relAtt = thumbs[i].getAttribute('rel');
  41.         if (relAtt == reltag){
  42.       if (thumbs[i].width > maxw){ maxw = thumbs[i].width; }
  43.       if (thumbs[i].height > maxh){ maxh = thumbs[i].height; }
  44.     }
  45.   }
  46.   var max = maxh; if (maxw > maxh){ max = maxw; }
  47.   return max;
  48. }
  49.