 function Browser() 
{  
  var ua, s, i;
  
  this.isIE    = false;  // Internet Explorer
  this.isOP    = false;  // Opera
  this.isNS    = false;  // Netscape
  this.version = null;
  
  ua = navigator.userAgent;
  
  s = "Opera";
  if ((i = ua.indexOf(s)) >= 0) {
      this.isOP = true;
      this.version = parseFloat(ua.substr(i + s.length));
      return;
  }
  
  s = "Netscape6/";
  if ((i = ua.indexOf(s)) >= 0) {
      this.isNS = true;
      this.version = parseFloat(ua.substr(i + s.length));
      return;
  }
  
  // Treat any other "Gecko" browser as Netscape 6.1.
  
  s = "Gecko";
  if ((i = ua.indexOf(s)) >= 0) {
      this.isNS = true;
      this.version = 6.1;
      return;
  }
  
  s = "MSIE";
  if ((i = ua.indexOf(s))) {
      this.isIE = true;
      this.version = parseFloat(ua.substr(i + s.length));
      return;
  }
}

var browser = new Browser();

var sketcherLoaded=true;        


/*
* Submit form only if the frames have been loaded
*/


function newWindow2(destination, windowName, width, height,scrollbars)
{
  
  popUpWindow = window.open(destination, windowName, "width=" + width + ",height=" + height + ",scrollbars="+ scrollbars+",toolbar=no,menubar=no");
  popUpWindow.focus();
}


function newWindow(destination, windowName, width, height)
{
  
  popUpWindow = window.open(destination, windowName, "width=" + width + ",height=" + height + ",scrollbars=no,toolbar=no,menubar=no");
  popUpWindow.focus();
}

function startSearch()
{
  parent.propertyFrame.document.savePropertiesForm.searchAction.value = "refresh-search"; 
  
  if (parent.structureFrame)
      {
          parent.propertyFrame.document.savePropertiesForm.structureMatching.value = structureForm.structureMatching.options[structureForm.structureMatching.selectedIndex].value;
          parent.propertyFrame.document.savePropertiesForm.structureBoolean.value = structureForm.structureBoolean.options[structureForm.structureBoolean.selectedIndex].value;
      }
      
      parent.propertyFrame.document.savePropertiesForm.submit();	
  }
  
  function saveSearchAs()
  {
      /*
      savePropertiesForm.action = "<c:url value="/dictionary-search.do"/>";
      
      savePropertiesForm.method.value = "prepareSaveAs";
      savePropertiesForm.submit();
      */
      return false;
  }
  
  function toggleStructure()
  {  /*
      savePropertiesForm.action = "<c:url value="/dictionary-search.do"/>";
      
      if (savePropertiesForm.struct.value == "hide")
          savePropertiesForm.struct.value = "";
      else
          savePropertiesForm.struct.value = "hide";
      
      savePropertiesForm.method.value = "toggleProperties";
      savePropertiesForm.submit();
      */
      return false;
  }
  
  function toggleProperties()
  {
    /*
      savePropertiesForm.action="<c:url value="/dictionary-search.do"/>";
      
      if (savePropertiesForm.props.value == "hide")
          savePropertiesForm.props.value = "";
      else
          savePropertiesForm.props.value = "hide";
      
      savePropertiesForm.method.value = "toggleProperties";
      savePropertiesForm.submit();
      */
      return false;
  }
  
  function validateNumber(inputBox, id)
  {
      var value = inputBox.value;
      if (isNaN(value))
          {
              alert("This field must be numeric.  If you are trying to do a range search, please select 'Range' from the drop down box in the Comparision Column.");
              inputBox.value = "";
              //document.getElementById(id).focus();
              
              setTimeout("document.getElementById('" + id + "').focus();",1);
              //setTimeout("document.getElementById('" + id + "').select();",1);
          }
          
          return false;
      }
      
      
      function importMol(struct,opts) {
          //alert("about to load:"+struct +";");
          
          if(struct == null || struct == '' ||struct == 'hide') {
              //
              //alert("Cannot import molecule:no JavaScript to Java communication in your browser.\n");
          }else{
          
          document.MView.setMol(struct, opts);
          
      }
  }
  function loadMol(){
      importMol(savePropertiesForm.escStructure.value,'');
      
  }








/******************************************************/

function Browser() 
{

  var ua, s, i;

  this.isIE    = false;  // Internet Explorer
  this.isOP    = false;  // Opera
  this.isNS    = false;  // Netscape
  this.version = null;

  ua = navigator.userAgent;

  s = "Opera";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isOP = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  s = "Netscape6/";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  // Treat any other "Gecko" browser as Netscape 6.1.

  s = "Gecko";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = 6.1;
    return;
  }

  s = "MSIE";
  if ((i = ua.indexOf(s))) {
    this.isIE = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }
}

var browser = new Browser();

        var sketcherLoaded=true;        


/*
 * Submit form only if the frames have been loaded
 */


function newWindow2(destination, windowName, width, height,scrollbars)
{
 
    popUpWindow = window.open(destination, windowName, "width=" + width + ",height=" + height + ",scrollbars="+ scrollbars+",toolbar=no,menubar=no");
    popUpWindow.focus();
}


function newWindow(destination, windowName, width, height)
{
 
    popUpWindow = window.open(destination, windowName, "width=" + width + ",height=" + height + ",scrollbars=no,toolbar=no,menubar=no");
    popUpWindow.focus();
}

function startSearch()
{
	parent.propertyFrame.document.savePropertiesForm.searchAction.value = "refresh-search"; 
	
	if (parent.structureFrame)
	{
		parent.propertyFrame.document.savePropertiesForm.structureMatching.value = structureForm.structureMatching.options[structureForm.structureMatching.selectedIndex].value;
		parent.propertyFrame.document.savePropertiesForm.structureBoolean.value = structureForm.structureBoolean.options[structureForm.structureBoolean.selectedIndex].value;
	}
	
	parent.propertyFrame.document.savePropertiesForm.submit();	
}

function saveSearchAs()
{
	savePropertiesForm.action = "/dictionary-search.do";
	
	savePropertiesForm.method.value = "prepareSaveAs";
	savePropertiesForm.submit();
	
	return false;
}

function toggleStructure()
{
	savePropertiesForm.action = "/dictionary-search.do";
	
	if (savePropertiesForm.struct.value == "hide")
		savePropertiesForm.struct.value = "";
	else
		savePropertiesForm.struct.value = "hide";
		
	savePropertiesForm.method.value = "toggleProperties";
	savePropertiesForm.submit();
	
	return false;
}

function toggleProperties()
{
	savePropertiesForm.action="/dictionary-search.do";

	if (savePropertiesForm.props.value == "hide")
		savePropertiesForm.props.value = "";
	else
		savePropertiesForm.props.value = "hide";
		
	savePropertiesForm.method.value = "toggleProperties";
	savePropertiesForm.submit();
	
	return false;
}

function validateNumber(inputBox, id)
{
	var value = inputBox.value;
	if (isNaN(value))
	{
		alert("This field must be numeric.  If you are trying to do a range search, please select 'Range' from the drop down box in the Comparision Column.");
		inputBox.value = "";
		//document.getElementById(id).focus();

		setTimeout("document.getElementById('" + id + "').focus();",1);
		//setTimeout("document.getElementById('" + id + "').select();",1);
	}
	
	return false;
}


 function importMol(struct,opts) {
//alert("about to load:"+struct +";");
 
    	if(struct == null || struct == '' ||struct == 'hide') {
          //
          	//alert("Cannot import molecule:no JavaScript to Java communication in your browser.\n");
          }else{
           
  document.MView.setMol(struct, opts);
      
    	}
    }
    function loadMol(){
        importMol(savePropertiesForm.escStructure.value,'');
        
                }
