/*

 h e i w a n o m o r i . c o m

*/

var mx = 0;
var my = 0;

var ppx = 0;
var ppy = 0;
var ppid = "";
var ppthreshold = 64;

var _p = {
	menu : {
		top : { url:"http://heiwanomori.com/",ttl:"平和の森トップページへ"},
		live : { url:"http://heiwanomori.com/live/",ttl:"最新情報ページへ"},
		song : { url:"http://heiwanomori.com/song/",ttl:"曲を聴くページへ"},
		photo : { url:"http://heiwanomori.com/photo/",ttl:"写真ギャラリーへ"},
		movie : { url:"http://heiwanomori.com/movie/",ttl:"動画ギャラリーへ"},
		member : { url:"http://heiwanomori.com/member/",ttl:"メンバー紹介ページへ"},
		past : {url:"http://heiwanomori.com/past/",ttl:"過去情報のページへ"},
		link : {url:"http://heiwanomori.com/link/",ttl:"リンクのページへ"}
	}
};

function getMouseXY(event){
	mx = Event.pointerX(event);
	my = Event.pointerY(event);
}

function getWindowWidth(){
	if(document.all) { if (document.body.clientWidth){ return document.body.clientWidth;} else { return document.body.offsetWidth;}}
	else { return window.innerWidth; }
}
function getWindowHeight(){
	if(document.all) { if (document.body.clientHeight){ return document.body.clientHeight;} else { return document.body.offsetHeight;}}
	else { return window.innerHeight;}
}
function getWindowY(){
	if(document.all)	return document.documentElement.scrollTop;
	else				return window.pageYOffset;
}
function getWindowX(){
	if(document.all)	return document.body.scrollLeft;
	else				return window.pageXOffset;
}

function pp_enlarge(adr){

	var photoWidth = 480;
	var photoId = "pp_"+adr.split(".")[0];

	if (photoId == ppid) return false;
	if (ppid != "") pp_vanish();

	ppx = mx;
	ppy = my;
	ppid = photoId;

	var o = document.createElement("div");
	o.id = photoId;
	o.style.padding = "2px";
	o.style.border = "1px solid #333";
	o.style.position = "absolute";
	o.style.background = "#fff";
	o.style.zIndex = 1000;
	o.style.top = (getWindowY()+48)+"px";
	o.style.left = (parseInt(getWindowWidth()/2)-parseInt(photoWidth/2))+"px";
	o.innerHTML = "<img src="+adr+" border=0 width="+photoWidth+" />";
	o.style.display = "none";
	document.body.appendChild(o);	

	new Effect.Appear (photoId, { duration:0.7 });
	Event.observe(window.document,"mousemove",pp_checkMove,false);

}

function pp_checkMove(){
	try {
		if (mx > ppx && (mx - ppx) > ppthreshold) pp_vanish();
		else if (my > ppy && (my - ppy) > ppthreshold) pp_vanish();
		else if (mx < ppx && (ppx - mx) > ppthreshold) pp_vanish();
		else if (my < ppy && (ppy - my) > ppthreshold) pp_vanish();
	} catch(e){}
}

function pp_vanish(){
	try {
		new Effect.Fade (ppid, { duration:0.3 });
		document.body.removeChild($(ppid));
		ppid = "";
	} catch (e){}
}

function setMenuBar(cid){

	var adr = "http://heiwanomori.com/img/menu/";

	for (var index in _p['menu']){

		var o = document.createElement("img");
		o.id = index;

		if (_p['menu'][index]['url']){

			o.title = _p['menu'][index]['ttl'];

			if (index == cid){
				o.src = adr + o.id + "_over.gif";
			} else {
				o.src = adr + o.id + ".gif";
				o.style.cursor = "pointer";
				$(o).hover(
					function(){this.src= adr + this.id +"_over.gif"},
					function(){this.src= adr + this.id +".gif"}
				);
				$(o).click(
					function(){location.href = _p['menu'][this.id]['url'];}
				);
			}
		} else {
			o.src = adr + o.id + ".gif";
		}

		$("#menuBar").append(o);
	}

	// diary
	var da = (Math.floor(Math.random()*15) <1) ? "kame":"diary";
	var o = document.createElement("img");
	o.id = da;
	o.title = "金子りずむの日記";
	o.src = adr + da + ".gif";
	o.style.cursor = "pointer";
	$(o).hover(
		function(){this.src= adr + this.id +"_over.gif"},
		function(){this.src= adr + this.id +".gif"}
	);
	$(o).click(
		function(){location.href = "http://rizumu.jp";}
	);
	$("#menuBar").append(o);

}

function footer(){
	var t = document.createElement("div");
	t.className = "footer";
	t.innerHTML = "h e i w a n o m o r i . c o m / 2003 - "+((new Date()).getFullYear())+" All Rights Reserved.<br>写真、動画などの無断複製転載を禁じます";
	$("body").append(t);
}

function jquery_dump($obj) {
	var dumphtml = [];
	if($.browser.msie) {
		for(var i = 0; i < $obj.length; i++) {
			dumphtml.push('[' + i + '] ');
			dumphtml.push($obj[i].outerHTML.replace(/^[\r\n\t]+/, ''));
			dumphtml.push("\n");
		}
	} else {
		for(var i = 0; i < $obj.length; i++) {
			dumphtml.push('[' + i + '] '
				+ '<' + $obj[i].nodeName.toLowerCase());
			for(var j = 0; j < $obj[i].attributes.length; j++) {
				dumphtml.push(' ' + $obj[i].attributes[j].nodeName + '="' 
					+ $obj[i].attributes[j].nodeValue + '"');
			}
			dumphtml.push('>' + $obj[i].innerHTML);
			dumphtml.push('<\/' + $obj[i].nodeName.toLowerCase() + '>');
			dumphtml.push("\n");
		}
	}
	alert(dumphtml.join(''));
}

function logout(){
	$.post("http://heiwanomori.com/login/",{a:"logout"},function(result,status){
		eval (result);
	});
}
