
    ///////////////////////////////////////////////////////////
    // Mouse&Touch events on
    ///////////////////////////////////////////////////////////
    function _initEvents() {

      cvs4.addEventListener("mousedown", _mouseDownListner, false);
      cvs4.addEventListener("mousemove", _mouseMoveListner, false);
      cvs4.addEventListener("mouseup", _mouseUpListner, false);
      cvs4.addEventListener("mouseout", _mouseOutListner, false);
      cvs4.addEventListener("dblclick", _mouseDblclickListner, false);
      cvs4.addEventListener("touchstart", _mouseDownListner, false);
      cvs4.addEventListener("touchmove", _mouseMoveListner, false);
      cvs4.addEventListener("touchend", _mouseUpListner, false);
      cvs4.addEventListener("touchcancel", _mouseUpListner, false);
      window.addEventListener("keydown", _doKeyDown, true);

      cvs2.addEventListener("mousedown", _mouseDownNavListner, false);
      cvs2.addEventListener("touchstart", _mouseDownNavListner, false);
      cvs2.addEventListener("mousemove", _mouseMoveNavListner, false);
      cvs2.addEventListener("mouseout", _mouseUpNavListner, false);

      cvs0.addEventListener("mousedown", _mouseDownTrackTitleListner, false);
      cvs0.addEventListener("mousemove", _mouseMoveTrackTitleListner, false);
      cvs0.addEventListener("mouseout", _mouseOutTrackTitleListner, false);

      cvs1.addEventListener("mousedown", _mouseDownTrackListner, false);
      cvs1.addEventListener("mousemove", _mouseMoveTrackListner, false);
      cvs1.addEventListener("mouseup", _mouseUpTrackListner, false);
      cvs1.addEventListener("mouseout", _mouseUpTrackListner, false);

      cvs3.addEventListener("mousedown", _mouseDownTitleListner, false);
      cvs3.addEventListener("mousemove", _mouseMoveTitleListner, false);
      cvs3.addEventListener("mouseout", _mouseUpTitleListner, false);
      cvs3.addEventListener("touchcancel", _mouseUpTitleListner, false);
      cvs3.addEventListener("touchstart", _mouseDownTitleListner, false);
 
    }

    ///////////////////////////////////////////////////////////
    // Mouse&Touch events on
    ///////////////////////////////////////////////////////////
    function _removeEvents() {
      cvs4.removeEventListener("mousedown", _mouseDownListner, false);
      cvs4.removeEventListener("mousemove", _mouseMoveListner, false);
      cvs4.removeEventListener("mouseup", _mouseUpListner, false);
      cvs4.removeEventListener("mouseout", _mouseOutListner, false);
      cvs4.removeEventListener("dblclick", _mouseDblclickListner, false);
      cvs4.removeEventListener("touchstart", _mouseDownListner, false);
      cvs4.removeEventListener("touchmove", _mouseMoveListner, false);
      cvs4.removeEventListener("touchend", _mouseUpListner, false);
      cvs4.removeEventListener("touchcancel", _mouseUpListner, false);
      window.removeEventListener("keydown", _doKeyDown, true);

      cvs2.removeEventListener("mousedown", _mouseDownNavListner, false);
      cvs2.removeEventListener("touchstart", _mouseDownNavListner, false);
      cvs2.removeEventListener("mousemove", _mouseMoveNavListner, false);
      cvs2.removeEventListener("mouseout", _mouseUpNavListner, false);

      cvs0.removeEventListener("mousedown", _mouseDownTrackTitleListner, false);
      cvs0.removeEventListener("mousemove", _mouseMoveTrackTitleListner, false);
      cvs0.removeEventListener("mouseout", _mouseOutTrackTitleListner, false);

      cvs1.removeEventListener("mousedown", _mouseDownTrackListner, false);
      cvs1.removeEventListener("mousemove", _mouseMoveTrackListner, false);
      cvs1.removeEventListener("mouseout", _mouseUpTrackListner, false);
      cvs1.removeEventListener("mouseout", _mouseUpTrackListner, false);

      cvs3.removeEventListener("mousedown", _mouseDownTitleListner, false);
      cvs3.removeEventListener("mousemove", _mouseMoveTitleListner, false);
      cvs3.removeEventListener("mouseout", _mouseUpTitleListner, false);
      cvs3.removeEventListener("touchcancel", _mouseUpTitleListner, false);
      cvs3.removeEventListener("touchstart", _mouseDownTitleListner, false);
    }

    /////////////////////////////////////////////// Mouse moving on Navigation
    function _mouseMoveNavListner(e) {
      var rect = e.target.getBoundingClientRect();
      e.preventDefault();
      // Getting coordinate(pc or iOS)
      var isiPad = navigator.userAgent.match(/iPad/i) != null;
      var isiPhone = navigator.userAgent.match(/iPhone/i) != null;
      if (isiPad || isiPhone) {    //iPad & iPhone
        XY.x2=parseInt(e.touches[0].pageX)-parseInt(rect.left);
        XY.y2=parseInt(e.touches[0].pageY)-parseInt(rect.top);
      } else {    //PC
        XY.x2=parseInt(e.clientX)-parseInt(rect.left);
        XY.y2=parseInt(e.clientY)-parseInt(rect.top);
      }

      ctx2.putImageData(frameChr, 0, 0);

      var o=_chromosome();
      if(XY.y2 < 30 && XY.x2 <= o.width) {
        document.body.style.cursor = "pointer";
        var t=XY.x2/o.width;
        var p=(parseInt(_last('1k')*t)/1000).toFixed(2);

        ctx2.fillStyle=_setColor().chrareaselected;
        if (XY.x2+o.area+1>o.width){
          ctx2.fillRect(o.width-o.area, 6, o.area+1, 21);
        } else if (XY.x2-o.area/2<0){
          ctx2.fillRect(0, 6, o.area+1, 21);
        } else {
          ctx2.fillRect(XY.x2-o.area/2, 6, o.area+1, 21);
        }

        if ( XY.x2 > o.width-134 ) {
          y=9;
        } else {
          y=20;
        }
        ctx2.textAlign="left";
        ctx2.fillStyle=_setColor().chrstringcolor;
        ctx2.fillText(String(p)+" M",XY.x2+10,y);

      // On the chromosome navigation
      } else if(XY.y2 < 32 && XY.x2 >= cvs2.width/2) {
        document.body.style.cursor = "pointer";
        if ( XY.x2 > cvs2.width/2+cvs2.width/2/5*2-o.s1 && XY.x2 < cvs2.width/2+cvs2.width/2/5*3+o.s2) {
          var s=XY.x2-(cvs2.width/2/5/2);
          if (s<cvs2.width/2+cvs2.width/2/5*2-o.s1){s=cvs2.width/2+cvs2.width/2/5*2-o.s1;}
          if ((s+cvs2.width/2/5)>cvs2.width/2+cvs2.width/2/5*3+o.s2){s=cvs2.width/2+cvs2.width/2/5*3+o.s2-cvs2.width/2/5;}
          ctx2.fillStyle=_setColor().detailareaselected;
          ctx2.fillRect(s, 10, (cvs2.width/2/5), 14);

          var p=XY.x2-(cvs2.width/2/5/2)-(cvs2.width/2+cvs2.width/2/5*2);
          var t=parseInt(p)/(cvs2.width/2/5);
          var k=Objects.Pos+parseInt(Objects.Block*t);
          if ( k < 1 ) { k=1;}
          ctx2.fillStyle=_setColor().detailupstring;
          ctx2.textAlign="left";
          ctx2.fillText(_printPos(k), s+12, 20);
          ctx2.beginPath();
          ctx2.moveTo(s+1,22);
          ctx2.lineTo(s+8,16);
          ctx2.lineWidth=1;
          ctx2.strokeStyle=_setColor().detailupstring;
          ctx2.stroke();
        }
      } else if(XY.y2 > 32) {
        _drawMeter(Objects.Pos,XY.x2);
      } else {
        document.body.style.cursor = "default";
      }

    }

    /////////////////////////////////////////////// Mouse down on Track
    function _mouseDownTrackListner(e) {
      var rect = e.target.getBoundingClientRect();
      e.preventDefault();
      // Getting coordinate(pc or iOS)
      var isiPad = navigator.userAgent.match(/iPad/i) != null;
      var isiPhone = navigator.userAgent.match(/iPhone/i) != null;
      if (isiPad || isiPhone) {    //iPad & iPhone
          XY.x1=parseInt(e.touches[0].pageX)-parseInt(rect.left);
          XY.y1=parseInt(e.touches[0].pageY)-parseInt(rect.top);
      } else {    //PC
          XY.x1=parseInt(e.clientX)-parseInt(rect.left);
          XY.y1=parseInt(e.clientY)-parseInt(rect.top);
      }
      var rightclick;
      if(e.which) rightclick = (e.which==3);
      else if (e.button) rightclick = (e.button==2);
 
      if ( IDo.id != "" ) {
        _setHistory("search,"+IDo.id);
        localStorage.setItem('_Keyword', IDo.id);
        _drawCanvas();
        var en=new Object(JSON.parse(localStorage.getItem("_Env")));
        window.open(en.external_link+IDo.id);
        isDrag=false;
      } else if (!rightclick) isDrag=true;

    }

    /////////////////////////////////////////////// Mouse out from Track
    function _mouseUpNavListner(e) {
      _drawTOP();
      document.body.style.cursor = "default";
    }

    /////////////////////////////////////////////// Mouse out from Track
    function _mouseUpTrackListner(e) {
      document.body.style.cursor = "default";
      if (isDrag) {
        isDrag=false;
        if(Math.abs(XY.x2-XY.x1)){
          _getData_p(XY.x2-XY.x1);
        }
      } else {
        _drawTOP();
      }
    }

    /////////////////////////////////////////////// Mouse moving on Track
    var IDo=new Object();
    function _mouseMoveTrackListner(e) {
      var rect = e.target.getBoundingClientRect();
      e.preventDefault();
      // Getting coordinate(pc or iOS)
      var isiPad = navigator.userAgent.match(/iPad/i) != null;
      var isiPhone = navigator.userAgent.match(/iPhone/i) != null;
      if (isiPad || isiPhone) {    //iPad & iPhone
        XY.x2=parseInt(e.touches[0].pageX)-parseInt(rect.left);
        XY.y2=parseInt(e.touches[0].pageY)-parseInt(rect.top);
      } else {    //PC
        XY.x2=parseInt(e.clientX)-parseInt(rect.left);
        XY.y2=parseInt(e.clientY)-parseInt(rect.top);
      }

      if(isDrag){
        _drawDrag("onTrack");
      } else {

      // Set ID info
      IDo.id="";
      IDo.s="";
      IDo.e="";

      ctx1.putImageData(frameTrackwR, 0, 0);
      ctx4.putImageData(frameCell, 0, 0);

      if (_cvtZoom(Objects.Zoom)<10000){

      var to=new Object();
      var o=new Object(JSON.parse(localStorage.getItem('_Tracks')));
        document.body.style.cursor = "default";

        var th=0;
        for (i=0;i<o.length;i++){
          if(o[i].track==Objects.Tracks[parseInt(XY.y2/40)]){
            to=Object(JSON.parse(localStorage.getItem('_Track_'+i)));
            th=parseInt(o[i].h);
            break;
          }
        }

        for(j=0;j<to.length;j++){
          if ( to[j].s*Objects.BlockW <= XY.x2 && to[j].e*Objects.BlockW >= XY.x2 && th==4 && to[j].name!=""
                && parseInt(XY.y2/40)*40+(to[j].h-1)*10 <= XY.y2 && parseInt(XY.y2/40)*40+(to[j].h-1)*10+10 >= XY.y2 ) {

            document.body.style.cursor = "pointer";

            if(XY.x2>cvs1.width-110){
              x=XY.x2-10;
              ctx1.textAlign="right";
            } else {
              x=XY.x2+12;
              ctx1.textAlign="left";
            }

            if((XY.y2+10)>cvs1.height){
              y=cvs1.height;
            } else {
              y=XY.y2+10;
            }

            ctx1.fillStyle=_setColor().locusid;
            var strand="";
            if ( to[j].strand == "0" ) {
              strand="-";
            }else{
              strand="+";
            }
            ctx1.fillText(to[j].id+" ("+strand+" strand)",x,y);

            // Set ID info
            IDo.id=to[j].id;
            IDo.s=to[j].s;
            IDo.e=to[j].e;

            break;
          }
        }

        // Focus red area under gene when 1b
        if ( _cvtZoom(Objects.Zoom) == 1 ) {
          if ( XY.y2 > cvs1.height-15 && XY.y2 < cvs1.height ) {
            var pos=parseInt(XY.x2/Objects.BlockW);
            ctx4.fillStyle="rgba(220,0,0,0.1)";
            ctx4.lineWidth=1;
            ctx4.fillRect(pos*Objects.BlockW,0,Objects.BlockW,cvs4.height);
            _drawTracks(pos);
          }
        }
      }
        _drawMeter(Objects.Pos,XY.x2);
      }

    }

    /////////////////////////////////////////////// Mouse down on Navigation
    function _mouseDownNavListner(e) {
      var rect = e.target.getBoundingClientRect();
      e.preventDefault();
      // Getting coordinate(pc or iOS)
      var isiPad = navigator.userAgent.match(/iPad/i) != null;
      var isiPhone = navigator.userAgent.match(/iPhone/i) != null;
      if (isiPad || isiPhone) {    //iPad & iPhone
          XY.x1=parseInt(e.touches[0].pageX)-parseInt(rect.left);
          XY.y1=parseInt(e.touches[0].pageY)-parseInt(rect.top);
      } else {    //PC
          XY.x1=parseInt(e.clientX)-parseInt(rect.left);
          XY.y1=parseInt(e.clientY)-parseInt(rect.top);
      }
      var rightclick;
      if(e.which) rightclick = (e.which==3);
      else if (e.button) rightclick = (e.button==2);

      if(!rightclick && XY.y1 < cvs2.height/2+5){
        var o=_chromosome();
        var m=o.width;
        // Click on chromsome
        if (XY.x1 > 0 && XY.x1 <= m){
          var t=(XY.x1-o.area/2)/m;
          var p=_checkPos(parseInt(_last(Objects.Zoom)*t),Objects.Zoom);
          _setHistory("position,"+Objects.Chr+","+p+","+Objects.Zoom);
          localStorage.setItem('_Pos', p);
          _showLoading();
          _messageOnScreen("Loading position "+(p*_cvtZoom(Objects.Zoom))+" b");
          _execCanvas();
        }

        if(XY.y1 < 27 && XY.x1 >= cvs2.width/2) {
          if ( XY.x1 > cvs2.width/2+cvs2.width/2/5*2-o.s1 && XY.x1 < cvs2.width/2+cvs2.width/2/5*3+o.s2) {
            var s=cvs2.width/2+cvs2.width/2/5*2-(XY.x1-cvs2.width/2/5*0.5)
            var p=_checkPos(Objects.Pos-parseInt(s/(cvs2.width/2/5)*Objects.Block),Objects.Zoom);
            _setHistory("position,"+Objects.Chr+","+p+","+Objects.Zoom);
            localStorage.setItem('_Pos', p);
            _showLoading();
            _messageOnScreen("Loading position "+(p*_cvtZoom(Objects.Zoom))+" b");
            _execCanvas();
          }
        }
      }
    }

    /////////////////////////////////////////////// Mouse down on cell
    var XY=new Object();
    var isDrag;
    function _mouseDownListner(e) {
      var rect = e.target.getBoundingClientRect();
      e.preventDefault();
      // Getting coordinate(pc or iOS)
      var isiPad = navigator.userAgent.match(/iPad/i) != null;
      var isiPhone = navigator.userAgent.match(/iPhone/i) != null;
      if (isiPad || isiPhone) {    //iPad & iPhone
          XY.x1=parseInt(e.touches[0].pageX)-parseInt(rect.left);
          XY.y1=parseInt(e.touches[0].pageY)-parseInt(rect.top);
      } else {    //PC
          XY.x1=parseInt(e.clientX)-parseInt(rect.left);
          XY.y1=parseInt(e.clientY)-parseInt(rect.top);
      }

      var rightclick;
      if(e.which) rightclick = (e.which==3);
      else if (e.button) rightclick = (e.button==2);

      // Draggin started
      if(!rightclick) isDrag=true;

      if ( Objects.Indicator == "on" ) {
        // Detecting left direction indicator
        if ( XY.x2 > 35 && XY.x2 < 45 && XY.y2 > cvs4.height-50 && XY.y2 < cvs4.height-30 ) {
          _getData_p(parseInt(cvs4.width/4));
          isDrag=false;
          ONINFOCELL.flag=false;
        } 
        // Detecting right direction indicator
        else if ( XY.x2 > 80 && XY.x2 < 90 && XY.y2 > cvs4.height-50 && XY.y2 < cvs4.height-30 ) {
          _getData_p(parseInt(-cvs4.width/4));
          isDrag=false;
          ONINFOCELL.flag=false;
        } 
        // Detecting zoom in direction indicator
        else if ( XY.x2 > 54 && XY.x2 < 72 && XY.y2 > cvs4.height-62 && XY.y2 < cvs4.height-42 ) {
          _changeZoomS('+');
          isDrag=false;
          ONINFOCELL.flag=false;
        } 
        // Detecting zoom out direction indicator
        else if ( XY.x2 > 54 && XY.x2 < 72 && XY.y2 > cvs4.height-29 && XY.y2 < cvs4.height-18 ) {
          _changeZoomS('-');
          isDrag=false;
          ONINFOCELL.flag=false;
        } 
        // Detecting filter indicator
        else if ( XY.x2 > cvs4.width-160 && XY.x2 < cvs4.width-10 && XY.y2 > cvs4.height-40 && XY.y2 < cvs4.height - 22 ) {
          _dialog_filter();
          isDrag=false;
          ONINFOCELL.flag=false;
        }
      }
      if ( ONINFOCELL.flag && XY.x2 > ONINFOCELL.x && XY.x2 < ONINFOCELL.x+ONINFOCELL.w
           && XY.y2 > ONINFOCELL.y && XY.y2 < ONINFOCELL.y+ONINFOCELL.h ) {
        isDrag=false;
        _dialog_infocell(ONINFOCELL.str);
      }

    }

    /////////////////////////////////////////////// Mouse move on track title
    function _mouseMoveTrackTitleListner(e) {
      var rect = e.target.getBoundingClientRect();
      e.preventDefault();
      // Getting coordinate(pc or iOS)
      var isiPad = navigator.userAgent.match(/iPad/i) != null;
      var isiPhone = navigator.userAgent.match(/iPhone/i) != null;
      if (isiPad || isiPhone) {    //iPad & iPhone
          XY.x1=parseInt(e.touches[0].pageX)-parseInt(rect.left);
          XY.y1=parseInt(e.touches[0].pageY)-parseInt(rect.top);
      } else {    //PC
          XY.x1=parseInt(e.clientX)-parseInt(rect.left);
          XY.y1=parseInt(e.clientY)-parseInt(rect.top);
      }
      document.body.style.cursor = "default";
      // Change direction of reference
      if ( _cvtZoom(Objects.Zoom) == 1 ) {
        if ( XY.y1 > cvs0.height-15 && XY.y1 < cvs0.height ) {
          document.body.style.cursor = "pointer";
        }
      }
    }

    /////////////////////////////////////////////// Mouse down on track title
    function _mouseOutTrackTitleListner(e) {
      document.body.style.cursor = "default";
    }

    /////////////////////////////////////////////// Mouse down on track title
    function _mouseDownTrackTitleListner(e) {
      var rect = e.target.getBoundingClientRect();
      e.preventDefault();
      // Getting coordinate(pc or iOS)
      var isiPad = navigator.userAgent.match(/iPad/i) != null;
      var isiPhone = navigator.userAgent.match(/iPhone/i) != null;
      if (isiPad || isiPhone) {    //iPad & iPhone
          XY.x1=parseInt(e.touches[0].pageX)-parseInt(rect.left);
          XY.y1=parseInt(e.touches[0].pageY)-parseInt(rect.top);
      } else {    //PC
          XY.x1=parseInt(e.clientX)-parseInt(rect.left);
          XY.y1=parseInt(e.clientY)-parseInt(rect.top);
      }
      // Change direction of reference
      if ( _cvtZoom(Objects.Zoom) == 1 ) {
        if ( XY.y1 > cvs0.height-15 && XY.y1 < cvs0.height ) {
          _changeDirRef();
          _drawCanvas();
        }
      }
    }

    /////////////////////////////////////////////// Mouse down on Title
    function _mouseDownTitleListner(e) {
      var rect = e.target.getBoundingClientRect();
      e.preventDefault();
      // Getting coordinate(pc or iOS)
      var isiPad = navigator.userAgent.match(/iPad/i) != null;
      var isiPhone = navigator.userAgent.match(/iPhone/i) != null;
      if (isiPad || isiPhone) {    //iPad & iPhone
          XY.x1=parseInt(e.touches[0].pageX)-parseInt(rect.left);
          XY.y1=parseInt(e.touches[0].pageY)-parseInt(rect.top);
      } else {    //PC
          XY.x1=parseInt(e.clientX)-parseInt(rect.left);
          XY.y1=parseInt(e.clientY)-parseInt(rect.top);
      }
      var rightclick;
      if(e.which) rightclick = (e.which==3);
      else if (e.button) rightclick = (e.button==2);
 
      if(!rightclick){
        ctx4.putImageData(frameCell, 0, 0);
        _changeRef(parseInt(XY.y2/Objects.BlockH));
      }
    }

    /////////////////////////////////////////////// Mouse move on title
    function _mouseUpTitleListner(e) {
      ctx3.putImageData(frameTitle, 0, 0);
      ctx4.putImageData(frameCell, 0, 0);
      document.body.style.cursor = "default";
    }

    /////////////////////////////////////////////// Mouse move on title
    function _mouseMoveTitleListner(e) {
      var rect = e.target.getBoundingClientRect();
      e.preventDefault();
      // Getting coordinate(pc or iOS)
      var isiPad = navigator.userAgent.match(/iPad/i) != null;
      var isiPhone = navigator.userAgent.match(/iPhone/i) != null;
      if (isiPad || isiPhone) {    //iPad & iPhone
        XY.x2=parseInt(e.touches[0].pageX)-parseInt(rect.left);
        XY.y2=parseInt(e.touches[0].pageY)-parseInt(rect.top);
      } else {    //PC
        XY.x2=parseInt(e.clientX)-parseInt(rect.left);
        XY.y2=parseInt(e.clientY)-parseInt(rect.top);
      }
      document.body.style.cursor = "pointer";
      ctx4.putImageData(frameCell, 0, 0);
      if ( Objects.id.length > 30 ) _draw_detail_accession(parseInt(XY.y2/Objects.BlockH));
      _drawTitle(parseInt(XY.y2/Objects.BlockH));
    }


    /////////////////////////////////////////////// Start drag during mouse down on cell
    function _mouseMoveListner(e) {

      var rect = e.target.getBoundingClientRect();
      e.preventDefault();
      // Getting coordinate(pc or iOS)
      var isiPad = navigator.userAgent.match(/iPad/i) != null;
      var isiPhone = navigator.userAgent.match(/iPhone/i) != null;
      if (isiPad || isiPhone) {    //iPad & iPhone
        XY.x2=parseInt(e.touches[0].pageX)-parseInt(rect.left);
        XY.y2=parseInt(e.touches[0].pageY)-parseInt(rect.top);
      } else {    //PC
        XY.x2=parseInt(e.clientX)-parseInt(rect.left);
        XY.y2=parseInt(e.clientY)-parseInt(rect.top);
      }

      document.body.style.cursor = "default";
      if(isDrag){
        _drawDrag("onCell");
      } else {

        ctx1.putImageData(frameTrackwR, 0, 0);

        _drawMeter(Objects.Pos,XY.x2);               // Drawing position on meter
        _drawTitle(parseInt(XY.y2/Objects.BlockH));  // Focus on title
        if(Objects.Zoom=='1b') _drawTracks(parseInt(XY.x2/Objects.BlockW)); // Focus on fasta

        if ( Objects.Indicator == "on" ) {
          // Detecting left direction
          if ( XY.x2 > 35 && XY.x2 < 45 && XY.y2 > cvs4.height-50 && XY.y2 < cvs4.height-30 ) {
            document.body.style.cursor = "pointer";
          } 
          // Detecting right direction
          else if ( XY.x2 > 80 && XY.x2 < 90 && XY.y2 > cvs4.height-50 && XY.y2 < cvs4.height-30 ) {
            document.body.style.cursor = "pointer";
          } 
          // Detecting zoom in direction
            else if ( XY.x2 > 54 && XY.x2 < 72 && XY.y2 > cvs4.height-62 && XY.y2 < cvs4.height-42 ) {
            document.body.style.cursor = "pointer";
          } 
          // Detecting zoom out direction
          else if ( XY.x2 > 54 && XY.x2 < 72 && XY.y2 > cvs4.height-29 && XY.y2 < cvs4.height-18 ) {
              document.body.style.cursor = "pointer";
          } 
          // Detecting filter
          else if ( XY.x2 > cvs4.width-160 && XY.x2 < cvs4.width-10 && XY.y2 > cvs4.height-40 && XY.y2 < cvs4.height - 22 ) {
            document.body.style.cursor = "pointer";
          }
        }
        // Detail information area
        if ( ONINFOCELL.flag && XY.x2 > ONINFOCELL.x && XY.x2 < ONINFOCELL.x+ONINFOCELL.w
          && XY.y2 > ONINFOCELL.y && XY.y2 < ONINFOCELL.y+ONINFOCELL.h ) document.body.style.cursor = "pointer";
      }
    }

    /////////////////////////////////////////////// Zooming when double clicked on cell
    function _mouseDblclickListner(e) {
      var rect = e.target.getBoundingClientRect();
      e.preventDefault();
      // Getting coordinate(pc or iOS)
      var isiPad = navigator.userAgent.match(/iPad/i) != null;
      var isiPhone = navigator.userAgent.match(/iPhone/i) != null;
      if (isiPad || isiPhone) {    //iPad & iPhone
        XY.x1=parseInt(e.touches[0].pageX)-parseInt(rect.left);
        XY.y1=parseInt(e.touches[0].pageY)-parseInt(rect.top);
      } else {    //PC
        XY.x1=parseInt(e.clientX)-parseInt(rect.left);
        XY.y1=parseInt(e.clientY)-parseInt(rect.top);
      }
      _execDblClick(XY.x1);
    }

    /////////////////////////////////////////////// Stop drag when mouse up on cell
    function _mouseOutListner(e) {

      document.body.style.cursor = "default";

      // When out in dragging
      if (isDrag && Math.abs(XY.x2-XY.x1)) {
        _getData_p(XY.x2-XY.x1);
      } else if ($('#dialog_infocell').dialog("isOpen")===true) {
        // nothing for detail viewer
      } else {
        ctx1.putImageData(frameTrackwR,0,0);
        ctx3.putImageData(frameTitle,0,0);
        ctx4.putImageData(frameCell, 0, 0);
      }

      isDrag=false;
      ONINFOCELL.flag=false;
      
    }


    /////////////////////////////////////////////// Popup cell info or drag
    var numClicks=0;
    var timeOut;
    function _doClick() {  numClicks=0; }// Check double click
    function _mouseUpListner(e) {

      document.body.style.cursor = "default";

      // Check double click
      numClicks++;
      if (numClicks == 2){
        clearTimeout(timeOut);
        numClicks=0;
      }

      if (numClicks == 1){
        // Detail information
        if ( !(XY.x2-XY.x1) && ( Objects.Indicator=="off" || Objects.Indicator=="on"
            && !( XY.x1 > Objects.Ix && XY.x1 < cvs4.width-10 && XY.y1 > 20 && XY.y1 < Objects.Iy)) )
           _execInfoCell(XY.x2,XY.y2);      // Single clicked
        // Dragging
        if(Math.abs(XY.x2-XY.x1)) _getData_p(XY.x2-XY.x1);
        timeOut = setTimeout("_doClick()", 400);
      }

      isDrag=false;
    }

    /////////////////////////////////////////////// Event of key down
    function _doKeyDown(e){

      var ONDIALOG=false;
      if ($('#dialog_csv').dialog("isOpen")===true) ONDIALOG=true;
      if ($('#dialog_go').dialog("isOpen")===true) ONDIALOG=true;
      if ($('#dialog_track').dialog("isOpen")===true) ONDIALOG=true;
      if ($('#dialog_reset').dialog("isOpen")===true) ONDIALOG=true;

      if(!ONDIALOG){
        switch (e.keyCode) {
          case 32:  /* space next key */
            _movePage('+');
            break;
          case 35:  /* end key for moving tail */
            _moveEdge('e');
            break;
          case 36:  /* home key for moving head */
            _moveEdge('s');
            break;
          case 37:  /*  previus key */
            if(ONINFOCELL.flag){
              _execInfoCell(ONINFOCELL.cx-Objects.BlockW,ONINFOCELL.cy);
            } else {
              _movePage('-');
            }
            break;
          case 38:  /* Up key Zoom IN */
            if(ONINFOCELL.flag){
              _execInfoCell(ONINFOCELL.cx,ONINFOCELL.cy-Objects.BlockH);
            } else {
              _changeZoomS('+');
            }
            break;
          case 39:  /* next key */
            if(ONINFOCELL.flag){
              _execInfoCell(ONINFOCELL.cx+Objects.BlockW,ONINFOCELL.cy);
            } else {
              _movePage('+');
            }
            break;
          case 40:  /* Down key Zoom OUT */
            if(ONINFOCELL.flag){
              _execInfoCell(ONINFOCELL.cx,ONINFOCELL.cy+Objects.BlockH);
            } else {
              _changeZoomS('-');
            }
            break;
          case 65:  /* a for ALL*/
            //_changeMode('dp+a');
			_changeModeSW('si');
            break;
          case 66:  /* b for Snpblock*/
            _changeSnpblock();
            break;
          case 68:  /* d for Indicator */
            _changeIndicator();
            break;
          case 69:  /* e for Effect */
            _changeEff();
            break;
//          case 70:  /* f for Effect */
//            _dialog_go();
//            break;
          case 72:  /* h for Manual(help) */
            _dialog_manual();
            break;
          case 80:  /* p for DEPTH */
            _changeMode('dp');
            break;
          case 83:  /* s for SNP */
            //_changeMode('dp+s');
			_changeModeSW('s');
            break;
          case 73:  /* i for INDEL */
            //_changeMode('dp+i');
			_changeModeSW('i');
            break;
          case 78:  /* n for NULL */
            _changeNull();
            break;
          case 107:  /* '+' key Zoom IN */
            _changeZoomS('+');
            break;
          case 109:  /* '-' key Zoom OUT */
            _changeZoomS('-');
            break;
        }
      }
    }


