/*

undercurrent - sho uchida photo journal

*/

var baseUrl = 'http://www.shouchida.com/blog/';
var mtp = 'cms/';



/* ----------------------------------------------------
	comments open/close
---------------------------------------------------- */

jQuery.easing.quart = function (x, t, b, c, d) {
    return -c * ((t=t/d-1)*t*t*t - 1) + b;
};

$(document).ready(function(){
	$('div.comments').css({ display: 'none' });

	$('div.entry div.footer p a[class*="comments"]').attr('href', 'javascript:void(0);');

	$('div.entry div.footer p a[class*="comments"]').click(function(){
		var commentsId = $(this).attr('class');
		$('div#'+commentsId+'').show('fast', function(){
			var targetOffset = $('div#'+commentsId+'').offset().top;
			$('html,body').animate({scrollTop: targetOffset}, 1000, 'quart');
		});
		return false;
	});
	
	
	$('div.comments p.close a').attr('href', 'javascript:void(0);');
	
	$('div.comments p.close a').click(function(){
		var entryId = $(this).attr('class');

		var targetOffset = $('div#entry-'+entryId+'').offset().top;
		$('html,body').animate({scrollTop: targetOffset}, 1000, 'quart', function(){
			$('div#comments-'+entryId+'').hide('fast');
		});
		return false;
	});
});



/* ----------------------------------------------------
	navigation rewrite
---------------------------------------------------- */

$(document).ready(function(){
	$('a[href*="'+mtp+'mt-search.cgi?search="]').each(function(){
		var oriUrl = $(this).attr('href');

		var lo = oriUrl.indexOf('search=');
		var loend = oriUrl.indexOf('%2F&__');
		if(loend != -1){
			var lon = oriUrl.slice(lo+7,loend);
		} else {
			var loend = oriUrl.indexOf('&__');
			var lon = oriUrl.slice(lo+7,loend);
		}

		var os = oriUrl.indexOf('offset=');
		if(os!=-1){
			var osnum = oriUrl.slice(os+7,oriUrl.length-1);
			var osn = Number(osnum)+1+'/';
		} else {
			var osn = '';
		}

		var newUrl = baseUrl+'location/'+lon+'/'+osn+'';
		$(this).attr('href',newUrl);
		
	});
});



/* ----------------------------------------------------
	archives open/close
---------------------------------------------------- */

$(document).ready(function(){
	var yhead = $('#archives h4');
	var ylist = $('#archives ul');
	var oc = '#bcbcbc';
	var cc = '#878787';

	yhead.css({ cursor: 'pointer', color: ''+oc+'' });
	$('#archives h4:first').css({ color: ''+cc+'' });
	ylist.css({ display: 'none' });
	$('#archives ul:first').css({ display: 'block' });
	
	yhead.hover(function(){
		if($(this).next().is(':hidden')){
			$(this).css({ color: ''+cc+''});
		};
	},function(){
		if($(this).next().is(':hidden')){
			$(this).css({ color: ''+oc+''});
		};
	});

	yhead.click(function(){
		if($(this).next().is(':hidden')){
			ylist.hide('fast');
			$(this).next().show('fast');
			yhead.css({ color: ''+oc+'' });
			$(this).css({ color: ''+cc+'' });
		}
	});
});





/*  ================================================================================
 *
 *  JavaScript -Default version 3.0.4
 *  (c) 2004-2009 coliss.com
 *
 *  この作品は、クリエイティブ・コモンズの表示 2.1 日本ライセンスの下で
 *  ライセンスされています。
 *  この使用許諾条件を見るには、http://creativecommons.org/licenses/by/2.1/jp/を
 *  チェックするか、クリエイティブ･コモンズに郵便にてお問い合わせください。
 *  住所は：559 Nathan Abbott Way, Stanford, California 94305, USA です。
 *
================================================================================  */


/*  ================================================================================
TOC
============================================================
Set Adjustment
Page Scroller
============================================================
this script requires jQuery 1.2.6(http://jquery.com/)
================================================================================  */


/*  ================================================================================
Set Adjustment
================================================================================  */
var virtualTopId = "top",
    virtualTop,
    adjTraverser,
    adjPosition,
    callExternal = "pSc",
    delayExternal= 200;

/* example
======================================================================  */
//    virtualTop = 0;    // virtual top's left position = 0
//    virtualTop = 1;    // virtual top's left position = vertical movement
//    adjTraverser = 0;  // left position = 0
//    adjTraverser = 1;  // horizontal movement.
//    adjPosition = -26;

/*  ================================================================================
Page Scroller
================================================================================  */
eval(function(p,a,c,k,e,d){e=function(c){return(c<a?"":e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)d[e(c)]=k[c]||e(c);k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1;};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p;}('(d($){b z=$.G.z,E=$.G.E,J=$.G.J,A=$.G.A;$.G.1U({E:d(){3(!9[0])O();3(9[0]==j)c 1g.21||$.1q&&8.C.1h||8.g.1h;3(9[0]==8)c((8.C&&8.1u=="1l")?8.C.1f:8.g.1f);c E.1m(9,1n)},z:d(){3(!9[0])O();3(9[0]==j)c 1g.1S||$.1q&&8.C.1p||8.g.1p;3(9[0]==8)c((8.C&&8.1u=="1l")?8.C.1o:8.g.1o);c z.1m(9,1n)},J:d(){3(!9[0])O();b l=8.N?8.N(9[0].B):8.1s(9[0].B);b k=1t 1r();k.x=l.1j;1b((l=l.1c)!=10){k.x+=l.1j}3((k.x*0)==0)c(k.x);h c(9[0].B)},A:d(){3(!9[0])O();b l=8.N?8.N(9[0].B):8.1s(9[0].B);b k=1t 1r();k.y=l.1a;1b((l=l.1c)!=10){k.y+=l.1a}3((k.y*0)==0)c(k.y);h c(9[0].B)}})})(1T);$(d(){$(\'a[@F^="#"]\').1e(d(){b i=U.1X+U.1W;b I=((9.F).1J(0,(((9.F).18)-((9.Y).18)))).T((9.F).1i("//")+2);3(i.H("?")!=-1)Z=i.T(0,(i.H("?")));h Z=i;3(I.H("?")!=-1)11=I.T(0,(I.H("?")));h 11=I;3(11==Z){f.12((9.Y).1N(1));c 1L}});$("g").1e(d(){f.M()})});9.r=10;b f={17:d(u){3(u=="x")c(($(8).E())-($(j).E()));h 3(u=="y")c(($(8).z())-($(j).z()))},13:d(u){3(u=="x")c(j.15||8.g.D||8.g.K.D);h 3(u=="y")c(j.1V||8.g.1v||8.g.K.1v)},S:d(m,n,w,q,p){b r;3(r)Q(r);b 1G=16;b P=f.13(\'x\');b R=f.13(\'y\');3(!m||m<0)m=0;3(!n||n<0)n=0;3(!w)w=$.1I.1O?7:$.1I.1M?5:6;3(!q)q=0+P;3(!p)p=0+R;q+=(m-P)/w;3(q<0)q=0;p+=(n-R)/w;3(p<0)p=0;b W=v.1z(q);b V=v.1z(p);j.20(W,V);3((v.1B(v.1w(P-m))<1)&&(v.1B(v.1w(R-n))<1)){Q(9.r);j.1x(m,n)}h 3((W!=m)||(V!=n))9.r=1A("f.S("+m+","+n+","+w+","+q+","+p+")",1G);h Q(9.r)},M:d(){Q(9.r)},1Q:d(e){f.M()},12:d(o){f.M();b s,t;3(!!o){3(o==1P){s=(L==0)?0:(L==1)?j.15||8.g.D||8.g.K.D:$(\'#\'+o).J();t=((L==0)||(L==1))?0:$(\'#\'+o).A()}h{s=(1C==0)?0:(1C==1)?($(\'#\'+o).J()):j.15||8.g.D||8.g.K.D;t=1E?($(\'#\'+o).A())+1E:($(\'#\'+o).A())}b 14=f.17(\'x\');b X=f.17(\'y\');3(((s*0)==0)||((t*0)==0)){b 1F=(s<1)?0:(s>14)?14:s;b 1y=(t<1)?0:(t>X)?X:t;f.S(1F,1y)}h U.Y=o}h f.S(0,0)},19:d(){b i=U.F;b 1H=i.1i("#",0);b 1d=i.1Z(1k);3(!!1d){1D=i.T(i.H("?"+1k)+4,i.18);1R=1A("f.12(1D)",1K)}3(!1H)j.1x(0,0);h c 1Y}};$(f.19);',62,126,'|||if|||||document|this||var|return|function||coliss|body|else|usrUrl|window|tagCoords|obj|toX|toY|idName|frY|frX|pageScrollTimer|anchorX|anchorY|type|Math|frms|||height|top|id|documentElement|scrollLeft|width|href|fn|lastIndexOf|anchorPath|left|parentNode|virtualTop|stopScroll|getElementById|error|actX|clearTimeout|actY|pageScroll|slice|location|posY|posX|dMaxY|hash|usrUrlOmitQ|null|anchorPathOmitQ|toAnchor|getWindowOffset|dMaxX|pageXOffset||getScrollRange|length|initPageScroller|offsetTop|while|offsetParent|checkPageScroller|click|scrollWidth|self|clientWidth|indexOf|offsetLeft|callExternal|CSS1Compat|apply|arguments|scrollHeight|clientHeight|boxModel|Object|all|new|compatMode|scrollTop|abs|scroll|setY|ceil|setTimeout|floor|adjTraverser|anchorId|adjPosition|setX|spd|checkAnchor|browser|substring|delayExternal|false|opera|substr|mozilla|virtualTopId|cancelScroll|timerID|innerHeight|jQuery|extend|pageYOffset|pathname|hostname|true|match|scrollTo|innerWidth'.split('|'),0,{}))