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

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