var script = 'pssm_viewer.cgi?';
var panelwidth = '350';
var panelheight = '400';

function barWindow(cdPos,cdAcc) {
 openURL = script+'mode=panel&cd='+cdAcc+'&refpos='+cdPos;
 newWindow = window.open(openURL,'panelWin','width=350,height=400,scrollbars=yes');
}

function helpWindow(helpUrl) {

   helpWin = window.open(helpUrl, 'helptext','scrollbars=yes,resizable,width=400,height=400')
   helpWin.focus()

}

function tutorialWindow(tutUrl) {

   tutWin = window.open(tutUrl, 'helptext','scrollbars=yes,resizable,width=750,height=700')
   tutWin.focus()

}

function colorKey() {;
 colorURL = script+'?&mode=colorkey';
 keyWindow = window.open(colorURL,'keyWin','width=600,height=100');
}

function setMenu() {

  restype = new Array('Any','acidic','aromatic','basic','charged','hydroxyl',
  			'nonpolar','polar');
  resval = new Array('','DE','FHWY','HKR','DEHKR','STY','AFGILMPVW','CDEHKNQRSTY');

  residue1 = new Array('A','C','D','E','F','G','H','I','K','L','M','N','P','Q','R','S',
  			'T','V','W','Y');
  residue3 = new Array('Ala','Cys','Asp','Glu','Phe','Gly','His','Ile','Lys','Leu','Met',
  			'Asn','Pro','Gln','Arg','Ser','Thr','Val','Trp','Tyr');
  infocont = new Array('full',"high or more","moderate or more","moderate or less",'low');
  infoval = new Array('100','4','3','2','1');
  
  var box = document.forms[0].hightype;
  var choice = box.options[box.selectedIndex].value;
  
  var resMenu = document.forms[0].res;
  resMenu.options.length = 0;
  
  
  var i;
  var j;
  var resstr;
  if (choice == "consensus") {
     for (i=0; i < restype.length; i++) {
       resMenu.options[i] = new Option(restype[i], resval[i]);
     }
 
     for (i=0; i < residue1.length; i++) {
       j = i + restype.length;
       resstr = residue1[i]+" - "+residue3[i];
       resMenu.options[j] = new Option(resstr, residue1[i]);
     }
  }
  if (choice == "conservation") {
    for (i=0; i < infocont.length; i++) {
       resMenu.options[i] = new Option(infocont[i], infoval[i]);
    }   
  }

}


function sortCol(resIndex) {

  var sf = document.getElementById("dynaform");
  var newinput = document.createElement('input');
  newinput.setAttribute('type', 'hidden');
  newinput.setAttribute('name', 'index');
  newinput.setAttribute('value', resIndex);
  sf.appendChild(newinput);
  
  newinput = document.createElement('input');
  newinput.setAttribute('type', 'hidden');
  newinput.setAttribute('name', 'mode');
  newinput.setAttribute('value', 'Residue');
  sf.appendChild(newinput);
  
  sf.submit();
}

function aaExplore(seqPos,selfRes,resIndex,pssmMode,cgiName) {

  var sf = document.getElementById("dynaform");
  sf.action = cgiName;
  
  var newinput = document.createElement('input');
  newinput.setAttribute('type', 'hidden');
  newinput.setAttribute('name', 'pos');
  newinput.setAttribute('value', seqPos);
  sf.appendChild(newinput);
  
  newinput = document.createElement('input');
  newinput.setAttribute('type', 'hidden');
  newinput.setAttribute('name', 'self');
  newinput.setAttribute('value', selfRes);
  sf.appendChild(newinput);
  
  newinput = document.createElement('input');
  newinput.setAttribute('type', 'hidden');
  newinput.setAttribute('name', 'pssmindex');
  newinput.setAttribute('value', resIndex);
  sf.appendChild(newinput);
  
  newinput = document.createElement('input');
  newinput.setAttribute('type', 'hidden');
  newinput.setAttribute('name', 'pssmmode');
  newinput.setAttribute('value', pssmMode);
  sf.appendChild(newinput);

  sf.submit();

}
