/*
#===============================================================================
#
#         FILE:  pmp_jmol.js
#
#        USAGE:  ---
#
#      PURPOSE:  JavaScript - jmol Routines
#
#      OPTIONS:  ---
#      RETURNS:  ---
# REQUIREMENTS:  ---
#     COMMENTS:
#
#       AUTHOR:  juergen
#      COMPANY:  SIB & Biozentrum University of Basel
#      VERSION:  $version$
#      CREATED:  7:16:08 PM Oct 20, 2010
#     REVISION:  $rev$
#===============================================================================
*/
 //make sure this colour table matches the one used in patterson_comparison.sh for gnuplot
function getColourPalette() {

  var colours = new Array();
  colours[0]  = "[x0A0A0A]"; //fix for: jmol renders black x000000 as transparent in atialias mode
  colours[1]  = "[x0000ff]";
  colours[2]  = "[x00ff00]";
  colours[3]  = "[xff0000]";
  colours[4]  = "[xffa500]";
  colours[5]  = "[xbebebe]";
  colours[6]  = "[xdaa520]";
  colours[7]  = "[x00ffff]";
  colours[8]  = "[xff00ff]";
  colours[9]  = "[xffff00]";
  colours[10] = "[x90ee90]";
  colours[11] = "[x008b8b]";
  colours[12] = "[xadd8e6]";
  colours[13] = "[x9400d3]";
  colours[14] = "[xa03232]";
  colours[15] = "[xffd700]";
  colours[16] = "[x87ceeb]";
  colours[17] = "[x4d4d4d]";
  colours[18] = "[xb3b3b3]";
  colours[19] = "[xf0e68c]";
  colours[20] = "[xa52a2a]";
  colours[21] = "[xee82ee]";
  colours[22] = "[xdda0dd]";
  colours[23] = "[x2e8b57]";
  colours[24] = "[x000080]";
  colours[25] = "[xf5f5dc]";
  colours[26] = "[xc8c800]";
  colours[27] = "[x8b0000]";
  colours[28] = "[x40e0d0]";
  colours[29] = "[x1a1a1a]";
  colours[30] = "[xdda0dd]";
  colours[31] = "[x2e8b57]";
  colours[32] = "[x000080]";
  colours[33] = "[xf5f5dc]";//CHECK colours
  colours[34] = "[xc8c800]";
  colours[35] = "[x8b0000]";
  colours[36] = "[x40e0d0]";
  colours[37] = "[x1a1a1a]";
  for (i=38;i<300;++i) {
    colours[i]="[x40e0d0]"; //dummy colours preventing js to fail
  }

  return colours;
}

function createJmolSelectionString(pdbindices){
  var mycolours=getColourPalette();
  var selectionString='';
  for (i=0;i<pdbindices.length;++i)
  {
    selectionString += "select "+(i+1)+".1;color "+mycolours[pdbindices[i]-1]+";select  "+(i+1)+".1 and (ATOMNO==1);label N;";
    
        //~ selectionString += "select "+(i+1)+".1;color "+mycolours[pdbindices[i]-1]+";select  "+(i+1)+".1 and ((ATOMNO==1) OR (ATOMNO==2));dipole mydip"+i+" (atomno==1) (atomno==3) width 1 nocross;color dipoles translucent"+mycolours[pdbindices[i]-1]+" ;";
  }
  return selectionString;
}

