MayaChemTools

   1 package HTMLUtil;
   2 #
   3 # $RCSfile: HTMLUtil.pm,v $
   4 # $Date: 2015/02/28 20:47:17 $
   5 # $Revision: 1.42 $
   6 #
   7 # Author: Manish Sud <msud@san.rr.com>
   8 #
   9 # Copyright (C) 2015 Manish Sud. All rights reserved.
  10 #
  11 # This file is part of MayaChemTools.
  12 #
  13 # MayaChemTools is free software; you can redistribute it and/or modify it under
  14 # the terms of the GNU Lesser General Public License as published by the Free
  15 # Software Foundation; either version 3 of the License, or (at your option) any
  16 # later version.
  17 #
  18 # MayaChemTools is distributed in the hope that it will be useful, but without
  19 # any warranty; without even the implied warranty of merchantability of fitness
  20 # for a particular purpose.  See the GNU Lesser General Public License for more
  21 # details.
  22 #
  23 # You should have received a copy of the GNU Lesser General Public License
  24 # along with MayaChemTools; if not, see <http://www.gnu.org/licenses/> or
  25 # write to the Free Software Foundation Inc., 59 Temple Place, Suite 330,
  26 # Boston, MA, 02111-1307, USA.
  27 #
  28 
  29 use strict;
  30 use Exporter;
  31 
  32 use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
  33 
  34 @ISA = qw(Exporter);
  35 @EXPORT = qw(InsertHTMLTags SetupHTMLAlignmentBegin SetupHTMLAlignmentEnd SetupHTMLButtonRef SetupHTMLDivBegin SetupHTMLDivEnd SetupHTMLEmptyLines SetupHTMLPageHeader SetupHTMLHRef SetupHTMLPageEnd SetupHTMLPageTitle SetupHTMLStyleSheetTags SetupHTMLTableHeader SetupHTMLTableEnd SetupHTMLTableColumnHeader SetupHTMLTableColumnEnd SetupHTMLTableRowHeader SetupHTMLTableRowEnd SetupHTMLTableRowHeaderValue SetupHTMLTableRowDataValue SetupJavaScriptCmds SetupStrViewerJSInitCmd SetupStrViewerJMEApplet SetupStrViewerJmolApplet SetupStrViewerChimePlugIn SetupStrViewerChem3DActiveX SetupStrViewerChemDrawActiveX SetupStrViewerChemDrawPlugIn SetupStrViewerMarvinViewApplet SetupStrViewerAccelrysActiveX);
  36 @EXPORT_OK = qw();
  37 
  38 %EXPORT_TAGS = (all  => [@EXPORT, @EXPORT_OK]);
  39 
  40 # Default window size for various supported structure viewers...
  41 my($StrViewerWidth, $StrViewerHeight) = (250, 170);
  42 
  43 # Insert specfied tags into existing tag string...
  44 sub InsertHTMLTags {
  45   my($Tag, %TagsMap) = @_;
  46   my($NewTag, $TagName, $TagValue, $TagPart1, $TagPart2);
  47 
  48   $NewTag = $Tag; $TagPart1 = ""; $TagPart2 = "";
  49   ($TagPart1) = $Tag =~ /^(.*?)>/;
  50 
  51   if ($TagPart1 && length($TagPart1)) {
  52     $TagPart2 = $Tag;
  53     $TagPart2 =~ s/^(.*?)>//;
  54     if ($TagPart2 && length($TagPart2)) {
  55       for $TagName (keys %TagsMap) {
  56         $TagValue = $TagsMap{$TagName};
  57         $TagPart1 .= qq( $TagName="$TagValue" );
  58       }
  59       $NewTag = "${TagPart1}>${TagPart2}";
  60     }
  61   }
  62 
  63   return $NewTag;
  64 }
  65 
  66 sub SetupHTMLAlignmentBegin {
  67   my($AlignmentTag, $Alignment);
  68 
  69   $Alignment = (@_ == 1) ? $_[0] : "left";
  70   $AlignmentTag = qq(<$Alignment>\n);
  71 
  72   return $AlignmentTag;
  73 }
  74 
  75 sub SetupHTMLAlignmentEnd {
  76   my($AlignmentTag, $Alignment);
  77 
  78   $Alignment = (@_ == 1) ? $_[0] : "left";
  79   $AlignmentTag = qq(</$Alignment>\n);
  80 
  81   return $AlignmentTag;
  82 }
  83 
  84 # Setup a button reference...
  85 sub SetupHTMLButtonRef {
  86   my($ButtonLabel, $RefFile, $ButtonTags);
  87 
  88   ($ButtonLabel, $RefFile) = @_;
  89 
  90   $ButtonTags = qq(<input type="button" value="$ButtonLabel" onClick="document.location='$RefFile'">);
  91   return $ButtonTags;
  92 }
  93 
  94 sub SetupHTMLDivBegin {
  95   my($Id) = @_;
  96   my($DivTag);
  97 
  98   $DivTag = qq(<div id="$Id">\n);
  99 
 100   return $DivTag;
 101 }
 102 
 103 sub SetupHTMLDivEnd {
 104   my($DivTag);
 105 
 106   $DivTag = qq(</div>\n);
 107 
 108   return $DivTag;
 109 }
 110 sub SetupHTMLEmptyLines {
 111   my($LineCount, $Index, $EmptyLineTags);
 112 
 113   $LineCount = 1;
 114   $EmptyLineTags = qq(<p>&nbsp</p>);
 115   ($LineCount) = @_;
 116   if ($LineCount > 1) {
 117     for $Index (2 .. $LineCount) {
 118       $EmptyLineTags .= qq(<p>&nbsp</p>);
 119     }
 120   }
 121   return $EmptyLineTags;
 122 }
 123 
 124 # Setup HTML page header...
 125 sub SetupHTMLPageHeader {
 126   my($HeaderTitle, $Stylesheet, $JavaScript, $PageHeader);
 127 
 128   $HeaderTitle = "";  $Stylesheet = ""; $JavaScript = "";
 129   if (@_ == 3) {
 130     ($HeaderTitle, $Stylesheet, $JavaScript) = @_;
 131   }
 132   elsif (@_ == 2) {
 133     ($HeaderTitle, $Stylesheet) = @_;
 134   }
 135   else {
 136     ($HeaderTitle) = @_;
 137   }
 138   $PageHeader = qq(<html>\n);
 139   $PageHeader .= qq(<head>\n);
 140   $PageHeader .= qq(<title>$HeaderTitle</title>\n);
 141   $PageHeader .= qq(<meta http-equiv="content-type" content="text/html;charset=utf-8">\n);
 142   if ($Stylesheet) {
 143     $PageHeader .= qq(<link rel="stylesheet" type="text/css" href="$Stylesheet">\n);
 144   }
 145   if ($JavaScript) {
 146     $PageHeader .= qq(<script src="$JavaScript"></script>\n);
 147   }
 148   $PageHeader .= <<ENDPAGEHEADER;
 149 </head>
 150 <body>
 151 <p>&nbsp</p>
 152 ENDPAGEHEADER
 153 
 154   return $PageHeader;
 155 }
 156 
 157 # Setup page title...
 158 sub SetupHTMLPageTitle {
 159   my($Title, $Alignment, $PageTitle);
 160 
 161   $Alignment = "center";
 162   if (@_ == 2) {
 163     ($Title, $Alignment) = @_;
 164   }
 165   else {
 166     ($Title) = @_;
 167   }
 168 
 169   $PageTitle=<<ENDPAGETITLE;
 170 <$Alignment>
 171 <h3>$Title</h3>
 172 </$Alignment>
 173 ENDPAGETITLE
 174 
 175   return $PageTitle;
 176 }
 177 
 178 # Setup HTML page end...
 179 sub SetupHTMLPageEnd {
 180   my($PageEnd, $Footer);
 181 
 182   $Footer = "";
 183   if (@_ == 1) {
 184     ($Footer) = @_;
 185   }
 186   if ($Footer) {
 187     $Footer = qq(<span class="Footer">$Footer</span>);
 188   }
 189   $PageEnd=<<ENDPAGE;
 190 <center>
 191 <p>&nbsp</p>
 192 $Footer
 193 </center>
 194 </body>
 195 </html>
 196 ENDPAGE
 197 
 198   return $PageEnd;
 199 }
 200 
 201 # Setup HTML link tags...
 202 sub SetupHTMLHRef {
 203   my($Value, $RefFile, $HRef, $Title);
 204 
 205   $Title = "";
 206   if (@_ == 3) {
 207     ($Value, $RefFile, $Title) = @_;
 208   }
 209   else {
 210     ($Value, $RefFile) = @_;
 211   }
 212 
 213   $HRef = qq(<a href="$RefFile");
 214   if ($Title) {
 215     $HRef .= qq( title="$Title");
 216   }
 217   $HRef .= qq(>$Value</a>);
 218   return $HRef;
 219 }
 220 
 221 #
 222 sub SetupHTMLStyleSheetTags {
 223   my($StyleSheetTags);
 224 
 225   $StyleSheetTags=<<ENDSTYLESHEET;
 226 body
 227 {
 228     background-color: #ffffff;
 229     font-family: Verdana, Arial, Helvetica, sans-serif;
 230     font-size: 11px;
 231 }
 232 p
 233 {
 234     font-family: Verdana, Arial, Helvetica, sans-serif;
 235     font-size: 11px;
 236 }
 237 h1
 238 {
 239     font-family: Verdana, Arial, Helvetica, sans-serif;
 240     font-size: 25px;
 241     font-weight: bold;
 242     color: #0054aa;
 243 }
 244 h2
 245 {
 246     font-family: Verdana, Arial, Helvetica, sans-serif;
 247     font-size: 18px;
 248     font-weight: bold;
 249     color: #0054aa;
 250 }
 251 h3
 252 {
 253     font-family: Verdana, Arial, Helvetica, sans-serif;
 254     font-size: 14px;
 255     font-weight: bold;
 256     color: #0054aa;
 257 }
 258 b
 259 {
 260     font-weight: bold;
 261 }
 262 td
 263 {
 264     font-family: Verdana, Arial, Helvetica, sans-serif;
 265     font-size: 11px;
 266 }
 267 th
 268 {
 269     font-family: Verdana, Arial, Helvetica, sans-serif;
 270     font-size: 11px;
 271     color: #0054aa;
 272     font-weight: bold;
 273 }
 274 .box {
 275   border-color: #000000;
 276   border-style: solid;
 277   border-top-width: 1px;
 278   border-bottom-width: 1px;
 279   border-left-width: 1px;
 280   border-right-width: 1px;
 281 }
 282 a
 283 {
 284     color: #0000bb;
 285     text-decoration: none;
 286     font-family: Verdana, Arial, Helvetica, sans-serif;
 287     font-size: 11px;
 288 }
 289 a:hover
 290 {
 291     color: #ff0000;
 292 }
 293 #tablenav {
 294     font-family: Verdana, Arial, Helvetica, sans-serif;
 295     font-size: 11px;
 296 }
 297 #tablenav td
 298 {
 299     font-family: Verdana, Arial, Helvetica, sans-serif;
 300     font-size: 11px;
 301 }
 302 #tablenav th
 303 {
 304     font-family: Verdana, Arial, Helvetica, sans-serif;
 305     font-size: 11px;
 306     font-weight: bold;
 307 }
 308 #tablenav a
 309 {
 310     color: #0000bb;
 311     text-decoration: none;
 312     font-family: Verdana, Arial, Helvetica, sans-serif;
 313     font-size: 11px;
 314 }
 315 #tablenav a:hover
 316 {
 317     color: #ff0000;
 318 }
 319 .footer
 320 {
 321     font-family: Arial, Verdana, Helvetica, sans-serif;
 322     font-size: 9px;
 323     color: #888888;
 324 }
 325 ENDSTYLESHEET
 326 
 327   return $StyleSheetTags;
 328 }
 329 
 330 # Setup HTML table header...
 331 sub SetupHTMLTableHeader {
 332   my($TableHeader, $BorderWidth, $CellPadding, $CellSpacing, $Width, $Height);
 333 
 334   $BorderWidth = 1; $CellPadding = 2; $CellSpacing = 0; $Width = ""; $Height = "";
 335   if (@_ == 5) {
 336     ($BorderWidth, $CellPadding, $CellSpacing, $Width, $Height) = @_;
 337   }
 338   elsif (@_ == 4) {
 339     ($BorderWidth, $CellPadding, $CellSpacing, $Width) = @_;
 340   }
 341   elsif (@_ == 3) {
 342     ($BorderWidth, $CellPadding, $CellSpacing) = @_;
 343   }
 344   elsif (@_ == 2) {
 345     ($BorderWidth, $CellPadding) = @_;
 346   }
 347   elsif (@_ = 1) {
 348     ($BorderWidth) = @_;
 349   }
 350   $TableHeader = qq(<table border=$BorderWidth cellpadding=$CellPadding cellspacing=$CellSpacing);
 351   if ($Width) {
 352     $TableHeader .= qq( width=$Width);
 353   }
 354   if ($Height) {
 355     $TableHeader .= qq( height=$Height);
 356   }
 357   $TableHeader .= qq(>\n);
 358 
 359   return $TableHeader;
 360 }
 361 
 362 # Setup HTML table end...
 363 sub SetupHTMLTableEnd {
 364   my($TableEnd);
 365 
 366   $TableEnd=<<ENDTABLE;
 367 </table>
 368 ENDTABLE
 369 
 370   return $TableEnd;
 371 }
 372 
 373 # Setup HTML table column header...
 374 sub SetupHTMLTableColumnHeader {
 375   my($BgColor, $Width, $ColumnHeader);
 376 
 377   $BgColor = ""; $Width = "";
 378   if (@_ == 1) {
 379     ($BgColor) = @_;
 380   }
 381   elsif (@_ == 2) {
 382     ($BgColor, $Width) = @_;
 383   }
 384   $ColumnHeader = qq(<td);
 385   if ($BgColor) {
 386     $ColumnHeader .= qq( bgcolor="$BgColor")
 387   }
 388   if ($Width) {
 389     $ColumnHeader .= qq( width="$Width")
 390   }
 391   $ColumnHeader .= qq(>);
 392   return $ColumnHeader;
 393 }
 394 
 395 # Setup HTML table column end...
 396 sub SetupHTMLTableColumnEnd {
 397   my($ColumnEnd);
 398 
 399   $ColumnEnd = qq(</td>);
 400   return $ColumnEnd;
 401 }
 402 
 403 # Setup HTML table row header...
 404 sub SetupHTMLTableRowHeader {
 405   my($RowHeader, $HAlignment, $BgColor, $VAlignment);
 406 
 407   $HAlignment = "center"; $BgColor = ""; $VAlignment = "top";
 408   if (@_ == 3) {
 409     ($HAlignment, $BgColor, $VAlignment) = @_;
 410   }
 411   elsif (@_ == 2) {
 412     ($HAlignment, $BgColor) = @_;
 413   }
 414   elsif (@_ == 1) {
 415     ($HAlignment) = @_;
 416   }
 417   if ($BgColor) {
 418     $RowHeader = qq(<tr bgcolor="$BgColor" align="$HAlignment" valign="$VAlignment">);
 419   }
 420   else {
 421     $RowHeader = qq(<tr align="$HAlignment" valign="$VAlignment">);
 422   }
 423 
 424   return $RowHeader;
 425 }
 426 
 427 # Setup HTML table row end...
 428 sub SetupHTMLTableRowEnd {
 429   my($RowEnd);
 430 
 431   $RowEnd = qq(</tr>\n);
 432   return $RowEnd;
 433 }
 434 
 435 # Setup HTML table header values...
 436 sub SetupHTMLTableRowHeaderValue {
 437   my($HeaderValue, $Value);
 438 
 439   $Value = "";
 440   if (@_ >= 1) {
 441     ($Value) = @_;
 442   }
 443   if (defined $Value && length $Value) {
 444     $HeaderValue = qq(<th>$Value</th>);
 445   }
 446   else {
 447     $HeaderValue = qq(<th>&nbsp</th>);
 448   }
 449   return $HeaderValue;
 450 }
 451 
 452 # Setup HTML table row data values...
 453 sub SetupHTMLTableRowDataValue {
 454   my($RowValues, $Value, $BgColor, $FontColor, $FontBold, $FontBoldTag1, $FontBoldTag2);
 455 
 456   $Value = ""; $BgColor = ""; $FontColor = ""; $FontBold = "";
 457   if (@_ == 1) {
 458     ($Value) = @_;
 459   }
 460   elsif (@_ == 2) {
 461     ($Value, $BgColor) = @_;
 462   }
 463   elsif (@_ == 3) {
 464     ($Value, $BgColor, $FontColor) = @_;
 465   }
 466   elsif (@_ == 4) {
 467     ($Value, $BgColor, $FontColor, $FontBold) = @_;
 468   }
 469   if (!(defined $Value && length $Value)) {
 470     $Value = qq(&nbsp);
 471   }
 472   $FontBoldTag1 = ""; $FontBoldTag2 = "";
 473   if ($FontBold) {
 474     $FontBoldTag1 = qq(<b>);
 475     $FontBoldTag2 = qq(</b>);
 476   }
 477   if ($BgColor || $FontColor) {
 478     my ($BgColorTag, $FontTag1, $FontTag2);
 479 
 480     $BgColorTag = "";
 481     if ($BgColor) {
 482       $BgColorTag = qq( bgcolor="$BgColor");
 483     }
 484     $FontTag1 = ""; $FontTag2 = "";
 485     if ($FontColor) {
 486       $FontTag1 = qq(<font color="$FontColor">);
 487       $FontTag2 = qq(</font>);
 488     }
 489     if ($FontBold) {
 490       $RowValues = "<td" . $BgColorTag . ">" . $FontBoldTag1 . $FontTag1 . "$Value" . $FontTag2 . $FontBoldTag2 .  "</td>";
 491     }
 492     else {
 493       $RowValues = "<td" . $BgColorTag . ">" . $FontTag1 . "$Value" . $FontTag2 .  "</td>";
 494     }
 495   }
 496   elsif ($FontBold) {
 497     $RowValues = "<td>" . $FontBoldTag1 . "$Value" . $FontBoldTag2 . "</td>";
 498   }
 499   else {
 500     $RowValues = qq(<td>$Value</td>);
 501   }
 502   return $RowValues;
 503 }
 504 
 505 # Setup Java scripts command...
 506 sub SetupJavaScriptCmds {
 507   my(@JSCmdList) = @_;
 508   my($JSTags, $JSCmd);
 509 
 510   $JSTags = qq(<script>\n);
 511   for $JSCmd (@JSCmdList) {
 512     $JSTags .= qq($JSCmd\n);
 513   }
 514   $JSTags .= qq(</script>\n);
 515 
 516   return $JSTags;
 517 }
 518 
 519 # Setup Java script initialize command...
 520 sub SetupStrViewerJSInitCmd {
 521   my($StrViewerType, $CodeBase) = @_;
 522   my($JSTag);
 523 
 524   $JSTag = "";
 525   if ($StrViewerType eq "Jmol") {
 526     $JSTag = qq(<script>jmolInitialize("$CodeBase", "JmolApplet.jar");</script>\n);
 527   }
 528   elsif ($StrViewerType eq "ChemDrawPlugIn" || $StrViewerType eq "ChemDrawActiveX") {
 529     $JSTag = qq(<script>cd_includeWrapperFile("$CodeBase/");</script>\n);
 530   }
 531   elsif ($StrViewerType eq "Chem3DActiveX") {
 532   }
 533   return $JSTag;
 534 }
 535 
 536 
 537 # Setup Jmol applet...
 538 sub SetupStrViewerJmolApplet {
 539   my($MolString, $CodeBase, $ParamsMapRef, %ParamsMap, $AppletTags, $JavaScriptTags, $ReturnTags, $Name, $Code, $Archive, $Width, $Height, $ParamName, $ParamValue, $JSFileName, $UseJavaScript);
 540   my($ProgressBar, $ProgressColor, $BoxMessage, $BoxFgColor, $BoxBgColor, $BgColor, $JMolScript);
 541 
 542   $AppletTags = "";  $JavaScriptTags = ""; $ReturnTags = "";
 543   $ParamsMapRef = ""; %ParamsMap = ();
 544   $Name = "Jmol"; $Code = "JmolApplet"; $Archive = "JmolApplet.jar"; $Width = $StrViewerWidth; $Height = $StrViewerHeight;
 545   $ProgressBar = "true"; $ProgressColor = "#0000ff"; $BgColor = "#000000";
 546   $BoxMessage = "Setting up JmolApplet..."; $BoxFgColor = "#000000"; $BoxBgColor = "#ffffff";
 547   $UseJavaScript = 0; $JSFileName = "";
 548   $JMolScript = "select *; set frank off; wireframe on; spacefill off";
 549 
 550  PARAMS: {
 551     if (@_ == 3) { ($MolString, $CodeBase, $ParamsMapRef) = @_; last PARAMS; }
 552     ($MolString, $CodeBase) = @_;
 553   }
 554 
 555   if ($ParamsMapRef) {
 556     %ParamsMap = %$ParamsMapRef;
 557     if (exists $ParamsMap{usejavascript} ) { $JSFileName = $ParamsMap{usejavascript}; $UseJavaScript = 1; $ParamsMap{usejavascript} = ""; }
 558     if (exists $ParamsMap{name} ) { $Name = $ParamsMap{name}; $ParamsMap{name} = ""; }
 559     if (exists $ParamsMap{code} ) { $Code = $ParamsMap{code}; $ParamsMap{code} = ""; }
 560     # if (exists $ParamsMap{archive} ) { $Archive = $ParamsMap{archive}; $ParamsMap{archive} = ""; }
 561     if (exists $ParamsMap{archive} ) { $ParamsMap{archive} = ""; }
 562     if (exists $ParamsMap{height} ) { $Height = $ParamsMap{height}; $ParamsMap{height} = ""; }
 563     if (exists $ParamsMap{width} ) { $Width = $ParamsMap{width}; $ParamsMap{width} = ""; }
 564     if (exists $ParamsMap{progressbar} ) { $ProgressBar = $ParamsMap{progressbar}; $ParamsMap{progressbar} = ""; }
 565     if (exists $ParamsMap{progresscolor} ) { $ProgressColor = $ParamsMap{progresscolor}; $ParamsMap{progresscolor} = ""; }
 566     if (exists $ParamsMap{boxmessage} ) { $BoxMessage = $ParamsMap{boxmessage}; $ParamsMap{boxmessage} = ""; }
 567     if (exists $ParamsMap{script} ) { $JMolScript = $ParamsMap{script}; $ParamsMap{script} = ""; }
 568     if (exists $ParamsMap{bgcolor}) {
 569       $BgColor = $ParamsMap{bgcolor};
 570       if (length($BgColor)) {
 571         if ($BgColor =~ /black/i || $BgColor =~ /#000000/ ) {
 572           $BoxFgColor = "#ffffff";
 573           $BoxBgColor = "#000000";
 574         }
 575       }
 576     }
 577     if (exists $ParamsMap{boxbgcolor} ) { $BoxBgColor = $ParamsMap{boxbgcolor}; $ParamsMap{boxbgcolor} = ""; }
 578     if (exists $ParamsMap{boxfgcolor} ) { $BoxFgColor = $ParamsMap{boxfgcolor}; $ParamsMap{boxfgcolor} = ""; }
 579   }
 580 
 581   $MolString =~ s/(\r\n)|(\r)|(\n)/|/g;
 582   if ($UseJavaScript) {
 583     $JavaScriptTags = qq(\n<script>\n);
 584     my($Size) = ($Width > $Height ) ? $Width : $Height;
 585     $JavaScriptTags .= qq(var $Name = \n);
 586     my(@MolLines) = split /\|/, $MolString;
 587     my($LineIndex);
 588     $JavaScriptTags .= qq("$MolLines[0]\\n");
 589     for $LineIndex (1 .. $#MolLines) {
 590       $JavaScriptTags .= qq( + \n"$MolLines[$LineIndex]\\n");
 591     }
 592     $JavaScriptTags .= qq(;\n);
 593     $JavaScriptTags .= qq(jmolSetAppletColor("$BgColor", "$BoxBgColor", "$BoxFgColor", "$ProgressColor");\n);
 594     # "set frank off turns" off JMol logo. For wireframe display; use wireframe on; spacefill off...
 595     # $JavaScriptTags .= qq(jmolAppletInline($Size, $Name);\n);
 596     $JavaScriptTags .= qq(jmolAppletInline([$Width,$Height], $Name, \"$JMolScript\");\n);
 597     $JavaScriptTags .= qq(</script>\n);
 598     $ReturnTags = $JavaScriptTags;
 599   }
 600   else {
 601     # Setup applet header...
 602     $AppletTags = qq(\n<applet name="$Name" id="$Name" code="$Code" archive="$Archive" codebase="$CodeBase" width="$Width" height="$Height">\n);
 603 
 604     # Setup molecule data...
 605     $AppletTags .= qq(<param name="loadInline" value="$MolString">\n);
 606 
 607     # Setup prograss bar...
 608     $AppletTags .= qq(<param name="progressbar" value="$ProgressBar">\n<param name="progresscolor" value="$ProgressColor">\n<param name="boxmessage" value="$BoxMessage">\n<param name="boxbgcolor" value="$BoxBgColor">\n<param name="boxfgcolor" value="$BoxFgColor">\n);
 609 
 610     # "set frank off turns" off JMol logo. For wireframe display; use wireframe on; spacefill off...
 611     $AppletTags .= qq(<param name="script" value="$JMolScript">);
 612 
 613     #Setup other parameters...
 614     for $ParamName (sort keys %ParamsMap) {
 615       $ParamValue = $ParamsMap{$ParamName};
 616       if (length $ParamValue) {
 617         $AppletTags .= qq(<param name="$ParamName" value="$ParamValue">\n);
 618       }
 619     }
 620     #Finish it up...
 621     $AppletTags .= qq(</applet>\n);
 622     $ReturnTags = $AppletTags;
 623   }
 624   return $ReturnTags;
 625 }
 626 
 627 # Setup JME applet...
 628 sub SetupStrViewerJMEApplet {
 629   my($MolString, $CodeBase, $ParamsMapRef, %ParamsMap, $AppletTags, $Name, $Code, $Archive, $Width, $Height, $ParamName, $ParamValue);
 630   my($Options);
 631 
 632   $AppletTags = "";  $ParamsMapRef = ""; %ParamsMap = ();
 633   $Name = "JME"; $Code = "JME"; $Archive = "JME.jar"; $Width = $StrViewerWidth; $Height = $StrViewerHeight;
 634   $Options = "depict";
 635 
 636   if (@_ == 3) {
 637     ($MolString, $CodeBase, $ParamsMapRef) = @_;
 638   }
 639   else {
 640     ($MolString, $CodeBase) = @_;
 641   }
 642   $MolString =~ s/(\r\n)|(\r)|(\n)/|/g;
 643 
 644   if ($ParamsMapRef) {
 645     %ParamsMap = %$ParamsMapRef;
 646     if (exists $ParamsMap{name} ) { $Name = $ParamsMap{name}; $ParamsMap{name} = ""; }
 647     if (exists $ParamsMap{code} ) { $Code = $ParamsMap{code}; $ParamsMap{code} = ""; }
 648     if (exists $ParamsMap{archive} ) { $Archive = $ParamsMap{archive}; $ParamsMap{archive} = ""; }
 649     if (exists $ParamsMap{height} ) { $Height = $ParamsMap{height}; $ParamsMap{height} = ""; }
 650     if (exists $ParamsMap{width} ) { $Width = $ParamsMap{width}; $ParamsMap{width} = ""; }
 651     if (exists $ParamsMap{options} ) { $Options = $ParamsMap{options}; $ParamsMap{options} = ""; }
 652   }
 653 
 654   # Setup applet header...
 655   $AppletTags = qq(\n<applet name="$Name" id="$Name" code="$Code" archive="$Archive" codebase="$CodeBase" width="$Width" height="$Height">\n);
 656 
 657   # Setup molecule data...
 658   $AppletTags .= qq(<param name="mol" value="$MolString">\n<param name="options" value="$Options">\n);
 659 
 660   #Setup other parameters...
 661   for $ParamName (sort keys %ParamsMap) {
 662     $ParamValue = $ParamsMap{$ParamName};
 663     if (length $ParamValue) {
 664       $AppletTags .= qq(<param name="$ParamName" value="$ParamValue">\n);
 665     }
 666   }
 667 
 668   #Finish it up...
 669   $AppletTags .= qq(</applet>\n);
 670 
 671   return $AppletTags;
 672 }
 673 
 674 # Setup MarvinView applet...
 675 sub SetupStrViewerMarvinViewApplet {
 676   my($MolString, $CodeBase, $ParamsMapRef, %ParamsMap, $AppletTags, $JavaScriptTags, $ReturnTags, $Name, $Code, $Archive, $Width, $Height, $ParamName, $NavMode, $ParamValue, $JSFileName, $UseJavaScript, $MarvinJVM);
 677 
 678   $AppletTags = "";  $JavaScriptTags = ""; $ReturnTags = "";
 679   $ParamsMapRef = ""; %ParamsMap = ();
 680   $Name = "MView"; $Code = "MView"; $Archive = "marvin.jar"; $Width = $StrViewerWidth; $Height = $StrViewerHeight;
 681   $NavMode = "zoom";
 682   $UseJavaScript = 0; $JSFileName = ""; $MarvinJVM = "";
 683 
 684   if (@_ == 3) {
 685     ($MolString, $CodeBase, $ParamsMapRef) = @_;
 686   }
 687   else {
 688     ($MolString, $CodeBase) = @_;
 689   }
 690 
 691   if ($ParamsMapRef) {
 692     %ParamsMap = %$ParamsMapRef;
 693     if (exists $ParamsMap{usejavascript} ) { $JSFileName = $ParamsMap{usejavascript}; $UseJavaScript = 1; $ParamsMap{usejavascript} = ""; }
 694     if (exists $ParamsMap{marvin_jvm} ) { $MarvinJVM = $ParamsMap{marvin_jvm}; $ParamsMap{marvin_jvm} = ""; }
 695     if (exists $ParamsMap{name} ) { $Name = $ParamsMap{name}; $ParamsMap{name} = ""; }
 696     if (exists $ParamsMap{code} ) { $Code = $ParamsMap{code}; $ParamsMap{code} = ""; }
 697     if (exists $ParamsMap{archive} ) { $Archive = $ParamsMap{archive}; $ParamsMap{archive} = ""; }
 698     if (exists $ParamsMap{height} ) { $Height = $ParamsMap{height}; $ParamsMap{height} = ""; }
 699     if (exists $ParamsMap{width} ) { $Width = $ParamsMap{width}; $ParamsMap{width} = ""; }
 700     if (exists $ParamsMap{bgcolor}) {
 701       $ParamsMap{background} = "$ParamsMap{bgcolor}";
 702       $ParamsMap{molbg} = "$ParamsMap{bgcolor}";
 703       $ParamsMap{bgcolor} = "";
 704     }
 705     if (exists $ParamsMap{navmode}) {
 706       $NavMode = $ParamsMap{navmode};
 707       $ParamsMap{navmode} = "";
 708     }
 709   }
 710   $MolString =~ s/(\r\n)|(\r)|(\n)/\\/g;
 711   if ($UseJavaScript) {
 712     $JavaScriptTags = qq(\n<script>\n);
 713     $JavaScriptTags .= qq(var marvin_name = "$Name";\n);
 714     $JavaScriptTags .= qq(var marvin_jvm = "$MarvinJVM";\n);
 715 
 716     $JavaScriptTags .= qq(mview_begin("$CodeBase", $Width, $Height);\n);
 717 
 718     $JavaScriptTags .= qq(var $Name = \n);
 719     my(@MolLines) = split /\\/, $MolString;
 720     my($LineIndex);
 721     $JavaScriptTags .= qq("$MolLines[0]\\n");
 722     for $LineIndex (1 .. $#MolLines) {
 723       $JavaScriptTags .= qq( + \n"$MolLines[$LineIndex]\\n");
 724     }
 725     $JavaScriptTags .= qq(;\n);
 726     $JavaScriptTags .= qq(mview_param("mol", $Name);\n);
 727 
 728     $JavaScriptTags .= qq(mview_param("navmode", "$NavMode");\n);
 729 
 730     for $ParamName (sort keys %ParamsMap) {
 731       $ParamValue = $ParamsMap{$ParamName};
 732       if (length $ParamValue) {
 733         $JavaScriptTags .= qq(mview_param("$ParamName", "$ParamValue");\n);
 734       }
 735     }
 736     $JavaScriptTags .= qq(mview_end();\n);
 737     $JavaScriptTags .= qq(</script>\n);
 738     $ReturnTags = $JavaScriptTags;
 739   }
 740   else {
 741     # Setup applet header...
 742     $AppletTags = qq(\n<applet name="$Name" id="$Name" code="$Code" archive="$Archive" codebase="$CodeBase" width="$Width" height="$Height">\n);
 743 
 744     # Setup molecule data...
 745     $AppletTags .= qq(<param name="mol" value="$MolString">\n);
 746 
 747     $AppletTags .= qq(<param name="navmode" value="$NavMode">\n);
 748 
 749     #Setup other parameters...
 750     for $ParamName (sort keys %ParamsMap) {
 751       $ParamValue = $ParamsMap{$ParamName};
 752       if (length $ParamValue) {
 753         $AppletTags .= qq(<param name="$ParamName" value="$ParamValue">\n);
 754       }
 755     }
 756     $AppletTags .= qq(</applet>\n);
 757     $ReturnTags = $AppletTags;
 758   }
 759   return $ReturnTags;
 760 }
 761 
 762 # Setup MDL chime plug-in...
 763 sub SetupStrViewerChimePlugIn {
 764   my($MolFile, $ParamsMapRef, %ParamsMap, $Width, $Height, $ParamName, $ParamValue, $PlugInTags);
 765   my($Display2D);
 766 
 767   $PlugInTags = ""; $ParamsMapRef = ""; %ParamsMap = ();
 768   $Width = $StrViewerWidth; $Height = $StrViewerHeight;
 769   $Display2D = "true";
 770 
 771   if (@_ == 2) {
 772     ($MolFile, $ParamsMapRef) = @_;
 773   }
 774   else {
 775     ($MolFile) = @_;
 776   }
 777 
 778   if ($ParamsMapRef) {
 779     %ParamsMap = %$ParamsMapRef;
 780     if (exists $ParamsMap{height} ) { $Height = $ParamsMap{height}; $ParamsMap{height} = ""; }
 781     if (exists $ParamsMap{width} ) { $Width = $ParamsMap{width}; $ParamsMap{width} = ""; }
 782     if (exists $ParamsMap{display2d} ) { $Display2D = $ParamsMap{display2d}; $ParamsMap{display2d} = ""; }
 783   }
 784   # Start plug-in tag...
 785   $PlugInTags = qq(<embed src="$MolFile" width="$Width" height="$Height" display2d="$Display2D");
 786 
 787   #Setup other parameters...
 788   for $ParamName (sort keys %ParamsMap) {
 789     $ParamValue = $ParamsMap{$ParamName};
 790     if (length $ParamValue) {
 791       $PlugInTags .= qq( $ParamName="$ParamValue");
 792     }
 793   }
 794 
 795   # Finish it off...
 796   $PlugInTags .= qq( >);
 797 
 798   return $PlugInTags;
 799 }
 800 
 801 # Setup Accelrys ViewerActiveX controls...
 802 sub SetupStrViewerAccelrysActiveX {
 803   my($MolFile, $ParamsMapRef, %ParamsMap, $ActiveXTags, $Name, $Width, $Height, $ParamName, $ParamValue);
 804   my($ClassId, $Convert2DTo3D, $Style, $Mouse);
 805 
 806   $ActiveXTags = "";  $ParamsMapRef = ""; %ParamsMap = ();
 807   $Name = "ViewerActiveX"; $Width = $StrViewerWidth; $Height = $StrViewerHeight;
 808   $ClassId = "clsid:90690CB6-BC07-11D4-AEF7-0050DA948176";
 809   $Convert2DTo3D = "0";
 810   $Mouse = 4;
 811 
 812   if (@_ == 2) {
 813     ($MolFile, $ParamsMapRef) = @_;
 814   }
 815   else {
 816     ($MolFile) = @_;
 817   }
 818 
 819   if ($ParamsMapRef) {
 820     %ParamsMap = %$ParamsMapRef;
 821     if (exists $ParamsMap{classid} ) { $ClassId = $ParamsMap{classid}; $ParamsMap{classid} = ""; }
 822     if (exists $ParamsMap{name} ) { $Name = $ParamsMap{name}; $ParamsMap{name} = ""; }
 823     if (exists $ParamsMap{height} ) { $Height = $ParamsMap{height}; $ParamsMap{height} = ""; }
 824     if (exists $ParamsMap{width} ) { $Width = $ParamsMap{width}; $ParamsMap{width} = ""; }
 825     if (exists $ParamsMap{Convert2Dto3D} ) { $Convert2DTo3D = $ParamsMap{Convert2Dto3D}; $ParamsMap{Convert2Dto3D} = ""; }
 826     if (exists $ParamsMap{Mouse} ) { $Mouse = $ParamsMap{Mouse}; $ParamsMap{Mouse} = ""; }
 827     if (exists $ParamsMap{bgcolor} ) {
 828       my($BgColor) = $ParamsMap{bgcolor};
 829       $ParamsMap{bgcolor} = "";
 830       # Get OLE color value: &aabbggrr&
 831       # Set it to white for now...
 832       $BgColor = "16777215";
 833       $ParamsMap{BackColor} = "$BgColor";
 834     }
 835   }
 836   $Style = qq(style="height: ) . $Height . qq(px; width: ) . $Width . qq(px");
 837 
 838   # Setup object header...
 839   $ActiveXTags = qq(\n<object id="$Name" classid="$ClassId" $Style>\n);
 840 
 841   # Setup molecule data...
 842   $ActiveXTags .= qq(<param name="Source" value="$MolFile">\n<param name="Mouse" value="$Mouse">\n<param name="Convert2Dto3D" value="$Convert2DTo3D">\n);
 843 
 844   #Setup other parameters...
 845   for $ParamName (sort keys %ParamsMap) {
 846     $ParamValue = $ParamsMap{$ParamName};
 847     if (length $ParamValue) {
 848       $ActiveXTags .= qq(<param name="$ParamName" value="$ParamValue">\n);
 849     }
 850   }
 851 
 852   # Finish it off...
 853   $ActiveXTags .= qq(</object>\n);
 854 
 855   return $ActiveXTags;
 856 }
 857 
 858 # Setup Chem3D ActiveX 8.0 control...
 859 sub SetupStrViewerChem3DActiveX {
 860   my($MolFile, $ParamsMapRef, %ParamsMap, $ActiveXTags, $JavaScriptTags, $ReturnTags, $Name, $Width, $Height, $ParamName, $ParamValue);
 861   my($ClassId, $Style, $DisplayType, $RotationBars, $MovieController, $JSFileName, $UseJavaScript);
 862 
 863   $ActiveXTags = ""; $JavaScriptTags = ""; $ReturnTags = "";
 864   $ParamsMapRef = ""; %ParamsMap = ();
 865   $Name = "Chem3D"; $Width = $StrViewerWidth; $Height = $StrViewerHeight;
 866   $ClassId = "clsid:B7A6B8E4-3E8B-4D18-8F8F-B4057EFC784B";
 867   $DisplayType = "Ball&Stick";
 868   $RotationBars = "false";
 869   $MovieController = "false";
 870 
 871   if (@_ == 2) {
 872     ($MolFile, $ParamsMapRef) = @_;
 873   }
 874   else {
 875     ($MolFile) = @_;
 876   }
 877 
 878   if ($ParamsMapRef) {
 879     %ParamsMap = %$ParamsMapRef;
 880     if (exists $ParamsMap{usejavascript} ) { $JSFileName = $ParamsMap{usejavascript}; $UseJavaScript = 1; $ParamsMap{usejavascript} = ""; }
 881     if (exists $ParamsMap{classid} ) { $ClassId = $ParamsMap{classid}; $ParamsMap{classid} = ""; }
 882     if (exists $ParamsMap{name} ) { $Name = $ParamsMap{name}; $ParamsMap{name} = ""; }
 883     if (exists $ParamsMap{height} ) { $Height = $ParamsMap{height}; $ParamsMap{height} = ""; }
 884     if (exists $ParamsMap{width} ) { $Width = $ParamsMap{width}; $ParamsMap{width} = ""; }
 885     if (exists $ParamsMap{displaytype} ) { $DisplayType = $ParamsMap{displaytype}; $ParamsMap{displaytype} = ""; }
 886     if (exists $ParamsMap{rotationbars} ) { $RotationBars = $ParamsMap{rotationbars}; $ParamsMap{rotationbars} = ""; }
 887     if (exists $ParamsMap{moviecontroller} ) { $MovieController = $ParamsMap{moviecontroller}; $ParamsMap{moviecontroller} = ""; }
 888   }
 889   $Style = qq(style="height: ) . $Height . qq(px; width: ) . $Width . qq(px");
 890 
 891   if ($UseJavaScript) {
 892     #Setup parameters...
 893     my($Params) = "";
 894     for $ParamName (sort keys %ParamsMap) {
 895       $ParamValue = $ParamsMap{$ParamName};
 896       if (length $ParamValue) {
 897         $Params .= qq( $ParamName='$ParamValue');
 898       }
 899     }
 900     $JavaScriptTags = qq(\n<script>\n);
 901     $JavaScriptTags .= qq(c3d_insert3dStr("name='$Name' src='$MolFile' width='$Width' height='$Height' displaytype='$DisplayType' rotation_bars_visible='$RotationBars' movie_controller_visible='$MovieController' $Params");\n);
 902     $JavaScriptTags .= qq(</script>\n);
 903     $ReturnTags = $JavaScriptTags;
 904   }
 905   else {
 906     # Setup object header...
 907     $ActiveXTags = qq(\n<object id="$Name" classid="$ClassId" $Style>\n);
 908 
 909     # Setup molecule data...
 910     $ActiveXTags .= qq(<param name="src" value="$MolFile">\n<param name="displaytype" value="$DisplayType">\n<param name="rotationbars" value="$RotationBars">\n<param name="moviecontroller" value="$MovieController">\n);
 911 
 912     #Setup other parameters...
 913     for $ParamName (sort keys %ParamsMap) {
 914       $ParamValue = $ParamsMap{$ParamName};
 915       if (length $ParamValue) {
 916         $ActiveXTags .= qq(<param name="$ParamName" value="$ParamValue">\n);
 917       }
 918     }
 919     $ActiveXTags .= qq(</object>\n);
 920     $ReturnTags = $ActiveXTags;
 921   }
 922   return $ReturnTags;
 923 }
 924 
 925 # Setup ChemDraw ActiveX 8.0 control...
 926 # Problems: "bgcolor" parameter doesn't work.
 927 sub SetupStrViewerChemDrawActiveX {
 928   my($MolFile, $ParamsMapRef, %ParamsMap, $ActiveXTags, $JavaScriptTags, $ReturnTags, $Name, $Width, $Height, $ParamName, $ParamValue);
 929   my($ClassId, $Style, $ViewOnly, $ShrinkToFit, $ShowToolsWhenVisible, $JSFileName, $UseJavaScript);
 930 
 931   $ActiveXTags = "";  $JavaScriptTags = ""; $ReturnTags = "";
 932   $ParamsMapRef = ""; %ParamsMap = ();
 933   $Name = "ChemDraw"; $Width = $StrViewerWidth; $Height = $StrViewerHeight;
 934   $ClassId = "clsid:51A649C4-3E3D-4557-9BD8-B14C0AD44B0C";
 935   $ViewOnly = "1"; $JavaScriptTags = "";
 936   $ShrinkToFit = "1";
 937   $ShowToolsWhenVisible = "1";
 938 
 939   if (@_ == 2) {
 940     ($MolFile, $ParamsMapRef) = @_;
 941   }
 942   else {
 943     ($MolFile) = @_;
 944   }
 945 
 946   if ($ParamsMapRef) {
 947     %ParamsMap = %$ParamsMapRef;
 948     if (exists $ParamsMap{usejavascript} ) { $JSFileName = $ParamsMap{usejavascript}; $UseJavaScript = 1; $ParamsMap{usejavascript} = ""; }
 949     if (exists $ParamsMap{classid} ) { $ClassId = $ParamsMap{classid}; $ParamsMap{classid} = ""; }
 950     if (exists $ParamsMap{name} ) { $Name = $ParamsMap{name}; $ParamsMap{name} = ""; }
 951     if (exists $ParamsMap{height} ) { $Height = $ParamsMap{height}; $ParamsMap{height} = ""; }
 952     if (exists $ParamsMap{width} ) { $Width = $ParamsMap{width}; $ParamsMap{width} = ""; }
 953     if (exists $ParamsMap{ViewOnly} ) { $ViewOnly = $ParamsMap{ViewOnly}; $ParamsMap{ViewOnly} = ""; }
 954     if (exists $ParamsMap{ShrinkToFit} ) { $ShrinkToFit = $ParamsMap{ShrinkToFit}; $ParamsMap{ShrinkToFit} = ""; }
 955     if (exists $ParamsMap{ShowToolsWhenVisible} ) { $ShowToolsWhenVisible = $ParamsMap{ShowToolsWhenVisible}; $ParamsMap{ShowToolsWhenVisible} = ""; }
 956   }
 957   if ($UseJavaScript) {
 958     #Setup parameter...
 959     my($Params) = "";
 960     for $ParamName (sort keys %ParamsMap) {
 961       $ParamValue = $ParamsMap{$ParamName};
 962       if (length $ParamValue) {
 963         $Params .= qq( $ParamName='$ParamValue');
 964       }
 965     }
 966     $JavaScriptTags = qq(\n<script>\n);
 967     $JavaScriptTags .= qq(cd_insertObjectStr("name='$Name' src='$MolFile' width='$Width' height='$Height' shrinktofit='$ShrinkToFit' viewonly='$ViewOnly' $Params");\n);
 968     $JavaScriptTags .= qq(</script>\n);
 969     $ReturnTags = $JavaScriptTags;
 970   }
 971   else {
 972     $Style = qq(style="height: ) . $Height . qq(px; width: ) . $Width . qq(px");
 973 
 974     # Setup object header...
 975     $ActiveXTags = qq(\n<object id="$Name" classid="$ClassId" $Style>\n);
 976 
 977     # Setup molecule data...
 978     $ActiveXTags .= qq(<param name="SourceURL" value="$MolFile">\n<param name="ShrinkToFit" value="$ShrinkToFit">\n<param name="ViewOnly" value="$ViewOnly">\n<param name="ShowToolsWhenVisible" value="$ShowToolsWhenVisible">\n);
 979 
 980     #Setup other parameters...
 981     for $ParamName (sort keys %ParamsMap) {
 982       $ParamValue = $ParamsMap{$ParamName};
 983       if (length $ParamValue) {
 984         $ActiveXTags .= qq(<param name="$ParamName" value="$ParamValue">\n);
 985       }
 986     }
 987     $ActiveXTags .= qq(</object>\n);
 988     $ReturnTags = $ActiveXTags;
 989   }
 990   return $ReturnTags;
 991 }
 992 
 993 # Setup ChemDraw plug-in used for Netscape browsers...
 994 # Problems: "bgcolor" parameter doesn't work.
 995 sub SetupStrViewerChemDrawPlugIn {
 996   my($MolFile, $Name, $ParamsMapRef, %ParamsMap, $Width, $Height, $ParamName, $ParamValue, $PlugInTags, $JavaScriptTags, $ReturnTags,);
 997   my($MimeType, $ViewOnly, $ShrinkToFit, $ShowToolsWhenVisible, $JSFileName, $UseJavaScript);
 998 
 999   $Name = "ChemDraw"; $PlugInTags = ""; $ParamsMapRef = ""; %ParamsMap = ();
1000   $Width = $StrViewerWidth; $Height = $StrViewerHeight;
1001   $MimeType = "chemical/x-mdl-molfile";
1002   $ViewOnly = "1";
1003   $ShrinkToFit = "1";
1004   $ShowToolsWhenVisible = "1"; $JavaScriptTags = "";
1005 
1006   if (@_ == 2) {
1007     ($MolFile, $ParamsMapRef) = @_;
1008   }
1009   else {
1010     ($MolFile) = @_;
1011   }
1012 
1013   if ($ParamsMapRef) {
1014     %ParamsMap = %$ParamsMapRef;
1015     if (exists $ParamsMap{usejavascript} ) { $JSFileName = $ParamsMap{usejavascript}; $UseJavaScript = 1; $ParamsMap{usejavascript} = ""; }
1016     if (exists $ParamsMap{height} ) { $Height = $ParamsMap{height}; $ParamsMap{height} = ""; }
1017     if (exists $ParamsMap{width} ) { $Width = $ParamsMap{width}; $ParamsMap{width} = ""; }
1018     if (exists $ParamsMap{type} ) { $MimeType = $ParamsMap{type}; $ParamsMap{type} = ""; }
1019     if (exists $ParamsMap{viewonly} ) { $ViewOnly = $ParamsMap{viewonly}; $ParamsMap{viewonly} = ""; }
1020     if (exists $ParamsMap{shrinktofit} ) { $ShrinkToFit = $ParamsMap{shrinktofit}; $ParamsMap{shrinktofit} = ""; }
1021     if (exists $ParamsMap{showtoolswhenvisible} ) { $ShowToolsWhenVisible = $ParamsMap{showtoolswhenvisible}; $ParamsMap{showtoolswhenvisible} = ""; }
1022   }
1023   if ($UseJavaScript) {
1024     $JavaScriptTags = qq(\n<script>\n);
1025     $JavaScriptTags .= qq(cd_insertObjectStr("name='$Name' src='$MolFile' type='$MimeType' width='$Width' height='$Height' shrinktofit='$ShrinkToFit' viewonly='$ViewOnly'");\n);
1026     $JavaScriptTags .= qq(</script>\n);
1027     $ReturnTags = $JavaScriptTags;
1028   }
1029   else {
1030     # Start plug-in tag...
1031     $PlugInTags = qq(<embed src="$MolFile" width="$Width" height="$Height" type="$MimeType" viewonly="$ViewOnly" shrinktofit="$ShrinkToFit" showtoolswhenvisible=''$ShowToolsWhenVisible");
1032 
1033     #Setup other parameters...
1034     for $ParamName (sort keys %ParamsMap) {
1035       $ParamValue = $ParamsMap{$ParamName};
1036       if (length $ParamValue) {
1037         $PlugInTags .= qq(" $ParamName"="$ParamValue");
1038       }
1039     }
1040     # Finish it off...
1041     $PlugInTags .= qq( >);
1042     $ReturnTags = $PlugInTags;
1043   }
1044 
1045   return $ReturnTags;
1046 }
1047 
1048