function toggleDisplay(link_elem_id, div_elem_id) {
	var el = document.getElementById(link_elem_id);
	if (toggleHide(div_elem_id)) {
		el.innerHTML = "Show Additional";

	} else {
		el.innerHTML = "Hide Additional";
	}
}

function toggleHide(elem_id) {
	var e = document.getElementById(elem_id);
	e.style.display = (e.style.display == 'none') ? 'block' : 'none';
	return (e.style.display == 'none') ? true : false;
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=1,scrollbars=1,location=1,statusbar=1,menubar=1,resizable=1,width=800,height=400,left = 412,top = 334');");
}

var checkflag = "false";
function check(field) {
	if (checkflag == "false") {
		for (i = 0; i < field.length; i++) {
		field[i].checked = true;}
		checkflag = "true";
		//return "Uncheck All"; 
	}
else {
	for (i = 0; i < field.length; i++) {
	field[i].checked = false; }
	checkflag = "false";
	//return "Check All"; 
	}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
   var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
   if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function popupPage() {
var page = "prices_option.html";
windowprops = "height=400,width=800,location=no,"
+ "scrollbars=no,menubars=no,toolbars=no,resizable=yes";
window.open(page, "Popup", windowprops);
}

function MsgBox (textstring) {
alert (textstring) }

function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=1,scrollbars=1,location=1,statusbar=1,menubar=1,resizable=1,width=600,height=400,left = 112,top = 184');");
}

function popUp2(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=1,menubar=0,resizable=1,width=600,height=480,left = 10,top = 200');");
}

function popUp3(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=625,height=300,left = 10,top = 300');");
}

function popUp4(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width=425,height=625,left = 500,top = 100');");
}

function popUp8(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=1,scrollbars=1,location=1,statusbar=1,menubar=1,resizable=1,width=800,height=400,left = 112,top = 184');");
}

function popUpWindow(URL, wd, ht) {
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=1,scrollbars=1,titlebar=1,location=1,statusbar=0,menubar=1,resizable=1,width=" + wd + ",height=" + ht + ",left = " + ((screen.availWidth - wd) / 2) + ",top = " + (((screen.availHeight - ht) / 2) - 60)+ "');");
}

function wopen(url, name, w, h) {
	 eval("win = window.open(url, '" + name + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=" + w + ",height=" + h + "');");

	 win.resizeTo(w, h);
	 win.focus();
}

function popUpDialog(URL, wd, ht) {
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=" + wd + ",height=" + ht + ",left = " + ((screen.availWidth - wd) / 2) + ",top = " + (((screen.availHeight - ht) / 2) - 60)+ "');");
}

//validate the input of the pathway search form
function validate() {
	if(document.form1.keyword.value==''){
		alert('Fill the Input box before submitting!');
		//alert(document.form1.search_option[1].value);
		return false;
	}else if(form1.search_option[1].checked == true){		  
			if(IsNumeric(document.form1.keyword.value)){
				 return true;
		  }else {
		  	 alert('Gene id must be a valid integer!');
		  	 return false;
		  }
	}else{
		return true;
	}
}

function IsNumeric(sText){
   var ValidChars = "0123456789";
   var IsNumber=true;
   var Char; 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
}

function reload(form){
	var val=form.search_option.options[form.search_option.options.selectedIndex].value;
	self.location='all_pathway_list.php?search_option=' + val ;
}