(function(){
	var	fdelete = function( f ) {
		f.parentNode.removeChild(f);
	}
	var	fhide = function( f ) {
		f.style.display = 'none' ;
	}
	var	getBlogURL = function() {
		var	blogURL = '' ;
		var	links = document.getElementsByTagName('link') ;
		var	ci ;
		for ( ci=0; ci < links.length; ci++ ) {
			if ( links[ci].title.match('RSS') && links[ci].href.match('index.rdf') ) break ;
		}
		if ( ci < links.length ) {
			blogURL = links[ci].href.replace( 'index.rdf', '' ) ;
		}
		else {
			blogURL = location.href ;
		}
		return blogURL ;
	}
	var	freplace = function( f, srchname ) {
		switch( srchname.toLowerCase() ) {
			case	'coconiiru'	:
				var	cocoNiiruCgi = 'http://furyu-tei.sakura.ne.jp/cgi-bin/cocoNiiru.cgi' ;
				var	credit = '<div style="font-size:10px;">powered by <a href="' + cocoNiiruCgi + '">ココニール</a></div>' ;
				var	pnode = f.parentNode ;
				var	nf = document.createElement('form') ;
				nf.action = cocoNiiruCgi ;
				nf.name = 'cocoNiiru' ;
				nf.innerHTML = [
//					'<input type="hidden" name="url" value="' + location.href + '" />'
					'<input type="hidden" name="url" value="' + getBlogURL() + '" />'
				,	'<input type="hidden" name="mn" value="3" />'
				,	'<input type="text" name="query" onblur="javascript:if(this.value==\'\'){this.value=\'キーワードを入力\';this.style.color=\'#808080\';}" style="width:100px;color:#808080" onfocus="if(this.value==\'キーワードを入力\'){this.value=\'\';this.style.color=\'#000000\';}" maxlength=255 size=16 value="キーワードを入力" />'
				,	'<input type="submit" name="submit" value="検索" />'
				,	credit
				].join('') ;
				pnode.insertBefore( nf, f ) ;
//				fdelete( f ) ;
				fhide( f ) ;
				break ;
			default	:
				fhide( f ) ;
				break ;
		}
	}
	var	check = function() {
		var	f = document.f ;
		if ( !f ) {
			setTimeout( check, 100 ) ;
			return ;
		}
		if ( !f.action.match( /search\.nifty\.com/ ) ) return ;
		if ( typeof cocoModSearch != 'undefined' ) {
			freplace( f, cocoModSearch ) ;
		}
		else {
			fhide( f ) ;
		}
	}
	check() ;
})();
