﻿//========================================//
// 富山県バドミントン協会
// 作成:CoralNet
// URL:http://www.coralnet.or.jp/
// 2008/8/26 ver1.00
//   作成
//========================================//

function tbad(){
//================初期設定================//
// ディレクトリの位置
  tbad.prototype.adPath='./admin/';
//  tbad.prototype.adPath='/badminton/admin/';
//  tbad.prototype.adPath='/test/php/toyama-badminton/admin/';
//========================================//
  this.initialize.apply(this,arguments);
}
tbad.prototype={
  initialize: function(){
    // コンストラクタ
    this.setInfo();
    this.setHtml();
    Event.observe('schedule_head','click',this.mClickId);
    Event.observe('schedule_head','mouseover',this.mOvarId);
    Event.observe('schedule_head','mouseout',this.mOutId);
  },
  setHtml: function(){
    // 初期セット
    this.setHead();
    var dateObj = new Date();
    var y = dateObj.getFullYear();
    this.setBody("inc"+y);
  },
  setHead: function(){
    // ヘッダーセット
    new Ajax.Updater(
      "schedule_head",
      this.adPath+"log/menu.inc",
      {
        "method": "post",
        "parameters": ""
      }
    );
  },
  setBody: function(bodyid){
    // 内容セット
    new Ajax.Request(
      this.adPath+"log/"+bodyid+".inc",
      {
        "method": "post",
        "parameters": "",
        onSuccess: function(request) {
          // 成功時の処理を記述
          var item = $('schedule_body');
          Element.update(item, request.responseText);
        },
        onComplete: function(request) {
          // 完了時の処理を記述
          // alert('読み込みが完了しました');
        },
        onFailure: function(request) {
          // alert('読み込みに失敗しました');
          var item = $('schedule_body');
          Element.update(item, "<h3>no data</h3>");
        },
        onException: function (request) {
          // alert('読み込み中にエラーが発生しました');
        }
      }
    );
  },
  mClickId: function(e){
    // クリックしたidをbodyに表示
    var elem = Event.element(e);
    if(elem.id.match(/^inc[0-9]{4}/)){
      tbad.prototype.setBody(elem.id);
    }
  },
  mOvarId: function(e){
    // マウスオーバーしたidの背景色変更
    var elem = Event.element(e);
    if(elem.id.match(/^inc[0-9]{4}/)){
      document.getElementById(elem.id).style.background='url(images/background-schedule-menu-hover.gif)';
    }
  },
  mOutId: function(e){
    // マウスアウトしたidの背景色変更
    var elem = Event.element(e);
    if(elem.id.match(/^inc[0-9]{4}/)){
      document.getElementById(elem.id).style.background='url(images/background-schedule-menu.gif)';
    }
  },
  setInfo: function(){
    // お知らせセット
    new Ajax.Updater(
      "info",
      this.adPath+"log/incinfo.inc",
      {
        "method": "post",
        "parameters": ""
      }
    );
  }
}

Event.observe(window,'load',function(){var obj = new tbad();},false);
