var theParent;
var theChild;
var theDestination

//-------------------------------------

function setDestination( parameter ) {
  theDestination = parameter;
}//end setDestination()

//-------------------------------------

function makeValuePairArray () {
  var aString = location.search;
  var anArray = aString.substring(1,aString.length).split("&");
  var valuePairArray = new Array(anArray.length);
  var matchRegObj = new RegExp("[\+]+","gi"); //To be used for stripping unwanted characters out of strings.

  if (aString.length == 0) {
  //What to do if there is no search string.
  self.location = ".";
  } else {
    //break location.search name+value pairs into a nice neat array...
    for (var loop=0; loop<anArray.length; loop++) {
      valuePairArray[anArray[loop].substring(0,anArray[loop].indexOf("="))] = anArray[loop].substring(anArray[loop].indexOf("=")+1,anArray[loop].length);
      //valuePairArray[loop] = valuePairArray[loop].replace(matchRegObj," ");
    }//end for loop
  }//end if(empty search string)
  return valuePairArray;
}//end makeValuePairArray()

//-------------------------------------

function initEntry () {
  var myArray = makeValuePairArray();
  theDestination = myArray["dest"];
  document.entry.sequence.focus();
}//end initEntry()

//-------------------------------------

function validate() {
  var theParent = self.opener;
  var theChild = self;

  var theEntry = document.entry.sequence.value.toLowerCase();

  if ( theEntry.indexOf("oncox") >= 0 ) {
    theParent.location.href = theDestination;
    theChild.close();
  } else {
    alert("Invalid entry, try again.");
  }

}//end validate()

//-------------------------------------

function entry( myDestination ) {
  var theParent = self;
  var theChild;

  if (myDestination.indexOf("amino") >= 0) {
    theChild = window.open('sequenceentryamino.htm?dest='+myDestination,'pop','width=450,height=200,dependent');
  } else if (myDestination.indexOf("dna") >= 0) {
    theChild = window.open('sequenceentrydna.htm?dest='+myDestination,'pop','width=450,height=200,dependent');
  } else if (myDestination.indexOf("blastn") >= 0) {
    theChild = window.open('sequenceentryblastn.htm?dest='+myDestination,'pop','width=450,height=200,dependent');
  } else if (myDestination.indexOf("blastp") >= 0) {
    theChild = window.open('sequenceentryblastp.htm?dest='+myDestination,'pop','width=450,height=200,dependent');
  }


  //theChild.focus();
  //theChild.setDestination(myDestination);

}//end entry()

//-------------------------------------

function selectDestination (aSelect) {
  var theSelectName = aSelect.name.toLowerCase();
  var theSelectedIndex = aSelect.selectedIndex;
  var theDestination = "";

  switch (theSelectName) {
    case "mdsa" :
      switch (theSelectedIndex) {
        case 0 :
          theDestination = "";
        break
        case 1 :
          theDestination = "oncoxclustaldna.htm";
        break
        default :
          theDestination = "denied.htm";
      }//end switch
      break
    case "masa" :
      switch (theSelectedIndex) {
        case 0 :
          theDestination = "";
        break
        case 1 :
          theDestination = "oncoxclustalaminoframe3.htm";
        break
        case 2 :
          theDestination = "oncoxclustalaminoframe4.htm";
        break
        default :
          theDestination = "denied.htm";
      }//end switch
      break
    case "blastn" :
      switch (theSelectedIndex) {
        case 0 :
          theDestination = "";
        break
        case 1 :
          theDestination = "oncoxblastn.htm";
        break
        default :
          theDestination = "denied.htm";
      }//end switch
      break
    case "blastp" :
      switch (theSelectedIndex) {
        case 0 :
          theDestination = "";
        break
        case 1 :
          theDestination = "oncoxblastpframe3.htm";
        break
        case 2 :
          theDestination = "oncoxblastpframe4.htm";
        break
        default :
          theDestination = "denied.htm";
      }//end switch
      break
    default :
      theDestination = "denied.htm";
  }//end switch

  aSelect.selectedIndex = 0;

  if (theDestination.length > 0) {
    self.location.href = theDestination;
  }//end if

}//end selectDestination()

//-------------------------------------

function searchString (inputString) {
  var returnValue = false;
  var theString = inputString.toLowerCase();
  if (theString.indexOf("at") == 0) {
    returnValue = true;
  }
  return returnValue;
}//end searchString()

//-------------------------------------
