//***************************************************************************
//*
//*  システム名　：フレームワークAMBER - サンプルプログラム
//*
//*  プログラム名：コンテンツ管理システム．JavaScript
//*
//*  ファイル名　：common.js
//*
//*  作成者　　　：横山祐介(U-Works)
//*
//*  作成日　　　：2008.06.25
//*
//*  概要　　　　：
//*
//*  Copyright (c) 2008 Yusuke Yokoyama. all rights reserved.
//*
//***************************************************************************

//***************************************************************************
//* ボタンによる２重送信を防止する。
//***************************************************************************
done = false;
function formSubmit() {
  if (done) {
    return false;
  }
  else {
    done = true;
    document.title = "送信中 しばらくお待ちください... >>>";
    return true;
  }
}

//***************************************************************************
//* ページ内各領域の高さと幅をウィンドウにあわせる。
//* ※ IE6では、スタイルにtop/bottom、left/rightを同時に指定できないため、
//*    height、widthを算出して設定する。
//***************************************************************************
function windowResize() {
//  alert("windowResize");
  divBase = document.getElementById("div-base");
  divTop = document.getElementById("div-top");
  divMain = document.getElementById("div-main");
  divBottom = document.getElementById("div-bottom");
  divSidebar = document.getElementById("div-sidebar");
  divContents = document.getElementById("div-contents");
  divContentsHeader = document.getElementById("div-contents-header");
  divContentsBody = document.getElementById("div-contents-body");
  divContentsFooter = document.getElementById("div-contents-footer");
  // ページ全体領域が存在し、ブラウザがIE6のとき
//  if ((divBase) && (navigator.userAgent.indexOf("MSIE 6") >= 0)) {
  if (divBase) {
    // 全体領域の高さを設定する。
    divBase.style.height = document.body.clientHeight - 10;
    // 主ペインの高さを設定する。
    if ((divTop) && (divMain) && (divBottom)) {
      divMain.style.height = divBase.clientHeight
                           - divTop.clientHeight
                           - divBottom.clientHeight; 
    }
    // コンテンツペインの幅を設定する。
    if ((divSidebar) && (divContents)) {
      divContents.style.width = divBase.clientWidth
                              - divSidebar.clientWidth;
    }
    // コンテンツペインのスクロール領域の高さを設定する。
    if ((divContents) && (divContentsBody)) {
      divContentsHeaderHeight = 0;
      divContentsFooterHeight = 0;
      // コンテンツペインの上部非スクロール領域が存在するとき、高さを取得する。
      if (divContentsHeader) {
        divContentsHeaderHeight = divContentsHeader.clientHeight;
      }
      // コンテンツペインの下部非スクロール領域が存在するとき、高さを取得する。
      if (divContentsFooter) {
        divContentsFooterHeight = divContentsFooter.clientHeight;
      }
      // スクロール領域の高さを設定する。
      divContentsBody.style.height = divContents.clientHeight
                                   - divContentsHeaderHeight
                                   - divContentsFooterHeight;
    }
  }
}

//***************************************************************************
//* 領域の高さを揃える。
//***************************************************************************
/*function adjustHeight() {
	block1 = document.getElementById("div-sidebar");
	block2 = document.getElementById("div-contents");

	debug("block1:" + block1 + " block2:" + block2);
	
	h1 = block1.clientHeight;
	h2 = block2.clientHeight;

	debug("h1:" + h1 + " h2:" + h2);
	
	
	h = (h1 > h2 ? h1 : h2);
	block1.style.height = h;
	block2.style.height = h;
	
	
}
*/

function debug(str) {
	
	//alert(str);
	
  obj = document.getElementById("debug");
  if (obj) {
    obj.innerText += str + "\n";
  }
}


