home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 2000 July / macformat-092.iso / Fireworks 3 / Settings / HTML Code / Dreamweaver 2 / slices.htt < prev   
Encoding:
Text File  |  1999-11-19  |  32.7 KB  |  1,042 lines

  1.  
  2. // Fireworks Dreamweaver 2.0 HTML & JavaScript for sliced output.
  3. // Version 2.0 04OCT99
  4.  
  5.  
  6. // To export HTML without comments change the value of variable doComments to "false".
  7. var doComments = true;
  8.  
  9. // These are the suffixes for the first 4 frames
  10. var sfx = new Array();
  11. sfx[0] = "";        // first frame doesn't normally have a suffix.
  12. sfx[1] = "_f2";        // second frame.
  13. sfx[2] = "_f3";        // third frame.
  14. sfx[3] = "_f4";        // fourth frame.
  15. var numSFX = 4;
  16. function UpdateFileNames(curSlices) {
  17.     for (var curRow = 0; curRow < curSlices.numRows; curRow++) {
  18.         for (var curCol = 0; curCol < curSlices.numColumns; curCol++) {
  19.             if (curSlices[curRow][curCol].skipCell) continue;
  20.             var nestedTable = curSlices[curRow][curCol].nestedTableSlices;
  21.             if (nestedTable) {
  22.                 UpdateFileNames(nestedTable);
  23.                 continue;
  24.             }
  25.             var curSlice = curSlices[curRow][curCol];
  26.             var cellName = "";
  27.             if (curSlice && curSlice.getFrameFileName(0)) {
  28.                 cellName = curSlice.getFrameFileName(0).toString();
  29.                 var i;
  30.                 var limit = exportDoc.numFrames;
  31.                 if (limit > numSFX) limit = numSFX;
  32.                 for (i=0; i<limit; i++) {
  33.                     if (curSlice.getFrameFileName(i)) {
  34.                         curSlice.setFrameFileName(i, cellName + sfx[i]);
  35.                     }
  36.                 }
  37.             }
  38.         }
  39.     }
  40. }
  41. UpdateFileNames(slices);
  42.  
  43. var doHeader = true;
  44. doHeader = exportDoc.generateHeader; 
  45. // When HTML is generated to a file, generateHeader is true.
  46. // When HTML is generated for the clipboard 
  47. // generateHeader is false.
  48.  
  49. // When doComments is set to "true" the WRITE_HTML_COMMENT and WRITE_JS_COMMENT functions
  50. // include HTML and JavaScript comments in the exported file.
  51. function WRITE_HTML_COMMENT(str) {
  52.     if (doComments) WRITE_HTML("<!--"+str+"-->\n");
  53. }
  54.  
  55. function WRITE_JS_COMMENT(str) {
  56.     if (doComments) WRITE_HTML("/* "+str+" */\n");
  57. }
  58.  
  59. // Declare variables for processing Behaviors.    
  60. var kActionStatusMessage = 1;
  61. var kActionSwapImage = 2;
  62. var kActionButtonDown = 4;
  63. var kActionSwapImageRestore = 5;
  64. var kActionButtonHighlight = 6; 
  65. var kActionButtonRestore = 7;
  66.  
  67. var kEventMouseOver = 0;
  68. var kEventOnClick = 1;
  69. var kEventMouseOut = 2;
  70. var kEventOnLoad = 3;
  71.  
  72. var hasStatusMessage = false;
  73. var hasSwap = false;
  74. var hasDown = false;
  75. var hasRestore = false;
  76.  
  77.  
  78. if (doHeader) {
  79.     // Write general comments for copying and pasting Fireworks-generated code into existing HTML documents.
  80.     WRITE_HTML_COMMENT("To put this html into an existing HTML document, you must copy the JavaScript and");
  81.     WRITE_HTML_COMMENT("paste it in a specific location within the destination HTML document. You must then copy");
  82.     WRITE_HTML_COMMENT("and paste the table in a different location.");
  83.     WRITE_HTML("\n");
  84.  
  85.     WRITE_HTML("<html>\n");
  86.  
  87.     WRITE_HTML("<head>\n");
  88.  
  89.     // Use Base Name from export dialog as document title.
  90.     WRITE_HTML("<title>", exportDoc.filename, "</title>\n");
  91.  
  92.     // Write Meta tags.
  93.     WRITE_HTML("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=");
  94.     var charSet = App.getPref("HtmlCharSet");
  95.     if (charSet == "") charSet = "iso-8859-1";
  96.     WRITE_HTML(charSet + "\">\n"); 
  97.     WRITE_HTML("<meta name=\"description\" content=\"Fireworks Splice HTML\">\n");
  98. }
  99.  
  100. // Write HTML target and date created.
  101. var d = new Date();
  102. WRITE_HTML("<!-- Fireworks 3.0  Dreamweaver 2.0 compatibility target.  Created ", d, " -->\n");
  103. WRITE_HTML("\n");
  104.  
  105. // Function cellName determines the name for the image in a particular table cel
  106. // cellName is based off of the slice name if one was specified. Otherwise the
  107. // Base file name from the export dialog is used.
  108. function CellName(curSlices, row, col) {
  109.     var curSlice = curSlices[row][col];
  110.     var cellName = "";
  111.     if (curSlice && curSlice.getFrameFileName(0)) {
  112.         cellName = curSlice.getFrameFileName(0).toString();
  113.         curSlice.setFrameFileName(0, cellName);
  114.         // remove illegal characters
  115.         cellName = cellName.replace(/\W/g, "");
  116.         // if it starts with a number, add N to the front.
  117.         if (cellName == "") cellName = "n" + exportDoc.imagename + "_" + (row+1) + "_" + (col+1);
  118.         if (cellName.search(/\d/) == 0) {
  119.             cellName = "n"+cellName;
  120.         }
  121.     }
  122.     if (cellName!="") return(cellName);     
  123.  
  124.     var prefix;
  125.     if (!curSlices) return("nullCellName");
  126.     if (curSlices.id == 0) {
  127.         prefix = "";
  128.     } else {
  129.         prefix = curSlices.id+"_";
  130.     }
  131.     var suffix="";
  132.     if (curSlices.numRows > 1 || curSlices.numColumns > 1) {
  133.         suffix = "_" + (row+1) + "_" + (col+1);
  134.     }
  135.     cellName = "n" + prefix + exportDoc.imagename + suffix;
  136.     return(cellName);
  137. }
  138.  
  139. // Determine and process Behaviors in the document.
  140. function ProcessEvent(theCurBehaviors, targetEvent) {
  141.     // Declare variable for processing Behaviors.
  142.     var javaScript = "";
  143.     var stat = false;
  144.     var eraseStatOnMouseOut = false;
  145.     var swapImage = "";
  146.     var nbHighlight = "";
  147.     var nbHighlightPreload = false;
  148.     var nbDown = "";
  149.     var nbDownPreload = false;
  150.     var swap = "";
  151.     var swapRestore = false;
  152.     var buttonRestore = false;
  153.     
  154.     // Translate Behaviors into JavaScript.
  155.     for (var i=0; i<theCurBehaviors.numberOfBehaviors; i++) {
  156.         curBehavior = theCurBehaviors[i];
  157.         
  158.         if (curBehavior.ignoreFlag) continue;
  159.         // Check for erase on mouse out status messages.
  160.         if (curBehavior.action == kActionStatusMessage) {
  161.             if (curBehavior.restoreOnMouseout) eraseStatOnMouseOut=true;
  162.         }
  163.         
  164.         if (curBehavior.event != targetEvent) continue;
  165.         
  166.         if (curBehavior.action == kActionStatusMessage) {
  167.             var statMsg = curBehavior.statusText;
  168.             var curStat = "";
  169.             curStat = "MM_displayStatusMsg('" + statMsg + "');";
  170.             javaScript += curStat;
  171.             stat = true;
  172.             continue;
  173.         }
  174.         if (curBehavior.action == kActionSwapImageRestore) {
  175.             swapRestore = true;
  176.             continue;
  177.         }
  178.         
  179.         if (curBehavior.action == kActionButtonRestore) {
  180.             buttonRestore = true;
  181.             continue;
  182.         }
  183.         
  184.         var swapRow = curBehavior.targetRowNum;
  185.         var swapCol = curBehavior.targetColumnNum;
  186.         var swapFrame = curBehavior.targetFrameNum; 
  187.         var swapTable = curBehavior.targetTable;
  188.         var fileName;
  189.         if (!swapTable) {
  190.             /* Not a swap behavior, so continue. */
  191.             continue;
  192.         }
  193.  
  194.         if (curBehavior.hasHref) {
  195.             fileName = curBehavior.href;
  196.         } else {
  197.             fileName = swapTable.imagesDirPath + swapTable[swapRow][swapCol].getFrameFileName(swapFrame) + swapTable[swapRow][swapCol].imageSuffix;
  198.         }
  199.  
  200.  
  201.         var cellName = CellName(swapTable, swapRow,swapCol);
  202.         
  203.         // Translate button Behaviors into JavaScript.
  204.         if (curBehavior.action == kActionButtonDown) {
  205.             //MM_nbGroup(event, groupName, imgName, downSrc...preloadMarker)
  206.             nbDown += "'" + cellName + "','" + fileName + "',";
  207.             if (curBehavior.preload) nbDownPreload = true;
  208.             continue;
  209.         }
  210.         // Translate button Behaviors into JavaScript.
  211.         if (curBehavior.action == kActionButtonHighlight) {
  212.             var highlightName = "";
  213.             if (curBehavior.downHighlight) {
  214.                 if (curBehavior.hasDhHref) {
  215.                     highlightName = curBehavior.dhHref;
  216.                 } else {
  217.                     var f = curBehavior.dhTargetFrameNum;
  218.                     highlightName = swapTable.imagesDirPath + swapTable[swapRow][swapCol].getFrameFileName(f) + swapTable[swapRow][swapCol].imageSuffix
  219.                 }
  220.             }            
  221.             nbHighlight += "'" + cellName + "','" + fileName + "','" + highlightName +"',";
  222.             if (curBehavior.preload) nbHighlightPreload = true;
  223.             continue;
  224.         }
  225.         // Translate Swap Image Behaviors into JavaScript.
  226.         if (curBehavior.action == kActionSwapImage) {        
  227.             swap += "'document." +cellName +"','document." + cellName + "','" + fileName + "',";
  228.             continue;
  229.         }        
  230.     }
  231.     if (nbDown != "" &&  targetEvent == kEventOnLoad) {
  232.          // Eat it.  Special handling for this one.
  233.         nbDown = "";
  234.     }
  235.     if (nbDown != "") {
  236.         javaScript += "MM_nbGroup('down','navbar1'," + nbDown
  237.         if (nbDownPreload) {
  238.             javaScript += "1);";
  239.         } else {
  240.             javaScript += "0);";
  241.         }
  242.     }
  243.      if (nbHighlight != "") {
  244.         javaScript += "MM_nbGroup('over'," + nbHighlight
  245.         if (nbHighlightPreload) {
  246.             javaScript += "1);";
  247.         } else {
  248.             javaScript += "0);";
  249.         }
  250.     }
  251.     if (swap != "") {
  252.         javaScript += "MM_swapImage(" + swap + "1);";
  253.     }
  254.     if (swapRestore) {
  255.         javaScript += "MM_swapImgRestore();";
  256.     }
  257.     if (buttonRestore) {
  258.         javaScript += "MM_nbGroup('out');";
  259.     }
  260.     // Erase status bar message onMouseOut.
  261.     if (eraseStatOnMouseOut && targetEvent == kEventMouseOut) {
  262.         javaScript += "MM_displayStatusMsg(' ');" ;
  263.         stat = true;
  264.     }
  265.     
  266.     if (stat) javaScript += "return document.MM_returnValue";
  267.     return(javaScript);
  268. }
  269.  
  270. // Determine and process Behaviors in the document.
  271. function ProcessBehavior(theCurBehaviors) {
  272.     
  273.     javaOver = ProcessEvent(theCurBehaviors, kEventMouseOver);
  274.     javaOut = ProcessEvent(theCurBehaviors, kEventMouseOut);
  275.     javaClick = ProcessEvent(theCurBehaviors, kEventOnClick);
  276.     if (javaOver != "" || javaOut != "" || javaClick != "") {
  277.         return(true);
  278.     }
  279.     return(false);
  280. }
  281.  
  282. function NavLoadInit(theCurBehaviors, myCellName) {
  283.     // Declare variable for processing Behaviors.
  284.     var nbDown = "";
  285.     var nbDownPreload = false;
  286.     var javaScript = "";
  287.     // Translate Behaviors into JavaScript.
  288.     for (var i=0; i<theCurBehaviors.numberOfBehaviors; i++) {
  289.         curBehavior = theCurBehaviors[i];
  290.         
  291.         if (curBehavior.ignoreFlag) continue;
  292.         
  293.         if (curBehavior.event != kEventOnLoad) continue;
  294.         
  295.         if (curBehavior.action != kActionButtonDown) {
  296.             continue;
  297.         }
  298.         
  299.         var swapRow = curBehavior.targetRowNum;
  300.         var swapCol = curBehavior.targetColumnNum;
  301.         var swapFrame = curBehavior.targetFrameNum; 
  302.         var swapTable = curBehavior.targetTable;
  303.         var fileName;
  304.         if (!swapTable) {
  305.             /* Not a swap behavior, so continue. */
  306.             continue;
  307.         }
  308.  
  309.         var cellName = CellName(swapTable, swapRow,swapCol);
  310.         if (cellName != myCellName) continue;
  311.         if (curBehavior.hasHref) {
  312.             fileName = curBehavior.href;
  313.         } else {
  314.             fileName = swapTable.imagesDirPath + swapTable[swapRow][swapCol].getFrameFileName(swapFrame) + swapTable[swapRow][swapCol].imageSuffix;
  315.         }
  316.         nbDown = fileName;
  317.      }
  318.  
  319.     return(nbDown);
  320. }
  321.  
  322. var filesToPreload = new Array;
  323. function PreloadFile(fileName) {
  324.     if (!fileName) return;
  325.     /* See if we already precached this one. */
  326.     for (j=0; j<filesToPreload.length; j++) {
  327.         if (filesToPreload[j] == fileName) {
  328.             return;
  329.         }
  330.     }
  331.     filesToPreload[j] = fileName;
  332. }
  333.  
  334. function DoPreload(curBeh, swapRow, swapCol, swapFrame, swapTable) {
  335.     var fileName;
  336.     var curFile;
  337.     var j;
  338.     if (curBeh.hasHref) {
  339.         fileName = curBeh.href;
  340.     } else {
  341.         curFile = swapTable[swapRow][swapCol].getFrameFileName(swapFrame);
  342.         if (curFile) 
  343.             fileName = swapTable.imagesDirPath + curFile + swapTable[swapRow][swapCol].imageSuffix;
  344.     }
  345.     PreloadFile(fileName);
  346.     if (curBeh.downHighlight) {
  347.         if (curBeh.hasDhHref) {
  348.             fileName = curBeh.dhHref;
  349.         } else {
  350.             var f = curBeh.dhTargetFrameNum;
  351.             curFile = swapTable[swapRow][swapCol].getFrameFileName(f);
  352.             if (curFile) {
  353.                 fileName = swapTable.imagesDirPath + curFile + swapTable[swapRow][swapCol].imageSuffix;
  354.             }
  355.         }
  356.         if (fileName) {
  357.             PreloadFile(fileName);
  358.         }
  359.     }
  360. }
  361.  
  362. function DoFile(curBeh) {
  363.     var swapRow = curBeh.targetRowNum;
  364.     var swapCol = curBeh.targetColumnNum;
  365.     var swapFrame = curBeh.targetFrameNum; 
  366.     var swapTable = curBeh.targetTable;
  367.     if (!swapTable) return;
  368.     var fileName = swapTable[swapRow][swapCol].getFrameFileName(0);
  369.     if (curBeh.downHighlight && curBeh.hasDhTargetFrame) {
  370.         var fm = curBeh.dhTargetFrameNum;
  371.         if (!swapTable[swapRow][swapCol].getFrameFileName(fm)) {
  372.             var tmp;
  373.             var frame = fm+1;
  374.             tmp = fileName + "_f" + frame;
  375.             swapTable[swapRow][swapCol].setFrameFileName(fm, tmp);
  376.         }
  377.     }
  378.     if (curBeh.preload) {
  379.         DoPreload(curBeh, swapRow, swapCol, swapFrame, swapTable);
  380.     }
  381.     if (curBeh.hasTargetFrame && swapFrame > 0) {
  382.         if (swapTable[swapRow][swapCol].getFrameFileName(swapFrame)) return;
  383.         var frame = swapFrame + 1;
  384.         fileName = fileName + "_f" + frame;
  385.         swapTable[swapRow][swapCol].setFrameFileName(swapFrame, fileName);
  386.     } 
  387. }
  388.  
  389. // Examine all behaviors to determine what actions are present. 
  390. // Determine which files to pre-cache.
  391. var FWLoadInit = "";
  392. function DoFileAndPreload(curSlices) {
  393.     for (var curRow = 0; curRow < curSlices.numRows; curRow++) {
  394.         for (var curCol = 0; curCol < curSlices.numColumns; curCol++) {
  395.             if (curSlices[curRow][curCol].skipCell) continue;
  396.             var nestedTable = curSlices[curRow][curCol].nestedTableSlices;
  397.             if (nestedTable) {
  398.                 DoFileAndPreload(nestedTable);
  399.                 continue;
  400.             }
  401.             if (curSlices[curRow][curCol].behaviors.numberOfBehaviors > 0) {
  402.                 var behaviors = curSlices[curRow][curCol].behaviors;
  403.                 for (var i=0; i<behaviors.numberOfBehaviors; i++) {
  404.                     var curBehavior = behaviors[i];
  405.                     if (curBehavior.action == kActionSwapImage) {
  406.                         DoFile(curBehavior);
  407.                         hasSwap = true;
  408.                     }
  409.                     if (curBehavior.action == kActionButtonDown) {
  410.                         DoFile(curBehavior);
  411.                         hasDown = true;
  412.                     }
  413.                     if (curBehavior.action == kActionButtonHighlight) {
  414.                         DoFile(curBehavior);
  415.                         hasDown = true;
  416.                     }
  417.                     if (curBehavior.action == kActionButtonRestore) {
  418.                         DoFile(curBehavior);
  419.                         hasDown = true;
  420.                     }
  421.                     if (curBehavior.action == kActionSwapImageRestore) {
  422.                         hasRestore = true;
  423.                     }
  424.                     if (curBehavior.action == kActionStatusMessage) {
  425.                         hasStatusMessage = true;
  426.                     }
  427.                 }
  428.                 var init = ProcessEvent(behaviors, kEventOnLoad) ;
  429.                 if (init != "") {
  430.                     FWLoadInit += init;
  431.                 }
  432.             }
  433.             var imagemap = curSlices[curRow][curCol].imagemap;
  434.             for (var j=0; j < imagemap.numberOfURLs; j++) {
  435.                 var curImagemap = imagemap[j];
  436.                 var behaviors = curImagemap.behaviors;
  437.                 for (var i=0; i<behaviors.numberOfBehaviors; i++) {
  438.                     var curBehavior = behaviors[i];
  439.                     if (curBehavior.action == kActionSwapImage) {
  440.                         DoFile(curBehavior);
  441.                         hasSwap = true;
  442.                     }
  443.                     if (curBehavior.action == kActionButtonDown) {
  444.                         DoFile(curBehavior);
  445.                         hasDown = true;
  446.                     }
  447.                     if (curBehavior.action == kActionButtonHighlight) {
  448.                         DoFile(curBehavior);
  449.                         hasDown = true;
  450.                     }
  451.                     if (curBehavior.action == kActionButtonRestore) {
  452.                         DoFile(curBehavior);
  453.                         hasDown = true;
  454.                     }
  455.                     if (curBehavior.action == kActionSwapImageRestore) {
  456.                         hasRestore = true;
  457.                     }
  458.                     if (curBehavior.action == kActionStatusMessage) {
  459.                         hasStatusMessage = true;
  460.                     }
  461.                 }
  462.                 var init = ProcessEvent(behaviors, kEventOnLoad) ;
  463.                 if (init != "") {
  464.                     FWLoadInit += init;
  465.                 }
  466.             }
  467.         }
  468.     }
  469. }
  470.  
  471. DoFileAndPreload(slices);
  472.     
  473. /*--------------------------  JavaScript functions used in the HTML -----------------*/
  474.     
  475.  
  476. // Write out only the JavaScript functions needed for the HTM
  477. if (doHeader) {
  478.     if (hasStatusMessage || hasDown || hasSwap || hasRestore || filesToPreload.length > 0) {
  479.         // Begin Script. Hide Script from non-javascript-enabled browsers.
  480.         WRITE_HTML("<script language=\"JavaScript\">\n");
  481.         WRITE_HTML("<!--hide this script from non-javascript-enabled browsers\n");
  482.         WRITE_HTML("\n");
  483.         // Write function dm if document includes status bar messages.
  484.         if (hasStatusMessage) {
  485.             WRITE_JS_COMMENT("Function that displays status bar messages.")
  486.             //WRITE_HTML(MM_displayStatusMsg);
  487.             WRITE_HTML("function MM_displayStatusMsg(msgStr)  { //v3.0\n");
  488.             WRITE_HTML("    status=msgStr; document.MM_returnValue = true;\n");
  489.             WRITE_HTML("}\n");
  490.             WRITE_HTML("\n");
  491.         }
  492.  
  493.  
  494.         if (hasDown) {
  495.             //WRITE_HTML(MM_findObj);
  496.             WRITE_HTML("function MM_findObj(n, d) { //v3.0\n");
  497.             WRITE_HTML("  var p,i,x;  if(!d) d=document; if((p=n.indexOf(\"?\"))>0&&parent.frames.length) {\n");
  498.             WRITE_HTML("    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}\n");
  499.             WRITE_HTML("  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];\n");
  500.             WRITE_HTML("  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;\n");
  501.             WRITE_HTML("}\n");
  502.  
  503.         }
  504.  
  505.         // Write function MM_swapImage if document includes swap image behaviors.
  506.         if (hasSwap) {
  507.             WRITE_JS_COMMENT("Functions that swaps images.")
  508.             //WRITE_HTML(MM_swapImage);
  509.             WRITE_HTML("function MM_swapImage() { //v2.0\n");
  510.             WRITE_HTML("  var i,j=0,objStr,obj,swapArray=new Array,oldArray=document.MM_swapImgData;\n");
  511.             WRITE_HTML("  for (i=0; i < (MM_swapImage.arguments.length-2); i+=3) {\n");
  512.             WRITE_HTML("    objStr = MM_swapImage.arguments[(navigator.appName == 'Netscape')?i:i+1];\n");
  513.             WRITE_HTML("    if ((objStr.indexOf('document.layers[')==0 && document.layers==null) ||\n");
  514.             WRITE_HTML("        (objStr.indexOf('document.all[')   ==0 && document.all   ==null))\n");
  515.             WRITE_HTML("      objStr = 'document'+objStr.substring(objStr.lastIndexOf('.'),objStr.length);\n");
  516.             WRITE_HTML("    obj = eval(objStr);\n");
  517.             WRITE_HTML("    if (obj != null) {\n");
  518.             WRITE_HTML("      swapArray[j++] = obj;\n");
  519.             WRITE_HTML("      swapArray[j++] = (oldArray==null || oldArray[j-1]!=obj)?obj.src:oldArray[j];\n");
  520.             WRITE_HTML("      obj.src = MM_swapImage.arguments[i+2];\n");
  521.             WRITE_HTML("  } }\n");
  522.             WRITE_HTML("  document.MM_swapImgData = swapArray; //used for restore\n");
  523.             WRITE_HTML("}\n");
  524.         }
  525.  
  526.         // Write function MM_swapImage if document includes swap image behaviors.
  527.         if (hasRestore) {
  528.             //WRITE_HTML(MM_swapImgRestore);    
  529.             WRITE_HTML("function MM_swapImgRestore() { //v2.0\n");
  530.             WRITE_HTML("  if (document.MM_swapImgData != null)\n");
  531.             WRITE_HTML("    for (var i=0; i<(document.MM_swapImgData.length-1); i+=2)");
  532.             WRITE_HTML("      document.MM_swapImgData[i].src = document.MM_swapImgData[i+1];\n");
  533.             WRITE_HTML("}\n");
  534.         }
  535.  
  536.         if (hasDown) {
  537.             WRITE_JS_COMMENT("Functions that swaps down images.")
  538.             //WRITE_HTML(MM_nbGroup);
  539.             WRITE_HTML("function MM_nbGroup(event, grpName) { //v3.0\n");
  540.             WRITE_HTML("  var i,img,nbArr,args=MM_nbGroup.arguments;\n");
  541.             WRITE_HTML("  if (event == \"init\" && args.length > 2) {\n");
  542.             WRITE_HTML("    if ((img = MM_findObj(args[2])) != null && !img.MM_init) {\n");
  543.             WRITE_HTML("      img.MM_init = true; img.MM_up = args[3]; img.MM_dn = img.src;\n");
  544.             WRITE_HTML("      if ((nbArr = document[grpName]) == null) nbArr = document[grpName] = new Array();\n");
  545.             WRITE_HTML("      nbArr[nbArr.length] = img;\n");
  546.             WRITE_HTML("      for (i=4; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {\n");
  547.             WRITE_HTML("        if (!img.MM_up) img.MM_up = img.src;\n");
  548.             WRITE_HTML("        img.src = img.MM_dn = args[i+1];\n");
  549.             WRITE_HTML("        nbArr[nbArr.length] = img;\n");
  550.             WRITE_HTML("    } }\n");
  551.             WRITE_HTML("  } else if (event == \"over\") {\n");
  552.             WRITE_HTML("    document.MM_nbOver = nbArr = new Array();\n");
  553.             WRITE_HTML("    for (i=1; i < args.length-1; i+=3) if ((img = MM_findObj(args[i])) != null) {\n");
  554.             WRITE_HTML("      if (!img.MM_up) img.MM_up = img.src;\n");
  555.             WRITE_HTML("      img.src = (img.MM_dn && args[i+2]) ? args[i+2] : args[i+1];\n");
  556.             WRITE_HTML("      nbArr[nbArr.length] = img;\n");
  557.             WRITE_HTML("    }\n");
  558.             WRITE_HTML("  } else if (event == \"out\" ) {\n");
  559.             WRITE_HTML("    for (i=0; i < document.MM_nbOver.length; i++) {\n");
  560.             WRITE_HTML("      img = document.MM_nbOver[i]; img.src = (img.MM_dn) ? img.MM_dn : img.MM_up; }\n");
  561.             WRITE_HTML("  } else if (event == \"down\") {\n");
  562.             WRITE_HTML("    if ((nbArr = document[grpName]) != null)\n");
  563.             WRITE_HTML("      for (i=0; i < nbArr.length; i++) { img=nbArr[i]; img.src = img.MM_up; img.MM_dn = 0; }\n");
  564.             WRITE_HTML("    document[grpName] = nbArr = new Array();\n");
  565.             WRITE_HTML("    for (i=2; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {\n");
  566.             WRITE_HTML("      if (!img.MM_up) img.MM_up = img.src;\n");
  567.             WRITE_HTML("      img.src = img.MM_dn = args[i+1];\n");
  568.             WRITE_HTML("      nbArr[nbArr.length] = img;\n");
  569.             WRITE_HTML("  } }\n");
  570.             WRITE_HTML("}\n");
  571.  
  572.  
  573.             WRITE_HTML("\n");
  574.         }
  575.  
  576.  
  577.         if (filesToPreload.length > 0) {
  578.             WRITE_JS_COMMENT("Functions that handle preload.")
  579.             //WRITE_HTML(MM_preloadImages);
  580.             WRITE_HTML("function MM_preloadImages() { //v3.0\n");
  581.             WRITE_HTML(" var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();\n");
  582.             WRITE_HTML("   var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)\n");
  583.             WRITE_HTML("   if (a[i].indexOf(\"#\")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}\n");
  584.             WRITE_HTML("}\n");
  585.             WRITE_HTML("\n");
  586.         }
  587.  
  588.         // Stop hiding script from non-javascript-enabled browsers. End script.
  589.         WRITE_HTML("// stop hiding -->\n");      
  590.         WRITE_HTML("</script>\n");
  591.         WRITE_HTML("\n");
  592.     }
  593. /*----------------- END JavaScript functions used in the HTML -----------------*/
  594.  
  595.     // Close head tag.
  596.     WRITE_HTML("</head>\n");      
  597.  
  598.     // Begin body tag. Set background color to Fireworks document canvas color.
  599.     WRITE_HTML("<body bgcolor=\"#", exportDoc.backgroundColor.toString(16), "\"");
  600.  
  601.     // Write onLoad function.
  602.         if (FWLoadInit || filesToPreload.length>0) {
  603.             WRITE_HTML(" onLoad=\"");
  604.             WRITE_HTML(FWLoadInit);
  605.             var i;
  606.             for (i=0; i<filesToPreload.length; i++) {
  607.                 if (i==0) WRITE_HTML("MM_preloadImages(");
  608.                 else WRITE_HTML(",");
  609.                 WRITE_HTML("'" + filesToPreload[i] + "'");
  610.             }
  611.             if (i>0) WRITE_HTML(");");
  612.             WRITE_HTML("\"");
  613.         }
  614.         WRITE_HTML(">\n");    // close the body tag.
  615.         WRITE_HTML("\n");
  616.         
  617. }    
  618.           
  619.  
  620. // Write comment for start of table copy/paste section.
  621. var needTable = slices.numRows > 1 || slices.numColumns > 1;
  622. if (needTable) {
  623.     WRITE_HTML_COMMENT("The following section is an HTML table which reassembles the sliced image in a browser.");
  624.     WRITE_HTML_COMMENT("Copy the table section including the opening and closing table tags, and paste the data where");
  625.     WRITE_HTML_COMMENT("you want the reassembled image to appear in the destination document. ");
  626.     WRITE_HTML("\n");
  627. }
  628. WRITE_HTML_COMMENT("------------------------ BEGIN COPYING THE HTML HERE --------------------------");
  629.  
  630. if (needTable) WRITE_HTML_COMMENT(" Image with table ");
  631.  
  632. function WriteTable(curSlices, indent) {
  633.     var needTable = curSlices.numRows > 1 || curSlices.numColumns > 1;
  634.     var curCol;
  635.     var curRow;
  636.     var downIndex = 0;
  637.     if (needTable) {
  638.         WRITE_HTML("<table ");
  639.  
  640.         // If the Fireworks document's canvas is not transparent and the Include undefined curSlices checkbox
  641.         // is off, give the table a background color based on the FIreworks document's canvas color.
  642.         if (!exportDoc.backgroundIsTransparent && curSlices.doSkipUndefined) {
  643.             WRITE_HTML("bgcolor=\"#", exportDoc.backgroundColor, "\" ");
  644.         } 
  645.  
  646.         WRITE_HTML("border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"",
  647.                 curSlices.width, "\">\n");
  648.  
  649.         /* This is the magic comment for html update. */
  650.         if (indent == "") {
  651.             //<--- fwtable fwsrc="mydoc" fwbase="basename" --->
  652.             var comment = "<!-- fwtable fwsrc=\"" + exportDoc.docSaveName + "\" fwbase=\"" + exportDoc.filename + "\"" + " -->\n";
  653.             WRITE_HTML(comment);
  654.         }
  655.  
  656.  
  657.         
  658.     // If shims have been specified, write shim row.    
  659.         if (curSlices.doShimEdges) {
  660.             WRITE_HTML(indent+"  <tr>\n");
  661.             WRITE_HTML_COMMENT(" Shim row, height 1. ");
  662.             for (curCol = 0; curCol < curSlices.numColumns; curCol++) {
  663.                 WRITE_HTML(indent+"   <td><img src=\"", curSlices.shimPath, "\" width=\"", 
  664.                     curSlices[0][curCol].cellWidth, "\" height=\"1\" border=\"0\"></td>\n"); 
  665.             }
  666.             WRITE_HTML(indent+"   <td><img src=\"", curSlices.shimPath, "\" width=\"1", 
  667.                 "\" height=\"1\" border=\"0\"></td>\n"); 
  668.             WRITE_HTML(indent+"  </tr>\n");
  669.             WRITE_HTML("\n");
  670.         }
  671.     }
  672.     // Write table rows.
  673.     for (curRow = 0; curRow < curSlices.numRows; curRow++) {
  674.         if (needTable) {
  675.             WRITE_HTML(indent+"  <tr valign=\"top\">");
  676.             WRITE_HTML_COMMENT(" row "+(curRow+1)+" ");
  677.             if (!doComments) WRITE_HTML("\n");
  678.         }
  679.         for (curCol = 0; curCol < curSlices.numColumns; curCol++) {
  680.             var curSlice = curSlices[curRow][curCol];
  681.             if (curSlice.skipCell) continue; 
  682.  
  683.             if (needTable) {
  684.                 // Write rowspan and colspan if necessary. Ex: rowspan="1" colspan="3"
  685.                 WRITE_HTML(indent+"   <td");
  686.                 if (curSlice.rowSpan > 1) {
  687.                     WRITE_HTML(" rowspan=\"", curSlice.rowSpan,"\"");
  688.                 }
  689.                 if (curSlice.columnSpan>1) {
  690.                     WRITE_HTML(" colspan=\"", curSlice.columnSpan, "\"");
  691.                 }
  692.                 WRITE_HTML(">");
  693.             }
  694.  
  695.             var nestedTable = curSlice.nestedTableSlices;
  696.             if (nestedTable) {
  697.                 WriteTable(nestedTable, "    "+indent);
  698.                 if (needTable) {
  699.                     WRITE_HTML("</td>");
  700.                 }
  701.                 WRITE_HTML("\n");
  702.                 continue;
  703.             }
  704.  
  705.             // Write HTML text from curSlices set to "Text (No Image)"
  706.             if (!curSlice.hasImage) {
  707.                 // no image, just dump out html text.
  708.                 if (curSlice.htmlText) {
  709.                     WRITE_HTML(curSlice.htmlText);
  710.                 } else if (needTable) {
  711.                     if (curSlices.shimPath) {
  712.                         WRITE_HTML("<img src=\"",
  713.                             curSlices.shimPath, "\" width=\"", curSlice.width, "\" height=\"", 
  714.                             curSlice.height, "\" border=\"0\">");
  715.                     } 
  716.                 }
  717.                 if (needTable) WRITE_HTML("</td>\n");
  718.                 continue;
  719.             }
  720.  
  721.             // If current slice is not defined by a slice object and Export Undefined
  722.             // curSlices is not checked, don't output an image and if Shims are specified 
  723.             // place a shim image in the current cel
  724.             if (curSlice.isUndefined && curSlices.doSkipUndefined) {
  725.                 if (needTable) {
  726.                     if (curSlices.shimPath) {
  727.                         WRITE_HTML("<img src=\"",
  728.                             curSlices.shimPath, "\" width=\"", curSlice.width, "\" height=\"", 
  729.                             curSlice.height, "\" border=\"0\">");
  730.                     } 
  731.                     WRITE_HTML("</td>\n");
  732.                 }
  733.                 // Tell Fireworks to not write the image file. Setting the filename to "" forces 
  734.                 // Fireworks to not generate the image.
  735.                 var q;
  736.                 for (q=0; q<exportDoc.numFrames; q++) {
  737.                     curSlice.setFrameFileName(q, "");
  738.                 }    
  739.                 continue;
  740.             }
  741.  
  742.             // Write link if slice has URL attached.
  743.             var href = "href=\"#\"";
  744.             var hasHref = curSlice.hasHref;
  745.             var abortHref = false;
  746.             if (curSlice.hasHref) {
  747.                 href = "href=\"";
  748.                 href += curSlice.href;
  749.                 href += "\"";
  750.                 if (curSlice.hasTargetText) {
  751.                     href += " target=\"";
  752.                     href += curSlice.targetText;
  753.                     href += "\"";
  754.                 }
  755.                 
  756.             } else {
  757.                 var link = "";
  758.                 if (exportDoc.backgroundLink) {
  759.                     link = exportDoc.backgroundLink.href;
  760.                 }
  761.                 if (link != "") {
  762.                     hasHref = true;
  763.                     href = "href=\"" + link +"\"";
  764.                 }
  765.             }
  766.  
  767.             if (slices.doDemoHTML && curSlice.downIndex>0) {
  768.                 href = "href=\"" + slices.demoHref(curSlice.downIndex) +".htm\"";
  769.             }
  770.  
  771.             var cellName = CellName(curSlices, curRow, curCol);
  772.             var anchorTagOpen = false;
  773.  
  774.             // If the slice has image map hotspots and has a url attached to it,
  775.             // ignore the url here and move it into the image map.
  776.             if (curSlice.hasImage && curSlice.hasImagemap) {
  777.                 abortHref = true;  // we will put the href in the imagemaps.
  778.             }
  779.  
  780.             // Write rollover and swap image events.
  781.             if (!abortHref) {
  782.                 var behaviors = curSlice.behaviors;
  783.                 var gotJavascript = ProcessBehavior(behaviors);
  784.  
  785.                 if ( gotJavascript || hasHref) {
  786.                       WRITE_HTML("<a ");
  787.                     anchorTagOpen = true;
  788.                     WRITE_HTML(href);
  789.  
  790.                     if (javaOut != "") {
  791.                         WRITE_HTML(" onMouseOut=\"", javaOut, "\" ");
  792.                     }
  793.                     if (javaOver != "") {
  794.                         WRITE_HTML(" onMouseOver=\"", javaOver, "\" ");
  795.                     }
  796.                     if (javaClick != "") {
  797.                         WRITE_HTML(" onClick=\"", javaClick, "\" ");
  798.                     }
  799.                     WRITE_HTML(">");
  800.                 }
  801.             }
  802.  
  803.             // Place image.
  804.             if (curSlice.hasImage) {
  805.                 var imageName = curSlice.getFrameFileName(0); 
  806.                 if (slices.doDemoHTML && slices.demoIndex>0 && 
  807.                     slices.demoIndex == curSlice.downIndex) {
  808.                     imageName = curSlice.getFrameFileName(2);
  809.                 } 
  810.                 var altText = "";
  811.                 if (curSlice.hasAltText) {
  812.                     altText = curSlice.altText;
  813.                 } else {
  814.                     altText = exportDoc.altText;
  815.                 }
  816.                 var btnDownSrc = NavLoadInit(curSlice.behaviors, cellName);
  817.                 var btnInitSrc = "";
  818.                     //onLoad="MM_nbGroup('init','navbar1','imgName','down.gif','img2Name','down',1)"
  819.                 var src = curSlices.imagesDirPath + imageName + curSlice.imageSuffix;
  820.                 if (btnDownSrc) {
  821.                     btnInitSrc = src;
  822.                     src = btnDownSrc;    
  823.                 }
  824.  
  825.                 // Assemble info for image tag.
  826.                 // Ex: <img name="n_03_02" src="File_03_02.gif" width="79" height="71" border="0"
  827.                 WRITE_HTML("<img name=\"", cellName, "\" src=\"",
  828.                     src, "\" width=\"",
  829.                     curSlice.width,"\" height=\"", curSlice.height, "\" border=\"0\"");
  830.                 
  831.                 // Write image map name.
  832.                 // Ex: usemap="#base_r1_c2"
  833.                 if (curSlice.hasImagemap) {     
  834.                     WRITE_HTML(" usemap=\"#m_", imageName, "\""); 
  835.                 }
  836.                 
  837.                 // Write alt text.
  838.                 if (altText != "") {
  839.                     WRITE_HTML(" alt=\"", altText, "\"");
  840.                 }
  841.                 var btnDown = "";
  842.                 if (btnInitSrc) {
  843.                     //MM_nbGroup(event, groupName, imgName, downSrc...preloadMarker)
  844.                     btnDown = " '" + cellName + "','" + btnInitSrc + "',";
  845.                      btnDown = "onLoad=\"MM_nbGroup('init','navbar1'," + btnDown
  846.                     btnDown += "1)\"";
  847.                 }
  848.  
  849.                 if (btnDown) WRITE_HTML(btnDown);
  850.                 WRITE_HTML(">");    
  851.             }
  852.  
  853.             if (anchorTagOpen) {
  854.                 WRITE_HTML("</a>");    
  855.             }
  856.             if (needTable) WRITE_HTML("</td>\n");    
  857.         }
  858.         
  859.         if (needTable) {
  860.             // Place shim in rightmost column of table.
  861.             if (curSlices.doShimEdges) {
  862.                 /* Write the 1 pixel transparent shim. */
  863.                 WRITE_HTML("   <td><img src=\"",
  864.                     curSlices.shimPath, "\" width=\"1\" height=\"", 
  865.                     curSlices[curRow][0].cellHeight, "\" border=\"0\"></td>\n"); 
  866.             }
  867.             WRITE_HTML(indent+"  </tr>\n");
  868.         }
  869.     }        
  870.     if (needTable) {
  871.         // Close table.
  872.         if (indent!="") WRITE_HTML(indent+"</table>");
  873.     }
  874. }
  875.  
  876. function WriteImagemaps(curSlices, indent) {
  877.     // Traverse all curSlices and generate any image maps needed.
  878.     for (var curRow = 0; curRow < curSlices.numRows; curRow++) {
  879.         for (var curCol = 0; curCol < curSlices.numColumns; curCol++) {
  880.             var curSlice = curSlices[curRow][curCol];
  881.             if (curSlice.skipCell) continue; 
  882.             var nestedTable = curSlice.nestedTableSlices;
  883.             if (nestedTable) {
  884.                 WriteImagemaps(nestedTable, "    "+indent);
  885.                 continue;
  886.             }
  887.             if (curSlice.hasImagemap) {
  888.                 
  889.                 // Write the image map.
  890.                 WRITE_HTML(indent+"<map name=\"m_", curSlice.getFrameFileName(0), "\">\n");
  891.  
  892.                 var i = 0;
  893.                 var imagemap = curSlice.imagemap;
  894.                 while (i < imagemap.numberOfURLs) {
  895.                     var curImagemap = imagemap[i];
  896.  
  897.                     var behaviors = curImagemap.behaviors;
  898.  
  899.                     if (behaviors.numberOfBehaviors==0) {
  900.                         var behaviors = curSlice.behaviors;
  901.                     }
  902.                      javaOver = "";
  903.                     javaOut = "";
  904.                     javaClick = "";
  905.                     var gotJavascript = ProcessBehavior(behaviors);
  906.     
  907.                     // Write the area tag with shape definitions.
  908.                     WRITE_HTML(indent+"<area shape=\"");
  909.                     WRITE_HTML(curImagemap.shape); // Shapes are rect poly and circle
  910.                     WRITE_HTML("\" coords=\"");
  911.                     for (var j=0; j<curImagemap.numCoords; j++) {
  912.                         if (j>0) WRITE_HTML(",");
  913.                         // polygon has n coords.
  914.                         // rect has 2 coords, topLeft, and botomRight.
  915.                         // circle has one coord, center; plus radius.
  916.                         WRITE_HTML((curImagemap.xCoord(j)-curSlice.left), ",", (curImagemap.yCoord(j)-curSlice.top)); 
  917.                     }
  918.                     if (curImagemap.shape == "circle") {
  919.                         // Write the radius for circle hotspots.
  920.                         WRITE_HTML(", ", curImagemap.radius);
  921.                     }
  922.                     WRITE_HTML("\"");
  923.                     var href = " href=\"#\"";
  924.                     if (curImagemap.hasHref) {
  925.                         href = " href=\"";
  926.                         href += curImagemap.href;
  927.                         href += "\"";
  928.                         if (curImagemap.hasTargetText) {
  929.                             href += " target=\"";
  930.                             href += curImagemap.targetText;
  931.                             href += "\"";
  932.                         }
  933.                     }
  934.  
  935.                     WRITE_HTML(href);
  936.                     
  937.                     // Write alt text for hotspot.
  938.                     var altText = "";
  939.                     if (curImagemap.hasAltText) {
  940.                         altText = curImagemap.altText;
  941.                     } else {
  942.                         altText = exportDoc.altText;
  943.                     }
  944.  
  945.                     if (altText!="") {
  946.                         WRITE_HTML(" title=\"", altText, "\"");
  947.                         WRITE_HTML(" alt=\"", altText, "\"");
  948.                     }
  949.  
  950.                     // Write rollover and swap image behaviors.
  951.                     if (javaOut != "") {
  952.                         WRITE_HTML(" onMouseOut=\"", javaOut, "\" ");
  953.                     }
  954.                     if (javaOver != "") {
  955.                         WRITE_HTML(" onMouseOver=\"", javaOver, "\" ");
  956.                     }
  957.                     if (javaClick != "") {
  958.                         WRITE_HTML(" onClick=\"", javaClick, "\" ");
  959.                     }
  960.  
  961.                     WRITE_HTML(" >\n");
  962.                     i++;
  963.                 } 
  964.                 var behaviors = curSlices[curRow][curCol].behaviors;
  965.                  javaOver = "";
  966.                 javaOut = "";
  967.                 javaClick = "";
  968.                 var gotJavascript = ProcessBehavior(behaviors);
  969.                 
  970.                 var link = "";
  971.                 if (curSlice.hasHref) {
  972.                     link = curSlice.href;
  973.                 } else {  
  974.                     if (exportDoc.backgroundLink) {
  975.                         link = exportDoc.backgroundLink.href;
  976.                     }
  977.                 }
  978.  
  979.                 // If the current slice had a URL attached, it was moved and written here.
  980.                 if (gotJavascript || link != "") {
  981.                     WRITE_HTML(indent+"<area shape=\"rect\" coords=\"0,0, ", curSlice.width, ",", curSlice.height, "\" ");
  982.                     var href="#";
  983.                     if (link!="") {
  984.                         href = link;
  985.                     }
  986.                     WRITE_HTML("href=\"", href, "\"");
  987.  
  988.                     if (curSlice.hasTargetText) {
  989.                         WRITE_HTML("\n  target=\"", curSlices[curRow][curCol].targetText, "\"");
  990.                     }
  991.                     if (javaOut != "") {
  992.                         WRITE_HTML(" onMouseOut=\"", javaOut, "\" ");
  993.                     }
  994.                     if (javaOver != "") {
  995.                         WRITE_HTML(" onMouseOver=\"", javaOver, "\" ");
  996.                     }
  997.                     if (javaClick != "") {
  998.                         WRITE_HTML(" onClick=\"", javaClick, "\" ");
  999.                     }
  1000.                     var altText = "";
  1001.                     if (curSlice.hasAltText) {
  1002.                         altText = curSlice.altText;
  1003.                     } else {
  1004.                         altText = exportDoc.altText;
  1005.                     }
  1006.                     if (altText!="") {
  1007.                         WRITE_HTML(" title=\"", altText, "\"");
  1008.                         WRITE_HTML(" alt=\"", altText, "\"");
  1009.                     }
  1010.                     WRITE_HTML(">\n");
  1011.                 }    
  1012.  
  1013.                 WRITE_HTML(indent+"</map>\n")
  1014.                 WRITE_HTML("\n");
  1015.             }
  1016.         }
  1017.     }
  1018. }
  1019.  
  1020. WriteTable(slices, "");
  1021. WriteImagemaps(slices, "");
  1022.  
  1023. // End table copy/paste section.
  1024. if (needTable) {
  1025.     WRITE_HTML_COMMENT("   This table was automatically created with Macromedia Fireworks 3.0   ");
  1026.     WRITE_HTML_COMMENT("   http://www.macromedia.com   ");
  1027. }
  1028. WRITE_HTML("\n");
  1029. if (needTable) {
  1030.     WRITE_HTML("</table>\n");
  1031. }
  1032.  
  1033. WRITE_HTML_COMMENT("------------------------- STOP COPYING THE HTML HERE -------------------------");
  1034. if (doHeader) {
  1035.     WRITE_HTML("\n");
  1036.     WRITE_HTML("</body>\n");
  1037.  
  1038.     WRITE_HTML("\n");
  1039.     WRITE_HTML("</html>\n");
  1040.     WRITE_HTML("\n");
  1041. }
  1042.