home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2004 September / maximum-cd-2004-09.iso / Software / Apps / OpenMind_Demo_UK.exe / misc.js < prev    next >
Encoding:
Text File  |  2003-12-04  |  5.1 KB  |  134 lines

  1. arrayButtonImages = new Array(100)
  2. buttoncount = 0
  3.  
  4. function button(image_normal1,image_normal2,image_normal3,image_hover1,image_hover2,image_hover3,image_active1,image_active2,image_active3)
  5. {
  6.     this.image_normal1 = new Image()
  7.     this.image_normal1.src = image_normal1
  8.     this.image_normal2 = new Image()
  9.     this.image_normal2.src = image_normal2
  10.     this.image_normal3 = new Image()
  11.     this.image_normal3.src = image_normal3
  12.  
  13.     if (image_hover1 == "") {
  14.         this.image_hover1 = this.image_normal1
  15.         this.image_hover2 = this.image_normal2
  16.         this.image_hover3 = this.image_normal3
  17.     } else {
  18.         this.image_hover1 = new Image()
  19.         this.image_hover1.src = image_hover1
  20.         this.image_hover2 = new Image()
  21.         this.image_hover2.src = image_hover2
  22.         this.image_hover3 = new Image()
  23.         this.image_hover3.src = image_hover3
  24.     }
  25.  
  26.     if (image_active1 == "") {
  27.         this.image_active1 = this.image_hover1
  28.         this.image_active2 = this.image_hover2
  29.         this.image_active3 = this.image_hover3
  30.     } else {
  31.         this.image_active1 = new Image()
  32.         this.image_active1.src = image_active1
  33.         this.image_active2 = new Image()
  34.         this.image_active2.src = image_active2
  35.         this.image_active3 = new Image()
  36.         this.image_active3.src = image_active3
  37.     }
  38. }
  39.  
  40. function AddButtonImages(image_normal1,image_normal2,image_normal3,image_hover1,image_hover2,image_hover3,image_active1,image_active2,image_active3)
  41. {
  42.     mybutton = new button(image_normal1,image_normal2,image_normal3,image_hover1,image_hover2,image_hover3,image_active1,image_active2,image_active3)
  43.     arrayButtonImages[buttoncount] = mybutton;
  44.     buttoncount = buttoncount + 1;
  45.     return (buttoncount-1)
  46. }
  47.  
  48. function ChangeButtonState(img1, img2, img3, nButton, nState)
  49. {
  50.     if (nState == 0) {
  51.         img1.src = arrayButtonImages[nButton].image_normal1.src
  52.         img2.src = arrayButtonImages[nButton].image_normal2.src
  53.         img3.src = arrayButtonImages[nButton].image_normal3.src
  54.     } else if (nState == 1) {
  55.         img1.src = arrayButtonImages[nButton].image_hover1.src
  56.         img2.src = arrayButtonImages[nButton].image_hover2.src
  57.         img3.src = arrayButtonImages[nButton].image_hover3.src
  58.     } else if (nState == 2) {
  59.         img1.src = arrayButtonImages[nButton].image_active1.src
  60.         img2.src = arrayButtonImages[nButton].image_active2.src
  61.         img3.src = arrayButtonImages[nButton].image_active3.src
  62.     }
  63. }
  64.  
  65. function ChangeLocation(url, newWindow)
  66. {
  67.     if (newWindow == "_new") {
  68.         window.open(url)
  69.     } else {
  70.         document.location.href=url
  71.     }
  72. }
  73.  
  74. function CreateButton(
  75.                     image_normal1,image_normal2,image_normal3,image_hover1,image_hover2,image_hover3,image_active1,image_active2,image_active3
  76.                     ,text,hovertext,target,openwhere
  77.                     ,x,y,width,height,xTextPos
  78.                     ,fontface,fontsize,color,bold,italic,underline,hrzalignment,bPreview
  79. {      
  80.     n = AddButtonImages(image_normal1,image_normal2,image_normal3,image_hover1,image_hover2,image_hover3,image_active1,image_active2,image_active3)
  81.  
  82.     sHtml ="<div style=\"Position:absolute; top:" + y + "px; left:" + x + "px;\">\n"
  83.       sHtml+="<table onmousedown=\"ChangeButtonState(img"+n+"1, img"+n+"2, img"+n+"3, "+n+", 2)\" onmouseover=\"ChangeButtonState(img"+n+"1, img"+n+"2, img"+n+"3, "+n+", 1)\" "
  84.          sHtml+="onmouseout=\"ChangeButtonState(img"+n+"1, img"+n+"2, img"+n+"3, "+n+", 0)\""
  85.  
  86.     
  87.     sHtml+="  style=\"cursor:pointer\" cellspacing=0 cellpadding=0 "
  88.  
  89.     if (!bPreview)
  90.          sHtml+="onclick=\"ChangeLocation('"+target+"', '"+openwhere+"')\" border=0><tr><td>\n"
  91.         else
  92.          sHtml+="onclick=\"alert('"+target+"')\" border=0><tr><td>\n"
  93.  
  94.       sHtml+="<div style=\"Position:absolute; top:0px; left:0px;\">\n"
  95.        sHtml+="<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr>\n"
  96.         sHtml+="<td><img alt=\"blah blah\" id=img"+n+"1 src=\""+image_normal1+"\"></td>\n"
  97.         sHtml+="<td><img alt=\"blah blah\" id=img"+n+"2 src=\""+image_normal2+"\" width=\""+(width-2*xTextPos)+"\" height=\""+height+"\"></td>\n"
  98.         sHtml+="<td><img alt=\"blah blah\" id=img"+n+"3 src=\""+image_normal3+"\"></td>\n"
  99.        sHtml+="</tr></table>\n"
  100.       sHtml+="</div>\n"
  101.       sHtml+="<div style=\"Position:absolute; top:0px; left:0px; width:"+width+"px;\">\n"
  102.        sHtml+="<table height=\""+height+"\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" style=\""
  103.       sHtml+="font-family: "+fontface+"; font-size: "+fontsize+"px; color:"+color+";"
  104.       if (bold == 1) {
  105.        sHtml+=" font-weight: 700;"
  106.       }
  107.       if (italic == 1) {
  108.        sHtml+=" font-style: italic;"
  109.       }
  110.       if (underline == 1) {
  111.        sHtml+=" text-decoration: underline;"
  112.       }
  113.        sHtml+="\"><tr>"
  114.        sHtml+="<td width=\""+xTextPos+"\"></td>\n"
  115.        sHtml+="<td valign=\"middle\" align=\""+hrzalignment+"\" width=\""+(width-2*xTextPos)+"\">"+text+"</td>\n"
  116.        sHtml+="<td width=\""+xTextPos+"\"></td>\n"
  117.       sHtml+="</tr></table>\n"
  118.       sHtml+="</div>\n"
  119.  
  120.  
  121.      if (hovertext != text) {
  122.       sHtml+="<div style=\"Position:absolute; top:0px; left:0px; height:"+height+"px; width:"+width+"px;\">\n"
  123.            sHtml+="<img alt=\""+hovertext+"\" height=\""+height+"\" width=\""+width+"\" src=\"blank.png\">";
  124.       sHtml+="</div>"
  125.      }
  126.  
  127.  
  128.      sHtml+="</td></tr></table>\n"
  129.     sHtml+="</div>\n"
  130.  
  131.     document.write(sHtml)
  132. }
  133.