/*
 * Javascript functions that manage
 * communication with AstexViewer.
 */


function toggle(s){
  document.av.execute('molecule display ' + s + ' toggle;');
}

function av_execute(command){
  document.av.execute(command);
  window.status = command;
}

function js_protein_surface(obj){
  if(obj.surfaced){
     if(obj.checked){
	  document.av.execute('object display protein_surface on;'); 
     }else{
	  document.av.execute('object display protein_surface off;'); 
     }
  }else{
     obj.surfaced = 1;
     av_execute('surface -solid true protein_surface white molecule protein and sphere 6 around molecule mol10;');
     av_execute('object protein_surface texture distance v molecule mol10;');
     av_execute('object protein_surface texture vrange 0 3.5;');
     av_execute('object protein_surface clip v;');
     av_execute('object protein_surface backface on;');
     }
  }

function surface10(obj){
  if(obj.surfaced){
     if(obj.checked){
	  document.av.execute('object display pose10_surface on;'); 
     }else{
	  document.av.execute('object display pose10_surface off;'); 
     }
  }else{
     obj.surfaced = 1;
      av_execute('surface -solid true pose10_surface purple molecule  mol10;');
     }
  }

function protein_cartoon(obj){
  if(obj.schematic){
     if(obj.checked){
	  document.av.execute('object display protein_schematic on;'); 
     }else{
	  document.av.execute('object display protein_schematic off;'); 
     }
  }else{
     obj.schematic = 1;
      av_execute('color_by_rainbow molecule protein; secstruc all; schematic -name protein_schematic molecule protein; color_by_atom;');
     }
  }

function protein_cartoon1(obj){
  if(obj.schematic){
     if(obj.checked){
	  document.av.execute('object display protein_schematic1 on;'); 
     }else{
	  document.av.execute('object display protein_schematic1 off;'); 
     }
  }else{
     obj.schematic = 1;
      av_execute('color_by_rainbow molecule mol1; secstruc all; schematic -name protein_schematic1 molecule mol1; color_by_atom;');
     }
  }

function protein_cartoon2(obj){
  if(obj.schematic){
     if(obj.checked){
	  document.av.execute('object display protein_schematic2 on;'); 
     }else{
	  document.av.execute('object display protein_schematic2 off;'); 
     }
  }else{
     obj.schematic = 1;
      av_execute('color_by_rainbow molecule mol2; secstruc all; schematic -name protein_schematic2 molecule mol2; color_by_atom;');
     }
  }

function protein_cartoon3(obj){
  if(obj.schematic){
     if(obj.checked){
	  document.av.execute('object display protein_schematic3 on;'); 
     }else{
	  document.av.execute('object display protein_schematic3 off;'); 
     }
  }else{
     obj.schematic = 1;
      av_execute('color_by_rainbow molecule mol3; secstruc all; schematic -name protein_schematic3 molecule mol3; color_by_atom;');
     }
  }
