
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 gene_OnClick() {
  var listBox = document.getElementById("gene");
  var subListBox = document.getElementById("probe");
  subListBox.options.length=0;
  var probelist = gene2probe[listBox.value];
  if(probelist) {
	for(j=0; j<probelist.length; j++) {
	subListBox.options.add(new Option(probelist[j],(probelist[j]).replace(/\//g,"=")));
	}
  }
}


function chr_OnClick() {
  var listBox = document.getElementById("chr");
  var subListBox = document.getElementById("pos");
  subListBox.options.length=0;
  var key = listBox.value;
  if(chr2pos[key]) {
	for(j=0; j<chr2pos[key].length; j++) {
	subListBox.options.add(new Option(chr2pos[key][j],chr2pos[key][j]));
	}
  }
}

function setHiddenProbename(name){
	document.getElementById("probetext").value = name;
}

var popupwindow;
var refreshed=1;

function show_legend(chr,pos)
{
  
  if(get_cookie("legendCookie")=='' || get_cookie("legendCookie")=='no'){
     popupwindow=window.open('pos_img/chr'+chr+'_'+pos+'.html',"_blank","left=900,top=20,toolbar=no, location=false, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, width=300,height=450");
  }
  else{
  	popupwindow.location='pos_img/chr'+chr+'_'+pos+'.html';
	popupwindow.focus();
  }
}

function get_cookie(Name) {
	var search = Name+'=';
	var returnvalue='';
	if (document.cookie.length > 0) {
	offset = document.cookie.indexOf(search)
	if (offset != -1) {
		offset += search.length
		end = document.cookie.indexOf(";", offset);
		if (end == -1)
			end = document.cookie.length;
			returnvalue=unescape(document.cookie.substring(offset, end))
		}
	}
	return returnvalue;
}

function closeLegend(){
	if(popupwindow)popupwindow.close();	
}