//*-----------------------------------------------------------------------------------------------*//
//common
//*-----------------------------------------------------------------------------------------------*//
function getSpeciesNo(species){
	if( species == Human){
		return 0;
	}
	else if( species == Patr){
		return 1;
	}
	else if(species == Macaque){
	    return 2;
	}
	else if( species == Mouse){
		return 3;
	}
	else if( species == Rat){
		return 4;
	}
}
//*-----------------------------------------------------------------------------------------------*//
function mousePoint(e){

	var pointX;
	var pointY;
	//get position of mouse point
	if(Opera){
		pointX =  window.event.clientX;
		pointY =  window.event.clientY;
	}else if (IE){
		pointX = event.x + document.documentElement.scrollLeft;
		pointY = event.y + document.documentElement.scrollTop;
	}else if (N6){
		pointX = e.clientX+window.scrollX;
		pointY = e.clientY+window.scrollY;
	}
	return new Array(pointX,pointY);
}
//*-----------------------------------------------------------------------------------------------*//
function popUp(pointX,pointY,explanation,id){
	var obj;
	if(Opera){	
		obj = document.getElementById(id);
		obj.style.left =  pointX;
		obj.style.top  =  pointY;
		obj.innerHTML=explanation;
		obj.style.visibility = popupVisible;
	}else if (IE){
		obj = document.all.item(id);
		obj.style.posLeft =  pointX;
		obj.style.posTop =  pointY;
		obj.innerHTML=explanation;
		obj.style.visibility = popupVisible;
	}else if (N6){
		obj = document.getElementById(id);
		obj.style.left = pointX + "px";
		obj.style.top = pointY + "px";
		obj.innerHTML=explanation;
		obj.style.visibility = popupVisible;
	}
}
//*-----------------------------------------------------------------------------------------------*//
function makeCloseFrame(explanation){
	explanation = "<a herf=# onClick=\"parentNode.style.visibility = 'hidden';popUpFlg = false;\"  id='expoClose'>x</a>" + explanation;
	return explanation;	
}
//*-----------------------------------------------------------------------------------------------*//
//load
//*-----------------------------------------------------------------------------------------------*//
function humanLoad(){
	debug.bDebug = false ;
	//debug.bDebug = true;
	//not to start the timer during a load
	//popUpFlg = true;
	popUpFlgChromosomeViewHuman = true;	
	popUpFlgChromosomeViewOthers = true;	
	popUpFlgZoomViewHuman = true;	
	popUpFlgZoomViewOthers = true;	
	
	Efs.getGene(checkHumanGene,humanAccessionNo);
}
//*-----------------------------------------------------------------------------------------------*//
function checkHumanGene(gene){
	if( gene == null){
                location.href="error.html";
	}else{
		humanGene = gene;
		humanFamilyName = humanGene.familyName;
		focusHumanGene = gene;
		Efs.getChromosomesBySpecies(setHumanChromosomeInfo,Human);
	}
}
//*-----------------------------------------------------------------------------------------------*//
function setHumanChromosomeInfo(List){

	var i;
	for(i = 0; i < List.length ;i++){
		chromosomeMaxBpHuman[i+1] = List[i].maxBp;
		chromosomeStartHuman[i+1] = List[i].startPointPx;
		chromosomeEndHuman[i+1] = List[i].endPointPx;
	}
	loadZoomView(Human);
	loadZoomView(selectedSpecies);

	othersLoad()
}
//*-----------------------------------------------------------------------------------------------*//
function othersLoad(){
	//not to start the timer during a load
	//popUpFlg = true;
	popUpFlgChromosomeViewHuman = true;
	popUpFlgChromosomeViewOthers = true;
	popUpFlgZoomViewHuman = true;
	popUpFlgZoomViewOthers = true;
	closePopupForFocusOthers();
	Efs.getOther1stAccessionNo(setAnimalChromosomeView,selectedSpecies,humanAccessionNo,humanFamilyName);
}
//*-----------------------------------------------------------------------------------------------*//
function setAnimalChromosomeView(str){
	if(str != null){
		other1stAccessionNo = str;
		debug.clear();
		debug.print("ortho:"+other1stAccessionNo + selectedSpecies);
		
	}else{
		btnDisabled(false);
	//	popUpFlg = false;	
		popUpFlgChromosomeViewHuman = false;
		popUpFlgChromosomeViewOthers = false;
		popUpFlgZoomViewHuman = false;
		popUpFlgZoomViewOthers = false;
		other1stAccessionNo = null;
		debug.clear();
		debug.print("ortho:"+other1stAccessionNo + selectedSpecies);
		/*
		if(selectedSpeciesOld != ""){
			alert("There is no ortholog in " + selectedSpecies + ".");
			//return to the last species
			selectedSpecies = selectedSpeciesOld;
			btnDisabled(false);
			// turn on the timer
			popUpFlg = false;	
		}else{
			location.href="error.html";
		}*/
	}
	chromosomeViewLoad();
	Efs.getChromosomesBySpecies(setAnimalChromosomeInfo,selectedSpecies);
	changeBandImage(bandDefault);
	
	document.getElementById("speciesSelect").selectedIndex = getSpeciesNo(selectedSpecies) -1;
}
//*-----------------------------------------------------------------------------------------------*//
function setAnimalChromosomeInfo(List){

	debug.print("chrm num"+List.length);

	if(List.length == 0){
		alert("there are no data for the species "+ selectedSpecies + ".");
		location.href="search.html";
	}
        var i;
	for(i = 0; i < List.length ;i++){
		chromosomeMaxBpOthers[i+1] = List[i].maxBp;
		chromosomeStartOthers[i+1] = List[i].startPointPx;
		chromosomeEndOthers[i+1] = List[i].endPointPx;
		//debug.print("chr animal max"+ chromosomeMaxBpOthers[i+1]);
		//debug.flush();
	}
	
	Efs.getGene(checkAnimalGene,other1stAccessionNo);

}
//*-----------------------------------------------------------------------------------------------*//
function checkAnimalGene(gene){

	if(gene != null){
		otherFamilyName = gene.familyName;
		
		
	}else{
		otherFamilyName = null;
	}
	
	
    
    
	othersGene = gene;
        
	focusOthersGene = gene;	
	changeMarkPoints();
	debug.print("after changeMarkPoint");
	debug.flush();
	Efs.getHumanGenesByFamily(setHumanGenesInfo,humanAccessionNo, humanFamilyName, selectedSpecies);

}
//*-----------------------------------------------------------------------------------------------*//
function setHumanGenesInfo(List){
	
	if(List == null){
		location.href="error.html";	
	}else{
     accessionNoListHuman = new Array(List.length);
	var i;
	for(i = 0;i < List.length;i++){
        accessionNoListHuman[i] = new Array( List[i].accessionNo ,List[i].classification.toLowerCase());	
	}
    setAnnotationByAccessionNoHuman(humanAccessionNo);
	setZoomPoint(Human,humanGene.chromosomeNo,humanGene.startBp,humanGene.endBp,humanGene.direction);
	Efs.getAnimalGenesByFamily(setAnimalGenesInfo,  humanAccessionNo, otherFamilyName, selectedSpecies);
	}
}
//*-----------------------------------------------------------------------------------------------*//
function setAnimalGenesInfo(List){
    if(List == null){
        location.href = "error.html";
    }else{
	    debug.print("in setAnimalGenesInfo");
	    debug.flush();
	    accessionNoListOthers = new Array(List.length);
	    var i;
	    for(i = 0;i < List.length;i++){
	    	var classificationStr = List[i].classification.toLowerCase();
//	    	if(classificationStr == ortholog){
//	    		classificationStr = List[i].orthology;
//	    	}
	    	accessionNoListOthers[i] = new Array( List[i].accessionNo ,classificationStr);
	    }
	    setAnnotationByAccessionNoOthers(other1stAccessionNo);
	    var imgSrc;
	    if(selectedSpecies == Mouse){
	    	imgSrc = graphicTitleMouse;
	    }else if(selectedSpecies == Rat){
	    	imgSrc = graphicTitleRat;
	    }else if(selectedSpecies == Macaque){
	        imgSrc = graphicTitleMacaque;
	    }else{
	    	imgSrc = graphicTitlePatr;
	    }
	    document.getElementById(graphicTitle).src = imgSrc;
       
	    if(List.length != 0){
	    	setZoomPoint(selectedSpecies,othersGene.chromosomeNo,othersGene.startBp,othersGene.endBp,othersGene.direction);
	    }else{
	    	setZoomPoint(selectedSpecies,1,1,1,"R");
	    }
	    btnDisabled(false);
	    //turn on the timer
	    //popUpFlg = false;
	    popUpFlgZoomViewHuman = false;
	    popUpFlgZoomViewOthers = false;	
	    popUpFlgChromosomeViewHuman = false;
	    popUpFlgChromosomeViewOthers = false;
	}
}
//*-----------------------------------------------------------------------------------------------*//
function btnDisabled(btnBoolean){
	//document.getElementById("bandSelect").disabled = btnBoolean;
	document.getElementById("check1").disabled = btnBoolean;
	document.getElementById("check2").disabled = btnBoolean;
	//document.getElementById("check3").disabled = btnBoolean;
	document.getElementById("speciesSelect").disabled = btnBoolean;
	document.getElementById("humanUp").disabled = btnBoolean;
	document.getElementById("humanDown").disabled = btnBoolean;
	document.getElementById("humanTop").disabled = btnBoolean;
	document.getElementById("humanLast").disabled = btnBoolean;
	document.getElementById("othersUp").disabled = btnBoolean;
	document.getElementById("othersDown").disabled = btnBoolean;
	document.getElementById("othersTop").disabled = btnBoolean;
	document.getElementById("othersLast").disabled = btnBoolean;
}
//*-----------------------------------------------------------------------------------------------*//
function changeSpecies(species){
	btnDisabled(true);
	document.getElementById(popupIdChromosomeViewHuman).style.visibility = 'hidden';
	document.getElementById(popupIdChromosomeViewOthers).style.visibility = 'hidden';
	document.getElementById(popupIdZoomViewHuman).style.visibility = 'hidden';
	document.getElementById(popupIdZoomViewOthers).style.visibility = 'hidden';
	//popUpFlg = false;
	popUpFlgChromosomeViewHuman = false;
	popUpFlgChromosomeViewOthers = false;
	popUpFlgZoomViewHuman = false;
	popUpFlgZoomViewOthers = false;
	clearTimeout(timerFocusIdHuman);
	clearTimeout(timerFocusIdOthers);
	
	closeLegend();
	
	selectedSpeciesOld = selectedSpecies;
	selectedSpecies = species;
	othersLoad();
}
//*-----------------------------------------------------------------------------------------------*//
function getFilter(){
	var filter = 0;
	if(document.getElementById(orthologCheckId).checked){
		filter += orthologCheckValue;
		
	}
	if(document.getElementById(paralogCheckId).checked){
		filter += paralogCheckValue;
	}
	
	
	return filter;
}

//*-----------------------------------------------------------------------------------------------*//
//chromosome view
//*-----------------------------------------------------------------------------------------------*//
function changeMarkPoints(){
	//initialization
    initializeMarkPoints();
	var filter = getFilter();
	debug.print("selectedSpecies:" +selectedSpecies);
	debug.print("familyName:"+humanFamilyName);
	debug.print("humanAccNo:"+humanAccessionNo);
	debug.print("filter"+filter);
	debug.flush();
	Efs.getMarkPoints(setMarkPoint,selectedSpecies,humanFamilyName,humanAccessionNo,filter);
}
//*-----------------------------------------------------------------------------------------------*//
function initializeMarkPoints(){
	var markPointOld = document.getElementById(markPointId);
	if(markPointOld != null){
		document.body.removeChild(markPointOld);
	}
	var markPointNew = document.createElement('div');
    markPointNew.id= markPointId;
    document.body.appendChild(markPointNew);
}	
//*-----------------------------------------------------------------------------------------------*//
function setMarkPoint(markPointList){	
	if(markPointList == null){
		location.href="error.html";	
	}else{
		var obj = document.getElementById(markPointId);
		debug.print("markPointNum " + markPointList.length);
		debug.flush();
		for (i = 0;i < markPointList.length ; i++){
		
		     
		
		    
			    var species = markPointList[i].species;
			    var chromosomeNo = markPointList[i].chromosomeNo;
			    var groupNo = markPointList[i].groupNo;
			    var direction = markPointList[i].direction;
			    var classification = markPointList[i].repClassification.toLowerCase();
			    var chromosomeY = markPointList[i].startBp;
			    var paralogCount = markPointList[i].paralogCount;
			
			    var chromosomeX;

			
			    if(species == Human){
			    	if(direction == directionRight){
					    chromosomeX = directionRightPosition;
				    }else{
					    chromosomeX = directionLeftPosition;
				    }
				    familyName = humanFamilyName;
			    }else{
				    if(direction == directionRight){
					    chromosomeX = directionRightPositionOthers;
				    }else{
				    	chromosomeX = directionLeftPositionOthers;
				    }
				    familyName = otherFamilyName;
			    }

			    var imgsrc;
			    //set URL of images
			    if(classification == ortholog){
			    	if(paralogCount > 0){
				    	if(direction == directionRight){
				    		imgsrc = markImgOrthologParalogRight;
					    }else{
					    	imgsrc = markImgOrthologParalogLeft;
					    }
				    }else{
				    	if(direction == directionRight){
				    		imgsrc = markImgOrthologRight;
				    	}else{
				    		imgsrc = markImgOrthologLeft;
				    	}
			    	}
			    }else if(classification == paralog){
			    	if(direction == directionRight){
				    	imgsrc = markImgParalogRight;
			    	}else{
				    	imgsrc = markImgParalogLeft;
				    }
			    }else{
				    imgsrc = markImgOther;
			    }
			
			    debug.print("before checkFocusMarker " + markPointList[i].species);
			    debug.print(" classification " + classification);
			    debug.flush();
			    imgsrc = imgsrc + checkFocusMarker(markPointList[i]);
			    imgsrc = imgsrc+markerSuffix;
			
		    	debug.print("imgsrc"+imgsrc +"\nafter checkFocusMarker classification" + classification);
			    debug.flush();
		
			    var point = calcMarkPoint(species,chromosomeNo,chromosomeX,chromosomeY);
			
			    //correct the location of a marker
			    var x = point[0];
			    var y = point[1];
			    if(direction == directionRight){
			    	x -= 6
			    }else{
			    	x -= 9
			    }
	//		    y -= 4
			    var protClone = document.createElement("img");
			    protClone.style.border = "none";
			    protClone.style.margin = "0px";
			    protClone.style.padding = "0px";
			    protClone.style.position = "absolute";
			    protClone.style.top = y + "px";
			    protClone.style.left = x + "px";
			    //protClone.style.width="7px";
			    protClone.style.width="10px";//10
	//		    protClone.style.height="8px"
			    protClone.style.height="10px"
			    protClone.style.zIndex = "30";

		    	var filter = getFilter();
			    var str = species + "," 
			    		+ chromosomeNo + "," 
			    		+ familyName + ","
				    	+ direction + ","
			    		+ groupNo + ","
			    		+ humanAccessionNo + ","
			    		//+ other1stAccessionNo;
			    		+ selectedSpecies;
					
			
			    protClone.className = str;
			    protClone.alt = classification;
			    //set event
			    if(Opera || IE){
			    	protClone.onclick = function () { 
			    		var arg = this.className.split(",");
			    		chromosomePopUpPoint = mousePoint(event);
                                            var filter = getFilter();
			    		debug.print("in IE getGenesByGroup markPointPopup sp:" +arg[0] + "\nflghuman:"+ popUpFlgChromosomeViewHuman
			    			 + "flgothers:"+ popUpFlgChromosomeViewOthers);
			    		debug.flush();
			    		if(((arg[0] == Human) && (popUpFlgChromosomeViewHuman == false)) || 
			    				((arg[0] != Human) && (popUpFlgChromosomeViewOthers == false))){ 					
			    			Efs.getGenesByGroup(markPointPopUp,arg[0],arg[1],arg[2],arg[3],arg[4],arg[5],arg[6],filter);
				    	}
			    	};
		    	}else if (N6){
				    protClone.addEventListener("click", function (event) {
				    	var arg = this.className.split(",");
				    	chromosomePopUpPoint = mousePoint(event);
				    	var filter = getFilter();
				    	if(((arg[0] == Human) && (popUpFlgChromosomeViewHuman == false)) || 
				    			((arg[0] != Human) && (popUpFlgChromosomeViewOthers == false))){ 
				    		Efs.getGenesByGroup(markPointPopUp,arg[0],arg[1],arg[2],arg[3],arg[4],arg[5],arg[6],filter);
				    	}

				      } ,true);
		    	}

		    	protClone.src = imgsrc;
			    obj.appendChild(protClone);
			
		}
	}
}
//*-----------------------------------------------------------------------------------------------*//

function checkFocusMarker(marker){
	var ImgNameSuffix = "";
        
	debug.print("in checkFocusMarker"+marker.species + marker.chromosomeNo +marker.direction+marker.groupNo);
	debug.flush();
	if(	(marker.species == Human) &&	
			(marker.chromosomeNo == focusHumanGene.chromosomeNo) &&
			(marker.direction == focusHumanGene.direction) &&
			(marker.groupNo == focusHumanGene.groupNo)){
		ImgNameSuffix = focusMarkerImg;
		
	}else if(focusOthersGene != null){
		if((marker.species == focusOthersGene.species) &&
			(marker.chromosomeNo == focusOthersGene.chromosomeNo) &&
			(marker.direction == focusOthersGene.direction) &&
			(marker.groupNo == focusOthersGene.groupNo)){
			ImgNameSuffix = focusMarkerImg;
		}
	}
	return ImgNameSuffix;
	debug.print("imgName "+imgNameSuffix);
	debug.flush();
}
//*-----------------------------------------------------------------------------------------------*//
function calcMarkPoint(species,chromosomeNo,chromosomeX,chromosomeY){
	
        var screenX;				//coordinate on the window
	var screenY;				//coordinate on the window
	var chromosomeAreaX;
	var chromosomeAreaY;
	var chromosomeUpper = chromosomeUpperNum;
       
	var chromosomeWidthTmp;
	if(species != Human){
		chromosomeWidthTmp = chromosomeWidthOthers;
		chromosomeUpper = chromosomeUpperOthers;
	}else{
		chromosomeWidthTmp = chromosomeWidth;
	}
	
	chromosomeAreaX = chromosomeWidthTmp * (chromosomeNo - 1 ) + chromosomeX;

	
	if(species == Human){
		chromosomeAreaY = (chromosomeEndHuman[chromosomeNo] - chromosomeStartHuman[chromosomeNo]) * chromosomeY / chromosomeMaxBpHuman[chromosomeNo] + chromosomeStartHuman[chromosomeNo];
	}else{
		chromosomeAreaY = (chromosomeEndOthers[chromosomeNo] - chromosomeStartOthers[chromosomeNo]) * chromosomeY / chromosomeMaxBpOthers[chromosomeNo] + chromosomeStartOthers[chromosomeNo];
	}
	
	if(chromosomeNo > chromosomeUpper){
		chromosomeAreaX -= chromosomeWidthTmp * chromosomeUpper
		chromosomeAreaY += (chromosomeHeight + chromosomeMiddleSpace)
	}

	if(species == Human){
		screenX = Math.round(chromosomeAreaX + chromosomeAreaLeftHuman);
		screenY = Math.round(chromosomeAreaY + chromosomeAreaTop);
	}else{
		screenX = Math.round(chromosomeAreaX + chromosomeAreaLeftOthers);
		screenY = Math.round(chromosomeAreaY + chromosomeAreaTop);
	}
	
	return new Array(screenX,screenY);
}
//*-----------------------------------------------------------------------------------------------*//
function changeBandImage(bandName){
	Efs.getBandImageUrl(setBandImageHuman,Human,bandName);
	Efs.getBandImageUrl(setBandImageOthers,selectedSpecies,bandName);
	bandDefault = bandName;
}

//*-----------------------------------------------------------------------------------------------*//
function setBandImageHuman(List){
	for (i=0; i < List.length; i++){
		document.getElementById(chrImgPrefixHuman + parseInt(i+1)).src = List[i];
	}
}
//*-----------------------------------------------------------------------------------------------*//
function setBandImageOthers(List){
	for (i=0; i < List.length; i++){
		document.getElementById(chrImgPrefixOthers + parseInt(i+1)).src = List[i];
	}
}
//*-----------------------------------------------------------------------------------------------*//
function markPointPopUp(geneList){
      if(geneList == null){
          location.href="error.html";
      }
	//if(!popUpFlgChromosome){
		//var explanation = "<dt class='markPointExpo'>\n";
		debug.print("in markPointPopup" );
		var explanation = "<img class='focusPopUpTriangle' src="+ triangleImage +"  /><dt class='focusPopup'>\n" +
				"<a herf=# onClick=\"closePopup('"
		debug.print("explanation" + explanation );
		debug.print("sp:" +  geneList[0].species);
		debug.flush();	
		if(geneList[0].species == Human){
			explanation += popupIdChromosomeViewHuman;
		}else{
			explanation += popupIdChromosomeViewOthers;
		}
						
		explanation += "')\" id='expoClose'>x</a>";
		debug.print("explanation" + explanation );
		debug.flush();
		var termColor;
		for (i =0 ; i< geneList.length ; i++){
			var classificationStr = geneList[i].classification.toLowerCase();
			if(classificationStr == ortholog){
				termColor = orthologColor;
			}else if(classificationStr == paralog){
				termColor = paralogColor;
			}else{
				termColor = otherColor;
			}
			if(i>0){
				explanation += "&nbsp;&nbsp;&nbsp;" ;
			}
			explanation += "&nbsp;<font color=" + termColor + ">";
			explanation += "<a link=#  onClick=changeFocus('" + geneList[i].accessionNo + "');";
			
		//	var accNo = geneList[i].accessionNo;
        //    if(accNo.match(/[a-z]$/)){
		//        var length = accNo.length;
		//	    accNo = accNo.substring(0,length-1);
		//    }
			
			if( geneList[i].species == Human){
                
				explanation += "setAnnotationByAccessionNoHuman('"+ geneList[i].accessionNo + "');>";
				
			}else{
				explanation += "setAnnotationByAccessionNoOthers('"+ geneList[i].accessionNo + "');>";

			}
			if(geneList[i].geneSyb == "-"){
                            explanation += geneList[i].accessionNo + "</a>&nbsp;</font><br />\n";
                        }else{
			    explanation += geneList[i].accessionNo + " &nbsp;<i>" + strFilter(geneList[i].geneSyb) + "</i></a>&nbsp;</font><br />\n";
                        }
		}
		explanation += "</dt>\n";

		//popUp(chromosomePopUpPoint[0],chromosomePopUpPoint[1],makeCloseFrame(explanation),popupId);
		if(geneList[0].species == Human){
			popUp(chromosomePopUpPoint[0],chromosomePopUpPoint[1],explanation,popupIdChromosomeViewHuman);
			popUpFlgChromosomeViewHuman = true;
		}else{
			popUp(chromosomePopUpPoint[0],chromosomePopUpPoint[1],explanation,popupIdChromosomeViewOthers);
			popUpFlgChromosomeViewOthers = true;
		}
	
		//popUpFlg = true;
	//}

}
//*-----------------------------------------------------------------------------------------------*//
function chromosomeViewLoad(){
	var chromosomeNum = 0;
	if(selectedSpecies == Mouse){
		chromosomeNum = chromosomeNumMouse;
	}else if(selectedSpecies == Patr){
		chromosomeNum = chromosomeNumPatr;
	}else if(selectedSpecies == Macaque){
		chromosomeNum = chromosomeNumMacaque;
	}else if(selectedSpecies == Rat){
		chromosomeNum = chromosomeNumRat;
	}else{
		alert("there are no data for the species "+ selectedSpecies + ".");
		location.href="search.html";
	}

	var strInnerHTML1 = "";
	var strInnerHTML2 = "";
	var strInnerHTML3 = "";
	var strInnerHTML4 = "";

	if(chromosomeNum > 24){
		chromosomeUpperOthers = Math.ceil(chromosomeNum / 2);
		//chromosomeWidthOthers = Math.floor(420 / Math.ceil(chromosomeNum / 2));
		chromosomeWidthOthers = 420 / Math.ceil(chromosomeNum / 2);
	}else{
		chromosomeUpperOthers = 12;
		chromosomeWidthOthers = 35;
	}
	
	//directionRightPositionOthers = parseInt(directionRightPosition * chromosomeWidthOthers / chromosomeWidth);
	//directionLeftPositionOthers = parseInt(directionLeftPosition * chromosomeWidthOthers / chromosomeWidth);
	directionRightPositionOthers = directionRightPosition * chromosomeWidthOthers / chromosomeWidth;
	directionLeftPositionOthers = directionLeftPosition * chromosomeWidthOthers / chromosomeWidth;

	var i;
	for(i = 1 ; i <= chromosomeUpperOthers * 2 ; i++){
		var chromosomeName;
                if(selectedSpecies == Macaque || selectedSpecies == Rat){
                    if(i == chromosomeNum){
                        chromosomeName = "X";
                    }else{
                        chromosomeName = i;
                    }
                }else if(selectedSpecies == Patr){
                    if(i == 1){
                        chromosomeName = 1;
                    }else if(i == 2){
                        chromosomeName = "2a";
                    }else if(i == 3){
                        chromosomeName = "2b";
                    }else if(i == chromosomeNum -1){
                        chromosomeName = "X";
		            }else if(i == chromosomeNum){
		                chromosomeName = "Y";
		            }else{
		                chromosomeName = i-1;
		            }                            
                }else{		
		            if(i == chromosomeNum -1){
			            chromosomeName = "X";
		            }else if(i == chromosomeNum){
		                chromosomeName = "Y";
		            }else{
			            chromosomeName=i;
		            }
               }
		
		if( i <= chromosomeUpperOthers){
			strInnerHTML1 =  strInnerHTML1 + "<td class=\"graphic-num\"><div class=\"graphic-font\">" + chromosomeName + "</div></td>";
		    strInnerHTML2 =  strInnerHTML2 + "<td class=\"graphic-band\"><img src=\"images/chr00.png\" id=\"othersChrImage" + i + "\" width=\"" + chromosomeWidthOthers + "\" height=\"100\"></td>";
		}else{
			if(i > chromosomeNum){
			    strInnerHTML3 =  strInnerHTML3 + "<td class=\"graphic-num\"></td>";
                                strInnerHTML4 =  strInnerHTML4 + "<td class=\"graphic-band table-border\"></td>"
                        }else{
                                strInnerHTML3 =  strInnerHTML3 + "<td class=\"graphic-num\"><div class=\"graphic-font\">" + chromosomeName + "</div></td>";
                                strInnerHTML4 =  strInnerHTML4 + "<td class=\"graphic-band table-border\"><img src=\"images/chr00.png\" id=\"othersChrImage" + i + "\" width=\"" + chromosomeWidthOthers + "\" height=\"100\"></td>"
			}
		}
	}


 
	var strInnerHTML = "<table class=\"graphic-table\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">"
	+ "<tr>"
	+ "<td class=\"graphic-title table-species\" rowspan=\"4\"><img src=\"\" id=\""
	+ graphicTitle
	+ "\" width=\"15\" height=\"100\"></td>"
	+ strInnerHTML1 + "  </tr>" + "  <tr>"
	+ strInnerHTML2 + "  </tr>" + "  <tr>"
	+ strInnerHTML3 + "  </tr>" + "  <tr>"
	+ strInnerHTML4 + "  </tr>" + "  </table>";

	var parentObj = document.getElementById(chromosomeViewOthersId);
	parentObj.innerHTML = strInnerHTML;
}

//*-----------------------------------------------------------------------------------------------*//
//ZoomView
//*-----------------------------------------------------------------------------------------------*//
function loadZoomView(species){
	
	var strInnerHTML = "";

	var divTopArea = zoomAreaTop;
	var divTopImage = zoomImageTop;
	var divDragAreaTop = zoomDragAreaTop;
	var divWidth = zoomImageShowBlockNum * zoomImageBlockSize;
	var divHeightArea = zoomDragAreaHeight;
	var diVHeightImage = zoomImageHeight;
	
	var clipTop = 0;
	var clipRight = zoomImageShowBlockNum * zoomImageBlockSize;
	var clipBottom = zoomImageHeight;
	var clipLeft = 0;

	var divAllImagesTop = 0;
	var divAllImagesWidth = ((zoomImageHiddenBlockLeftNum+zoomImageShowBlockNum+zoomImageHiddenBlockRightNum)*zoomImageBlockSize);
		
	//var i;
	//for(i =0 ; i < 2 ; i++){	//i=0:Human ; i=1:Others
		//if(i == 0){
		if(species == Human){
			var zoomId = zoomIdHuman;
			var divLeft = zoomAreaLeftHuman;
		}else{
			var zoomId =  zoomIdOthers;
			var divLeft = zoomAreaLeftOthers;
		}

		//strInnerHTML = '<img src=\"' + zoomClearSheet + '\" style=\"position:absolute; top:'+divTopArea+'px; left:'+divLeft+'px; width:'+divWidth+'px; height:'+divHeightArea+'px; z-index:50 \" ';
		strInnerHTML = '<img src=\"' + zoomClearSheet + '\" style=\"position:absolute; top:'+divDragAreaTop+'px; left:'+divLeft+'px; width:'+divWidth+'px; height:'+divHeightArea+'px; z-index:50 \" ';	
			//if(i == 0){
			if(species == Human){
				strInnerHTML = strInnerHTML + '\n' + 'onMouseDown=\"dragOnZoomImageHuman(event); return false\" ';
				strInnerHTML = strInnerHTML + '\n' + 'onmouseup=\"dragOffZoomImageHuman(event);return false\" ';
				strInnerHTML = strInnerHTML + '\n' + 'onMouseOut=\"timerZoomEventClearHuman(event)\" ';			//gene explanation
				strInnerHTML = strInnerHTML + '\n' + 'onmousemove = \"moveZoomImageHuman(event);return false\"';
			}else{
				strInnerHTML = strInnerHTML + '\n' + 'onMouseDown=\"dragOnZoomImageOthers(event); return false\" ';
				strInnerHTML = strInnerHTML + '\n' + 'onmouseup=\"dragOffZoomImageOthers(event);return false\" ';
				strInnerHTML = strInnerHTML + '\n' + 'onMouseOut=\"timerZoomEventClearOthers(event)\" ';			//gene explanation
				strInnerHTML = strInnerHTML + '\n' + 'onmousemove = \"moveZoomImageOthers(event);return false\"';
			}
			strInnerHTML = strInnerHTML + '\n' + '>';

		strInnerHTML = strInnerHTML + '\n' + '<div style=\"position:absolute; top:'+divTopImage+'px; left:'+divLeft+'px; width:'+divWidth+'px; height:'+diVHeightImage+'px; clip:rect('+clipTop+'px '+clipRight+'px '+clipBottom+'px '+clipLeft+'px);overflow:hidden \">';
			strInnerHTML = strInnerHTML + '\n' + '<div id=\"' + zoomId + '\" style=\"position:absolute; top:'+divAllImagesTop+'; left:0px; width:'+divAllImagesWidth+'px; height:'+diVHeightImage+'px;\" >';

				for (x=0; x<(zoomImageHiddenBlockLeftNum + zoomImageShowBlockNum + zoomImageHiddenBlockRightNum); x++){
					//if(i == 0){
					if(species == Human){
						strInnerHTML = strInnerHTML + '<img src=\"\" width=\"'+zoomImageBlockSize+'\" height=\"'+diVHeightImage+'\" name=\"' + zoomImgPrefixHuman +x+'\" onError=\"this.src=zoomNoImageData\">';
					}else{
						strInnerHTML = strInnerHTML + '<img src=\"\" width=\"'+zoomImageBlockSize+'\" height=\"'+diVHeightImage+'\" name=\"' + zoomImgPrefixOthers + x+'\" onError=\"this.src=zoomNoImageData\">';
					}
				}
	 
			strInnerHTML = strInnerHTML + '\n' + '</div>';
		strInnerHTML = strInnerHTML + '\n' + '</div>';

		
		//if(i == 0){
		if(species == Human){
			var parentObj = document.getElementById(zoomParentIdHuman);
			parentObj.innerHTML = strInnerHTML;
		}else{
			var parentObj = document.getElementById(zoomParentIdOthers);
			parentObj.innerHTML = strInnerHTML;
		}
	//}
}

//*-----------------------------------------------------------------------------------------------*//
function setZoomPoint(species,chromosomeNo,startBp,endBp,direction){

        draggedEverFlg = false; //because of a new gene
        
        
    
	changeScaleButton(presentScaleArray[getSpeciesNo(species)], species);
	
	
	
	//presentScaleArray[getSpeciesNo(species)] = defaultScale;//**
	
	if(species == Human){
		selectedChromosomeNoHuman = chromosomeNo;
		zoomImgMaxHuman = chromosomeMaxBpHuman[chromosomeNo] / BPPArray[presentScaleArray[getSpeciesNo(species)]];
		//popUpForFocus(focusHumanGene);
	}else{
		selectedChromosomeNoOthers = chromosomeNo;
		zoomImgMaxOthers = chromosomeMaxBpOthers[chromosomeNo] / BPPArray[presentScaleArray[getSpeciesNo(species)]];
		//popUpForFocus(focusOthersGene);
	}

	var focusBp;
	if(direction == directionRight){
		focusBp = startBp;
	}else{
		focusBp = endBp;
	}
	
	var veiwPoint = calcPxFromBp(focusBp, species);

	setZoomImage(species,veiwPoint);
	defaultStartBpArray[getSpeciesNo(species)]= focusBp;

	//set ChromosomeNo and popup for focus 
	var obj;
	if(species == Human){
		obj = document.getElementById(zoomChrNoIdHuman);
		popUpForFocus(focusHumanGene);
	}else{
		obj = document.getElementById(zoomChrNoIdOthers);
		if(focusOthersGene != null){
			popUpForFocus(focusOthersGene);
		}
	}
	obj.innerHTML = getChromosomeNo(chromosomeNo,species);
	
	
}
//*-----------------------------------------------------------------------------------------------*//
function calcPxFromBp(focusBp,species){
	var veiwPoint = parseInt(focusBp / BPPArray[presentScaleArray[getSpeciesNo(species)]]);	//(bp to px)
	veiwPoint -= parseInt(zoomImageShowBlockNum * zoomImageBlockSize / 2);
	return veiwPoint;
}
//*-----------------------------------------------------------------------------------------------*//
function setZoomImageDummy(species,moveDiff){
	
	var tmpDiffOld = startPxArray[getSpeciesNo(species)] % zoomImageBlockSize;
	var leftOld = - parseInt((zoomImageBlockSize * zoomImageHiddenBlockLeftNum) + tmpDiffOld);

	var leftNew = parseInt(leftOld) + parseInt(moveDiff);
	var startPx = startPxArray[getSpeciesNo(species)] - parseInt(moveDiff);
	
	
	
	//the left most point
	//if(startPx < 0){
	var minStartPx = -((zoomImageShowBlockNum * zoomImageBlockSize)/2);
	if(startPx < minStartPx){
		//leftNew += startPx;
		//startPx = 0;
		//leftNew =  minStartPx - startPx;
		startPx = minStartPx;
		leftNew = - startPx % zoomImageBlockSize - parseInt(zoomImageBlockSize * zoomImageHiddenBlockLeftNum);
		
	}

	var maxStartPx;
	if(species == Human){
		maxStartPx = zoomImgMaxHuman - (zoomImageShowBlockNum * zoomImageBlockSize)/2;
	}else{
		maxStartPx = zoomImgMaxOthers - (zoomImageShowBlockNum * zoomImageBlockSize)/2;
	}
	
	//the right most point
	if(startPx > maxStartPx){
		//leftNew += startPx - maxStartPx;
		startPx = maxStartPx;
		leftNew = - startPx % zoomImageBlockSize - parseInt(zoomImageBlockSize * zoomImageHiddenBlockLeftNum);
	}
	
	if(species == Human){
		document.getElementById(zoomIdHuman).style.left =  leftNew + "px";
	}else{
		document.getElementById(zoomIdOthers).style.left =  leftNew + "px";
	}
	showZoomPointBp(species,startPx);
	//not set to startPxArray during a dragging
}
//*-----------------------------------------------------------------------------------------------*//
function setZoomImage(species,startPx){

	var maxStartPx;
	if(species == Human){
		maxStartPx = zoomImgMaxHuman - (zoomImageShowBlockNum * zoomImageBlockSize)/2;
	}else{
		maxStartPx = zoomImgMaxOthers - (zoomImageShowBlockNum * zoomImageBlockSize)/2;
	}
	//the left most point
	//if(startPx < 0){
	if(startPx < -((zoomImageShowBlockNum * zoomImageBlockSize)/2)){
		//startPx = 0;
		startPx = -((zoomImageShowBlockNum * zoomImageBlockSize)/2);
	//the right most point
	}else if(startPx > maxStartPx){
		startPx = maxStartPx;
	}

	var tmpDiff = startPx % zoomImageBlockSize;
	var hiddenBlockNum = ((startPx - tmpDiff) / zoomImageBlockSize);

	//set startPxArray when the dragging is ended
	startPxArray[getSpeciesNo(species)] = startPx;
	var scale = parseInt(presentScaleArray[getSpeciesNo(species)]);
	

	var imageNo = hiddenBlockNum - zoomImageHiddenBlockLeftNum;
	
	if(species == Human){
		Efs.getZoomImageUrl(species,selectedChromosomeNoHuman,imageNo,scale,selectedSpecies,setZoomImageUrlHuman);
	}else{
		Efs.getZoomImageUrl(species,selectedChromosomeNoOthers,imageNo,scale,selectedSpecies,setZoomImageUrlOthers);
	}
	
}
//*-----------------------------------------------------------------------------------------------*//
function setZoomImageUrlHuman(List){
    if(List == null){
        location.href="error.html";
    }

	var startPx = startPxArray[getSpeciesNo(Human)];
	var tmpDiff =  startPx % zoomImageBlockSize;
	var leftNew = - parseInt((zoomImageBlockSize * zoomImageHiddenBlockLeftNum) + tmpDiff);

	document.getElementById(zoomIdHuman).style.left =  leftNew + "px";

	var x;
	//in case of no image because of chromosome's edge
	var noImgFlgStart = getNoImgFlgStart(startPx);
	var noImgFlgEnd = getNoImgFlgEnd(startPx,Human);
	var centerImgIndexStart = zoomImageHiddenBlockLeftNum + zoomImageShowBlockNum/2;

	for (x=0; x < zoomImageHiddenBlockLeftNum + zoomImageShowBlockNum + zoomImageHiddenBlockRightNum ; x++){
		//in case of the  end of chromosome
		if(noImgFlgEnd && (List.length - 1 < x)){
			document.images[zoomImgPrefixHuman + x].src = zoomNoImageDataEdge;
		}else {
			if(List[x] == "" ){
				//in case of chromosome start
				if((x < centerImgIndexStart) && noImgFlgStart) {
					List[x] = zoomNoImageDataEdge;
				}else{
					List[x] = zoomNoImageData;
				}	
			}
			debug.print(List[x]);
			document.images[zoomImgPrefixHuman + x].src = List[x];
		}
	}
	debug.flush();
	
	showZoomPointBp(Human,startPx);
}
//*-----------------------------------------------------------------------------------------------*//
function setZoomImageUrlOthers(List){
    if(List == null){
        location.href="error.html";
    }
	var startPx = startPxArray[getSpeciesNo(selectedSpecies)];
	var tmpDiff =  startPx % zoomImageBlockSize;
	var leftNew = - parseInt((zoomImageBlockSize * zoomImageHiddenBlockLeftNum) + tmpDiff);
	document.getElementById(zoomIdOthers).style.left = leftNew + "px";

	var x;
	//in case of no image because of chromosome's edge
	var noImgFlgStart = getNoImgFlgStart(startPx);
	var noImgFlgEnd = getNoImgFlgEnd(startPx,selectedSpecies);
	var centerImgIndexStart = parseInt(zoomImageHiddenBlockLeftNum + zoomImageShowBlockNum/2);

	for (x=0; x < zoomImageHiddenBlockLeftNum + zoomImageShowBlockNum + zoomImageHiddenBlockRightNum ; x++){
		//in case of chromosome end 
		if(noImgFlgEnd && (List.length < x)){
			document.images[zoomImgPrefixOthers + x].src = zoomNoImageDataEdge;
		}else {
			if(List[x] == ""){
			//in case of chromosome start
				if((x<centerImgIndexStart) && noImgFlgStart){
					List[x] = zoomNoImageDataEdge;
				}else{
					List[x] = zoomNoImageData;
				}
			}
			document.images[zoomImgPrefixOthers + x].src = List[x];
		}
		
	}
	showZoomPointBp(selectedSpecies,startPx);
}
//*-----------------------------------------------------------------------------------------------*//
function getNoImgFlgStart(startPx) {
	if(startPx < 0){
		return true;
	}else{
		return false;
	}
}
//*-----------------------------------------------------------------------------------------------*//
function getNoImgFlgEnd(startPx,species) {
	var endPx = parseInt(startPx) + parseInt(parseInt(zoomImageShowBlockNum + zoomImageHiddenBlockRightNum) * parseInt(zoomImageBlockSize));
	var scale = presentScaleArray[getSpeciesNo(species)];
	var viewEndBp = parseInt(endPx * BPPArray[scale]);
	if(species == Human){
		if(viewEndBp > chromosomeMaxBpHuman[selectedChromosomeNoHuman]){
			return true;
		}else{
			return false;
		}
	}else{
		if(viewEndBp > chromosomeMaxBpOthers[selectedChromosomeNoOthers]){
			return true;	
		}else{
			return false;
		}
	}
}
//*-----------------------------------------------------------------------------------------------*//
function showZoomPointBp(species,startPx) {
	debug.print("in showZoomPointBp");
	debug.flush();
	var endPx = parseInt(startPx) + parseInt(parseInt(zoomImageShowBlockNum) * parseInt(zoomImageBlockSize));
	var scale = presentScaleArray[getSpeciesNo(species)];

	if(startPx < 0){
		startPx = 0;
	}
	var viewStartBp = Math.round(startPx * BPPArray[scale] /1000) ;
	var viewEndBp = Math.round(endPx * BPPArray[scale] / 1000);

	if(species == Human){
		if(viewEndBp > Math.round(chromosomeMaxBpHuman[selectedChromosomeNoHuman]/1000)){
			viewEndBp = Math.round(chromosomeMaxBpHuman[selectedChromosomeNoHuman]/1000);
		}
		document.getElementById(zoomStartPointIdHuman).innerHTML = addFigure(viewStartBp) + " kb";
		document.getElementById(zoomEndPointIdHuman).innerHTML = addFigure(viewEndBp) + " kb";
	}else{
		if(viewEndBp >Math.round(chromosomeMaxBpOthers[selectedChromosomeNoOthers]/1000)){
			viewEndBp = Math.round(chromosomeMaxBpOthers[selectedChromosomeNoOthers]/1000);
		}
		document.getElementById(zoomStartPointIdOthers).innerHTML = addFigure(viewStartBp) + " kb";
		document.getElementById(zoomEndPointIdOthers).innerHTML = addFigure(viewEndBp) + " kb";
	}
}
//*-----------------------------------------------------------------------------------------------*//
// add "," every 3ketas
function addFigure(str) {
var num = new String(str).replace(/,/g, "");
while(num != (num = num.replace(/^(-?\d+)(\d{3})/, "$1,$2")));
return num;
}

//*-----------------------------------------------------------------------------------------------*//

function dragOnZoomImage(species,e){
	var point = mousePoint(e);
	var imgid;

	zoomImageDragStartX = point[0];
	zoomImageDragFlg = true;

	if(species == Human){
		imgid = zoomIdHuman;
	}else{
		imgid = zoomIdOthers;
	}
	draggedEverFlg = true;
}
//*-----------------------------------------------------------------------------------------------*//
function dragOnZoomImageHuman(e){
	dragOnZoomImage(Human,e);
	return false;
}
//*-----------------------------------------------------------------------------------------------*//
function dragOnZoomImageOthers(e){
	dragOnZoomImage(selectedSpecies,e);
	return false;
}
//*-----------------------------------------------------------------------------------------------*//
function dragOffZoomImage(species,e){
	if (zoomImageDragFlg){
		//distance from the clicked point(px)
		var moveDiff = mousePoint(e)[0] - zoomImageDragStartX;
		var viewPoint = startPxArray[getSpeciesNo(species)] - parseInt(moveDiff);

		//re-draw
		setZoomImage(species,viewPoint);
		zoomImageDragFlg = false;
	}
}
//*-----------------------------------------------------------------------------------------------*//
function dragOffZoomImageHuman(e){
	dragOffZoomImage(Human,e);
	return false;
}
//*-----------------------------------------------------------------------------------------------*//
function dragOffZoomImageOthers(e){
	dragOffZoomImage(selectedSpecies,e);
	return false;
}
//*-----------------------------------------------------------------------------------------------*//
function moveZoomImage(species,e){
	//turn off the timer because of moving
	clearTimeout(timerId);

	if (zoomImageDragFlg){
		//distance from the clicked point(px)
		var moveDiff = mousePoint(e)[0] - zoomImageDragStartX;
		//re-draw for moving
		setZoomImageDummy(species,moveDiff);
	}else if(((species == Human) && !popUpFlgZoomViewHuman) || 
			((species != Human) && !popUpFlgZoomViewOthers)){
		//popup for a gene info.
		timerPoint = mousePoint(e);

		if(species == Human){
			//run timerZoomEvent() at regular time intervals 
			timerId = setTimeout("timerZoomEvent(Human)",500);
		}else{
			timerId = setTimeout("timerZoomEvent(selectedSpecies)",500);
		}
	}
}
//*-----------------------------------------------------------------------------------------------*//
function moveZoomImageHuman(e){
	moveZoomImage(Human,e);
	return false;
}
//*-----------------------------------------------------------------------------------------------*//
function moveZoomImageOthers(e){
	moveZoomImage(selectedSpecies,e);
	return false;
}
//*-----------------------------------------------------------------------------------------------*//
function timerZoomEventClearHuman(e){
	//turn off the timer because of moving
	clearTimeout(timerId);
	dragOffZoomImageHuman(e);
}
//*-----------------------------------------------------------------------------------------------*//
function timerZoomEventClearOthers(e){
	//turn off the timer because of moving
	clearTimeout(timerId);
	dragOffZoomImageOthers(e);
}
//*-----------------------------------------------------------------------------------------------*//
function timerZoomEvent(species){

	clearTimeout(timerId);

	var screenX = timerPoint[0];
	var screenY = timerPoint[1];
	var pointX;
	var pointY;
	var displayGeneLevel;
	var showPopupFlg = true;

	if(species == Human){
		pointX = parseInt(screenX) - parseInt(zoomAreaLeftHuman);
	}else{
		pointX = parseInt(screenX) - parseInt(zoomAreaLeftOthers);
	}

	pointX += startPxArray[getSpeciesNo(species)];
	if(IE){
		pointX -= 2;//chousei
	}
	pointY = parseInt(screenY) - parseInt(zoomImageTop);
	
	var chromosomeNo;
	if(species == Human){
		chromosomeNo = selectedChromosomeNoHuman;
	}else{
		chromosomeNo = selectedChromosomeNoOthers;
		//timerPoint[0] = screenX - 300;		
	}
	
	var direction;

	if(pointY >= zoomAreaUpperHeight){
		direction = directionLeft;
	}else{
		direction = directionRight;
	}
	if(direction == directionRight){
		if(zoomAreaUpperGeneBottom <= pointY ){
			showPopupFlg = false;
		}else if((zoomAreaUpperGeneBottom - pointY)%zoomAreaMultiLevelInterval == 0){
			showPopupFlg = false;
		}else{
			displayGeneLevel = Math.ceil((zoomAreaUpperGeneBottom - pointY)/zoomAreaMultiLevelInterval);
		}
		
	}else{
		if(pointY <= zoomAreaLowerGeneTop){
			showPopupFlg = false;
		}else if((pointY - zoomAreaLowerGeneTop)%zoomAreaMultiLevelInterval == 0){
			showPopupFlg = false;
		}else{
			displayGeneLevel = Math.ceil((pointY - zoomAreaLowerGeneTop)/zoomAreaMultiLevelInterval);
		}
	}
	if(displayGeneLevel > zoomAreaMultiLevelNum){
			showPopupFlg = false;
	}
	debug.clear();
	debug.print("sy:"+screenY);
	debug.print("x:"+pointX);
	debug.print("y"+pointY);
	var pointBpStart = parseInt(pointX * BPPArray[presentScaleArray[getSpeciesNo(species)]])+ 1;
	var pointBpEnd = parseInt((pointX + 1) * BPPArray[presentScaleArray[getSpeciesNo(species)]]);
	debug.print("pointBpStart:"+pointBpStart);
	debug.print("pointBpEnd"+pointBpEnd);
	debug.print("level:"+displayGeneLevel);
	debug.print("direction:" + direction);
	debug.flush();

	if(showPopupFlg){
		Efs.getGeneByLocation(species,chromosomeNo,direction,pointBpStart,pointBpEnd,displayGeneLevel,zoomPopUp);
	}
}
//*-----------------------------------------------------------------------------------------------*//
function zoomPopUp(gene){
	
	if(gene != null){
		var termColor;
		var classificationStr =	getClassification(gene);

		//if(classificationStr != ""){
		termColor = getClassificationColor(classificationStr);
		if(classificationStr != ""){
			classificationStr = classificationStr.toLowerCase();
		}
		var explanation;
		var pointX = timerPoint[0];
		var pointY = timerPoint[1];
		if(gene.species == Human){
                       if(gene.geneSyb == "-"){
                           explanation = "<img class='focusPopUpTriangle' src="+ triangleImage +"  />" +
                                "<dt class='focusPopup'> <a herf=# onClick=\"closePopup('"+ popupIdZoomViewHuman + "')\"  id='expoClose'>x</a>" +
                                "&nbsp;<font color=" + termColor +">"+
                                                         gene.accessionNo + "&nbsp;</font></dt>";   
                       }else{
			    explanation = "<img class='focusPopUpTriangle' src="+ triangleImage +"  />" +
				"<dt class='focusPopup'> <a herf=# onClick=\"closePopup('"+ popupIdZoomViewHuman + "')\"  id='expoClose'>x</a>" +
				"&nbsp;<font color=" + termColor +">"+
							 gene.accessionNo + "&nbsp; <i> " +
							 strFilter(gene.geneSyb) + 
							 "</i>&nbsp;</font></dt>";
		       }
                        popUp(pointX,pointY,explanation,popupIdZoomViewHuman);
			popUpFlgZoomViewHuman = true;
		}else{
                    if(gene.geneSyb ="-"){
                        explanation = "<img class='focusPopUpTriangle' src="+ triangleImage +"  />" +
                                "<dt class='focusPopup'> <a herf=# onClick=\"closePopup('"+ popupIdZoomViewOthers + "')\"  id='expoClose'>x</a>" +
                                "&nbsp;<font color=" + termColor +">"+
                                                         gene.accessionNo + " &nbsp;</font></dt>"
                     }else{
			explanation = "<img class='focusPopUpTriangle' src="+ triangleImage +"  />" +
				"<dt class='focusPopup'> <a herf=# onClick=\"closePopup('"+ popupIdZoomViewOthers + "')\"  id='expoClose'>x</a>" +
				"&nbsp;<font color=" + termColor +">"+
							 gene.accessionNo + "&nbsp; <i> " +
							 strFilter(gene.geneSyb) + 
							 "</i>&nbsp;</font></dt>";
		      }
                        popUp(pointX,pointY,explanation,popupIdZoomViewOthers);
			popUpFlgZoomViewOthers = true;
		}
		
	}
}
//*-----------------------------------------------------------------------------------------------*//
function clickScaleButton(size, species){
	if(species == Human){
		if(size==2)	{
			document.button10kHuman.src = scale2OnclickPic;
		}else if(size == 1) {
	  		document.button100kHuman.src = scale1OnclickPic;
		}else if(size == 0) {
	  		document.button1mHuman.src = scale0OnclickPic;
		}
	}else{
		if(size==2)	{
			document.button10kOthers.src = scale2OnclickPic;
		}else if(size == 1) {
	  		document.button100kOthers.src = scale1OnclickPic;
		}else if(size == 0) {
	  		document.button1mOthers.src = scale0OnclickPic;
		}
	}
}
//*-----------------------------------------------------------------------------------------------*//
function changeScaleButton(size, species){
	if(species == Human){
		if(size==2)	{
			document.button10kHuman.src = scale2OnPic;
			document.button100kHuman.src = scale1Pic;
			document.button1mHuman.src = scale0Pic;
		}else if(size == 1) {
			document.button100kHuman.src = scale1OnPic;
			document.button10kHuman.src = scale2Pic;
			document.button1mHuman.src = scale0Pic;
		}else if(size == 0) {
			document.button1mHuman.src = scale0OnPic;
			document.button10kHuman.src = scale2Pic;
			document.button100kHuman.src = scale1Pic;
		}
	}else{
		if(size==2)	{
			document.button10kOthers.src = scale2OnPic;
			document.button100kOthers.src = scale1Pic;
			document.button1mOthers.src = scale0Pic;
		}else if(size == 1) {
			document.button100kOthers.src = scale1OnPic;
			document.button10kOthers.src = scale2Pic;
			document.button1mOthers.src = scale0Pic;
		}else if(size == 0) {
			document.button1mOthers.src = scale0OnPic;
			document.button10kOthers.src = scale2Pic;
			document.button100kOthers.src = scale1Pic;
		}
	}
}
//*-----------------------------------------------------------------------------------------------*//
function changeScale(size, species){
	changeScaleButton(size, species);
	if(species != Human){
		species = selectedSpecies;
	}
	setZoomPointForScaleChange(species, size);		
}
//*-----------------------------------------------------------------------------------------------*//
function returnScaleButton(size, species){
	if(species == Human){
		if(size==2)	{
			if(presentScaleArray[getSpeciesNo(species)] == 2){
				document.button10kHuman.src = scale2OnPic;
			}else{
				document.button10kHuman.src = scale2Pic;
			}			
		}else if(size == 1) {
			if(presentScaleArray[getSpeciesNo(species)] == 1){
				document.button100kHuman.src = scale1OnPic;
			}else{
				document.button100kHuman.src = scale1Pic;
			}	
		}else if(size == 0) {
			if(presentScaleArray[getSpeciesNo(species)] == 0){
				document.button1mHuman.src = scale0OnPic;
			}else{
				document.button1mHuman.src = scale0Pic;
			}	
		}
	}else{
		species = selectedSpecies;
		if(size==2)	{
			if(presentScaleArray[getSpeciesNo(species)] == 2){
				document.button10kOthers.src = scale2OnPic;
			}else{
				document.button10kOthers.src = scale2Pic;
			}	
		}else if(size == 1) {
			if(presentScaleArray[getSpeciesNo(species)] == 1){
				document.button100kOthers.src = scale1OnPic;
			}else{
				document.button100kOthers.src = scale1Pic;
			}	
		}else if(size == 0) {
			if(presentScaleArray[getSpeciesNo(species)] == 0){
				document.button1mOthers.src = scale0OnPic;
			}else{
				document.button1mOthers.src = scale0Pic;
			}	
		}
	}
	return 1;
	
}
//*-----------------------------------------------------------------------------------------------*//
function popUpLegend(species){
	var ogj;
	var leftPosition;
	var topPosition;
	var explanation; 
	
	if(species == Human){
		/*
		 if(selectedSpecies == Mouse){
			explanation = "<dt><img src="+ legendHumanMousePic +  " /></dt>";
		}else if(selectedSpecies == Patr){
			explanation = "<dt><img src="+ legendHumanPatrPic +  " /></dt>";
		}else if(selectedSpecies == Macaque){
			explanation = "<dt><img src="+ legendHumanMacaquePic +  " /></dt>";
		}else if(selectedSpecies == Rat){
			explanation = "<dt><img src="+ legendHumanRatPic +  " /></dt>";
		}*/
		explanation = "<dt class='legendTitle'> <a herf=# onClick='closeLegend()'  id='legendClose'>x</a>" +
				"<span id='legendTitleName'>LEGEND</span></dt>";
		if(selectedSpecies == Mouse){
			explanation += getLegendSource(Human+" - "+Mouse);
		}else if(selectedSpecies == Patr){
			explanation += getLegendSource(Human+" - "+Patr);
		}else if(selectedSpecies == Macaque){
			explanation += getLegendSource(Human+" - "+Macaque);
		}else if(selectedSpecies == Rat){
			explanation += getLegendSource(Human+" - "+Rat);
		}

		leftPosition = legendHumanLeftPosition;
		topPosition = legendHumanTopPosition;	
	}else{		
		explanation = "<dt class='legendTitle'><a herf=# onClick='closeLegend()' id='legendClose'>x</a>" +
				"<span id='legendTitleName'>LEGEND</span></dt>";

		if(selectedSpecies == Mouse){
			explanation += getLegendSource(Mouse +" - "+Human);
		}else if(selectedSpecies == Patr){
			explanation += getLegendSource(Patr+" - "+Human);
		}else if(selectedSpecies == Macaque){
			explanation += getLegendSource(Macaque+" - "+Human);
		}else if(selectedSpecies == Rat){
			explanation += getLegendSource(Rat+" - "+Human);
		}
		//explanation += getLegendSource("human");
		leftPosition = legendOthersLeftPosition;
		topPosition = legendOthersTopPosition;
		
	}
	//explanation = makeCloseFrame(explanation);
	if(Opera){
		obj=document.getElementById(legendPopup);
		obj.style.left = leftPosition;
		obj.style.top = topPosition;
		obj.innerHTML=explanation;
		obj.style.visibility = "visible";
	}else if (IE){
		obj=document.all.item(legendPopup);
		obj.style.left =leftPosition;
		obj.style.top = topPosition;
		obj.innerHTML=explanation;
		obj.style.visibility = "visible";
	}else if (N6){
		obj=document.getElementById(legendPopup);
		obj.style.left = leftPosition+"px";
		obj.style.top = topPosition+"px";
		obj.innerHTML=explanation;
		obj.style.visibility = "visible";
	}
}
//*-----------------------------------------------------------------------------------------------*//
function getLegendSource(syntenySpecies){
	var source;
	source = "<dt class='legendPopup'>\n H-InvDB representative transcript <img src='"+legendGenePic + "' /><br>" +
			"&nbsp;CDS (H-Inv cDNA <img src='"+legendCdsHInvPic + "' />" +
			" &nbsp; Other mRNA <img src='"+ legendCdsOtherPic + "' />" +
			" &nbsp; RefSeq <img src='"+legendCdsRefseqPic + "' />" +
			" &nbsp; Ensembl <img src='"+legendCdsEnsemblPic + "' /> )<br>" +
			"&nbsp;UTR <img src='" + legendUtrPic + "' /><br>" +
			//"Predicted gene <img src='"+legendPredictedPic + "' /><br>" +
			"H-InvDB HIX (gene locus) <img src='"+legendHixPic + "' /><br>" +		
			"Genome <img src='"+legendGenomePic + "' /><br>" +
			" &nbsp; Repeat-masked <img src='" + legendRepeatMaskedPic + "' />&nbsp;" +
			" &nbsp; Unsequenced (NNN...) <img src='" + legendNnnPic + "' /><br>" +
			" &nbsp; Syntenic region (" + syntenySpecies + ") <img src='" + legendSyntenyPic + "' /></dt>"
					
	return source;
	
}
//*-----------------------------------------------------------------------------------------------*//
function closeLegend(){
	var ogj;
		
	if(Opera){
		obj=document.getElementById(legendPopup);
		obj.style.visibility = "hidden";
	}else if (IE){
		obj=document.all.item(legendPopup);
		obj.style.visibility = "hidden";
	}else if (N6){
		obj=document.getElementById(legendPopup);
		obj.style.visibility = "hidden";
	}
	
}
//*-----------------------------------------------------------------------------------------------*//
function setZoomPointForScaleChange(species, nextScale){
	if(presentScaleArray[getSpeciesNo(species)] == null){
		presentScaleArray[getSpeciesNo(species)] = defaultScale;
	}
	if(species == Human){
		zoomImgMaxHuman = chromosomeMaxBpHuman[selectedChromosomeNoHuman] / BPPArray[nextScale];
	}else{
		zoomImgMaxOthers = chromosomeMaxBpOthers[selectedChromosomeNoOthers] / BPPArray[nextScale];
	}
	var oldStartPx; 

	if(draggedEverFlg){
		oldStartPx = startPxArray[getSpeciesNo(species)];
	}else{
		var focusBp = defaultStartBpArray[getSpeciesNo(species)];
		oldStartPx = calcPxFromBp(focusBp, species);
	}
	var oldCentralPx;
	var newStartPx;
	
	if(nextScale == presentScaleArray[getSpeciesNo(species)]){
		return 1;
	}else {
		oldCentralPx = parseInt(oldStartPx + (zoomImageBlockSize * zoomImageShowBlockNum / 2));
		newStartPx = parseInt(oldCentralPx * BPPArray[presentScaleArray[getSpeciesNo(species)]]/ BPPArray[nextScale]
				 -  (zoomImageBlockSize * zoomImageShowBlockNum / 2));	
		presentScaleArray[getSpeciesNo(species)] = nextScale;
		startPxArray[getSpeciesNo(species)] = newStartPx;
	}
	setZoomImage(species,newStartPx);
}
//*-----------------------------------------------------------------------------------------------*//
//annotation view
//*-----------------------------------------------------------------------------------------------*//
function changeAnnotationListHuman(){
	setHumanAccessionListBox();
	targetAccessionNo = accessionNoListHuman[(startAccessionNoHuman + focusNum)][0];
	targetClassification = accessionNoListHuman[(startAccessionNoHuman + focusNum)][1];
	Efs.getOrthologAccessionNo(setOrthologSearch,selectedSpecies, targetAccessionNo);
	
}
//*-----------------------------------------------------------------------------------------------*//
function setOrthologSearch(str){
	if(str == null){
		orthologSearchFlg=false;
	}else{
		orthologSearchFlg=true;
	}
	Efs.getGeneWithClassification(setAnnotationTextHuman, targetAccessionNo,targetClassification);
}
//*-----------------------------------------------------------------------------------------------*//
function strFilter(str){
	if(str != undefined){
		return str;
	}else{
		return "&nbsp;";
	}
}
//*-----------------------------------------------------------------------------------------------*//
function setAnnotationTextHuman(data){
    if(data == null){
        location.href = "error.html";
    }
	var str;
	var accNo;
	var symbol;
	
	str = "<table><tr><td class='annotation_txt_human'>";
	str = str +"<a href=#  onClick=changeFocus('" + data.accessionNo + "')><span title='"+locatePopUpMsg+"'><img src='" + locateButton + "' border='0'/></span></a>&nbsp;&nbsp;";
	//str = str + "<a class='annotation_accession' href=#  onClick=changeFocus('" + data.accessionNo + "') >";
	str = str +"<a class='annotation_accession' href='"+ getDbLinkUrl( data.accessionNo) + "'>";
	// str = str + "<b>";
	str = str + "<font color='" + getClassificationColor(data.classification.toLowerCase())+ "'>";
	str = str +  data.accessionNo + "</font></a>&nbsp;&nbsp;";
	// str = str +  data.accessionNo + "</font></b>&nbsp;&nbsp;";
	//str = str + "<a class='annotation_genesymbol' href=#  onClick=changeFocus('" + data.accessionNo + "') >";
	//str = str + "<font class='annotation_genesymbol' color='" + getClassificationColor(data.classification.toLowerCase())+ "'>";
	// if(data.geneSyb =="-"){
	if (data.geneSyb =="-" || data.geneSyb ==""){
            // str = str + "</font></a>&nbsp;"
        }else{
		symbol = data.geneSyb;
		symbol = symbol.replace(/\,.+/,"");
            // str = str + "<i>" +  strFilter(data.geneSyb)+ "</i></font></a>&nbsp;"
            str = str + "<a href='"+hgncLinkUrl + symbol + "'><font class='annotation_genesymbol' color='" + getClassificationColor(data.classification.toLowerCase())+ "'><i>" +  strFilter(data.geneSyb)+ "</i></font></a>";
	}
        // str = str + data.classification.toLowerCase() + "</td>";
	str = str + "</td>";
	// str = str +	"<td class='annotation_btn'>";
	//str = str +"<a href='"+hinvLinkURL + data.accessionNo + "'><img alt='" + hinvPopUpMsg + "' src='" + hinvPic + "' border='0'/></a>";
	// str = str +"</td><td><a href='"+evolaLinkUrl + data.accessionNo + "'><span title='"+evolaPopUpMsg + "'><img src='" + evolaPic + "' border='0'/></span></a>";
	str = str +"<td width='76' align='right'><a href='"+evolaLinkUrl + data.accessionNo + "'><span title='"+evolaPopUpMsg + "'><img src='" + evolaPic + "' border='0'/></span></a>";
	// str = str +"<a href='"+gintegraLinkURL + data.accessionNo + "'><span title='"+ gintegraPopUpMsg+"'><img src='" + gintegraPic + "' border='0'/></span></a>";
        str = str +"<a href='"+gcompassLinkURL + "hit=" + data.accessionNo + "&species_1=Hg18&species_2=";
        if(selectedSpecies == Patr){
            str = str + "pt2";
        }else if(selectedSpecies == Macaque){
            str = str + "rm2";
        }else if(selectedSpecies == Mouse){
            // str = str + "mm8";
            str = str + "mm9";
        }else{
            str = str + "rn4";
        } 

        str = str + "'><span title='"+ gcompassPopUpMsg +"'><img src='" + gcompassPic + "' border='0'/></span></a>";
	str = str + "</td></tr><tr><td class='annotation_txt_human'>";
        // str = str + data.classification.toLowerCase() + "&nbsp;";
        str = str + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
	if(data.ddbjAcc != undefined){
		//str = str + "<a target='_blank' href='" + hitLinkURL + data.accessionNo +"'>";
		str = str + "<a href='" + getDbLinkUrl( data.ddbjAcc) +"'>";
		str = str + "<font color='" + getClassificationColor(data.classification.toLowerCase())+ "'>";
		str = str + strFilter(data.ddbjAcc);
		str = str +"</font>";
		str = str +"</a>";
	}
	str = str + "&nbsp;&nbsp;";
	if(data.hix != undefined){
		//str = str + "<a target='_blank' href='" + hixLinkURL + strFilter(data.hix) +"'>";
		str = str + "<a href='" + hixLinkURL + strFilter(data.hix) +"'>";
		str = str + "<font color='" + getClassificationColor(data.classification.toLowerCase())+ "'>";
		str = str + strFilter(data.hix); 
		str = str +"</font>";
		str = str + "</a>";
	}
	
	// str = str +"</td><td colspan='3'>";
	str = str +"</td><td rowspan='2'>";
	if((orthologSearchFlg==true) && (data.classification.toLowerCase()==paralog)){
		str = str + "<a href='genefamily.html?accessionNo=" + data.accessionNo + "&amp;species=" + selectedSpecies + 
		// "'><img alt='search orhologs for " + data.accessionNo + "' vspace='1' src='" + orthologSearchImg + "' border='0'/></a>";
		"'><span title='Show ortholog(s) of the other species.'><img alt='search orhologs for " + data.accessionNo + "' vspace='1' src='" + orthologSearchImg + "' border='0'/></span></a>";
	}
	str = str +"</td></tr>";

	// str = str +"<tr><td colspan='4'>";
	str = str +"<tr><td>";
	str = str + getChromosomeNo(data.chromosomeNo,Human) + "&nbsp;";
	if(data.direction == "R"){
		str = str + plusStrand + "&nbsp;";
	}else{
		str = str + minusStrand + "&nbsp;";
	}
	//str = str + addFigure(data.startBp) + "-";
	//str = str + addFigure(data.endBp) + "&nbsp;(bp)<br/>";
	str = str + data.startBp + "-";
	// str = str + data.endBp + "&nbsp;(bp)<br/>";
	// str = str + data.endBp + "<br/>";
	str = str + data.endBp + "</td></tr><tr><td colspan='2'>";
	str = str + "<font class='annotation_definition'>" + data.definition + "</font><br/>";
		
	str = str + "</td></tr></table>";
	textObj = document.getElementById(annotationTextIdHuman);
	textObj.innerHTML = str;
}
//*-----------------------------------------------------------------------------------------------*//
function clickAnnotationButton(type, species){
	if(species == Human){
		if(type=="up")	{
			document.annotationHumanUp.src = annotationUpClickPic;
		}else if(type == "top") {
	  		document.annotationHumanTop.src = annotationTopClickPic;
		}else if(type == "down") {
	  		document.annotationHumanDown.src = annotationDownClickPic;
		}else if(type == "last") {
	  		document.annotationHumanLast.src = annotationLastClickPic;
		}
	}else{
		if(type=="up")	{
			document.annotationOthersUp.src = annotationUpClickPic;
		}else if(type == "top") {
	  		document.annotationOthersTop.src = annotationTopClickPic;
		}else if(type == "down") {
	  		document.annotationOthersDown.src = annotationDownClickPic;
		}else if(type == "last") {
	  		document.annotationOthersLast.src = annotationLastClickPic;
		}
	}
}
//*-----------------------------------------------------------------------------------------------*//
function returnAnnotationButton(type, species){
	if(species == Human){
		if(type=="up")	{
			document.annotationHumanUp.src = annotationUpPic;
		}else if(type == "top") {
	  		document.annotationHumanTop.src = annotationTopPic;
		}else if(type == "down") {
	  		document.annotationHumanDown.src = annotationDownPic;
		}else if(type == "last") {
	  		document.annotationHumanLast.src = annotationLastPic;
		}
	}else{
		if(type=="up")	{
			document.annotationOthersUp.src = annotationUpPic;
		}else if(type == "top") {
	  		document.annotationOthersTop.src = annotationTopPic;
		}else if(type == "down") {
	  		document.annotationOthersDown.src = annotationDownPic;
		}else if(type == "last") {
	  		document.annotationOthersLast.src = annotationLastPic;
		}
	}
	return 1;
	
}
//*-----------------------------------------------------------------------------------------------*//
function moveDownAnnotationListHuman(){
	document.annotationHumanDown.src = annotationDownPic;
	if(accessionNoListHuman[(startAccessionNoHuman + focusNum + 1)] != undefined){
		startAccessionNoHuman += 1;
		changeAnnotationListHuman();
	}

}
//*-----------------------------------------------------------------------------------------------*//
function moveUpAnnotationListHuman(){
	document.annotationHumanUp.src = annotationUpPic;
	if(accessionNoListHuman[(startAccessionNoHuman + focusNum - 1)] != undefined){
		startAccessionNoHuman -= 1;		
		changeAnnotationListHuman();
	}
}
//*-----------------------------------------------------------------------------------------------*//
function wheelEventAnnotationListHuman(){   
	if(event.wheelDelta > 0){
		moveUpAnnotationListHuman();
	}else{
		moveDownAnnotationListHuman();
	}
}
//*-----------------------------------------------------------------------------------------------*//
function setAnnotationByAccessionNoHuman(targetAccessionNo){
	var i,j,max;
    var accNo;
    var data;
	for (i = 0; i < accessionNoListHuman.length; i++) {
	    
	   // if(accessionNoListHuman[i][0].match(/[a-z]$/)){
		    //var length = accNo.length;
			//accNo = accNo.substring(0,length-1);
		//    var diff = i - (startAccessionNoHuman + focusNum);
		//	startAccessionNoHuman += diff;
		//	changeAnnotationListHuman();
	    //}
		if(accessionNoListHuman[i][0] == targetAccessionNo){
			var diff = i - (startAccessionNoHuman + focusNum);
			startAccessionNoHuman += diff;
			changeAnnotationListHuman();
		}
	}
	textObj = document.getElementById(geneCountIdHuman);
	if(accessionNoListHuman.length == 1){
		textObj.innerHTML = accessionNoListHuman.length + geneCountUnitSingular;
	}else{
		textObj.innerHTML = accessionNoListHuman.length + geneCountUnitPlural;
	}
	Efs.getDownloadFileUrl(humanFamilyName, humanFamilyName, setDownloadFileLinkHuman);
	//do nothing in case of no accessionNo
}
//*-----------------------------------------------------------------------------------------------*//
function moveTopAnnotationListHuman(){
	document.annotationHumanTop.src = annotationTopPic;
	setAnnotationByAccessionNoHuman(accessionNoListHuman[0][0]);
}
//*-----------------------------------------------------------------------------------------------*//
function moveLastAnnotationListHuman(){
	document.annotationOthersLast.src = annotationLastPic;
	setAnnotationByAccessionNoHuman(accessionNoListHuman[accessionNoListHuman.length-1][0]);
}
//*-----------------------------------------------------------------------------------------------*//
function changeAnnotationListOthers(){
	setOtherAccessionListBox();
	var targetAccessionNo = accessionNoListOthers[(startAccessionNoOthers + focusNum)][0];
	var targetClassification = accessionNoListOthers[(startAccessionNoOthers + focusNum)][1];
	Efs.getGeneWithClassification(setAnnotationTextOthers, targetAccessionNo,targetClassification);
}
//*-----------------------------------------------------------------------------------------------*//
function setAnnotationTextOthers(data){
    if(data == null){
        location.href = "error.html";
    }
	var str
	str = "<table><tr><td class='annotation_txt_others'>";
	str = str +"<a href=#  onClick=changeFocus('" + data.accessionNo + "')><span title ='"+ locatePopUpMsg + "'><img src='" + locateButton + "' border='0'/></span></a>&nbsp;&nbsp;";
	str = str + "<a class='annotation_accession' href='" + getDbLinkUrl( data.accessionNo) +"'>";
	str = str + "<font color='" + getClassificationColor(data.classification.toLowerCase())+ "'>";
	str = str + data.accessionNo + "</font></a>&nbsp;&nbsp;";
	str = str + "<a class='annotation_genesymbol' >";
	str = str + "<font color='" + getClassificationColor(data.classification.toLowerCase())+ "'>";
	if(data.geneSyb == "-"){
            str = str + "</font></a>&nbsp;&nbsp;";
        }else{
		symbol = data.geneSyb;
            // str = str +"<i>"+ strFilter(data.geneSyb) +  "</i></font></a>&nbsp;&nbsp;";
            // str = str +"<i>"+ strFilter(symbol) +  "</i></font></a>&nbsp;&nbsp;";
	}
	str = str + "<font color='" + getClassificationColor(data.classification.toLowerCase())+ "'>";
        // str = str + "(" + data.classification.toLowerCase() + ")</td>";
        str = str + "(" + data.classification.toLowerCase() + ")</font></td>";
        //str = str + "</td>";
	// str = str +	"<td align='right' valign='top' class='annotation_btn'>";
	// str = str +"</td><td><a href='"+evolaLinkUrl + data.accessionNo + "'><span title='"+evolaPopUpMsg + "'><img src='" + evolaPic + "' border='0'/></span></a>";
	// str = str +"<td width='76' align='right'><a href='"+evolaLinkUrl + targetAccessionNo + "'><span title='"+evolaPopUpMsg + "'><img src='" + evolaPic + "' border='0'/></span></a>";
	str = str +"<td width='76' align='right'>";
	if (data.classification.toLowerCase() == ortholog) {
		str = str +"<a href='"+evolaLinkUrl + targetAccessionNo + "'><span title='"+evolaPopUpMsg + "'><img src='" + evolaPic + "' border='0'/></span></a>";
	}
	// str = str +"<a href='"+gintegraLinkURL + data.accessionNo ;
	// if(selectedSpecies == Patr){
	// 	str = str + patrForGintegra;
	// }else if(selectedSpecies == Macaque){
	// 	str = str + macaqueForGintegra;
	// }else if(selectedSpecies == Mouse){
	// 	str = str + mouseForGintegra;
	// }else if(selectedSpecies == Rat){
	// 	str = str + ratForGintegra;
	// }
	// str = str + "'><span title='" + gintegraPopUpMsg + "'><img src='" + gintegraPic +"' border='0'/></span></a>"
	str = str +"<a href='"+gcompassLinkURL + "acc_2=" + data.accessionNo + "&species_1=Hg18&species_2=";
        if(selectedSpecies == Patr){
            str = str + "pt2";
        }else if(selectedSpecies == Macaque){
            str = str + "rm2";
        }else if(selectedSpecies == Mouse){
            // str = str + "mm8"
            str = str + "mm9"
        }else{
            str = str + "rn4";
        }
        // str = str + "'><span title='" + gcompassPopUpMsg + "'><img src='" + gcompassPic + "' border='0'/></span></a>";
        // str = str + "&hit=" + targetAccessionNo + "'><span title='" + gcompassPopUpMsg + "'><img src='" + gcompassPic + "' border='0'/></span></a>";
	if (data.classification.toLowerCase() == ortholog) {
		// str = str + "&hit=" + targetAccessionNo + "'>";
		str = str + "&hit=" + humanAccessionNo + "'>";
	} else {
		str = str + "'>";
	} 
	str = str + "<span title='" + gcompassPopUpMsg + "'><img src='" + gcompassPic + "' border='0'/></span></a>";
        str = str + "</td></tr><tr><td colspan='2'>";
        // str = str + "</td></tr><tr><td>";
	str = str + getChromosomeNo(data.chromosomeNo,selectedSpecies) + "&nbsp;";
	
	if(data.direction == "R"){
		str = str + plusStrand + "&nbsp;";
	}else{
		str = str + minusStrand + "&nbsp;";
	}
	//str = str + addFigure(data.startBp) + "-";
	//str = str + addFigure(data.endBp) + "&nbsp;(bp)<br/>";
	str = str + data.startBp + "-";
	// str = str + data.endBp + "&nbsp;(bp)<br/>";
	str = str + data.endBp + "</td></tr><tr><td colspan='2'>";
	// str = str + data.endBp + "</td><td align='right'>";
	// str = str + data.classification.toLowerCase() + "</td></tr><tr><td colspan='2'>";
        
        if(data.definition == null){
            str = str + "<font class='annotation_definition'></font><br/>";
        }else{
	    str = str + "<font class='annotation_definition'>"+data.definition + "</font><br/>";
	}
        str = str + "</td></tr></table>";
	
	textObj = document.getElementById(annotationOthersText);
	textObj.innerHTML = str;
}
//*-----------------------------------------------------------------------------------------------*//
function moveDownAnnotationListOthers(){
	document.annotationOthersDown.src = annotationDownPic;
	if(accessionNoListOthers[(startAccessionNoOthers + focusNum + 1)] != undefined){
		startAccessionNoOthers += 1;
		changeAnnotationListOthers();
	}

}
//*-----------------------------------------------------------------------------------------------*//
function moveUpAnnotationListOthers(){
	document.annotationOthersUp.src = annotationUpPic;
	if(accessionNoListOthers[(startAccessionNoOthers + focusNum - 1)] != undefined){
		startAccessionNoOthers -= 1;
		changeAnnotationListOthers();
	}
}
//*-----------------------------------------------------------------------------------------------*//
function wheelEventAnnotationListOthers(){   
	if(event.wheelDelta > 0){
		moveUpAnnotationListOthers();
	}else{
		moveDownAnnotationListOthers();
	}
}
//*-----------------------------------------------------------------------------------------------*//
function setAnnotationByAccessionNoOthers(targetAccessionNo){
	var i,j,max;
	debug.print("in setAnnotationByAccessionNoOthers");
	debug.flush();
	if(accessionNoListOthers.length == 0){
		setNothingToAnnotationList();
		textObj = document.getElementById(annotationOthersText);
		textObj.innerHTML = "&nbsp;";
		textObj = document.getElementById(geneCountIdOthers);
		textObj.innerHTML = "";
	}else{
		for (i = 0; i < accessionNoListOthers.length; i++) {
			if(accessionNoListOthers[i][0] == targetAccessionNo){
				var diff = i - (startAccessionNoOthers + focusNum);
				startAccessionNoOthers += diff;
				changeAnnotationListOthers();
			}
		}
		document.getElementById(annotationListPrefixOthers + 2).className =annotationListClassCurrent;
		textObj = document.getElementById(geneCountIdOthers);
		if(accessionNoListOthers.length == 1){
			textObj.innerHTML = accessionNoListOthers.length + geneCountUnitSingular;
		}else{
			textObj.innerHTML = accessionNoListOthers.length + geneCountUnitPlural;
		}
		Efs.getDownloadFileUrl(humanFamilyName, otherFamilyName, setDownloadFileLinkOthers);		
		//do nothing in case of no accessionNo
	}
}
//*-----------------------------------------------------------------------------------------------*//
function setDownloadFileLinkOthers(url){
	var linkObj = document.getElementById(downloadFileIdOthers);
	if(url != null){	
		linkObj.innerHTML = "<a href='" + url + "'><img src='" +downloadFileButton +"' border='0'></a>";
	}else{
		linkObj.innerHTML = "";
	}
}
//*-----------------------------------------------------------------------------------------------*//
function setDownloadFileLinkHuman(url){
	var linkObj = document.getElementById(downloadFileIdHuman);
	if(url != null){
		linkObj.innerHTML = "<a href='" + url + "'><img src='" +downloadFileButton +"'  border='0'></a>";
	}else{
		linkObj.innerHTML = "";
	}
}
//*-----------------------------------------------------------------------------------------------*//
function setNothingToAnnotationList(){
	debug.print("in setNothingToAnnotationList");
	debug.flush();
	for (i = 0; i < annotationListSize; i++) {
		AccElement = document.getElementById(annotationListPrefixOthers + i);
		AccColorElement = document.getElementById(annotationListColorPrefixOthers + i);
		AccElement.innerHTML = "&nbsp;";
		AccColorElement.className = annotationListColorNone;
				
	}
	document.getElementById(annotationListPrefixOthers + 2).className =annotationListClassNormal;
	
}
//*-----------------------------------------------------------------------------------------------*//
function moveTopAnnotationListOthers(){
	document.annotationOthersTop.src = annotationTopPic;
	if(accessionNoListOthers.length != 0){
		setAnnotationByAccessionNoOthers(accessionNoListOthers[0][0]);
	}
}
//*-----------------------------------------------------------------------------------------------*//
function moveLastAnnotationListOthers(){
	document.annotationOthersLast.src = annotationLastPic;
	if(accessionNoListOthers.length != 0){
		setAnnotationByAccessionNoOthers(accessionNoListOthers[accessionNoListOthers.length-1][0]);
	}
}
//*-----------------------------------------------------------------------------------------------*//
function changeFocus(targetAccNo){
	Efs.getGene(changeMarkAndZoom,targetAccNo);
}
//*-----------------------------------------------------------------------------------------------*//
function changeMarkAndZoom(gene){
	if(gene.species == Human){
		focusHumanGene = gene;
		document.getElementById(popupIdZoomViewHuman).style.visibility = 'hidden';
		popUpFlgZoomViewHuman = false;
		if(popupFocusFlgHuman){
			closePopupForFocusHuman();
		}	
		setHumanAccessionListBox();
	}else{
		focusOthersGene = gene;
		document.getElementById(popupIdZoomViewOthers).style.visibility = 'hidden';
		popUpFlgZoomViewOthers = false;
		if(popupFocusFlgOthers){
			closePopupForFocusOthers();
		}
		setOtherAccessionListBox();
	}
	setZoomPoint(gene.species,gene.chromosomeNo,gene.startBp,gene.endBp,gene.direction);
	initializeMarkPoints();
	var filter = getFilter();
	Efs.getMarkPoints(setMarkPoint,selectedSpecies,humanFamilyName,humanAccessionNo,filter);	
}
//*-----------------------------------------------------------------------------------------------*//
function setHumanAccessionListBox(){
	var classification;
	var color;
	var AccElement;
	var AccColorElement;
	var diff;
	var i;
	var accNo;
	for (i = 0; i < annotationListSize; i++) {
		//AccessionNo
		AccElement = document.getElementById(annotationListPrefixHuman + i);
		AccColorElement = document.getElementById(annotationListColorPrefixHuman + i);
		if(accessionNoListHuman[(startAccessionNoHuman + i)] != undefined){
			accNo = accessionNoListHuman[(startAccessionNoHuman + i)][0];
			classification = accessionNoListHuman[(startAccessionNoHuman + i)][1];
				
			if(classification.toLowerCase() == ortholog){
				color = annotationListColorOrtholog;
			}else if(classification.toLowerCase() == paralog){
				color = annotationListColorParalog;
			}
			if(accNo == focusHumanGene.accessionNo){
				color = color + annotationListColorFocus;
			}
		}else{
			accNo = "&nbsp;";
			color = annotationListColorNone;
		}
		
		
	    if(accNo.length > 22){
		    accNo = accNo.substring(0,22) + "..";
	    }

		AccElement.innerHTML = accNo;
	    AccColorElement.className = color;
		if(i != focusNum){
			AccElement.onclick = function () {setAnnotationByAccessionNoHuman(this.innerHTML)};
		  }
	}
}
//*-----------------------------------------------------------------------------------------------*//
function setOtherAccessionListBox(){
	debug.print("in seOtherAccessionListBox");
	debug.flush();
	var classification;
	var color;
	var AccElement;
	var AccColorElement;
	var diff;
	var i;
	var accNo;
	for (i = 0; i < annotationListSize; i++) {
		//AccessionNo
		AccElement = document.getElementById(annotationListPrefixOthers + i);	//each element
		AccColorElement = document.getElementById(annotationListColorPrefixOthers + i);	//each element
	
		if(accessionNoListOthers[(startAccessionNoOthers + i)] != undefined){
			accNo = accessionNoListOthers[(startAccessionNoOthers + i)][0];
			classification = accessionNoListOthers[(startAccessionNoOthers + i)][1];
			if(classification == ortholog){
				color = annotationListColorOrtholog;
			}else if(classification == paralog){
				color = annotationListColorParalog;
			}
			if(accNo == focusOthersGene.accessionNo){
				color = color + annotationListColorFocus;
			}
				
		}else{
			accNo = "&nbsp;";
			color = annotationListColorNone;
		}
			
		if(accNo.length > 22){
			accNo = accNo.substring(0,22) + "..";
		}
			
		AccElement.innerHTML = accNo;
		AccColorElement.className = color;
		
		if(i != focusNum){
			AccElement.onclick = function () {setAnnotationByAccessionNoOthers(this.innerHTML)};
		}
	}
}
//*-----------------------------------------------------------------------------------------------*//
function popUpForFocus(gene){
	debug.print("in popUpForFocus");
	debug.flush();
	var classificationStr =	getClassification(gene);
	var termColor = getClassificationColor(classificationStr);
	var pointX;
	var pointY;
	var id;
	
	var explanation;
	
	if(classificationStr != ""){
		classificationStr = classificationStr.toLowerCase();
	}
	
	/*
	if(classificationStr == ortholog){
		triangleImage = triangleImageOrtholog;
	}else if(classificationStr == paralog){
		triangleImage = triangleImageParalog;
	}else{
		triangleImage = triangleImageOther;
	}*/
  //  var accNo = gene.accessionNo;
  //  if(accNo.match(/[a-z]$/)){
  //      var length = accNo.length;
	//	accNo = accNo.substring(0,length-1);
//	} 
	var triangle = "<img class='focusPopUpTriangle' src="+ triangleImage +"  />";
        if(gene.geneSyb == "-"){
            var geneInfo =  "<font color=" + termColor +">&nbsp;" +
                                                gene.accessionNo +
                                                //strFilter(gene.geneSyb) + " : " +
                                                //strFilter(classificationStr) + " </font>";
                                                 "&nbsp;" + "</font>";
        }else{
	    var geneInfo = 	"<font color=" + termColor +">&nbsp;" +
						gene.accessionNo + "&nbsp;<i>" + 
						strFilter(gene.geneSyb) + 
						//strFilter(gene.geneSyb) + " : " + 
						//strFilter(classificationStr) + " </font>";
						 "</i>&nbsp;" + "</font>";
	}
	if(gene.species == Human){
		pointX = zoomAreaLeftHuman + (zoomImageBlockSize*zoomImageShowBlockNum/2);
		pointY = calcYForFocusPopup(gene.direction, gene.displayLevel);
		id = popupIdFocusHuman;
		explanation = triangle + "<dt class='focusPopup'><a herf=# onClick=closePopupForFocusHuman()  id='expoClose'>x</a>" 
								+ geneInfo  +"</dt>";
		
		popUp(pointX,pointY,explanation,id);
		popupFocusFlgHuman = true;
		timerFocusIdHuman = setTimeout("closePopupForFocusHuman()",timerFocusMMSecongs);
	}else{
		pointX = zoomAreaLeftOthers + (zoomImageBlockSize*zoomImageShowBlockNum/2);
		pointY = calcYForFocusPopup(gene.direction, gene.displayLevel);
		id = popupIdFocusOthers;
		explanation = triangle + "<dt class='focusPopup'><a herf=# onClick=\"closePopupForFocusOthers()\"  id='expoClose'>x</a>" 
							+ geneInfo  +"</dt>";
		popUp(pointX,pointY,explanation,id);
		popupFocusFlgOthers = true;
		timerFocusIdOthers = setTimeout("closePopupForFocusOthers()",timerFocusMMSecongs);
	}
	
}
//*-----------------------------------------------------------------------------------------------*//
function closePopup(id){
	debug.print("close id:" + id);
	debug.flush();
	document.getElementById(id).style.visibility="hidden";
	
	if(id == popupIdZoomViewHuman){
		popUpFlgZoomViewHuman = false;	
	}else if(id == popupIdZoomViewOthers){
		popUpFlgZoomViewOthers = false;	
	}else if(id == popupIdChromosomeViewHuman){
		popUpFlgChromosomeViewHuman = false;	
	}else if(id == popupIdChromosomeViewOthers){
		popUpFlgChromosomeViewOthers = false;
	}
}

//*-----------------------------------------------------------------------------------------------*//
function closePopupForFocusHuman(){
	document.getElementById(popupIdFocusHuman).style.visibility="hidden";
	if(popupFocusFlgHuman){
		clearTimeout(timerFocusIdHuman);
		popupFocusFlgHuman = false;
	}
}

//*-----------------------------------------------------------------------------------------------*//
function closePopupForFocusOthers(){
	document.getElementById(popupIdFocusOthers).style.visibility="hidden";
	if(popupFocusFlgOthers){
		clearTimeout(timerFocusIdOthers);
		popupFocusFlgOthers = false;
	}
}
//*-----------------------------------------------------------------------------------------------*//
function calcYForFocusPopup(direction,level){
	var y;
	//alert("d:"+direction+",level:"+level);
	if(direction == directionRight){
		y = zoomAreaGenomeLineY - geneYOffset  - zoomAreaMultiLevelInterval * (level - 1)  ;
	}else{
		y = zoomAreaGenomeLineY + geneYOffset + 1 + zoomAreaMultiLevelInterval * level ;
	}
	return y;
}
//*-----------------------------------------------------------------------------------------------*//
function getClassification(gene){
	debug.print("in getClassification");
	debug.flush();
	var classificationStr = "";
	if(gene.species == Human){
		for (i = 0; i < accessionNoListHuman.length; i++) {
			if(accessionNoListHuman[i][0] == gene.accessionNo){
				classificationStr = accessionNoListHuman[i][1];
			}
		}
			
	}else{
		for (i = 0; i < accessionNoListOthers.length; i++) {
			if(accessionNoListOthers[i][0] == gene.accessionNo){
				classificationStr = accessionNoListOthers[i][1];
			}
		}
	}
	return classificationStr;	
}
//*-----------------------------------------------------------------------------------------------*//
function getClassificationColor(classificationStr){
	debug.print("in getClassificationColor");
	debug.flush();
	var termColor;
	if(classificationStr == ortholog){
		termColor = orthologColor;
	}else if(classificationStr == paralog){
		termColor = paralogColor;
	}else if(classificationStr == predicted){
		termColor = thirdColor;	
	}else{
		termColor = otherColor;
	}
	return termColor;
}
//*-----------------------------------------------------------------------------------------------*//
function getChromosomeNo(chromosomeNo,species){
    var chrNo = "";
    var chromosomeNum;
    
    if(species == Human){
        chromosomeNum = chromosomeNumHuman;
    }else if(species == Patr){
        chromosomeNum = chromosomeNumPatr;
    }else if(species == Macaque){
        chromosomeNum = chromosomeNumMacaque;
    }else if(species == Mouse){
        chromosomeNum = chromosomeNumMouse;
    }else{
        chromosomeNum = chromosomeNumRat;
    }
    
    if(species == Macaque || species == Rat){
        if(chromosomeNo == chromosomeNum){
            chrNo = "X";
        }else{
            chrNo = chromosomeNo;
        }
    }else{
        if(chromosomeNo == chromosomeNum-1){
            chrNo = "X";
        }else if(chromosomeNo == chromosomeNum){
            chrNo ="Y";
        }else if(chromosomeNo == 1){
            chrNo = chromosomeNo;
        }else{            
            if(species == Patr){
                if(chromosomeNo == 2){
                    chrNo = "2a";
                }else if(chromosomeNo == 3){
                    chrNo = "2b";
                }else{
                    chrNo = chromosomeNo - 1;
                }
            }else{
                chrNo = chromosomeNo;
            }
        }
    }
    chrNo = "chr. " + chrNo;
    return chrNo;
}

//*-----------------------------------------------------------------------------------------------*//
function getDbLinkUrl(accessionNo){
    var url;
    
    if(accessionNo.substring(0,1).match(/[a-z]$/)){
        url=hitLinkURL;
    }else if(accessionNo.substring(0,3)=="HIT"){
        url=hitLinkURL;
    }else if( accessionNo.substring(0,7)=="ENSPTRT") {
        url=ensPatrLinkUrl;
    }else if(accessionNo.substring(0,7)=="ENSMMUT"){
        url=ensMacaqueLinkUrl;
    }else if(accessionNo.substring(0,7)=="ENSMUST"){
        url=ensMouseLinkUrl;
    }else if(accessionNo.substring(0,7)=="ENSRNOT"){
        url=ensRatLinkUrl;
    }else if(accessionNo.substring(0,2)=="NM" || accessionNo.substring(0,2)=="NP" || accessionNo.substring(0,2)=="XM" || accessionNo.substring(0,2)=="XR" ||accessionNo.substring(0,2)=="NR"){
        url=refseqLinkUrl;
    }else{
        url=ddbjLinkUrl;
    }
	
	url = url + accessionNo;

	return url;
    
}









