function imgData( thisname, file_name, x_size, y_size, thumbnail, placename, picwin ){
  
  this.instname = thisname;
  this.len = 1;
  this.imglst = new Array();
  this.imglst[0] = new imgDetail( file_name, x_size, y_size, thumbnail, placename );
  this.maxpic = 10;
  this.tagpic = "topimg";
  this.tagtext = "imgexp1_w";
  this.textcls = new Array();
  this.textcls[0] = "text1_var";
  this.textcls[1] = "text2_var";
  this.tagtext_ext = "imgexp2";
  this.textextcls = new Array();
  this.textextcls[0] = "text3_var";
  this.textextcls[1] = "text4_var";
  this.picmenucls = new Array();
  this.picmenucls[0] = "picmenu_outofwin";
  this.picmenucls[1] = "picmenu_outofwin";
  this.pnode;
  this.tagbottom = "addinfo";
  this.currentpic = 1;
  this.dammypic = "../../images/window.gif";
  this.markcolor = "#F3A715";
  this.recreation = false;
  this.first = true;
  this.picwin;
  //this.picwin_filename = "n_tokyo_pic.html";
  this.picwin_filename = picwin;
  this.picwin_height = 700;
  this.picwin_width = 716;
  this.picwin_title = "Tokyo";
  
  this.addImg = addImg;
  this.showTn = showTn;
  this.markSelect = markSelect;
  this.deleteSel = deleteSel;
  this.showImg = showImg;
  this.setTextcls = setTextcls;
  this.setTextextcls = setTextextcls;
  this.setPicmenucls = setPicmenucls;
  this.closeWindow = closeWindow;
  
  function addImg( file_name, x_size, y_size, thumbnail, placename ){
    this.imglst[this.len] = new imgDetail( file_name, x_size, y_size, thumbnail, placename );
    this.len++;
  }
  
  function showTn( parent, bordercolor ){
    this.pnode = parent;
    var node = document.getElementById( parent );
    while( node && node.lastChild ){
       node.removeChild( node.lastChild );
    }
    var i;
    for( i=0; i<this.len; i++ ){
       var linknode = document.createElement( 'a' );
       linknode.setAttribute( 'href', "javascript:" + this.instname + ".showImg(" + i + ")" );
       node.appendChild( linknode );
       node.childNodes[i].style.position = "absolute";
       if( i%2 == 0 ){
         node.childNodes[i].style.left = 1 + 'px';
       }
       else{
         node.childNodes[i].style.left = 78 + 'px';
       }
       node.childNodes[i].style.top = (76*Math.floor(i/2) + 1) + 'px';
       var imgnode = document.createElement( 'img' );
       imgnode.setAttribute( 'border', '0' );
       imgnode.setAttribute( 'height', 75 );
       imgnode.setAttribute( 'width', 75 );
       imgnode.setAttribute( 'src', this.imglst[i].tn );
       node.childNodes[i].appendChild( imgnode );
       node.childNodes[i].childNodes[0].style.top = 0;
       node.childNodes[i].childNodes[0].style.left = 0;
    }
    for( ; i<this.maxpic; i++ ){
       var divnode = document.createElement( 'div' );
       node.appendChild( divnode );
       node.childNodes[i].style.position = "absolute";
       if( i%2 != 0 ){
         node.childNodes[i].style.left = 1 + 'px';
       }
       else{
         node.childNodes[i].style.left = 78 + 'px';
       }
       node.childNodes[i].style.top = (76*Math.floor(i/2) + 1) + 'px';
       node.childNodes[i].style.width = 75 + 'px';
       node.childNodes[i].style.height = 75 + 'px';
       node.childNodes[i].style.borderStyle = "solid";
       node.childNodes[i].style.borderWidth = "1px";
       node.childNodes[i].style.borderColor = bordercolor;
    }
    //this.markSelect( node, 0 );
  }
  
  function markSelect( node, index ){
    var divnode = document.createElement( 'div' );
    node.appendChild( divnode );
    node.lastChild.style.position = "absolute";
    node.lastChild.style.left = node.childNodes[index].style.left;
    node.lastChild.style.top = node.childNodes[index].style.top;
    node.lastChild.style.width = 75 + 'px';
    node.lastChild.style.height = 75 + 'px';
    node.lastChild.style.borderStyle = "dashed";
    node.lastChild.style.borderWidth = "5px";
    //node.lastChild.style.borderColor = "#7AAB45";
    node.lastChild.style.borderColor = this.markcolor;
  }
  
  function deleteSel( node ){
    node.removeChild( node.lastChild );
  }
  
  function showImg( index ){
    //if( index == (this.currentpic-1) ){return;}
    
    var node = document.getElementById( this.pnode );
    if( this.first == false ){
      this.deleteSel( node );
    }else{
      this.first = false;
    }
    this.markSelect( node, index );
    this.currentpic = index+1;
    
    if( this.picwin == null || this.picwin.closed ){
      this.picwin = window.open( this.picwin_filename, this.picwin_title, "status=no,scrollbars=no,top=50,left=200,width=" + this.picwin_width + ",height=" + this.picwin_height );
      while( 1 ){
        if( this.picwin.setImg != null ){break;}
      }
    }
    this.picwin.setText( this.imglst[index].place ); // function name must be "setText"
    this.picwin.setImg( this.imglst[index].name, this.imglst[index].x, this.imglst[index].y ); // function name must be "setImg"
  }
  
  function setTextcls( cls1, cls2 ){
    this.textcls[0] = cls1;
    this.textcls[1] = cls2;
    this.recreation = true
  }
  
  function setTextextcls( cls1, cls2 ){
    this.textextcls[0] = cls1;
    this.textextcls[1] = cls2;
  }
  
  function setPicmenucls( cls1, cls2 ){
    this.picmenucls[1] = cls1;
    this.picmenucls[0] = cls2;
  }
  
  function closeWindow(){
    if( this.picwin != undefined || this.picwin.closed == false ){
      this.picwin.close();
    }
  }
}

function imgDetail( file_name, x_size, y_size, thumbnail, place ){
    this.name = file_name;
    this.x = x_size;
    this.y = y_size;
    this.tn = thumbnail;
    this.place = place;
    return this;
}


function displayText( textid ){
  
  this.storysecid = textid;
  this.data = new Array();
  
  this.addData = addData;
  this.changeText = changeText;
  this.deleteChild = deleteChild;
  this.dispText = dispText;
  
  var count = 0;
  
  function addData( _storytitle, _story ){
    this.data[count++] = new textData( _storytitle, _story );
  }
  
  function changeText( index, bchgscroll ){
    pnode = document.getElementById( this.storysecid );
    pnode.getElementsByTagName( 'h1' )[0].firstChild.nodeValue = this.data[index].storytitle;
    this.deleteChild( pnode.getElementsByTagName( 'p' )[0] );
    if( bchgscroll == true ){
       scroll( 0, 0 );
    }
    var str = new String( this.data[index].story );
    this.dispText( pnode.getElementsByTagName( 'p' )[0], str );
  }
  
  function deleteChild( node ){
    while(1){
       if( node.firstChild != undefined ){
          node.removeChild( node.firstChild );
       }else{
          break;
       }
    }
  }
  
  function dispText( node, str ){
    while(1){
       var rtn = str.indexOf( '\n' );
       var tmpstr;
       if( rtn != -1 ){
          tmpstr = str.substring( 0, rtn );
          str = str.substring( rtn+1, str.length );
       }else{
          tmpstr = str;
       }
       var textnode = document.createTextNode( tmpstr );
       node.appendChild( textnode );
       if( rtn != -1 ){
          var brnode = document.createElement( 'br' );
          node.appendChild( brnode );
       }else{
          break;
       }
    }
  }
}

function textData( _storytitle, _story ){

  this.storytitle = _storytitle;
  this.story = _story;
  
  return this;
}

function sectData( _file, _place ){

  this.sectfile = _file;
  this.sectplace = _place;
  
  return this;
}

