// ブラウザ認証
var ie = !!document.all
var n4 = !!document.layers
var w3c= !!document.getElementById
var ua = navigator.userAgent
var mac45= ua.indexOf('MSIE 4.5; Mac_PowerPC')!=-1
var mac5 = ua.indexOf('MSIE5.0;Mac_PowerPC')!=-1
var macie = ua.indexOf('Mac_PowerPC')!=-1&&ie
var moz = ( ua.indexOf('Gecko')!=-1 )
var opr = ( ua.indexOf('Opera')!=-1 )
var Obj = new Array();
var tmD;
var tmU;


function init() {
	Obj[0] = new DDM("mko_1");
	Obj[1] = new DDM("mko_2");
	Obj[2] = new DDM("mko_3");
    setInterval("proc()", 50);
    fixedLAYER(0,0);
}
function fixedLAYER(offSetX,offSetY) {

    offSetX = parseInt(0,10);
    offSetY = parseInt(0,10);
    if(ie&&!opr) offLeft = document.body.clientWidth/2 + offSetX;
    else         offLeft = window.innerWidth/2         + offSetX;
    offLeft = parseInt(offLeft)

    if(document.all&&!opr){
      var mx = parseInt(document.body.scrollLeft +offLeft)
    } else {
      var mx = parseInt(self.pageXOffset+offLeft)
    }
    my = -89;
    if(offLeft <= 375) {
        mx = 30
    } else {
        mx = offLeft - 375 + 30;
    }
    moveLAYER("mko_2",mx,my);
}
function moveLAYER(layName,x,y){
    
    if(document.getElementById){         //Moz,NN6,IE5用
      document.getElementById(layName).style.left=x
      document.getElementById(layName).style.top=y
    }
    else if(document.all){
      document.all(layName).style.pixelLeft=x    //IE4用
      document.all(layName).style.pixelTop=y
    }
    else if(document.layers){
      document.layers[layName].moveTo(x,y)
                                                 //NN4用
    }
}
function DDM(ObjName) {
	this.name = ObjName;
	this.child = document.all(ObjName);
	this.mode = "stop";
}
DDM.prototype.up = up_;
DDM.prototype.down = down_;
DDM.prototype.motion = motion_;
DDM.prototype.downHandler = downHandler_;
DDM.prototype.upHandler = upHandler_;
function showLay(layObj) {
	layObj.child.style.visibility="visible";
}
function hideLay(layObj) {
	layObj.child.style.visibility="hidden";
}
function clearTime() {
	clearTimeout(tmD);
	clearTimeout(tmU);
}
function proc() {
	for(var i in Obj) {
		if(Obj[i].mode != "stop") {
			Obj[i].motion();
		}
	}
}
function motion_() {
//	alert(this.mode);
	if(this.mode=="down") {
		this.down();
	} else if(this.mode=="up") {
		this.up();
    }
}
// 下降
function down_() {
	if(this.child.offsetTop < 0) {
		this.child.style.top = (this.child.offsetTop + 10 ) + 'px';
        onMOver("works");
	} else {
		this.mode = "stop";


	}
}
// 上昇
function up_() {
	if(this.child.offsetTop > -120) {
		this.child.style.top = (this.child.offsetTop - 10 ) + 'px';
        onMOut("works");
	} else {
		this.mode = "stop";
		hideLay(this);
	}
}
function downHandler_() {
	showLay(this);
	this.mode = "down";
}
function upHandler_() {
	this.mode = "up";
}
window.onload = init;

function onMOver(btnName){
  document.images[btnName].src="./btn/" + "ro_" + btnName + ".jpg";
}
function onMOut(btnName){
  document.images[btnName].src="./btn/" + btnName + ".jpg";
}
function showWrite() {
    window.open("./write.html", "WW","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=500,height=630");
}
function showFriend() {
    window.open("./friend.html", "WW","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=517,height=630");
}
function showOrder() {
    window.open("./order.html", "WW","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=500,height=480");
}
// PDF表示
function showPDF() {
    window.open("./pdf/KAIGO_JINZAI.pdf", "PW","toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=800,height=600");
}
// 入力チェック
function input_Check(form) {
	str=form.text.value;
	if(cut_Space(str).length==0) {
		return false;
	}
	if(!chk_HanKana(str)) {
		return false;
	}
	return true;
}
/* 文章の先頭からスペースと改行文字を除去します。*/
function cut_Space(str) {
	var trm = str;
	return trm.replace(/^[ 　\r\n]+/,"");
}
/* 半角カタカナが含まれていないかチェックします。 */
function chk_HanKana(str) {
	kana="ｱｲｳｴｵｶｷｸｹｺｻｼｽｾｿﾀﾁﾂﾃﾄﾅﾆﾇﾈﾉﾊﾋﾌﾍﾎﾏﾐﾑﾒﾓﾔﾕﾖﾗﾘﾙﾚﾛﾜｦﾝｧｨｩｪｫｬｭｮｯｰ､｡｢｣ﾞﾟ";
	for(i=0;i<str.length;i++) {
		if(kana.indexOf(str.charAt(i),0)>=0) {
			alert("半角カナ文字が含まれています。修正して下さい。");
			return false;
		}
	}
	return true;
}
// 入力チェック
function input_Check2(form) {
	str=form.text.value;
	if(!chk_HanKana(str)) {
		return false;
	}
	return true;
}