var myID = "editbox";
var source = new Array();
var line = new Array();
var rline = new Array();
var line_data = new Array();

function init(){
  var myOP = window.opera;             //OP
  var myN6 = document.getElementById;  // N6 or IE
  var myIE = document.all;             // IE
  var myN4 = document.layers;          // N4

  if (myOP){                          // OP?
     // document.onclick = myClickOP;
     document.ondblclick = myClickIE;
  }else if (myIE){                    // IE?
     document.ondblclick = myClickIE;
     document.onmousedown = setBody;
     document.onmouseup = allHide;
  }else if (myN6){                    // N6?
     window.addEventListener("dblclick",myClickN6,true);
  }else if (myN4){                    // N4?
     window.captureEvents(Event.DBLCLICK);
     window.ondblclick = myClickN4;
  }
}

var editing = false;
/*
function myClickOP(){  // OPで左クリックは封印
  if(editing == false){
    editing = true
    myObj=document.getElementById(myID).style;
    myObj.left = window.event.clientX + "px";
    myObj.top  = window.event.clientY + "px";
    setEditValue('', '', window.event.clientX, window.event.clientY,'');
    myObj.visibility = "visible";
  }
}*/
function myClickN6(myEvent){  // N6でＷクリック
  if(editing == false){
    editing = true
    myObj=document.getElementById(myID).style;
    myObj.left = myEvent.clientX + window.pageXOffset + "px";
    myObj.top  = myEvent.clientY + window.pageYOffset + "px";
    setEditValue('', '', myEvent.clientX + window.pageXOffset, myEvent.clientY + window.pageYOffset,'');
    myObj.visibility = "visible";
  }
}
function myClickIE(){ // IEでＷクリック
  if(editing == false){
    editing = true
    myObj=document.all[myID].style;
    if(document.getElementById && (document.compatMode=='CSS1Compat')){
      myObj.left = window.event.clientX + document.documentElement.scrollLeft + "px";
      myObj.top  = window.event.clientY + document.documentElement.scrollTop + "px";
    }else{
      myObj.left = window.event.clientX + document.body.scrollLeft + "px";
      myObj.top  = window.event.clientY + document.body.scrollTop + "px";
    }
    setEditValue('', '', window.event.clientX + document.body.scrollLeft, window.event.clientY + document.body.scrollTop,'');
    myObj.visibility = "visible";
  }
}
function myClickN4(myEvent){ // N4でＷクリック
  if(editing == false){
    editing = true
    myObj=document[myID];
    myObj.left = myEvent.x ;
    myObj.top  = myEvent.y ;
    setEditValue('', '', myEvent.x, myEvent.y,'');
    myObj.visibility = "visible";
  }
}

function showLAYER(layName){ 
  if ( document.all )document.all( layName ).style.visibility ='visible' 
  else if ( document.layers)document.layers[ layName ].visibility ='show' 
  else if ( document.getElementById )
            document.getElementById( layName ).style.visibility ='visible' 
}

function hideLAYER(layName){ 
  if ( document.all )document.all( layName ).style.visibility ='hidden' 
  else if ( document.layers)document.layers[ layName ].visibility ='hide' 
  else if ( document.getElementById )
            document.getElementById( layName ).style.visibility ='hidden' 
}

function setEditValue(src, id, x, y, color){
  document.EditForm['MainPage.StickySourceField'].value = src;
  document.EditForm['MainPage.StickyIdField'].value = id
  document.EditForm['MainPage.StickyLeftField'].value = x
  document.EditForm['MainPage.StickyTopField'].value = y
  var sel = document.EditForm['MainPage.StickyColorField']
  for(i=0; i<sel.length; i++){
    if(sel[i].value == color){
      sel[i].selected = true
      return
    }
  }
}
var selElement = null
function showMenu(e,layName) {
  clickElement = null
  selElement = layName
  var oj=(!!document.layers)?getLayOj("menubox")
                            :getLayOj("menubox").style
  moveLAYOJ(oj,getMouseX(e),getMouseY(e))
  showLAYER("menubox")
}

function showPageMenu(e) {
  clickElement = null
  var oj=(!!document.layers)?getLayOj("page_menubox")
                            :getLayOj("page_menubox").style
  moveLAYOJ(oj,getMouseX(e),getMouseY(e))
  showLAYER("page_menubox")
}

function showEdit(e){
  var oj=(!!document.layers)?getLayOj("editbox")
                            :getLayOj("editbox").style
  editing = true
  moveLAYOJ(oj,getMouseX(e),getMouseY(e))
  if(selElement == '')
    setEditValue('', '', 100, 100, '')
  else
    setEditValue(sticky[selElement].src, sticky[selElement].id, sticky[selElement].x, sticky[selElement].y, sticky[selElement].color)
  hideLAYER("page_menubox")
  hideLAYER("menubox")
  showLAYER("editbox")
}

var lMode = false
var ldMode = false
function setLine(e){
  document.onmousemove = settingLine;
  hideLAYER("menubox")
  lMode = true
  document.SetLineForm['MainPage.SrcLineField'].value = sticky[selElement].id
}

function delLine(e){
  setLine(e)
  ldMode = true
}

function settingLine(e){
  if(lMode){
    if(sticky['mouse']){
      sticky['mouse'].x = getMouseX(e)
      sticky['mouse'].y = getMouseY(e)
    }else{
      sticky['mouse'] = new sticky('mouse','',getMouseX(e),getMouseY(e),'')
    }
    id = ldMode ? 'delLine' : 'workLine'
    line = ldMode ? 'red 2px solid' : 'black 1px dotted'
    ml = new makeLine(selElement, 'mouse')
    var oj=(!!document.layers)?getLayOj(id)
                              :getLayOj(id).style

    moveLAYOJ(oj,ml.left,ml.top)
    oj.width = ml.width + 'px'
    oj.height = ml.height + 'px'

    oj.border = 'none';
    switch(ml.mode){
    case 1:
      oj.borderBottom = line;
      oj.borderRight = line;
      break;
    case 2:
      oj.borderTop = line;
      break;
    case 3:
      oj.borderTop = line;
      oj.borderRight = line;
      break;
    case 4:
      oj.borderLeft = line;
      break;
    case 5:
      oj.borderBottom = line;
      oj.borderLeft = line;
      break;
    case 6:
      oj.borderTop = line;
      oj.borderLeft = line;
      break;
    }
  }
}

function saveLine(){
  if(clickElement){
    var oj=(!!document.layers)?getLayOj("line_editbox")
                              :getLayOj("line_editbox").style
    editing = true
    document.SetLineForm['MainPage.TargetLineField'].value = clickElement
    moveLAYOJ(oj,sticky[clickElement].x+10,sticky[clickElement].y+10)
    
    id = document.SetLineForm['MainPage.SrcLineField'].value + '-' + clickElement
    if(line_data[id]){
      var sel = document.SetLineForm['MainPage.LineColorField']
      for(i=0; i<sel.length; i++){
        if(sel[i].value == line_data[id].color){
          sel[i].selected = true
          break
        }
      }
      var sel2 = document.SetLineForm['MainPage.LineStyleField']
      for(i=0; i<sel2.length; i++){
        if(sel2[i].value == line_data[id].lstyle){
          sel2[i].selected = true
          break
        }
      }
      document.SetLineForm['MainPage.LineLabelField'].value = line_data[id].label
      document.SetLineForm['MainPage.LineWidthField'].value = line_data[id].width
      document.SetLineForm['MainPage.LineArrowStartField'].checked = (line_data[id].asflag == '1')
      document.SetLineForm['MainPage.LineArrowEndField'].checked = (line_data[id].aeflag == '1')
    }
    
    showLAYER("line_editbox")
    lMode = false
  }
}

function showPageList(e){
  var oj=(!!document.layers)?getLayOj("page_listbox")
                            :getLayOj("page_listbox").style
  document.MoveForm['MainPage.MoveStickyIdField'].value = sticky[selElement].id
  moveLAYOJ(oj,getMouseX(e),getMouseY(e))
  showLAYER("page_listbox")
}

function showMovePageList(e){
  var oj=(!!document.layers)?getLayOj("dm_page_listbox")
                            :getLayOj("dm_page_listbox").style
  moveLAYOJ(oj,getMouseX(e),getMouseY(e))
  showLAYER("dm_page_listbox")
}

function setPosition(){
  setEditValue(sticky[selElement].src, sticky[selElement].id, sticky[selElement].x, sticky[selElement].y, sticky[selElement].color)
  document.EditForm['MainPage.StickyFormSubmit'].click()
}

function setAllPosition(){
    pos_env = ''
    for (i = 0; i < sticky_index.length; i++) {
      idx = sticky_index[i]
      pos_env += sticky[idx].id + ',' + sticky[idx].x + ',' + sticky[idx].y + ':'
    }

    document.PositionAllSetForm['MainPage.PositionEnv'].value = pos_env
    document.PositionAllSetForm['MainPage.PositionAllSetButton'].click()
}

function pageJump(page){
  if(page == ''){
    pagename = prompt("作成したいページ名を入力してください。\n（既に存在する場合は、そのページに移動します）")
  }else{
    pagename = page
  }
  if(pagename != '' && pagename != null){
    document.jump.page.value = pagename
    document.jump.submit()
  }
}

function moveSticky(page){
  document.MoveForm['MainPage.TargetPageField'].value = page
  document.MoveForm['MainPage.MoveStickyIdField'].value = sticky[selElement].id
  document.MoveForm['MainPage.MoveStickyFormSubmit'].click()
}

function preMoveSticky(){
  if(document.MoveForm['MainPage.TargetPageField'].value == ''){
    document.MoveForm['MainPage.TargetPageField'].value = 
    	prompt("作成したいページ名を入力してください。\n（既に存在する場合は、そのページに移動します）","")
    if(document.MoveForm['MainPage.TargetPageField'].value == '') return false
  }
}

function restoreSticky(){
  document.StickyActionForm['MainPage.StickyIdField'].value = sticky[selElement].id
  document.StickyActionForm['MainPage.RestoreStickyFormSubmit'].click()
}

function deleteSticky(){
  if(confirm("付箋が完全に消去されます。よろしいですか？")){
    document.StickyActionForm['MainPage.StickyIdField'].value = sticky[selElement].id
    document.StickyActionForm['MainPage.DeleteStickyFormSubmit'].click()
  }
}

function lockSticky(){
  document.StickyActionForm['MainPage.StickyIdField'].value = sticky[selElement].id
  document.StickyActionForm['MainPage.PasswordField'].value =
      prompt("ロック解除用パスワード（または管理用パスワード）を入力してください","")
  document.StickyActionForm['MainPage.LockStickyFormSubmit'].click()
}

function unLockSticky(id){
  document.StickyActionForm['MainPage.StickyIdField'].value = id
  document.StickyActionForm['MainPage.PasswordField'].value =
      prompt("ロック解除用パスワード（または管理用パスワード）を入力してください","")
  document.StickyActionForm['MainPage.UnLockStickyFormSubmit'].click()
}

function restoreAllSticky(){
  document.StickyActionForm['MainPage.PasswordField'].value =
      prompt("管理用パスワードを入力してください","")
  document.StickyActionForm['MainPage.RestoreAllStickyFormSubmit'].click()
}

function deleteAllSticky(){
  document.StickyActionForm['MainPage.PasswordField'].value =
      prompt("管理用パスワードを入力してください","")
  if(confirm("ページ内の全ての付箋が完全に消去されます。よろしいですか？")){
    document.StickyActionForm['MainPage.DeleteAllStickyFormSubmit'].click()
  }
}

function preMovePage(){
  document.PageMoveForm['page'].value = document.PageMoveForm['PageMenuParts.TargetPageSelect'].value
}

function sticky(layName,src,x,y,color){
  this.id      = layName   // ドラッグできるようにするレイヤー名
  this.src     = src       // 付箋の内容
  this.x       = x         // 初期left位置
  this.y       = y         // 初期top位置
  this.color   = color     // 付箋の帯色
  return 
}

function getLineStyle(mode, style){
  switch(mode){
  case 1:
    return 'border-bottom:' + style + '; border-right:' + style + ';';
  case 2:
    return 'border-top:' + style + ';';
  case 3:
    return 'border-top:' + style + '; border-right:' + style + ';';
  case 4:
    return 'border-left:' + style + ';';
  case 5:
    return 'border-bottom:' + style + '; border-left:' + style + ';';
  case 6:
    return 'border-top:' + style + '; border-left:' + style + ';';
  }
  
  return '';
}

function getArrowStyle(mode, color){
  switch(mode){
  case 1:
    return 'border-bottom: 10px solid ' + color + ';border-left: 5px solid ' + bcolor + ';border-right: 5px solid ' + bcolor + ';'
  case 2:
    return 'border-left: 10px solid ' + color + ';border-top: 5px solid ' + bcolor + ';border-bottom: 5px solid ' + bcolor + ';'
  case 3:
    return 'border-top: 10px solid ' + color + ';border-left: 5px solid ' + bcolor + ';border-right: 5px solid ' + bcolor + ';'
  case 4:
    return 'border-right: 10px solid ' + color + ';border-top: 5px solid ' + bcolor + ';border-bottom: 5px solid ' + bcolor + ';'
  }
  
  return '';
}

function drawLine(src, target, label, color, width, lstyle, asflg, aeflg){
  id = src + '-' + target
  if(line[src]){
    line[src].push(target)
  }else{
    line[src] = new Array()
    line[src].push(target)
  }
  if(rline[target]){
    rline[target].push(src)
  }else{
    rline[target] = new Array()
    rline[target].push(src)
  }

  this.src = src
  this.target = src
  this.label = label
  this.color = color
  this.width = width
  this.lstyle = lstyle
  this.style = color + ' ' + width + 'px ' + lstyle
  this.asflag = asflg
  this.aeflag = aeflg

  ml = new makeLine(src, target)
  if(ml.left == undefined) return "";
  style = getLineStyle(ml.mode, this.style)  

  document.write('<div id="' + id + '" ' +
                      'class="line" style="' + style + ' left:' + ml.left + 'px;'
                                                      + 'top:' + ml.top + 'px;'
                                                      + 'width:' + ml.width + 'px;'
                                                      + 'height:' + ml.height + 'px"></div>')
  if(this.aeflag == '1'){
    style = getArrowStyle(ml.amode, this.color)
    document.write('<div id="' + id + '-a" ' +
                        'class="arrow" style="z-index: 0; ' + style + 'left:' + ml.aleft + 'px;'
                                                   + 'top:' + ml.atop + 'px"></div>')
  }
  if(this.asflag == '1'){
    style = getArrowStyle(ml.ramode, this.color)
    document.write('<div id="' + id + '-ra" ' +
                        'class="arrow" style="z-index: 0; ' + style + 'left:' + ml.raleft + 'px;'
                                               + 'top:' + ml.ratop + 'px"></div>')
  }
  
  document.write('<div id="' + id + '-l" ' +
                        'class="label" style="left:' + ml.lleft + 'px;'
                                                   + 'top:' + ml.ltop + 'px">' + label + '</div>')
}

function getShape(id){
  if(id == 'mouse'){
    this.left = sticky[id].x
    this.top = sticky[id].y
    this.width = 0
    this.height = 0

    return this
  }
  
  var obj = (!!document.layers)?getLayOj(id)
                               :getLayOj(id).style
  
  this.left = parseInt(obj.left)
  this.top = parseInt(obj.top)
  this.width = parseInt(document.getElementById(id).offsetWidth)
  this.height = parseInt(document.getElementById(id).offsetHeight)
}

function makeLine(src, target){
  try{
    var s = new getShape(src)
    var t = new getShape(target)
  }catch(e){
    return;
  }

  if(s.left+s.width-10 < t.left){
    if(t.top-10+t.height<s.top){ // ┘
      this.left = s.left + s.width + 2
      this.top = t.top + t.height + 2
      this.width = t.left + 10 - s.left - s.width - 4
      this.height = s.top + 10 - t.top - t.height - 4
      this.mode = 1
      this.amode = 1
      this.aleft = t.left + 3
      this.atop = t.top + t.height + 2
      this.ramode = 4
      this.raleft = s.left + s.width
      this.ratop = s.top + 3
      this.lleft = this.left + this.width + 5
      this.ltop = this.top + this.height / 2
    }else if(t.top<s.top+10){ //　─
      this.left = s.left + s.width + 2
      this.top = s.top + 10
      this.width = t.left-s.left-s.width - 4
      this.height = 0
      this.mode = 2
      this.amode = 2
      this.aleft = t.left - 10
      this.atop = s.top + 5
      this.ramode = 4
      this.raleft = s.left + s.width
      this.ratop = s.top + 5
      this.lleft = this.left + 15
      this.ltop = this.top - 15
    }else{ //　┐
      this.left = s.left + s.width + 2
      this.top = s.top + 10 + 2
      this.width = t.left + 10 - s.left - s.width - 2
      this.height = t.top - s.top - 10 - 2
      this.mode = 3
      this.amode = 3
      this.aleft = t.left + 5
      this.atop = t.top - 10
      this.ramode = 4
      this.raleft = s.left + s.width
      this.ratop = s.top + 7
      this.lleft = this.left + this.width + 5
      this.ltop = this.top + this.height / 2
    }
  }else if(s.left-10 < t.left){
    if(t.top+t.height<s.top+10){ // │
      this.left = t.left + 10
      this.top = t.top + t.height + 2
      this.width = 0
      this.height = s.top - t.top - t.height - 4
      this.mode = 4
      this.amode = 1
      this.aleft = t.left + 5
      this.atop = t.top + t.height + 2
      this.ramode = 3
      this.raleft = t.left + 5
      this.ratop = s.top - 10
      this.lleft = this.left + this.width + 5
      this.ltop = this.top + this.height / 2
    }else if(t.top<s.top+s.height){ //　□
      this.left = s.left + 10
      this.top = s.top + 10
      this.width = 0
      this.height = 0
      this.mode = 0
      this.amode = 0
      this.aleft = 0
      this.atop = 0
      this.ramode = 0
      this.raleft = 0
      this.ratop = 0
      this.lleft = -200
      this.ltop = -200
    }else{ //　│
      this.left = t.left + 10
      this.top = s.top + s.height + 2
      this.width = 0
      this.height = t.top - s.top - s.height - 4
      this.mode = 4
      this.amode = 3
      this.aleft = t.left + 5
      this.atop = t.top - 10
      this.ramode = 1
      this.raleft = t.left + 5
      this.ratop = s.top + s.height + 2
      this.lleft = this.left + this.width + 5
      this.ltop = this.top + this.height / 2
    }
  }else{
    if(t.top+t.height<s.top+10){ // └
      this.left = t.left + 10
      this.top = t.top + t.height + 2
      this.width = s.left - t.left - 10 - 2
      this.height = s.top + 10 - t.top - t.height - 2
      this.mode = 5
      this.amode = 1
      this.aleft = t.left + 5
      this.atop = t.top + t.height + 2
      this.ramode = 2
      this.raleft = s.left - 10
      this.ratop = s.top + 5
      this.lleft = this.left + 5
      this.ltop = this.top + this.height / 2
    }else if(t.top<s.top+10){ //　─
      if(t.left+t.width<s.left){
        this.left = t.left + t.width + 2
        this.top = s.top + 10
        this.width = s.left-t.left-t.width - 4
        this.height = 0
        this.mode = 2
        this.amode = 4
        this.aleft = t.left + t.width
        this.atop = s.top + 5
        this.ramode = 2
        this.raleft = s.left - 10
        this.ratop = s.top + 5
        this.lleft = this.left + 15
        this.ltop = this.top - 15
      }else{
        this.left = s.left + 10
        this.top = s.top + 10
        this.width = 0
        this.height = 0
        this.mode = 0
        this.amode = 0
        this.aleft = 0
        this.atop = 0
        this.ramode = 0
        this.raleft = 0
        this.ratop = 0
        this.lleft = -200
        this.ltop = -200
      }
    }else{ //　┌
      this.left = t.left + 10
      this.top = s.top + 10
      this.width = s.left - t.left - 10 - 2
      this.height = t.top - s.top - 10 - 2
      this.mode = 6
      this.amode = 3
      this.aleft = t.left + 5
      this.atop = t.top - 10
      this.ramode = 2
      this.raleft = s.left - 10
      this.ratop = s.top + 5
      this.lleft = this.left + 5
      this.ltop = this.top + this.height / 2
    }
  }
}

function moveLine(src){
  if(line[src]){
    for(i=0; i<line[src].length; i++){
      moveLineObj(src, line[src][i])
    }
  }
  if(rline[src]){
    for(i=0; i<rline[src].length; i++){
      moveLineObj(rline[src][i], src)
    }
  }
}

function moveLineObj(src, target){
  id = src + '-' + target

  ml = new makeLine(src, target)
  if(ml.left == undefined) return "";
  var oj=(!!document.layers)?getLayOj(id)
                            :getLayOj(id).style
  var lb=(!!document.layers)?getLayOj(id + '-l')
                            :getLayOj(id + '-l').style

  moveLAYOJ(oj,ml.left,ml.top)
  moveLAYOJ(lb,ml.lleft,ml.ltop)
  if(ml.width > 0){
    oj.width = ml.width + 'px'
  }
  if(ml.height > 0){
    oj.height = ml.height + 'px'
  }

  oj.border = 'none';
  switch(ml.mode){
  case 1:
    oj.borderBottom = line_data[id].style;
    oj.borderRight = line_data[id].style;
    break;
  case 2:
    oj.borderTop = line_data[id].style;
    break;
  case 3:
    oj.borderTop = line_data[id].style;
    oj.borderRight = line_data[id].style;
    break;
  case 4:
    oj.borderLeft = line_data[id].style;
    break;
  case 5:
    oj.borderBottom = line_data[id].style;
    oj.borderLeft = line_data[id].style;
    break;
  case 6:
    oj.borderTop = line_data[id].style;
    oj.borderLeft = line_data[id].style;
    break;
  }

  if(line_data[id].aeflag == '1'){
    var ar=(!!document.layers)?getLayOj(id + '-a')
                              :getLayOj(id + '-a').style
    moveLAYOJ(ar,ml.aleft,ml.atop)
    ar.border = 'none';
    switch(ml.amode){
    case 1:
      ar.borderBottom = line_data[id].color + ' 10px solid';
      ar.borderRight = bcolor + ' 5px solid';
      ar.borderLeft = bcolor + ' 5px solid';
      break;
    case 2:
      ar.borderTop = bcolor + ' 5px solid';
      ar.borderBottom = bcolor + ' 5px solid';
      ar.borderLeft = line_data[id].color + ' 10px solid';
      break;
    case 3:
      ar.borderTop = line_data[id].color + ' 10px solid';
      ar.borderRight = bcolor + ' 5px solid';
      ar.borderLeft = bcolor + ' 5px solid';
      break;
    case 4:
      ar.borderTop = bcolor + ' 5px solid';
      ar.borderBottom = bcolor + ' 5px solid';
      ar.borderRight = line_data[id].color + ' 10px solid';
      break;
    }
  }

  if(line_data[id].asflag == '1'){
    var rar=(!!document.layers)?getLayOj(id + '-ra')
                               :getLayOj(id + '-ra').style
    moveLAYOJ(rar,ml.raleft,ml.ratop)
    rar.border = 'none';
    switch(ml.ramode){
    case 1:
      rar.borderBottom = line_data[id].color + ' 10px solid';
      rar.borderRight = 'transparent 5px solid';
      rar.borderLeft = 'transparent 5px solid';
      break;
    case 2:
      rar.borderTop = 'transparent 5px solid';
      rar.borderBottom = 'transparent 5px solid';
      rar.borderLeft = line_data[id].color + ' 10px solid';
      break;
    case 3:
      rar.borderTop = line_data[id].color + ' 10px solid';
      rar.borderRight = 'transparent 5px solid';
      rar.borderLeft = 'transparent 5px solid';
      break;
    case 4:
      rar.borderTop = 'transparent 5px solid';
      rar.borderBottom = 'transparent 5px solid';
      rar.borderRight = line_data[id].color + ' 10px solid';
      break;
    }
  }
}

function pageLock () {
  document.PageLockForm['MainPage.PasswordField'].value =
      prompt("ページをロックします。管理用パスワードを入力してください")
  if(document.PageLockForm['MainPage.PasswordField'].value != "")
    document.PageLockForm['MainPage.PageLockSubmit'].click()
}

function pageUnLock () {
  document.PageLockForm['MainPage.PasswordField'].value =
      prompt("ページのロックを解除します。管理用パスワードを入力してください")
  if(document.PageLockForm['MainPage.PasswordField'].value != "")
    document.PageLockForm['MainPage.PageUnLockSubmit'].click()
}

var popc = 0;
function popSticky(id) {
  if(id != ''){
    for (i = 0; i < sticky_index.length; i++) {
      idx = sticky_index[i]
      if (idx == id) {
        showLAYER(sticky[idx].id)
      } else {
        hideLAYER(sticky[idx].id)
      }
    }
  
    tim = setInterval("allShow()", 3000);
  }
}

function allShow(){
  for (i = 0; i < sticky_index.length; i++) {
    idx = sticky_index[i]
    showLAYER(sticky[idx].id)
  }
}

function sticky_grep (pattern) {
  try {
    regex = new RegExp(pattern, "im");
    for (i = 0; i < sticky_index.length; i++) {
      idx = sticky_index[i]
      if (sticky[idx].src.match(regex)) {
        showLAYER(sticky[idx].id)
      } else {
        hideLAYER(sticky[idx].id)
      }
    }
  } catch (e) {}
}

function page_grep (pattern) {
  try {
    regex = new RegExp(pattern, "i")
    spans = document.getElementsByTagName('span')
    for (i = 0; i < spans.length; i++) {
      e = spans[i]
      if (e.className == "page") {
        if (e.innerHTML.match(/(.*)<a.*>(.*)<\/a>/)) {
          str = RegExp.$1 + " " + RegExp.$2
          if(str.match(pattern)){
            e.style.display = "inline"
          } else {
            e.style.display = "none"
          }
        }
      }
    }
  } catch (e) {}
}

function setBody(){
  clickItem = 'body'
}

function allHide(event){
  if(clickItem == 'body'){
    try{
      hideLAYER("page_menubox")
      hideLAYER("dm_page_listbox")
      hideLAYER("menubox")
    }catch(e){}
  }
  mup(event)
}

function showpre(id){
  var oj=(!!document.layers)?getLayOj(id)
                            :getLayOj(id).style
  var oj2=(!!document.layers)?getLayOj('p'+id)
                             :getLayOj('p'+id).style
  oj.display = "block";
  oj2.display = "none";
}

function hidepre(id){
  var oj=(!!document.layers)?getLayOj(id)
                            :getLayOj(id).style
  var oj2=(!!document.layers)?getLayOj('p'+id)
                             :getLayOj('p'+id).style
  oj.display = "none";
  oj2.display = "block";
}
