function hidediv(id) {
	//safe function to hide an element with a specified id
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'none';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'none';
		}
		else { // IE 4
			document.all.id.style.display = 'none';
		}
	}
}

function showdiv(id) {
	//safe function to show an element with a specified id
		  
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'block';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'block';
		}
		else { // IE 4
			document.all.id.style.display = 'block';
		}
	}
}	

// return the value of the radio button that is checked
// return an empty string if none are checked, or
// there are no radio buttons
function getCheckedValue(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}

// set the radio button with the given value as being checked
// do nothing if there are no radio buttons
// if the given value does not exist, all the radio buttons
// are reset to unchecked
function setCheckedValue(radioObj, newValue) {
	if(!radioObj)
		return;
	var radioLength = radioObj.length;
	if(radioLength == undefined) {
		radioObj.checked = (radioObj.value == newValue.toString());
		return;
	}
	for(var i = 0; i < radioLength; i++) {
		radioObj[i].checked = false;
		if(radioObj[i].value == newValue.toString()) {
			radioObj[i].checked = true;
		}
	}
}
	
function doBlast(blastno, mblastType, bestaccn) {
 // alert('doBlast  blastno:' + blastno + '  btype:' + btype + ' accn: ' + bestaccn);
 var mblastmatch = bestaccn   // was bestaccession[blastno];
 switch (mblastType) {
  case "N": 
   url = 'http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?db=protein&cmd=search&term=' + mblastmatch;
   break;
  case "R": 
   // url = 'http://www.tigr.org/tigr-scripts/euk_manatee/shared/ORF_infopage.cgi?orf=' + mblastmatch + '&' + 'db=osa1r5'; break;
   var temp = new Array();
   temp = mblastmatch.split('.');
   url = 'http://www.phytozome.net/cgi-bin/gbrowse/rice/?name=' + temp[0]; break; 
   break;
  case "M": url = 'http://mips.gsf.de/proj/plant/jsf/medi/reportsjsp/geneticElement.jsp?gene='+ mblastmatch; break;
  case "A":
   url = 'http://www.arabidopsis.org/servlets/Search?action=search&type=gene&name=' + mblastmatch
      //    http://www.tigr.org/tigr-scripts/euk_manatee/shared/ORF_infopage.cgi?orf='+mblastmatch+'&' + 'db=ath1&user=access&password=access'

   break;
  
  case "P": 
   var temp = new Array();
   temp = mblastmatch.split('|');
   url='http://genome.jgi-psf.org/cgi-bin/dispGeneModel?db=Poptr1_1&id=' + temp[1];
   break;

  case 'S':  // Soy
   var temp = new Array();
   temp = mblastmatch.split('.');
   url = 'http://www.phytozome.net/cgi-bin/gbrowse/soybean/?name=' + temp[0]; break; 

  case '1':  // Brachy
   var temp = new Array();
   temp = mblastmatch.split('.');   // just want before the period
   url = 'http://www.phytozome.net/cgi-bin/gbrowse/brachy/?name=' + temp[0]; break;

  case "U": url = 'http://www.UniProt.org/entry/' + mblastmatch; break;
 }
 // alert('URL: ' + url);
 window.open(url, 'Blast')
 }

function substr(str, start, len) {
  // Make sure start and len are within proper bounds
  if (start < 0 || len < 0) return "";

  var iEnd, iLen = String(str).length;
  if (start + len > iLen)
          iEnd = iLen;
  else
          iEnd = start + len;

  return String(str).substring(start,iEnd);
}

// Get Window Size
function getwsize() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }

  var inputs = document.getElementsByTagName('input');
  wsize= myWidth+'x'+myHeight;
  formwidth=myWidth;  // calling prog can use
  formHeight=myHeight;
  for( var i = 0; i < inputs.length; i++ ) {
    if (inputs[i].name == 'wsize') {
      inputs[i].value = wsize
    }
  }
}


// && SPINNERS -------------------
function y2k(number) { return (number < 1000) ? number + 1900 : number; }

var date = new Date();
var milliseconds =
    Date.UTC(y2k(date.getYear()),date.getMonth(),date.getDate());

function prevDay() {
    milliseconds -= 86400000;
    formatDate();
}

function nextDay() {
    milliseconds += 86400000;
    formatDate();
}

function formatDate() {
    date = new Date(milliseconds);
    var year = date.getYear();
    var month = date.getMonth() + 1;
    var day = date.getDate();
    document.date.spinner.value = ((year < 1000) ? year + 1900 : year) +
                            '-' + ((month < 10) ? '0' + month : month) +
                            '-' + ((day < 10) ? '0' + day : day);
}

function prevSpinNum(id, minvalue) {
  var mvalue = document.getElementById(id).value
  if (mvalue != null) {
    mvalue = mvalue - 0
    mvalue = mvalue-1
    if (mvalue < minvalue) {
      mvalue = minvalue;
    }
    document.getElementById(id).value = mvalue
  }
}
function nextSpinNum(id,maxvalue) {
  var mvalue = document.getElementById(id).value
  if (mvalue != null) {
    mvalue = mvalue-0;
    mvalue = mvalue+1;
    if (mvalue > maxvalue) {
      mvalue = maxvalue;
    }
    document.getElementById(id).value = mvalue
  }
}
//--></SCRIPT>

