/**********************************************************
  モダンブラウザ対応
 **********************************************************/
if (!(document.all || window.opera)) {
  initEvents() ;
}
function initEvents() {
  var events = new Array('mousedown', 'mouseover', 'mouseout', 'mousemove', 'mousedrag', 'click', 'dblclick') ;
  var len = events.length ;
  for (var i = 0 ; i < len ; i++) {
    window.addEventListener(
      events[i],
      function(e) {window.event = e ;},
      true) ;
  }
}

/**********************************************************
  IDからオブジェクトを生成する
  @param id
 **********************************************************/
function objGen(id) {
  var obj = null ;
  if (!id || (id.length == 0)) {
    return obj ;
  }
  if (typeof(id) != "object") {
    obj = document.getElementById(id) ;
  }
  else {
    obj = id ;
  }
  return obj ;
}

/**********************************************************
  指定ページにジャンプする
  @param url
 **********************************************************/
function callPage(url) {
  window.top.location.href = url ;
}

/**********************************************************
  指定サイズのウインドウを開く(スクロール可)
  @param url
  @param w    ウインドウの幅
  @param h    ウインドウの高さ
 **********************************************************/
function windowOpen(url, w, h) {
  if (!h) {
    h = window.outerHeight ;
  }
  window.open(url, "", "toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,left=0,top=0,width="+w+",height="+h+"") ;
}
/**********************************************************
  指定サイズのウインドウを開く(スクロール可)
  @param url
  @param w    ウインドウの幅
  @param h    ウインドウの高さ
 **********************************************************/
function windowOpen1(url, w, h) {
  if (!h) {
    h = window.outerHeight ;
  }
  window.open(url, "win1", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,left=0,top=0,width="+w+",height="+h+"") ;
}
/**********************************************************
  指定サイズのウインドウを開く(スクロール不可/固定)
  @param url
  @param w    ウインドウの幅
  @param h    ウインドウの高さ
 **********************************************************/
function windowOpen2(url, w, h) {
  if (!h) {
    h = window.outerHeight ;
  }
  window.open(url, "win2", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,left=0,top=0,width="+w+",height="+h+"") ;
}

/**********************************************************
  各コンテンツのリスト項目を表示・非表示にする
  @param id   項目一覧を記述したdiv要素のid
 **********************************************************/
function categoryOpen(id) {
  var obj = objGen(id) ;
  if (obj.style.display != 'block') {
    obj.style.display = 'block' ;
  }
  else {
    obj.style.display = 'none' ;
  }
}

/**********************************************************
  プルダウンで選択したページを表示する
  @param sel  select要素のオブジェクト
 **********************************************************/
function displaySelectPage(sel) {
  var idx = sel.selectedIndex ;
  var opt = sel.options ;
  var cnt = opt.length ;
  var url ;
  for (var i = 0 ; i < cnt ; i++) {
    if (i == idx) {
      opt[i].className = "colSelected" ;
      url = opt[i].value ;
    }
    else {
      opt[i].className = "colDefault"
    }
  }
 // var url = sel.options[idx].value ;
  if (url.length > 0) {
    parent.display.location = url ;
  }
}

/**********************************************************
  ボックス要素の表示・非表示を切り替える
  @param box  ボックス要素のid
  @param flg  '0'の場合非表示、'1'の場合表示
 **********************************************************/
function changeDispBox(box, flg) {
  var obj = objGen(box) ;
  if (flg == FLG_TRUE) {
    obj.style.top = window.event.clientY - 5 ;
    obj.style.left = window.event.clientX + 5 ;
    obj.style.display = 'block' ;
  }
  else {
    obj.style.display = 'none' ;
  }
}

/**********************************************************
  イラスト選択用プルダウンを設定する
  @param typ  イラストのジャンル(識別子)
  @param sel1 セレクトオブジェクトのID
 **********************************************************/
function setIllustPulldown(typ, sel1, sel2, sel3) {
  var obj1 = objGen(sel1) ;
  var obj2 = objGen(sel2) ;
  var obj3 = objGen(sel3) ;
  if (typ == 'JOGIO') {
    for (var i = 0 ; i < illustTyp01.length ; i++) {
      obj1.options[i] = document.createElement("option") ;
      obj1.options[i].text  = illustTyp01[i][0] ;
      obj1.options[i].value = illustTyp01[i][1] ;
    }
    for (var i = 0 ; i < illustTyp02.length ; i++) {
      obj2.options[i] = document.createElement("option") ;
      obj2.options[i].text  = illustTyp02[i][0] ;
      obj2.options[i].value = illustTyp02[i][1] ;
    }
    for (var i = 0 ; i < illustTyp03.length ; i++) {
      obj3.options[i] = document.createElement("option") ;
      obj3.options[i].text  = illustTyp03[i][0] ;
      obj3.options[i].value = illustTyp03[i][1] ;
    }
  }
  else if (typ == 'MV') {
    for (var i = 0 ; i < illustTyp04.length ; i++) {
      obj1.options[i] = document.createElement("option") ;
      obj1.options[i].text  = illustTyp04[i][0] ;
      obj1.options[i].value = illustTyp04[i][1] ;
    }
    for (var i = 0 ; i < illustTyp05.length ; i++) {
      obj2.options[i] = document.createElement("option") ;
      obj2.options[i].text  = illustTyp05[i][0] ;
      obj2.options[i].value = illustTyp05[i][1] ;
    }
  }
  else if (typ == 'SEIYA') {
    for (var i = 0 ; i < illustTyp06.length ; i++) {
      obj1.options[i] = document.createElement("option") ;
      obj1.options[i].text  = illustTyp06[i][0] ;
      obj1.options[i].value = illustTyp06[i][1] ;
    }
    for (var i = 0 ; i < illustTyp07.length ; i++) {
      obj2.options[i] = document.createElement("option") ;
      obj2.options[i].text  = illustTyp07[i][0] ;
      obj2.options[i].value = illustTyp07[i][1] ;
    }
  }
  else if (typ == 'COPYRIGHT') {
    for (var i = 0 ; i < illustTyp08.length ; i++) {
      obj1.options[i] = document.createElement("option") ;
      obj1.options[i].text  = illustTyp08[i][0] ;
      obj1.options[i].value = illustTyp08[i][1] ;
    }
    for (var i = 0 ; i < illustTyp09.length ; i++) {
      obj2.options[i] = document.createElement("option") ;
      obj2.options[i].text  = illustTyp09[i][0] ;
      obj2.options[i].value = illustTyp09[i][1] ;
    }
  }
  else if (typ == 'ORIGINAL') {
    for (var i = 0 ; i < illustTyp10.length ; i++) {
      obj1.options[i] = document.createElement("option") ;
      obj1.options[i].text  = illustTyp10[i][0] ;
      obj1.options[i].value = illustTyp10[i][1] ;
    }
    for (var i = 0 ; i < illustTyp11.length ; i++) {
      obj2.options[i] = document.createElement("option") ;
      obj2.options[i].text  = illustTyp11[i][0] ;
      obj2.options[i].value = illustTyp11[i][1] ;
    }
  }
}

/**********************************************************
  選択した項目のリンクを外す
  @param typ  選択した項目の識別詞
 **********************************************************/
function setInfoType(typ) {
  for (var i = 0 ; i < infoTyp.length ; i++) {
    objGen(infoTyp[i][0]).className = "dispY" ;
    objGen(infoTyp[i][1]).className = "dispN" ;
  }
  if (typ == 'ONLINE') {
    objGen(infoTyp[0][0]).className = "dispN" ;
    objGen(infoTyp[0][1]).className = "dispY" ;
  }
  else if (typ == 'OFFLINE') {
    objGen(infoTyp[1][0]).className = "dispN" ;
    objGen(infoTyp[1][1]).className = "dispY" ;
  }
}

function setIllustType(typ) {
  for (var i = 0 ; i < illustTyp.length ; i++) {
    parent.menu.objGen(illustTyp[i][0]).className = "dispY" ;
    parent.menu.objGen(illustTyp[i][1]).className = "dispN" ;
  }
  if (typ == 'JOGIO') {
    parent.menu.objGen(illustTyp[0][0]).className = "dispN" ;
    parent.menu.objGen(illustTyp[0][1]).className = "dispY" ;
  }
  else if (typ == 'MV') {
    parent.menu.objGen(illustTyp[1][0]).className = "dispN" ;
    parent.menu.objGen(illustTyp[1][1]).className = "dispY" ;
  }
  else if (typ == 'SEIYA') {
    parent.menu.objGen(illustTyp[2][0]).className = "dispN" ;
    parent.menu.objGen(illustTyp[2][1]).className = "dispY" ;
  }
  else if (typ == 'COPYRIGHT') {
    parent.menu.objGen(illustTyp[3][0]).className = "dispN" ;
    parent.menu.objGen(illustTyp[3][1]).className = "dispY" ;
  }
  else if (typ == 'ORIGINAL') {
    parent.menu.objGen(illustTyp[4][0]).className = "dispN" ;
    parent.menu.objGen(illustTyp[4][1]).className = "dispY" ;
  }
}

function setNoteType(typ) {
  for (var i = 0 ; i < noteTyp.length ; i++) {
    self.menu.objGen(noteTyp[i][0]).className = "dispY" ;
    self.menu.objGen(noteTyp[i][1]).className = "dispN" ;
  }
  if (typ == 'ILLUSTNOTE') {
    self.menu.objGen(noteTyp[0][0]).className = "dispN" ;
    self.menu.objGen(noteTyp[0][1]).className = "dispY" ;
  }
  else if (typ == 'PHOTONOTE') {
    self.menu.objGen(noteTyp[1][0]).className = "dispN" ;
    self.menu.objGen(noteTyp[1][1]).className = "dispY" ;
  }
}

/**********************************************************
  画像イメージを表示する
  @param id   画像表示用のdiv要素のid
  @param img  画像のURL
 **********************************************************/
function dispImage(id, img) {
  var disp = objGen(id) ;
  disp.src = img.src ;
} // dispImage()

function dispImage2(id, s, w, h) {
  var newImg ;
  if (typeof(s) != "object") {
    newImg = new Image(w, h) ;
    newImg.src = s ;
  }
  else {
    newImg = s ;
  }
  var disp = objGen(id) ;
  disp.src = newImg.src ;
  disp.width = newImg.width ;
  disp.height = newImg.height ;
} // dispImage2()

/**********************************************************
  テキストボックスに文言を表示する
  @param id   画像表示用のinput要素のid
  @param val  文言
 **********************************************************/
function dispTxt(id, val) {
  var txt = objGen(id) ;
  txt.value = val ;
} // dispTxt()
