/* ========================================================================
   << Library for cross browser >>

   (c)2004 - kawazu. All rights reserved.
________________________________________________________________________ */

/* =====================================================================
 * 以下の変数はブラウザの識別及び関数の互換をとるためのものです。
 * もし、このファイルを外部ソース( SCRIPT タグ内の src属性 )で使用する
 * 場合は、以下の変数を HTML 本体の SCRIPT タグ内に移動して使用してください。
 * ( 外部ソース内で直接定義した変数値は NN4 では実行されない場合があります )
________________________________________________________________________ */
// variables
// version of library
LCB_version = 3.2;
// _mac : true = macintosh, false = other os
_mac   =navigator.userAgent.toLowerCase().indexOf('mac')!=-1;
// _ie512 : true = MSIE 5.12(mac), false = others
_ie512 =navigator.userAgent.toLowerCase().indexOf('msie 5.12')!=-1;
// _kon : true = konqueror, false = others
_kon   =navigator.userAgent.toLowerCase().indexOf('konqueror')!=-1;
// _safari : true = safari, false = others
_safari=navigator.userAgent.toLowerCase().indexOf('safari')!=-1;
// _dom : kind of DOM.
//        IE4 = 1, IE5+ = 2, NN4 = 3, NN6+ = 4, others = 0
_dom = document.all?(document.getElementById?2:1):
                   (document.getElementById?4:(document.layers?3:0));
_createLayerNo = 0;                    // layer no.

/* ======================================================================
 *このスクリプトを外部ソースとして使用する場合は以下の関数を有効にして
 * 使用する最初に onLoad イベントでこの関数を呼び出して初期化して下さい */
function initCrossBrowserLib(){
  var ua=navigator.userAgent.toLowerCase();
  _mac   =ua.indexOf('mac'      )!=-1;
  _ie512 =ua.indexOf('msie 5.12')!=-1;
  _kon   =ua.indexOf('konqueror')!=-1;
  _safari=ua.indexOf('safari'   )!=-1;
  _dom=document.all?(document.getElementById?2:1):
                     (document.getElementById?4:(document.layers?3:0));
  _createLayerNo=0;
}


  var ua=navigator.userAgent.toLowerCase();
  _mac   =ua.indexOf('mac'      )!=-1;
  _ie512 =ua.indexOf('msie 5.12')!=-1;
  _kon   =ua.indexOf('konqueror')!=-1;
  _safari=ua.indexOf('safari'   )!=-1;
  _dom=document.all?(document.getElementById?2:1):
                     (document.getElementById?4:(document.layers?3:0));
  _createLayerNo=0;

//myOP = window.opera;            // OP
//myN6 = document.getElementById; // N6
//myIE = document.all;            // IE
//myN4 = document.layers;         // N4
//if      (myOP) myBR="O6"; // ブラウザは OP6以上
//else if (myIE) myBR="I4"; // ブラウザは IE4以上
//else if (myN6) myBR="N6"; // ブラウザは NS6以上
//else if (myN4) myBR="N4"; // ブラウザは NN4
//else           myBR="";   // ブラウザは 分からん


function GetDate()
{
	mdate = new Date()
	yy = mdate.getFullYear();
	mm = mdate.getMonth() + 1;
	if ( mm < 10 )
		mm = "0" + mm;
	dd = mdate.getDate();
	if ( dd < 10 )
		dd = "0" + dd;
	
	switch ( mdate.getDay() )
	{
		case 0:
			iwk = "日";
			break;
		case 1:
			iwk = "月";
			break;
		case 2:
			iwk = "火";
			break;
		case 3:
			iwk = "水";
			break;
		case 4:
			iwk = "木";
			break;
		case 5:
			iwk = "金";
			break;
		case 6:
			iwk = "土";
			break;
	}
	
	return yy + "年" + mm + "月" + dd + "日" + "(" + iwk + ")";
}

function GetTime()
{
	mtime = new Date()
	hh = mtime.getHours();
	mm = mtime.getMinutes();
	if ( mm < 10 )
		mm = "0" + mm;
	sec = mtime.getSeconds();
	if ( sec < 10 )
		sec = "0" + sec;
	
	return "只今の時刻は、"+ hh + "時" + mm + "分" + sec + "秒 です。" 
}

function myFunc()
{
	now = new Date();
	hour = now.getHours();
	min = now.getMinutes();
	sec = now.getSeconds();
	
	if (hour < 10) {
		hour = "0" + hour;
	}
	if (min < 10) {
		min = "0" + min;
	}
	if (sec < 10) {
		sec = "0" + sec;
	}
	
	mytime = "只今の時刻は、" + hour + "時" + min + "分" + sec + "秒 です。"
	
	if ( _dom == 2 || _dom == 1 ) {		// IE 4++
		document.all( "myTime" ).innerHTML = mytime;
	} else if (_dom == 3 ) {		// NetScape 4.*

/*	----------------------------------
'	2005/03/04	しばらくコメント
		with ( document.layers["myTime"] ) {
			document.open();
			document.write( mytime );
			document.close();
		}
    ----------------------------------*/

	} else if ( _dom == 4 ) {	// NetScape 6.* ++
		myNode=document.getElementById( "myTime" );
		myNode.firstChild.deleteData( 0, myNode.firstChild.length );
		myNode.firstChild.appendData( mytime );
	}
	
	if ( _dom != 3 )
 		setTimeout("myFunc()",1000);
}


function createLayer(left,top,width,height,parentDiv){
  var s='';

  if(arguments.length>5){
    for(var i=5; i<arguments.length; i++) s+=arguments[i];
  }

  // ホントは createElement あたりでチェックしたいが IE4.0 から実装 (T_T;
  if(document.createAttribute){
    var divName= '_js_layer_'+_createLayerNo; _createLayerNo++;
    var pDiv   =parentDiv?parentDiv:document.body;
    var div    =document.createElement('DIV');
    div.id=divName;
    // IE の setAttribute 関数は腐っているのでしょーがなく...
    div.style.position='absolute';
    div.style.left=left;
    div.style.top =top;
    if(width >0) div.style.width =width +'px';
    if(height>0) div.style.height=height+'px';
    div.style.visibility='hidden';
    if(_mac && pDiv.insertAdjacentHTML){
      // Mac版 IE5.2 用描画バグ対策
      pDiv.appendChild(div); div.innerHTML=s;
    }
    else {
      div.innerHTML=s; pDiv.appendChild(div);
    }
    return div;
  }

  if(_dom == 2 || _dom == 1 ){
    var adj    =(_mac&&!_ie512)?' ':'';
    var divName= '_js_layer_'+_createLayerNo; _createLayerNo++;
    var ha     =(height>0)?(';height:'+height):'';
    var pDiv   =parentDiv?parentDiv:document.body;
    var html = '<div id="'+divName+'" style="position:absolute;'
             + 'left:'+left+';top:'+top
	     + (width >0?(';width:' +width +'px'):';width:1')
	     + (height>0?(';height:'+height+'px'):'')
	     + ';visibility:hidden;">'+s+'<'+'/div>'+adj;
    if(pDiv.insertAdjacentHTML) pDiv.insertAdjacentHTML('BeforeEnd',html);
    else pDiv.innerHTML+=html;
    return document.all(divName);
  }
	
  if( _dom==3 ){
    var div=parentDiv?(new Layer(width,parentDiv)):(new Layer(width));
    if(height>0) div.resizeTo(width,height);
    div.moveTo(left,top);
	if(s!=''){
      div.document.open('text/html','replace');
      div.document.write(s);
      div.document.close();
    }
    return div;
  }
  return null;
}


function setDivVisibility(div,visible){
  if(_dom==4 || _dom==2 || _dom==1){
    div.style.visibility=(visible)?'inherit':'hidden';
    return;
  }
  if(_dom==3){
    div.visibility      =(visible)?'inherit':'hide';
    return;
  }
}


function setDivBackgroundColor(div,color){
  if( _dom==3 ) div.bgColor=color;
  else        div.style.backgroundColor=color?color:'transparent';
}
