//	DO NOT EDIT AND/OR COPY!
var x, y, fl, al, dl, sr, bIm, fIm, pIm, tg = t = pfl = oi = op = sx = sy = oh = ud = 0;
var $O = {
	a:function(a){return navigator.userAgent.match(a);},
	n:function(){return $O.a(/MSIE/);},
	b:function(){return ($O.a(/iPod|Nintendo/));},
	i:function(i){return document.getElementById(i);},
	e:function(e){return document.createElement(e);},
	h:function(h){return h.offsetHeight;},
	w:function(w){return w.offsetWidth;},
	Set:function(){
		bIm.style.backgroundImage = 'none';
		if(pfl){pIm.style.visibility = 'visible';}
		if(!$O.n()){setTimeout(popAlpha,25);}
	},
	Load:function(l){
		if(pIm.complete){$O.Set();} else if(pIm){pIm.onload = $O.Set;} else {return;}
	}
};
function creImg(){
	bIm = $O.e('div');
	bIm.className = 'pop';
	bIm.style.zindex = '100';
	bIm.style.background = 'url(/img/loading_b.gif) #000 center center no-repeat';
	document.body.appendChild(bIm);
	fIm = $O.e('div');
	fIm.className = 'pop';
	fIm.style.zindex = '150';
	document.body.appendChild(fIm);
	tg = 1;
}
function movImg(ev){
	if($O.n()){
		var d = document.documentElement?document.documentElement:document.body;
		x = d.scrollLeft + event.clientX;
		y = d.scrollTop + event.clientY;
	} else {
		x = ev.pageX;
		y = ev.pageY;
	}
	if(t){posImg();}
}
function posImg(){
	bIm.style.left = x - sx + 14 + 'px';
	bIm.style.top = y - sy + 14 + 'px';
	fIm.style.left = x - sx + 20 + 'px';
	fIm.style.top = y - sy + 20 + 'px';
}
function popImg(uri,tx,ty,opt){
	if(!tg || $O.b()){return;}
	if(pfl){fIm.removeChild(pIm);}
	pfl = pIm = op = oi = 0;
	clearTimeout(dl);
	furi = uri.substr(1);
	switch(uri.substr(0,1)){
		case'#':uri = '/img/' + furi; break;
		case'?':uri = '/img/thumb/' + furi; break;
		case'%':uri = 'http://sos-dan.skr.jp/img/link/' + furi; break;
	}
	tx = tx?tx:200;
	ty = ty?ty:40;
	t = 1;
	if(typeof opt == 'object'){
		t = opt.f?0:1;
		sx = opt.x?opt.x * (tx + 40):0;
		sy = opt.y?opt.y * (ty + 40):0;
		if(typeof opt.t == 'object'){opt.t.title = '';}
	} else {
		sx = opt?opt * (tx + 40):0;
		sy = 0;
	}
	posImg();
	bIm.style.width = tx + 12 + 'px';
	bIm.style.height = ty + 12 + 'px';
	bIm.style.visibility = fIm.style.visibility = 'visible';
	bIm.style.backgroundImage = 'url(/img/loading_b.gif)';
	if($O.n()){bIm.style.filter = 'alpha(opacity=60)';} else {bIm.style.opacity = fIm.style.opacity = '0';}
	pIm = $O.e('img');
	pIm.src = uri;
	pIm.style.margin = '0';
	pIm.style.width = tx + 'px';
	pIm.style.height = ty + 'px';
	pIm.style.visibility = 'hidden';
	pIm.onerror = function(){
		bIm.style.backgroundImage = 'url(/img/loading_e.png)';
		if(pfl){pIm.style.visibility = 'hidden';}
	};
	pfl = 1;
	fIm.style.width = fIm.style.height = 'auto';
	fIm.innerHTML = '';
	fIm.appendChild(pIm);
	if(!$O.n()){popAlphaBg();}
	fIm.onclick = delImg;
	fIm.style.cursor = 'pointer';
	fIm.title = 'click to close';
	$O.Load(false);
}
function popAlpha(){
	if(oi <= 100){
		fIm.style.opacity = oi / 100;
		oi += 10;
		fl = setTimeout(popAlpha,25);
	}
}
function popAlphaBg(){
	if(op <= 60){
		bIm.style.opacity = op / 100;
		op += 10;
		al = setTimeout(popAlphaBg,25);
	} else {op = 100;}
}
function delImg(){
	if(!tg || $O.b()){return;}
	t = pfl = 0;
	clearTimeout(fl);
	clearTimeout(al);
	if(op >= 0 && !$O.n()){
		fIm.style.opacity = op / 100;
		if(op <= 60){bIm.style.opacity = op / 100;}
		op -= 10;
		dl = setTimeout(delImg,25);
	} else {
		op = 0;
		bIm.style.visibility = fIm.style.visibility = 'hidden';
		if(pIm){fIm.removeChild(pIm);}
		delete pIm;
		pIm = 0;
	}
}
function objHide(days,opt){
	if(!tg){return false;}
	hide = $O.i('H' + days);
	try{htex = $O.i('T' + days);} catch(e) {htex = 0;}
	if(opt && opt.n && !$O.h(hide)){if(!confirm('OK?')){return false;}}
	if(!$O.b()){tg = 0;}
	on = '&#34920;&#31034;';
	cl = '&#38560;&#12377;';
	if(opt){
		on = opt.o?opt.o:'&#34920;&#31034;';
		cl = opt.c?opt.c:'&#38560;&#12377;';
	}
	oh = ud = $O.h(hide);
	if(oh){
		if($O.b()){hide.style.height = '0'; return false;}
		objRollUp();
	} else {
		hide.style.height = 'auto';
		if($O.b()){return false;}
		oh = $O.h(hide);
		ud = 0;
		hide.style.height = '0';
		objRollDown();
	}
	return false;
}
function objRollUp(){
	if(ud > 1){
		ud -= Math.max(1,Math.min(Math.round(ud / 3),Math.round(oh / 6)));
		hide.style.height = ud + 'px';
		setTimeout(objRollUp,20);
	} else {
		hide.style.height = '0';
		tg = 1;
		if(htex){htex.innerHTML = on;}
	}
}
function objRollDown(){
	if(ud < oh){
		ud += Math.max(1,Math.min(Math.round(oh / 6),Math.round((oh - ud) / 3)));
		hide.style.height = ud + 'px';
		setTimeout(objRollDown,20);
	} else {
		hide.style.height = 'auto';
		tg = 1;
		if(htex){htex.innerHTML = cl;}
	}
}
window.onload = creImg;
document.onmousemove = movImg;