/*
 * Javascript functions that manage
 * communication with AstexViewer.
 */

function toggle(s){
  document.av.execute('molecule display ' + s + ' toggle;');
}

function object(s){
  document.av.execute('object display ' + s + ' toggle;');
}

function av_execute(command){
  document.av.execute(command);
  window.status = command;
}

function av_lipophilicity(obj){
  av_execute("run 'lipophilicity.properties';");
  av_execute("object '" + obj +"' texture lipophilicity u 7.0 aminoacid;");
}

function av_texture(obj, tex){
  if(tex == 'off'){
    av_execute("object '" + obj + "' texture 'off';");
  }else{
    if(tex == 'simple'){
      av_execute("texture '" + tex + "' simple;");
    }else{
      av_execute("texture load '" + tex + "' '" + tex + "';");
    }
    av_execute("object '" + obj + "' texture '" + tex + "';");
  }
}

function av_transparency(obj, tr){
  av_execute("object '" + obj + "' transparency " + tr + ";");
}

function av_display(obj, tr){
  var command = "object display '" + obj + "' " + tr + ";";
  av_execute(command);
}

function av_colour(obj, tr){
  var command = "object '" + obj + "' color " + tr + ";";
  av_execute(command);
}

function av_background(tr){
  var command = "background '" + tr + "';";
  av_execute(command);
}





/*
 * Javascript functions that manage interaction with
 * controls on the page.
 */




/* Transparancy of surfaces */



function js_transparency_pose1(sel){
  var val = sel.options[sel.selectedIndex].value;
  val = Math.round(val * 2.55);
  av_transparency('pose1_surface', val);
}
function js_transparency_pose2(sel){
  var val = sel.options[sel.selectedIndex].value;
  val = Math.round(val * 2.55);
  av_transparency('pose2_surface', val);
}
function js_transparency_pose3(sel){
  var val = sel.options[sel.selectedIndex].value;
  val = Math.round(val * 2.55);
  av_transparency('pose3_surface', val);
}
function js_transparency_pose4(sel){
  var val = sel.options[sel.selectedIndex].value;
  val = Math.round(val * 2.55);
  av_transparency('pose4_surface', val);
}
function js_transparency_pose5(sel){
  var val = sel.options[sel.selectedIndex].value;
  val = Math.round(val * 2.55);
  av_transparency('pose5_surface', val);
}
function js_transparency_pose6(sel){
  var val = sel.options[sel.selectedIndex].value;
  val = Math.round(val * 2.55);
  av_transparency('pose6_surface', val);
}
function js_transparency_pose7(sel){
  var val = sel.options[sel.selectedIndex].value;
  val = Math.round(val * 2.55);
  av_transparency('pose7_surface', val);
}
function js_transparency_pose8(sel){
  var val = sel.options[sel.selectedIndex].value;
  val = Math.round(val * 2.55);
  av_transparency('pose8_surface', val);
}
function js_transparency_pose9(sel){
  var val = sel.options[sel.selectedIndex].value;
  val = Math.round(val * 2.55);
  av_transparency('pose9_surface', val);
}
function js_transparency_pose10(sel){
  var val = sel.options[sel.selectedIndex].value;
  val = Math.round(val * 2.55);
  av_transparency('pose10_surface', val);
}
function js_transparency_pose11(sel){
  var val = sel.options[sel.selectedIndex].value;
  val = Math.round(val * 2.55);
  av_transparency('pose11_surface', val);
}
function js_transparency_pose12(sel){
  var val = sel.options[sel.selectedIndex].value;
  val = Math.round(val * 2.55);
  av_transparency('pose12_surface', val);
}
function js_transparency_pose13(sel){
  var val = sel.options[sel.selectedIndex].value;
  val = Math.round(val * 2.55);
  av_transparency('pose13_surface', val);
}
function js_transparency_pose14(sel){
  var val = sel.options[sel.selectedIndex].value;
  val = Math.round(val * 2.55);
  av_transparency('pose14_surface', val);
}
function js_transparency_pose15(sel){
  var val = sel.options[sel.selectedIndex].value;
  val = Math.round(val * 2.55);
  av_transparency('pose15_surface', val);
}
function js_transparency_pose16(sel){
  var val = sel.options[sel.selectedIndex].value;
  val = Math.round(val * 2.55);
  av_transparency('pose16_surface', val);
}
function js_transparency_pose17(sel){
  var val = sel.options[sel.selectedIndex].value;
  val = Math.round(val * 2.55);
  av_transparency('pose17_surface', val);
}
function js_transparency_pose18(sel){
  var val = sel.options[sel.selectedIndex].value;
  val = Math.round(val * 2.55);
  av_transparency('pose18_surface', val);
}
function js_transparency_pose19(sel){
  var val = sel.options[sel.selectedIndex].value;
  val = Math.round(val * 2.55);
  av_transparency('pose19_surface', val);
}
function js_transparency_pose20(sel){
  var val = sel.options[sel.selectedIndex].value;
  val = Math.round(val * 2.55);
  av_transparency('pose20_surface', val);
}




/* Make surfaces */



function js_pose1_surface(obj){
    if(obj.checked){
    if(!obj.surface){
      av_execute('surface -solid true pose1_surface white molecule mol1;');
      obj.surface = true;
    }else{
      av_display('pose1_surface', 'on');
    }
  }else{
    av_display('pose1_surface', 'off');
  }
}
function js_pose2_surface(obj){
    if(obj.checked){
    if(!obj.surface){
      av_execute('surface -solid true pose2_surface white molecule mol2;');
      obj.surface = true;
    }else{
      av_display('pose2_surface', 'on');
    }
  }else{
    av_display('pose2_surface', 'off');
  }
}
function js_pose3_surface(obj){
    if(obj.checked){
    if(!obj.surface){
      av_execute('surface -solid true pose3_surface white molecule mol3;');
      obj.surface = true;
    }else{
      av_display('pose3_surface', 'on');
    }
  }else{
    av_display('pose3_surface', 'off');
  }
}
function js_pose4_surface(obj){
    if(obj.checked){
    if(!obj.surface){
      av_execute('surface -solid true pose4_surface white molecule mol4;');
      obj.surface = true;
    }else{
      av_display('pose4_surface', 'on');
    }
  }else{
    av_display('pose4_surface', 'off');
  }
}
function js_pose5_surface(obj){
    if(obj.checked){
    if(!obj.surface){
      av_execute('surface -solid true pose5_surface white molecule mol5;');
      obj.surface = true;
    }else{
      av_display('pose5_surface', 'on');
    }
  }else{
    av_display('pose5_surface', 'off');
  }
}
function js_pose6_surface(obj){
    if(obj.checked){
    if(!obj.surface){
      av_execute('surface -solid true pose6_surface white molecule mol6;');
      obj.surface = true;
    }else{
      av_display('pose6_surface', 'on');
    }
  }else{
    av_display('pose6_surface', 'off');
  }
}
function js_pose7_surface(obj){
    if(obj.checked){
    if(!obj.surface){
      av_execute('surface -solid true pose7_surface white molecule mol7;');
      obj.surface = true;
    }else{
      av_display('pose7_surface', 'on');
    }
  }else{
    av_display('pose7_surface', 'off');
  }
}
function js_pose8_surface(obj){
    if(obj.checked){
    if(!obj.surface){
      av_execute('surface -solid true pose8_surface white molecule mol8;');
      obj.surface = true;
    }else{
      av_display('pose8_surface', 'on');
    }
  }else{
    av_display('pose8_surface', 'off');
  }
}
function js_pose9_surface(obj){
    if(obj.checked){
    if(!obj.surface){
      av_execute('surface -solid true pose9_surface white molecule mol9;');
      obj.surface = true;
    }else{
      av_display('pose9_surface', 'on');
    }
  }else{
    av_display('pose9_surface', 'off');
  }
}
function js_pose10_surface(obj){
    if(obj.checked){
    if(!obj.surface){
      av_execute('surface -solid true pose10_surface white molecule mol10;');
      obj.surface = true;
    }else{
      av_display('pose10_surface', 'on');
    }
  }else{
    av_display('pose10_surface', 'off');
  }
}
function js_pose11_surface(obj){
    if(obj.checked){
    if(!obj.surface){
      av_execute('surface -solid true pose11_surface white molecule mol11;');
      obj.surface = true;
    }else{
      av_display('pose11_surface', 'on');
    }
  }else{
    av_display('pose11_surface', 'off');
  }
}
function js_pose12_surface(obj){
    if(obj.checked){
    if(!obj.surface){
      av_execute('surface -solid true pose12_surface white molecule mol12;');
      obj.surface = true;
    }else{
      av_display('pose12_surface', 'on');
    }
  }else{
    av_display('pose12_surface', 'off');
  }
}
function js_pose13_surface(obj){
    if(obj.checked){
    if(!obj.surface){
      av_execute('surface -solid true pose13_surface white molecule mol13;');
      obj.surface = true;
    }else{
      av_display('pose13_surface', 'on');
    }
  }else{
    av_display('pose13_surface', 'off');
  }
}
function js_pose14_surface(obj){
    if(obj.checked){
    if(!obj.surface){
      av_execute('surface -solid true pose14_surface white molecule mol14;');
      obj.surface = true;
    }else{
      av_display('pose14_surface', 'on');
    }
  }else{
    av_display('pose14_surface', 'off');
  }
}
function js_pose15_surface(obj){
    if(obj.checked){
    if(!obj.surface){
      av_execute('surface -solid true pose15_surface white molecule mol15;');
      obj.surface = true;
    }else{
      av_display('pose15_surface', 'on');
    }
  }else{
    av_display('pose15_surface', 'off');
  }
}
function js_pose16_surface(obj){
    if(obj.checked){
    if(!obj.surface){
      av_execute('surface -solid true pose16_surface white molecule mol16;');
      obj.surface = true;
    }else{
      av_display('pose16_surface', 'on');
    }
  }else{
    av_display('pose16_surface', 'off');
  }
}
function js_pose17_surface(obj){
    if(obj.checked){
    if(!obj.surface){
      av_execute('surface -solid true pose17_surface white molecule mol17;');
      obj.surface = true;
    }else{
      av_display('pose17_surface', 'on');
    }
  }else{
    av_display('pose17_surface', 'off');
  }
}
function js_pose18_surface(obj){
    if(obj.checked){
    if(!obj.surface){
      av_execute('surface -solid true pose18_surface white molecule mol18;');
      obj.surface = true;
    }else{
      av_display('pose18_surface', 'on');
    }
  }else{
    av_display('pose18_surface', 'off');
  }
}
function js_pose19_surface(obj){
    if(obj.checked){
    if(!obj.surface){
      av_execute('surface -solid true pose19_surface white molecule mol19;');
      obj.surface = true;
    }else{
      av_display('pose19_surface', 'on');
    }
  }else{
    av_display('pose19_surface', 'off');
  }
}
function js_pose20_surface(obj){
    if(obj.checked){
    if(!obj.surface){
      av_execute('surface -solid true pose20_surface white molecule mol20;');
      obj.surface = true;
    }else{
      av_display('pose20_surface', 'on');
    }
  }else{
    av_display('pose20_surface', 'off');
  }
}






/* Atom displays */





function js_atomcolour(sel){
  var val = sel.options[sel.selectedIndex].value;
  av_execute(val);
}

function js_atoms(obj){
  if(obj.checked){
    av_execute('display lines on not solvent;');
  }else{
    av_execute('display lines off not solvent;');
  }
}

function js_solvent(obj){
  if(obj.checked){
    av_execute('display lines on solvent;');
  }else{
    av_execute('display lines off solvent;');
  }
}


function js_spheres(obj){
  if(obj.checked){
    av_execute('display spheres aminoacid;');
  }else{
    av_execute('display spheres none;');
  }
}







/* Atom rendering*/





function js_atomstyle_pose1(sel){
  var val = sel.options[sel.selectedIndex].value;
    av_execute('display lines on molecule mol1;');
    av_execute('display sticks off molecule mol1;');
    av_execute('display cylinders off molecule mol1;');
    av_execute('display spheres off molecule mol1;');
    if(val=='1'){
      av_execute('bond_width '+ val + ' molecule mol1;');
    }else if(val=='2'){
      av_execute('bond_width '+ val + ' molecule mol1;');
    }else if(val=='3'){
      av_execute('bond_width '+ val + ' molecule mol1;');
    }else{
      av_execute('display '+ val + ' molecule mol1;');
    }
}
function js_atomstyle_pose2(sel){
  var val = sel.options[sel.selectedIndex].value;
    av_execute('display lines on molecule mol2;');
    av_execute('display sticks off molecule mol2;');
    av_execute('display cylinders off molecule mol2;');
    av_execute('display spheres off molecule mol1;');
    if(val=='1'){
      av_execute('bond_width '+ val + ' molecule mol2;');
    }else if(val=='2'){
      av_execute('bond_width '+ val + ' molecule mol2;');
    }else if(val=='3'){
      av_execute('bond_width '+ val + ' molecule mol2;');
    }else{
      av_execute('display '+ val + ' molecule mol2;');
    }
}
function js_atomstyle_pose3(sel){
  var val = sel.options[sel.selectedIndex].value;
    av_execute('display lines on molecule mol3;');
    av_execute('display sticks off molecule mol3;');
    av_execute('display cylinders off molecule mol3;');
    av_execute('display spheres off molecule mol3;');
    if(val=='1'){
      av_execute('bond_width '+ val + ' molecule mol3;');
    }else if(val=='2'){
      av_execute('bond_width '+ val + ' molecule mol3;');
    }else if(val=='3'){
      av_execute('bond_width '+ val + ' molecule mol3;');
    }else{
      av_execute('display '+ val + ' molecule mol3;');
    }
}
function js_atomstyle_pose4(sel){
  var val = sel.options[sel.selectedIndex].value;
    av_execute('display lines on molecule mol4;');
    av_execute('display sticks off molecule mol4;');
    av_execute('display cylinders off molecule mol4;');
    av_execute('display spheres off molecule mol4;');
    if(val=='1'){
      av_execute('bond_width '+ val + ' molecule mol4;');
    }else if(val=='2'){
      av_execute('bond_width '+ val + ' molecule mol4;');
    }else if(val=='3'){
      av_execute('bond_width '+ val + ' molecule mol4;');
    }else{
      av_execute('display '+ val + ' molecule mol4;');
    }
}
function js_atomstyle_pose5(sel){
  var val = sel.options[sel.selectedIndex].value;
    av_execute('display lines on molecule mol5;');
    av_execute('display sticks off molecule mol5;');
    av_execute('display cylinders off molecule mol5;');
    av_execute('display spheres off molecule mol5;');
    if(val=='1'){
      av_execute('bond_width '+ val + ' molecule mol5;');
    }else if(val=='2'){
      av_execute('bond_width '+ val + ' molecule mol5;');
    }else if(val=='3'){
      av_execute('bond_width '+ val + ' molecule mol5;');
    }else{
      av_execute('display '+ val + ' molecule mol5;');
    }
}
function js_atomstyle_pose6(sel){
  var val = sel.options[sel.selectedIndex].value;
    av_execute('display lines on molecule mol6;');
    av_execute('display sticks off molecule mol6;');
    av_execute('display cylinders off molecule mol6;');
    av_execute('display spheres off molecule mol6;');
    if(val=='1'){
      av_execute('bond_width '+ val + ' molecule mol6;');
    }else if(val=='2'){
      av_execute('bond_width '+ val + ' molecule mol6;');
    }else if(val=='3'){
      av_execute('bond_width '+ val + ' molecule mol6;');
    }else{
      av_execute('display '+ val + ' molecule mol6;');
    }
}
function js_atomstyle_pose7(sel){
  var val = sel.options[sel.selectedIndex].value;
    av_execute('display lines on molecule mol7;');
    av_execute('display sticks off molecule mol7;');
    av_execute('display cylinders off molecule mol7;');
    av_execute('display spheres off molecule mol7;');
    if(val=='1'){
      av_execute('bond_width '+ val + ' molecule mol7;');
    }else if(val=='2'){
      av_execute('bond_width '+ val + ' molecule mol7;');
    }else if(val=='3'){
      av_execute('bond_width '+ val + ' molecule mol7;');
    }else{
      av_execute('display '+ val + ' molecule mol7;');
    }
}
function js_atomstyle_pose8(sel){
  var val = sel.options[sel.selectedIndex].value;
    av_execute('display lines on molecule mol8;');
    av_execute('display sticks off molecule mol8;');
    av_execute('display cylinders off molecule mol8;');
    av_execute('display spheres off molecule mol8;');
    if(val=='1'){
      av_execute('bond_width '+ val + ' molecule mol8;');
    }else if(val=='2'){
      av_execute('bond_width '+ val + ' molecule mol8;');
    }else if(val=='3'){
      av_execute('bond_width '+ val + ' molecule mol8;');
    }else{
      av_execute('display '+ val + ' molecule mol8;');
    }
}
function js_atomstyle_pose9(sel){
  var val = sel.options[sel.selectedIndex].value;
    av_execute('display lines on molecule mol9;');
    av_execute('display sticks off molecule mol9;');
    av_execute('display cylinders off molecule mol9;');
    av_execute('display spheres off molecule mol9;');
    if(val=='1'){
      av_execute('bond_width '+ val + ' molecule mol9;');
    }else if(val=='2'){
      av_execute('bond_width '+ val + ' molecule mol9;');
    }else if(val=='3'){
      av_execute('bond_width '+ val + ' molecule mol9;');
    }else{
      av_execute('display '+ val + ' molecule mol9;');
    }
}
function js_atomstyle_pose10(sel){
  var val = sel.options[sel.selectedIndex].value;
    av_execute('display lines on molecule mol10;');
    av_execute('display sticks off molecule mol10;');
    av_execute('display cylinders off molecule mol10;');
    av_execute('display spheres off molecule mol10;');
    if(val=='1'){
      av_execute('bond_width '+ val + ' molecule mol10;');
    }else if(val=='2'){
      av_execute('bond_width '+ val + ' molecule mol10;');
    }else if(val=='3'){
      av_execute('bond_width '+ val + ' molecule mol10;');
    }else{
      av_execute('display '+ val + ' molecule mol10;');
    }
}
function js_atomstyle_pose11(sel){
  var val = sel.options[sel.selectedIndex].value;
    av_execute('display lines on molecule mol11;');
    av_execute('display sticks off molecule mol11;');
    av_execute('display cylinders off molecule mol11;');
    av_execute('display spheres off molecule mol11;');
    if(val=='1'){
      av_execute('bond_width '+ val + ' molecule mol11;');
    }else if(val=='2'){
      av_execute('bond_width '+ val + ' molecule mol11;');
    }else if(val=='3'){
      av_execute('bond_width '+ val + ' molecule mol11;');
    }else{
      av_execute('display '+ val + ' molecule mol11;');
    }
}
function js_atomstyle_pose12(sel){
  var val = sel.options[sel.selectedIndex].value;
    av_execute('display lines on molecule mol12;');
    av_execute('display sticks off molecule mol12;');
    av_execute('display cylinders off molecule mol12;');
    av_execute('display spheres off molecule mol12;');
    if(val=='1'){
      av_execute('bond_width '+ val + ' molecule mol12;');
    }else if(val=='2'){
      av_execute('bond_width '+ val + ' molecule mol12;');
    }else if(val=='3'){
      av_execute('bond_width '+ val + ' molecule mol12;');
    }else{
      av_execute('display '+ val + ' molecule mol12;');
    }
}
function js_atomstyle_pose13(sel){
  var val = sel.options[sel.selectedIndex].value;
    av_execute('display lines on molecule mol13;');
    av_execute('display sticks off molecule mol13;');
    av_execute('display cylinders off molecule mol13;');
    av_execute('display spheres off molecule mol13;');
    if(val=='1'){
      av_execute('bond_width '+ val + ' molecule mol13;');
    }else if(val=='2'){
      av_execute('bond_width '+ val + ' molecule mol13;');
    }else if(val=='3'){
      av_execute('bond_width '+ val + ' molecule mol13;');
    }else{
      av_execute('display '+ val + ' molecule mol13;');
    }
}
function js_atomstyle_pose14(sel){
  var val = sel.options[sel.selectedIndex].value;
    av_execute('display lines on molecule mol14;');
    av_execute('display sticks off molecule mol14;');
    av_execute('display cylinders off molecule mol14;');
    av_execute('display spheres off molecule mol14;');
    if(val=='1'){
      av_execute('bond_width '+ val + ' molecule mol14;');
    }else if(val=='2'){
      av_execute('bond_width '+ val + ' molecule mol14;');
    }else if(val=='3'){
      av_execute('bond_width '+ val + ' molecule mol14;');
    }else{
      av_execute('display '+ val + ' molecule mol14;');
    }
}
function js_atomstyle_pose15(sel){
  var val = sel.options[sel.selectedIndex].value;
    av_execute('display lines on molecule mol15;');
    av_execute('display sticks off molecule mol15;');
    av_execute('display cylinders off molecule mol15;');
    av_execute('display spheres off molecule mol15;');
    if(val=='1'){
      av_execute('bond_width '+ val + ' molecule mol15;');
    }else if(val=='2'){
      av_execute('bond_width '+ val + ' molecule mol15;');
    }else if(val=='3'){
      av_execute('bond_width '+ val + ' molecule mol15;');
    }else{
      av_execute('display '+ val + ' molecule mol15;');
    }
}
function js_atomstyle_pose16(sel){
  var val = sel.options[sel.selectedIndex].value;
    av_execute('display lines on molecule mol16;');
    av_execute('display sticks off molecule mol16;');
    av_execute('display cylinders off molecule mol16;');
    av_execute('display spheres off molecule mol16;');
    if(val=='1'){
      av_execute('bond_width '+ val + ' molecule mol16;');
    }else if(val=='2'){
      av_execute('bond_width '+ val + ' molecule mol16;');
    }else if(val=='3'){
      av_execute('bond_width '+ val + ' molecule mol16;');
    }else{
      av_execute('display '+ val + ' molecule mol16;');
    }
}
function js_atomstyle_pose17(sel){
  var val = sel.options[sel.selectedIndex].value;
    av_execute('display lines on molecule mol17;');
    av_execute('display sticks off molecule mol17;');
    av_execute('display cylinders off molecule mol17;');
    av_execute('display spheres off molecule mol17;');
    if(val=='1'){
      av_execute('bond_width '+ val + ' molecule mol17;');
    }else if(val=='2'){
      av_execute('bond_width '+ val + ' molecule mol17;');
    }else if(val=='3'){
      av_execute('bond_width '+ val + ' molecule mol17;');
    }else{
      av_execute('display '+ val + ' molecule mol17;');
    }
}
function js_atomstyle_pose18(sel){
  var val = sel.options[sel.selectedIndex].value;
    av_execute('display lines on molecule mol18;');
    av_execute('display sticks off molecule mol18;');
    av_execute('display cylinders off molecule mol18;');
    av_execute('display spheres off molecule mol18;');
    if(val=='1'){
      av_execute('bond_width '+ val + ' molecule mol18;');
    }else if(val=='2'){
      av_execute('bond_width '+ val + ' molecule mol18;');
    }else if(val=='3'){
      av_execute('bond_width '+ val + ' molecule mol18;');
    }else{
      av_execute('display '+ val + ' molecule mol18;');
    }
}
function js_atomstyle_pose19(sel){
  var val = sel.options[sel.selectedIndex].value;
    av_execute('display lines on molecule mol19;');
    av_execute('display sticks off molecule mol19;');
    av_execute('display cylinders off molecule mol19;');
    av_execute('display spheres off molecule mol19;');
    if(val=='1'){
      av_execute('bond_width '+ val + ' molecule mol19;');
    }else if(val=='2'){
      av_execute('bond_width '+ val + ' molecule mol19;');
    }else if(val=='3'){
      av_execute('bond_width '+ val + ' molecule mol19;');
    }else{
      av_execute('display '+ val + ' molecule mol19;');
    }
}
function js_atomstyle_pose20(sel){
  var val = sel.options[sel.selectedIndex].value;
    av_execute('display lines on molecule mol20;');
    av_execute('display sticks off molecule mol20;');
    av_execute('display cylinders off molecule mol20;');
    av_execute('display spheres off molecule mol20;');
    if(val=='1'){
      av_execute('bond_width '+ val + ' molecule mol20;');
    }else if(val=='2'){
      av_execute('bond_width '+ val + ' molecule mol20;');
    }else if(val=='3'){
      av_execute('bond_width '+ val + ' molecule mol20;');
    }else{
      av_execute('display '+ val + ' molecule mol20;');
    }
}
function js_atomstyle_all(sel){
  var val = sel.options[sel.selectedIndex].value;
    av_execute('display lines on molecule mol*;');
    av_execute('display sticks off molecule mol*;');
    av_execute('display cylinders off molecule mol*;');
    av_execute('display spheres off molecule mol*;');
    if(val=='1'){
      av_execute('bond_width '+ val + ' molecule mol*;');
    }else if(val=='2'){
      av_execute('bond_width '+ val + ' molecule mol*;');
    }else if(val=='3'){
      av_execute('bond_width '+ val + ' molecule mol*;');
    }else{
      av_execute('display '+ val + ' molecule mol*;');
    }
}

/* Colour atoms */



function js_colour_pose1_atoms(sel){
  var val = sel.options[sel.selectedIndex].value;
  if(val=='atom_green'){
    av_execute('select molecule mol1;');
    av_execute('color_by_atom;');
    av_execute('select none;');
  }else if(val=='atom_grey'){
    av_execute('select molecule mol1;');
    av_execute('color_by_atom;');
    av_execute('select none;');
    av_execute('color 0xa9a9a9 atom C* and molecule mol1;');
  }else if(val=='atom_black'){
    av_execute('select molecule mol1;');
    av_execute('color_by_atom;');
    av_execute('select none;');
    av_execute('color 0x000000 atom C* and molecule mol1;');
  }else if(val=='atom_white'){
    av_execute('select molecule mol1;');
    av_execute('color_by_atom;');
    av_execute('select none;');
    av_execute('color white atom C* and molecule mol1;');
  }else{
    av_execute('color '+ val + ' molecule mol1;');
    }
}
function js_colour_pose2_atoms(sel){
  var val = sel.options[sel.selectedIndex].value;
  if(val=='atom_green'){
    av_execute('select molecule mol2;');
    av_execute('color_by_atom;');
    av_execute('select none;');
  }else if(val=='atom_grey'){
    av_execute('select molecule mol2;');
    av_execute('color_by_atom;');
    av_execute('select none;');
    av_execute('color 0xa9a9a9 atom C* and molecule mol2;');
  }else if(val=='atom_black'){
    av_execute('select molecule mol2;');
    av_execute('color_by_atom;');
    av_execute('select none;');
    av_execute('color 0x000000 atom C* and molecule mol2;');
  }else if(val=='atom_white'){
    av_execute('select molecule mol2;');
    av_execute('color_by_atom;');
    av_execute('select none;');
    av_execute('color white atom C* and molecule mol2;');
  }else{
    av_execute('color '+ val + ' molecule mol2;');
    }
}
function js_colour_pose3_atoms(sel){
  var val = sel.options[sel.selectedIndex].value;
  if(val=='atom_green'){
    av_execute('select molecule mol3;');
    av_execute('color_by_atom;');
    av_execute('select none;');
  }else if(val=='atom_grey'){
    av_execute('select molecule mol3;');
    av_execute('color_by_atom;');
    av_execute('select none;');
    av_execute('color 0xa9a9a9 atom C* and molecule mol3;');
  }else if(val=='atom_black'){
    av_execute('select molecule mol3;');
    av_execute('color_by_atom;');
    av_execute('select none;');
    av_execute('color 0x000000 atom C* and molecule mol3;');
  }else if(val=='atom_white'){
    av_execute('select molecule mol3;');
    av_execute('color_by_atom;');
    av_execute('select none;');
    av_execute('color white atom C* and molecule mol3;');
  }else{
    av_execute('color '+ val + ' molecule mol3;');
    }
}
function js_colour_pose4_atoms(sel){
  var val = sel.options[sel.selectedIndex].value;
  if(val=='atom_green'){
    av_execute('select molecule mol4;');
    av_execute('color_by_atom;');
    av_execute('select none;');
  }else if(val=='atom_grey'){
    av_execute('select molecule mol4;');
    av_execute('color_by_atom;');
    av_execute('select none;');
    av_execute('color 0xa9a9a9 atom C* and molecule mol4;');
  }else if(val=='atom_black'){
    av_execute('select molecule mol4;');
    av_execute('color_by_atom;');
    av_execute('select none;');
    av_execute('color 0x000000 atom C* and molecule mol4;');
  }else if(val=='atom_white'){
    av_execute('select molecule mol4;');
    av_execute('color_by_atom;');
    av_execute('select none;');
    av_execute('color white atom C* and molecule mol4;');
  }else{
    av_execute('color '+ val + ' molecule mol4;');
    }
}
function js_colour_pose5_atoms(sel){
  var val = sel.options[sel.selectedIndex].value;
  if(val=='atom_green'){
    av_execute('select molecule mol5;');
    av_execute('color_by_atom;');
    av_execute('select none;');
  }else if(val=='atom_grey'){
    av_execute('select molecule mol5;');
    av_execute('color_by_atom;');
    av_execute('select none;');
    av_execute('color 0xa9a9a9 atom C* and molecule mol5;');
  }else if(val=='atom_black'){
    av_execute('select molecule mol5;');
    av_execute('color_by_atom;');
    av_execute('select none;');
    av_execute('color 0x000000 atom C* and molecule mol5;');
  }else if(val=='atom_white'){
    av_execute('select molecule mol5;');
    av_execute('color_by_atom;');
    av_execute('select none;');
    av_execute('color white atom C* and molecule mol5;');
  }else{
    av_execute('color '+ val + ' molecule mol5;');
    }
}
function js_colour_pose6_atoms(sel){
  var val = sel.options[sel.selectedIndex].value;
  if(val=='atom_green'){
    av_execute('select molecule mol6;');
    av_execute('color_by_atom;');
    av_execute('select none;');
  }else if(val=='atom_grey'){
    av_execute('select molecule mol6;');
    av_execute('color_by_atom;');
    av_execute('select none;');
    av_execute('color 0xa9a9a9 atom C* and molecule mol6;');
  }else if(val=='atom_black'){
    av_execute('select molecule mol6;');
    av_execute('color_by_atom;');
    av_execute('select none;');
    av_execute('color 0x000000 atom C* and molecule mol6;');
  }else if(val=='atom_white'){
    av_execute('select molecule mol6;');
    av_execute('color_by_atom;');
    av_execute('select none;');
    av_execute('color white atom C* and molecule mol6;');
  }else{
    av_execute('color '+ val + ' molecule mol6;');
    }
}
function js_colour_pose7_atoms(sel){
  var val = sel.options[sel.selectedIndex].value;
  if(val=='atom_green'){
    av_execute('select molecule mol7;');
    av_execute('color_by_atom;');
    av_execute('select none;');
  }else if(val=='atom_grey'){
    av_execute('select molecule mol7;');
    av_execute('color_by_atom;');
    av_execute('select none;');
    av_execute('color 0xa9a9a9 atom C* and molecule mol7;');
  }else if(val=='atom_black'){
    av_execute('select molecule mol7;');
    av_execute('color_by_atom;');
    av_execute('select none;');
    av_execute('color 0x000000 atom C* and molecule mol7;');
  }else if(val=='atom_white'){
    av_execute('select molecule mol7;');
    av_execute('color_by_atom;');
    av_execute('select none;');
    av_execute('color white atom C* and molecule mol7;');
  }else{
    av_execute('color '+ val + ' molecule mol7;');
    }
}
function js_colour_pose8_atoms(sel){
  var val = sel.options[sel.selectedIndex].value;
  if(val=='atom_green'){
    av_execute('select molecule mol8;');
    av_execute('color_by_atom;');
    av_execute('select none;');
  }else if(val=='atom_grey'){
    av_execute('select molecule mol8;');
    av_execute('color_by_atom;');
    av_execute('select none;');
    av_execute('color 0xa9a9a9 atom C* and molecule mol8;');
  }else if(val=='atom_black'){
    av_execute('select molecule mol8;');
    av_execute('color_by_atom;');
    av_execute('select none;');
    av_execute('color 0x000000 atom C* and molecule mol8;');
  }else if(val=='atom_white'){
    av_execute('select molecule mol8;');
    av_execute('color_by_atom;');
    av_execute('select none;');
    av_execute('color white atom C* and molecule mol8;');
  }else{
    av_execute('color '+ val + ' molecule mol8;');
    }
}
function js_colour_pose9_atoms(sel){
  var val = sel.options[sel.selectedIndex].value;
  if(val=='atom_green'){
    av_execute('select molecule mol9;');
    av_execute('color_by_atom;');
    av_execute('select none;');
  }else if(val=='atom_grey'){
    av_execute('select molecule mol9;');
    av_execute('color_by_atom;');
    av_execute('select none;');
    av_execute('color 0xa9a9a9 atom C* and molecule mol9;');
  }else if(val=='atom_black'){
    av_execute('select molecule mol9;');
    av_execute('color_by_atom;');
    av_execute('select none;');
    av_execute('color 0x000000 atom C* and molecule mol9;');
  }else if(val=='atom_white'){
    av_execute('select molecule mol9;');
    av_execute('color_by_atom;');
    av_execute('select none;');
    av_execute('color white atom C* and molecule mol9;');
  }else{
    av_execute('color '+ val + ' molecule mol9;');
    }
}
function js_colour_pose10_atoms(sel){
  var val = sel.options[sel.selectedIndex].value;
  if(val=='atom_green'){
    av_execute('select molecule mol10;');
    av_execute('color_by_atom;');
    av_execute('select none;');
  }else if(val=='atom_grey'){
    av_execute('select molecule mol10;');
    av_execute('color_by_atom;');
    av_execute('select none;');
    av_execute('color 0xa9a9a9 atom C* and molecule mol10;');
  }else if(val=='atom_black'){
    av_execute('select molecule mol10;');
    av_execute('color_by_atom;');
    av_execute('select none;');
    av_execute('color 0x000000 atom C* and molecule mol10;');
  }else if(val=='atom_white'){
    av_execute('select molecule mol10;');
    av_execute('color_by_atom;');
    av_execute('select none;');
    av_execute('color white atom C* and molecule mol10;');
  }else{
    av_execute('color '+ val + ' molecule mol10;');
    }
}
function js_colour_pose11_atoms(sel){
  var val = sel.options[sel.selectedIndex].value;
  if(val=='atom_green'){
    av_execute('select molecule mol11;');
    av_execute('color_by_atom;');
    av_execute('select none;');
  }else if(val=='atom_grey'){
    av_execute('select molecule mol11;');
    av_execute('color_by_atom;');
    av_execute('select none;');
    av_execute('color 0xa9a9a9 atom C* and molecule mol11;');
  }else if(val=='atom_black'){
    av_execute('select molecule mol11;');
    av_execute('color_by_atom;');
    av_execute('select none;');
    av_execute('color 0x000000 atom C* and molecule mol11;');
  }else if(val=='atom_white'){
    av_execute('select molecule mol11;');
    av_execute('color_by_atom;');
    av_execute('select none;');
    av_execute('color white atom C* and molecule mol11;');
  }else{
    av_execute('color '+ val + ' molecule mol11;');
    }
}
function js_colour_pose12_atoms(sel){
  var val = sel.options[sel.selectedIndex].value;
  if(val=='atom_green'){
    av_execute('select molecule mol12;');
    av_execute('color_by_atom;');
    av_execute('select none;');
  }else if(val=='atom_grey'){
    av_execute('select molecule mol12;');
    av_execute('color_by_atom;');
    av_execute('select none;');
    av_execute('color 0xa9a9a9 atom C* and molecule mol12;');
  }else if(val=='atom_black'){
    av_execute('select molecule mol12;');
    av_execute('color_by_atom;');
    av_execute('select none;');
    av_execute('color 0x000000 atom C* and molecule mol12;');
  }else if(val=='atom_white'){
    av_execute('select molecule mol12;');
    av_execute('color_by_atom;');
    av_execute('select none;');
    av_execute('color white atom C* and molecule mol12;');
  }else{
    av_execute('color '+ val + ' molecule mol12;');
    }
}
function js_colour_pose13_atoms(sel){
  var val = sel.options[sel.selectedIndex].value;
  if(val=='atom_green'){
    av_execute('select molecule mol13;');
    av_execute('color_by_atom;');
    av_execute('select none;');
  }else if(val=='atom_grey'){
    av_execute('select molecule mol13;');
    av_execute('color_by_atom;');
    av_execute('select none;');
    av_execute('color 0xa9a9a9 atom C* and molecule mol13;');
  }else if(val=='atom_black'){
    av_execute('select molecule mol13;');
    av_execute('color_by_atom;');
    av_execute('select none;');
    av_execute('color 0x000000 atom C* and molecule mol13;');
  }else if(val=='atom_white'){
    av_execute('select molecule mol13;');
    av_execute('color_by_atom;');
    av_execute('select none;');
    av_execute('color white atom C* and molecule mol13;');
  }else{
    av_execute('color '+ val + ' molecule mol13;');
    }
}
function js_colour_pose14_atoms(sel){
  var val = sel.options[sel.selectedIndex].value;
  if(val=='atom_green'){
    av_execute('select molecule mol14;');
    av_execute('color_by_atom;');
    av_execute('select none;');
  }else if(val=='atom_grey'){
    av_execute('select molecule mol14;');
    av_execute('color_by_atom;');
    av_execute('select none;');
    av_execute('color 0xa9a9a9 atom C* and molecule mol14;');
  }else if(val=='atom_black'){
    av_execute('select molecule mol14;');
    av_execute('color_by_atom;');
    av_execute('select none;');
    av_execute('color 0x000000 atom C* and molecule mol14;');
  }else if(val=='atom_white'){
    av_execute('select molecule mol14;');
    av_execute('color_by_atom;');
    av_execute('select none;');
    av_execute('color white atom C* and molecule mol14;');
  }else{
    av_execute('color '+ val + ' molecule mol14;');
    }
}
function js_colour_pose15_atoms(sel){
  var val = sel.options[sel.selectedIndex].value;
  if(val=='atom_green'){
    av_execute('select molecule mol15;');
    av_execute('color_by_atom;');
    av_execute('select none;');
  }else if(val=='atom_grey'){
    av_execute('select molecule mol15;');
    av_execute('color_by_atom;');
    av_execute('select none;');
    av_execute('color 0xa9a9a9 atom C* and molecule mol15;');
  }else if(val=='atom_black'){
    av_execute('select molecule mol15;');
    av_execute('color_by_atom;');
    av_execute('select none;');
    av_execute('color 0x000000 atom C* and molecule mol15;');
  }else if(val=='atom_white'){
    av_execute('select molecule mol15;');
    av_execute('color_by_atom;');
    av_execute('select none;');
    av_execute('color white atom C* and molecule mol15;');
  }else{
    av_execute('color '+ val + ' molecule mol15;');
    }
}
function js_colour_pose16_atoms(sel){
  var val = sel.options[sel.selectedIndex].value;
  if(val=='atom_green'){
    av_execute('select molecule mol16;');
    av_execute('color_by_atom;');
    av_execute('select none;');
  }else if(val=='atom_grey'){
    av_execute('select molecule mol16;');
    av_execute('color_by_atom;');
    av_execute('select none;');
    av_execute('color 0xa9a9a9 atom C* and molecule mol16;');
  }else if(val=='atom_black'){
    av_execute('select molecule mol16;');
    av_execute('color_by_atom;');
    av_execute('select none;');
    av_execute('color 0x000000 atom C* and molecule mol16;');
  }else if(val=='atom_white'){
    av_execute('select molecule mol16;');
    av_execute('color_by_atom;');
    av_execute('select none;');
    av_execute('color white atom C* and molecule mol16;');
  }else{
    av_execute('color '+ val + ' molecule mol16;');
    }
}
function js_colour_pose17_atoms(sel){
  var val = sel.options[sel.selectedIndex].value;
  if(val=='atom_green'){
    av_execute('select molecule mol17;');
    av_execute('color_by_atom;');
    av_execute('select none;');
  }else if(val=='atom_grey'){
    av_execute('select molecule mol17;');
    av_execute('color_by_atom;');
    av_execute('select none;');
    av_execute('color 0xa9a9a9 atom C* and molecule mol17;');
  }else if(val=='atom_black'){
    av_execute('select molecule mol17;');
    av_execute('color_by_atom;');
    av_execute('select none;');
    av_execute('color 0x000000 atom C* and molecule mol17;');
  }else if(val=='atom_white'){
    av_execute('select molecule mol17;');
    av_execute('color_by_atom;');
    av_execute('select none;');
    av_execute('color white atom C* and molecule mol17;');
  }else{
    av_execute('color '+ val + ' molecule mol17;');
    }
}
function js_colour_pose18_atoms(sel){
  var val = sel.options[sel.selectedIndex].value;
  if(val=='atom_green'){
    av_execute('select molecule mol18;');
    av_execute('color_by_atom;');
    av_execute('select none;');
  }else if(val=='atom_grey'){
    av_execute('select molecule mol18;');
    av_execute('color_by_atom;');
    av_execute('select none;');
    av_execute('color 0xa9a9a9 atom C* and molecule mol18;');
  }else if(val=='atom_black'){
    av_execute('select molecule mol18;');
    av_execute('color_by_atom;');
    av_execute('select none;');
    av_execute('color 0x000000 atom C* and molecule mol18;');
  }else if(val=='atom_white'){
    av_execute('select molecule mol18;');
    av_execute('color_by_atom;');
    av_execute('select none;');
    av_execute('color white atom C* and molecule mol18;');
  }else{
    av_execute('color '+ val + ' molecule mol18;');
    }
}
function js_colour_pose19_atoms(sel){
  var val = sel.options[sel.selectedIndex].value;
  if(val=='atom_green'){
    av_execute('select molecule mol19;');
    av_execute('color_by_atom;');
    av_execute('select none;');
  }else if(val=='atom_grey'){
    av_execute('select molecule mol19;');
    av_execute('color_by_atom;');
    av_execute('select none;');
    av_execute('color 0xa9a9a9 atom C* and molecule mol19;');
  }else if(val=='atom_black'){
    av_execute('select molecule mol19;');
    av_execute('color_by_atom;');
    av_execute('select none;');
    av_execute('color 0x000000 atom C* and molecule mol19;');
  }else if(val=='atom_white'){
    av_execute('select molecule mol19;');
    av_execute('color_by_atom;');
    av_execute('select none;');
    av_execute('color white atom C* and molecule mol19;');
  }else{
    av_execute('color '+ val + ' molecule mol19;');
    }
}
function js_colour_pose20_atoms(sel){
  var val = sel.options[sel.selectedIndex].value;
  if(val=='atom_green'){
    av_execute('select molecule mol20;');
    av_execute('color_by_atom;');
    av_execute('select none;');
  }else if(val=='atom_grey'){
    av_execute('select molecule mol20;');
    av_execute('color_by_atom;');
    av_execute('select none;');
    av_execute('color 0xa9a9a9 atom C* and molecule mol20;');
  }else if(val=='atom_black'){
    av_execute('select molecule mol20;');
    av_execute('color_by_atom;');
    av_execute('select none;');
    av_execute('color 0x000000 atom C* and molecule mol20;');
  }else if(val=='atom_white'){
    av_execute('select molecule mol20;');
    av_execute('color_by_atom;');
    av_execute('select none;');
    av_execute('color white atom C* and molecule mol20;');
  }else{
    av_execute('color '+ val + ' molecule mol20;');
    }
}
function js_colour_all_atoms(sel){
  var val = sel.options[sel.selectedIndex].value;
  if(val=='atom_green'){
    av_execute('select molecule mol*;');
    av_execute('color_by_atom;');
    av_execute('select none;');
  }else if(val=='atom_grey'){
    av_execute('select molecule mol*;');
    av_execute('color_by_atom;');
    av_execute('select none;');
    av_execute('color 0xa9a9a9 atom C* and molecule mol*;');
  }else if(val=='atom_black'){
    av_execute('select molecule mol*;');
    av_execute('color_by_atom;');
    av_execute('select none;');
    av_execute('color 0x000000 atom C* and molecule mol*;');
  }else if(val=='atom_white'){
    av_execute('select molecule mol*;');
    av_execute('color_by_atom;');
    av_execute('select none;');
    av_execute('color white atom C* and molecule mol*;');
  }else{
    av_execute('color '+ val + ' molecule mol*;');
    }
}

/* Colour surfaces */




function js_colour_pose1(sel){
  var val = sel.options[sel.selectedIndex].value;
  av_colour('pose1_surface', val);
}
function js_colour_pose2(sel){
  var val = sel.options[sel.selectedIndex].value;
  av_colour('pose2_surface', val);
}
function js_colour_pose3(sel){
  var val = sel.options[sel.selectedIndex].value;
  av_colour('pose3_surface', val);
}
function js_colour_pose4(sel){
  var val = sel.options[sel.selectedIndex].value;
  av_colour('pose4_surface', val);
}
function js_colour_pose5(sel){
  var val = sel.options[sel.selectedIndex].value;
  av_colour('pose5_surface', val);
}
function js_colour_pose6(sel){
  var val = sel.options[sel.selectedIndex].value;
  av_colour('pose6_surface', val);
}
function js_colour_pose7(sel){
  var val = sel.options[sel.selectedIndex].value;
  av_colour('pose7_surface', val);
}
function js_colour_pose8(sel){
  var val = sel.options[sel.selectedIndex].value;
  av_colour('pose8_surface', val);
}
function js_colour_pose9(sel){
  var val = sel.options[sel.selectedIndex].value;
  av_colour('pose9_surface', val);
}
function js_colour_pose10(sel){
  var val = sel.options[sel.selectedIndex].value;
  av_colour('pose10_surface', val);
}
function js_colour_pose11(sel){
  var val = sel.options[sel.selectedIndex].value;
  av_colour('pose11_surface', val);
}
function js_colour_pose12(sel){
  var val = sel.options[sel.selectedIndex].value;
  av_colour('pose12_surface', val);
}
function js_colour_pose13(sel){
  var val = sel.options[sel.selectedIndex].value;
  av_colour('pose13_surface', val);
}
function js_colour_pose14(sel){
  var val = sel.options[sel.selectedIndex].value;
  av_colour('pose14_surface', val);
}
function js_colour_pose15(sel){
  var val = sel.options[sel.selectedIndex].value;
  av_colour('pose15_surface', val);
}
function js_colour_pose16(sel){
  var val = sel.options[sel.selectedIndex].value;
  av_colour('pose16_surface', val);
}
function js_colour_pose17(sel){
  var val = sel.options[sel.selectedIndex].value;
  av_colour('pose17_surface', val);
}
function js_colour_pose18(sel){
  var val = sel.options[sel.selectedIndex].value;
  av_colour('pose18_surface', val);
}
function js_colour_pose19(sel){
  var val = sel.options[sel.selectedIndex].value;
  av_colour('pose19_surface', val);
}
function js_colour_pose20(sel){
  var val = sel.options[sel.selectedIndex].value;
  av_colour('pose20_surface', val);
}





/* Viewer controls */



function js_antialias(sel){
  if(sel.checked){
    av_execute("view -antialias true;");
  }else{
    av_execute("view -antialias false;");
  }
}

function js_shadows(sel){
  if(sel.checked){
    av_execute("view -realspheres true; view -shadows true;");
  }else{
    av_execute("view -realspheres false; view -shadows false;");
  }
}

function js_background(sel){
  var val = sel.options[sel.selectedIndex].value;
  av_execute("view -gradient false;");
  av_background(val);
}
function js_background2(sel){
  var val = sel.options[sel.selectedIndex].value;
  av_execute('view -gradient true -gradientbottom black -gradienttop '+ val+';');
}


/* browser controls */



function js_displayoff(){
  av_execute("molecule display mol* off;");
}

function js_displayon(){
  av_execute("molecule display mol* on;");
}

function js_displaymol(val){
  var mol = "mol" + val;
  av_execute("molecule display mol* off;");
  av_execute("molecule display " + mol + " on;");
}

function js_displaymol_up(val){
  var mol = "mol" + val;
  var val2 = val -1;
  var molm = "mol" + val2;
  av_execute("molecule display " + molm + " off;");
  av_execute("molecule display " + mol + " on;");
}

function js_displaymol_down(val){
  var mol = "mol" + val;
  var val2 = val -(-1);
  var molp = "mol" + val2;
  av_execute("molecule display " + molp + " off;");
  av_execute("molecule display " + mol + " on;");
}

function js_atomstyle(sel, mol){
  var val = sel.options[sel.selectedIndex].value;
  var mol = "mol" + mol;
    av_execute('display lines on molecule ' + mol + ';');
    av_execute('display sticks off molecule ' + mol + ';');
    av_execute('display cylinders off molecule ' + mol + ';');
    av_execute('display spheres off molecule ' + mol + ';');
    if(val=='1'){
      av_execute('bond_width '+ val + ' molecule ' + mol + ';');
    }else if(val=='2'){
      av_execute('bond_width '+ val + ' molecule ' + mol + ';');
    }else if(val=='3'){
      av_execute('bond_width '+ val + ' molecule ' + mol + ';');
    }else{
      av_execute('display '+ val + ' molecule ' + mol + ';');
    }
}

function js_colouratoms(sel, mol){
  var val = sel.options[sel.selectedIndex].value;
  var mol = "mol" + mol;
  if(val=='atom_green'){
    av_execute('select molecule ' + mol + ';');
    av_execute('color_by_atom;');
    av_execute('select none;');
  }else if(val=='atom_grey'){
    av_execute('select molecule ' + mol + ';');
    av_execute('color_by_atom;');
    av_execute('select none;');
    av_execute('color 0xa9a9a9 atom C* and molecule ' + mol + ';');
  }else if(val=='atom_black'){
    av_execute('select molecule ' + mol + ';');
    av_execute('color_by_atom;');
    av_execute('select none;');
    av_execute('color 0x000000 atom C* and molecule ' + mol + ';');
  }else if(val=='atom_white'){
    av_execute('select molecule ' + mol + ';');
    av_execute('color_by_atom;');
    av_execute('select none;');
    av_execute('color white atom C* and molecule ' + mol + ';');
  }else{
    av_execute('color '+ val + ' molecule ' + mol + ';');
    }
}

function js_displaysurface(val){
  var molsurface = "molsurface" + val;
  var mol = "mol" + val;
  av_display('molsurface*', 'off');
  if(!molsurface.surface){
    av_execute('surface -solid true ' + molsurface + ' white molecule ' + mol + ';');
  }else{
      av_display('molsurface', 'on');
    }
}
function js_displaysurface_off(val){
  var molsurface = "molsurface" + val;
  av_display('molsurface*', 'off');
}

function js_coloursurface(sel, mol){
  var val = sel.options[sel.selectedIndex].value;
  var molsurface = "molsurface" + mol;
  av_colour(molsurface, val);
}

function js_transparencysurface(sel, mol){
  var val = sel.options[sel.selectedIndex].value;
  val = Math.round(val * 2.55);
  var molsurface = "molsurface" + mol;
  av_transparency(molsurface, val);
}

function js_texturesurface(sel, mol){
  var val = sel.options[sel.selectedIndex].value;
  var molsurface = "molsurface" + mol;
  if(!sel.textured){
    av_lipophilicity(molsurface);
    sel.textured = true;
  }
  av_texture(molsurface, val);
}

function js_displaymesh(val){
  var molmesh = "molmesh" + val;
  var mol = "mol" + val;
  av_display('molmesh*', 'off');
  if(!molmesh.surface){
    av_execute('surface -solid false ' + molmesh + ' white molecule ' + mol + ';');
  }else{
      av_display('molmesh', 'on');
    }
}

function js_displaymesh_off(val){
  var molmesh = "molmesh" + val;
  av_display('molmesh*', 'off');
}

function js_colourmesh(sel, mol){
  var val = sel.options[sel.selectedIndex].value;
  var molmesh = "molmesh" + mol;
  av_colour(molmesh, val);
}

