// ==UserScript==
// @name           cocoQAsearch
// @namespace      http://furyu.tea-nifty.com/annex/2006/06/post_5a64.html
// @description    Makes a Cocolog Q&A BBS search box
// @include        http://message2.nifty.com/tb/board/cocolog/top?service_id=*
// ==/UserScript==

//----------------------------------------------------------------------------------------------------
// original: http://homepage3.nifty.com/facet/cocoQAsearch.user.js by facet (Greasemonkey for Firefox)
//----------------------------------------------------------------------------------------------------

(function () {
	var	script = document.createElement('script') ;
	script.type = "text/javascript" ;
	script.charset = "UTF-8" ;
	script.src = "http://furyu.tea-nifty.com/script/cocoQAsearch.js" ;
	document.body.appendChild( script ) ;

	var	patch = document.createElement('script') ;
	patch.type = "text/javascript" ;
	patch.text = [
		'function	patch2cocoQAsearch() {'
	,	'	if ( typeof cocoQAsearch == "undefined" || typeof cocoQAsearch.toTopAfter == "undefined" ) { setTimeout( "patch2cocoQAsearch()", 100 ) ; return ; }'
	,	'	cocoQAsearch.toTopAfter=false ;'
	,	'}'
	,	'patch2cocoQAsearch() ;'
	].join('') ;
	document.body.appendChild( patch ) ;

	var	tds = document.getElementsByTagName('td') ;
	var	target = null
	for ( var ci=0; ci < tds.length; ci++ ) {
		if ( tds[ci].innerHTML.match( '@search検索機能が使用できない' ) ) {
			target = tds[ci] ;
			break ;
		}
	}
	if ( target ) {
		target.innerHTML = [
			'<div style="padding: 16px;">'
		,	'<form name="ccqas_form" class="ccqas_form" action="javascript:cocoQAsearch.requestForm();">'
		,	'<input type="text" size="80" name="search_box" class="search_box" value="" />'
		,	'<input type="button" name="search_button" class="search_button" onclick="javascript:cocoQAsearch.requestForm(this.form);" value="検索" /><br />'
		,	'<div class="check_box">'
		,	'<input type="checkbox" name="debut" checked />はじめる前　'
		,	'<input type="checkbox" name="beginner" checked />初級者向け　'
		,	'<input type="checkbox" name="expert" checked />上級者向け　'
		,	'<input type="checkbox" name="info" />ブログ紹介　'
		,	'</div>'
		,	'</form>'
		,	'</div>'
		,	'<div class="content"></div>'
		].join('') ;
	}
	
})() ;

