/* ##### BLOGNAVIの検索機能を自分のサイトに埋め込むスクリプト ver1.0####
   author F-shin (http://www.milkstand.net/fsgarage)
   create date 2003/12/28
   last update  2003/12/28

■設置方法：
１．本JavaScriptファイルの文字コードを自分のBlOGに合わせて変更する。
２．下部の「■設定項目」に、自分のサイト情報を記述する。
３．自分のサイトに本ファイルをアップロードし、テンプレート側に以下の記述を行う。
	<script src="<設置URL>/blogSearch.js"></script>
	絶対パス表記例：<script src="/fsgarage/blogSearch.js"></script>

　　src属性内の<設置URL>は絶対パスまたは相対パスで適切な値を設定すること。

　　Entryをリビルドしてプレビューし、JavaScriptエラーが出なければ、検索ボックスの配置は終了です。

４．Entry記述にキーワード検索呼び出し機能を埋め込む場合は、以下のapiを使うこと。
【簡単api】
関数名：mkSch(検索キーワード（カンマ区切りで複数記述可能）)
機能：リンク文字列を自動生成する
詳細：

Entry中のリンクを出力したい場所で、

<script>mkSch('Office 2003','excel 2003','longhorn','MSDE');</script>

のように、カンマ区切りの検索キーワードを並べると、自動的にBlogNaviの検索機能を利用するタグが出力されます。
なお、Entryにこの記述を行うと、Entry表示時に、自動的に本JSファイル内のJavaScriptを呼び出すことになります。そのためEntryが出力されるすべてのテンプレートに、このJSファイルをincludeする必要があります。

正常に実行されると標準では、
[Office 2003][excel 2003][longhorn][MSDE]
のように表示されます。
括弧および、項目間の区切り文字はカスタマイズ可能です。


【カスタムapi】
関数名：doSearch(検索キーワード）
機能：単一の検索を実行します。
詳細：
MovableTypeのリンク入力ボックスに、リンク先として「javascript:doSearch("検索キーワード")」と入力すると検索機能を付加することができます。

 ■注意
・このファイルは自分のBlogの文字コードと同じコードで保存すること。（デフォルトUTF-8)
・私が作成したJavaScript部に関しては自由に改造していただいて構いません。ただし、BLOGNAVI検索機能および検索タグの記述ルールに関しては、BLOGNAVI様の規約に従います。必ず、http://www.blognavi.com/search/how_to_use.html　をご覧になってから利用してください。

*/

//■設定項目
//以下、サイト毎にカスタマイズすること。

//## あなたのサイトのURLを記入してください。（blogNaviに登録してない場合は、空白にすること）
var thisSiteUrl = "http://www.milkstand.net/fsgarage/";

//## 検索ボックスに表示するあなたのサイト名を記入してください。
var thisSiteName = "F's Garage";

//## あなたのサイトの文字コードのエンコードを入力してください。
//「UTF-8」「EUC-JP」「Shift_JIS」、よくわからない方は「AUTO」を入力
var thisSiteEncoding = "UTF-8" ;		     

//## BLOGNAVI様のロゴURL、下記のいずれかをコメントアウトしてください。
//　 Copyright(C) 2003 NetAge, Inc. All Rights Reserved.

//#薄い背景色向き
//# logoImg = "http://www.blognavi.com/images/logo/BNS_brown_small.gif";

//#濃い背景色向き
logoImg = "http://www.blognavi.com/images/logo/BNS_yellow_small.gif";

//mkSch関数利用時のキーワードの左に表示される文字列
var wordLeft  ="[";
//mkSch関数利用時のキーワードの右に表示される文字列
var wordRight = "]";
//mkSch関数利用時のキーワードの項目間に表示される区切り文字列
var delimiter = "";


//■以下、出力プログラム

document.write('<!-- BLOGNAVI SEARCH WINDOW -->');
document.write('<form name="blog_search" method="post" action="http://www.blognavi.com/?ctrl=search" target="_blank">');
document.write('<select name="url">');
document.write('<option value="" selected>すべてのblogから探す</option>');

if (thisSiteUrl != ""){
document.write('<option value="' + thisSiteUrl + '">' + thisSiteName + 'から探す</option>');
}

document.write('</select>');
document.write('<br />');
document.write('<input type="text" name="query">');
document.write('<input type="hidden" name="version" value="1.1">');
document.write('<input type="hidden" name="encoding" value="' + thisSiteEncoding + '">');
document.write('<input type="hidden" name="search" value="検索">');
document.write('<input type="submit" name="btn" value="検索">');
document.write('<br />');
document.write('blogの記事をキーワード検索<br />');
document.write('powered by<br />');
document.write('<a href="http://www.blognavi.com">');
document.write('<img src="' + logoImg + '" border="0" alt="Blog検索 by BLOGNAVI SEARCH">');
document.write('</a>');
document.write('</form>');
document.write('<!-- BLOGNAVI SEARCH WINDOW -->');


function doSearch(q){

	//現在の入力値を退避
	var tmpIndex = document.blog_search.url.selectedIndex;
	var tmpQuery = document.blog_search.query.value;

	document.blog_search.url.options[0].selected= true;  //すべてのblogを検索
    document.blog_search.query.value= q;
    document.blog_search.submit();

	//退避していた値を戻す
	document.blog_search.url.options[tmpIndex].selected=true;
	document.blog_search.query.value = tmpQuery;

}
function mkSch(){

var args = arguments;

	if (args.length){
	    for (var i = 0; i<args.length; i++){
		document.write(wordLeft + "<a href=\"javascript:doSearch('" + args[i] + "')\">" + args[i] + "</a>" + wordRight);
		if (i < args.length -1) document.write(delimiter);
	    }
	}
}

