home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 March / Chip_2004-03_cd1.bin / chplus / svethardware / shw.js < prev    next >
Text File  |  2003-09-16  |  3KB  |  112 lines

  1. window.onload = init
  2. window.onresize = init
  3.  
  4. function init() {
  5.     objects()
  6.     width()
  7.     height()
  8. }
  9.  
  10. function ahoj() {
  11. alert("ahoj")
  12. }
  13.  
  14. var MF,LB,MB,RB,LM,TLB,TMB,TRB,TLM,BT,SP,TB
  15.  
  16. function objects() {
  17.     MF = gEBI('mainframe')
  18.     LM = gEBI('wrapper')
  19.     LB = gEBI('left')
  20.     MB = gEBI('middle')
  21.     RB = gEBI('right')
  22.     TLM = gEBI('topwrapper')
  23.     TLB = gEBI('topleft')
  24.     TMB = gEBI('topmiddle')
  25.     TRB = gEBI('topright')
  26.     TB = gEBI('topbar')
  27.     FT = gEBI('footer')
  28.     SP = gEBI('spacing')
  29. }
  30.  
  31. function gEBI(id) {
  32.        if(Boolean(document.getElementById)) {
  33.         return document.getElementById(id);
  34.        } else if(Boolean(document.all)) {
  35.           return eval('document.all.'+id);
  36.     }
  37. }
  38.  
  39. function width() {
  40.  
  41. //alert(document.body.clientHeight)
  42.  
  43. var pw = SP.offsetWidth
  44. //alert(document.styleSheets[0].rules)
  45. if (pw > 930) {
  46. MF.style.width='100%'
  47. SP.style.width='100%'
  48. }
  49. else {
  50. MF.style.width='930px'
  51. SP.style.width='930px'
  52. }
  53. //alert(SP.offsetWidth)
  54. //var total = MF.offsetWidth
  55. var total = SP.offsetWidth
  56. TLM.style.width = (total-256)+'px' // topwrapper
  57. LM.style.width = TLM.style.width // wrapper
  58. //TMB.style.width = (total-TLB.offsetWidth-TRB.offsetWidth)+'px'
  59. TMB.style.width = (total-160-256)+'px' //topmiddle
  60. //MB.style.width = (total-TLB.offsetWidth-TRB.offsetWidth)+'px'
  61. MB.style.width = (total-160-256)+'px' //middle
  62. TB.style.width = (total)+'px' //topbar
  63. }
  64.  
  65. function topwidth() {
  66.     var msie = window.navigator.userAgent.match('MSIE') && !window.navigator.userAgent.match('Opera')
  67.     if (msie) {
  68.         var SP = gEBI('spacing')
  69.         var pw = SP.offsetWidth
  70.         if (pw > 930) {
  71.             document.styleSheets[0].addRule("DIV#mainframe", "width:100%");
  72.             SP.style.width='100%'
  73.         }
  74.         else {
  75.             document.styleSheets[0].addRule("DIV#mainframe", "width:930px");
  76.             SP.style.width='930px'
  77.         }
  78.         var total = SP.offsetWidth
  79.         document.styleSheets[0].addRule("DIV#topwrapper", "width:"+(total-256)+"px");
  80.         document.styleSheets[0].addRule("DIV#wrapper", "width:"+(total-256)+"px");
  81.         document.styleSheets[0].addRule("DIV#topmiddle", "width:"+(total-160-256)+"px");
  82.         document.styleSheets[0].addRule("DIV#middle", "width:"+(total-160-256)+"px");
  83.         document.styleSheets[0].addRule("DIV#topbar", "width:"+(total)+"px");
  84.     }
  85. }
  86.  
  87. function height() {
  88.     var leftH = LB.offsetHeight
  89.     var middleH = MB.offsetHeight
  90.     var rightH = RB.offsetHeight
  91. /*    
  92.     alert(leftH)
  93.     alert(middleH)
  94.     alert(rightH)
  95. */    
  96.     var m, maxi
  97. //    m = leftH
  98.     if (leftH > rightH) { m = leftH } else { m = rightH }
  99.     if (middleH > m) { m = middleH }
  100.     /*
  101.     if (!(Opera && leftH > contentH))
  102.         LB.style.height = (maxi)+'px'
  103.         */
  104.     LB.style.height = (m)+'px'    
  105.     MB.style.height = (m)+'px'
  106.     RB.style.height = (m)+'px'
  107.     
  108. }
  109.  
  110.  
  111.  
  112.