<script>
function wopen(url) {
	if (loadCookie("index_jump_targettype") == "_blank") {
		w01 = window.open(url,"","");				// 新しいウインドウで開く
	} else {
		top.location.href = url;
	}
}
function sp2han(str) {
	return(str.replace(/　/g, ' '));
}
function sp2plus(str) {
	return(str.replace(/ /g, '+').replace(/　/g, '+'));
}
function sp2comma(str) {
	return(str.replace(/ /g, ',').replace(/　/g, ','));
}
function MyIndexSch() {
	url = "list.php?key=";
	url += encodeURL(sp2han(document.getElementById('search_str').value));
	top.location.href = url;
}
function MyMemoSch() {
	url = "../memo/list.php?key=";
	url += encodeURL(sp2han(document.getElementById('search_str').value));
	top.location.href = url;
}
function MyCalendarSch() {
	url = "../calendar/list.php?key=";
	url += encodeURL(sp2han(document.getElementById('search_str').value));
	top.location.href = url;
}
function GoogleSch() {
	url = "http://www.google.com/search?q=";
	url += encodeURL(sp2han(document.getElementById('search_str').value));
	wopen(url);
}
function YahooSch() {
	url = "http://search.yahoo.co.jp/search?ei=UTF-8&p=";
	url += encodeURL(sp2han(document.getElementById('search_str').value));
	wopen(url);
}
function BaiduSch() {
	url = "http://www.baidu.jp/s?tn=baidujp&ie=utf-8&wd=";
	url += encodeURL(sp2han(document.getElementById('search_str').value));
	wopen(url);
}
function NaverSch() {
	url = "http://search.naver.jp/search?q=";
	url += encodeURL(sp2han(document.getElementById('search_str').value));
	wopen(url);
}
function BingSch() {
	url = "http://www.bing.com/search?q=";
	url += encodeURL(sp2han(document.getElementById('search_str').value)) + "&go=&form=QBLH&filt=all";
	wopen(url);
}
function FresheyeSch() {
	url = "http://kotochu.fresheye.com/search/?kw=";
	url += encodeURL(sp2han(document.getElementById('search_str').value));
	wopen(url);
}
function MarsSch() {
	url = "http://www.marsflag.com/search.x?phrase=";
	url += encodeURL(sp2han(document.getElementById('search_str').value));
	wopen(url);
}
function GoogleBooksSch() {
	url = "http://books.google.com/books?q=";
	url += encodeURL(sp2han(document.getElementById('search_str').value)) + "&btnG=%E6%9B%B8%E7%B1%8D%E3%81%AE%E6%A4%9C%E7%B4%A2&hl=ja";
	wopen(url);
}
function NewsSch() {
	url = "http://news.google.co.jp/news?q=";
	url += encodeURL(sp2han(document.getElementById('search_str').value));
	wopen(url);
}
function TrainTimeSch() {
	url = "http://timetable.ekitan.com/train/TimeSearch?SFNAME=";
	str = document.getElementById('search_str').value;
	if (str != "") {
		url += EscapeSJIS(str);
	} else {
		url += EscapeSJIS("<?= $_SESSION['login_friends_home_station_'.$_SESSION['login_id']] ?>");
	}
	wopen(url);
}
function TrainChangeSch() {
	url = "http://transit.ekitan.com/norikae/NorikaeSearch?SFNAME=";
	saddr = "<?= $_SESSION['login_friends_home_station_'.$_SESSION['login_id']] ?>";
	str = sp2han(document.getElementById('search_str').value);
	key = str.split(" ");
	if (key.length == 2) {
		url += EscapeSJIS(key[0]) + "&STNAME=" + EscapeSJIS(key[1]);
	} else if ((key.length == 1) && (saddr != "")) {
		url += EscapeSJIS(saddr) + "&STNAME=" + EscapeSJIS(key[0]);
	} else {
		window.alert('乗車駅と下車駅をスペースで区切って入れてください。');
		return false;
	}
	wopen(url);
}
function TrainChangeGoogle() {
	url = "http://maps.google.co.jp/maps?ie=UTF8&f=d&ttype=dep&dirflg=r";
	saddr = "<?= $_SESSION['login_friends_home_address_'.$_SESSION['login_id']] ?>";
	str = sp2han(document.getElementById('search_str').value);
	key = str.split(" ");
	if (key.length == 2) {
		url += "&saddr=" + encodeURL(key[0]) + "&daddr=" + encodeURL(key[1]);
	} else if ((key.length == 1) && (saddr != "")) {
		url += "&saddr=" + encodeURL(saddr) + "&daddr=" + encodeURL(key[0]);
	} else {
		window.alert('出発地と目的地をスペースで区切って入れてください。');
		return false;
	}
	wopen(url);
}
function DicAlcSch() {
	url = "http://eow.alc.co.jp/";
	url += encodeURL(sp2han(document.getElementById('search_str').value));
	wopen(url);
}
function DicYahooSch() {
	url = "http://dic.yahoo.co.jp/bin/dsearch?enc=UTF-8&p=";
	url += encodeURL(sp2han(document.getElementById('search_str').value));
	wopen(url);
}
function WeblioSch() {
	url = "http://www.weblio.jp/content/";
	url += encodeURL(sp2han(document.getElementById('search_str').value));
	wopen(url);
}
function Yahoo100Sch() {
	url = "http://100.yahoo.co.jp/search?p=";
	url += encodeURL(sp2han(document.getElementById('search_str').value));
	wopen(url);
}
function MapSch() {
	url = "http://maps.google.co.jp/maps?q=";
	url += encodeURL(sp2han(document.getElementById('search_str').value));
	wopen(url);
}
function MyMapSch() {
<?php	if (GOOGLE_MAPS_API_VERSION == 'V3') { ?>
		url = "../tools/google-maps-earth-v3.php?addr=";
<?php	} else { ?>
		url = "../tools/google-maps-earth.php?addr=";
<?php	} ?>
	url += encodeURL(sp2plus(document.getElementById('search_str').value));
	wopen(url);
}
function ZipSch() {
	url = "http://postcode.goo.ne.jp/search.php?MT=";
	url += EscapeEUCJP(sp2han(document.getElementById('search_str').value));
	wopen(url);
}
function PhoneSch() {
	url = "http://search.loco.yahoo.co.jp/search?p=";
	url += encodeURL(sp2han(document.getElementById('search_str').value));
	wopen(url);
/*	iタウンページ
	url = "http://itp.ne.jp/result/?kw=";
	url += EscapeSJIS(sp2han(document.getElementById('search_str').value));
	wopen(url);
*/
}
function GoogleBlogSch() {
	url = "http://blogsearch.google.com/blogsearch?q=";
	url += encodeURL(sp2han(document.getElementById('search_str').value)) + "&um=1&ie=UTF-8&sa=N&hl=ja&tab=wb";
	wopen(url);
}
function TenkiSch() {
	url = "http://tenki.jp/search/?keyword=";
	url += encodeURL(sp2han(document.getElementById('search_str').value));
	wopen(url);
}
function CookpadSch() {
	url = "http://cookpad.com/%E3%83%AC%E3%82%B7%E3%83%94/";
	url += encodeURL(sp2han(document.getElementById('search_str').value));
	wopen(url);
}
function KikkomanSch() {
	url = "http://www.kikkoman.co.jp/homecook/search/select_search.php?free_word=";
	url += EscapeSJIS(sp2han(document.getElementById('search_str').value));
	wopen(url);
}
function googleRecipeSch() {
	url = "http://www.google.com/search?q=";
	url += encodeURL(sp2han(document.getElementById('search_str').value));
	url += "&tbs=lr:lang_1ja,rcp:1";
	wopen(url);
}
function KakakuSch() {
	url = "http://kakaku.com/search_results/";
	url += EscapeSJIS(sp2han(document.getElementById('search_str').value)) + "/";
	wopen(url);
}
function ShoppingSch() {
	url = "http://www.google.co.jp/products/?q=";
	url += encodeURL(sp2han(document.getElementById('search_str').value));
	wopen(url);
}
function RakutenSch() {
	url = "http://esearch.rakuten.co.jp/rms/sd/esearch/vc?sv=2&sitem=";
	url += EscapeEUCJP(sp2han(document.getElementById('search_str').value));
	wopen(url);
}
function AmazonSch() {
	url = "http://www.amazon.co.jp/s/ref=nb_ss_gw?__mk_ja_JP=%83J%83%5E%83J%83i&url=search-alias%3Daps&field-keywords=";
	url += EscapeSJIS(sp2han(document.getElementById('search_str').value));
	wopen(url);
}
function YahooAuctions() {
	url = "http://search.auctions.yahoo.co.jp/jp/search/auc?p=";
	url += EscapeEUCJP(sp2han(document.getElementById('search_str').value)) + "&auccat=0&submit=%B8%A1%BA%F7&alocale=0jp&acc=jp";
	wopen(url);
}
function YoutubeSch() {
	url = "http://www.youtube.com/results?search_query=";
	url += encodeURL(sp2han(document.getElementById('search_str').value)) + "&search_type=&aq=f";
	wopen(url);
}
function TwitterSch() {
	//url = "http://search.twitter.com/realtime/search?q=";
	url = "http://twitter.com/#!/search/realtime/";
	url += encodeURL(sp2han(document.getElementById('search_str').value)+" lang:ja");
	wopen(url);
}
function TwitterGoogle() {
	url = "http://www.google.com/search?tbs=mbl:1&hl=ja&num=100&q=";
	url += encodeURL(sp2han(document.getElementById('search_str').value));
	wopen(url);
}
function YahooRealtimeSch() {
	url = "http://realtime.search.yahoo.co.jp/search?ei=UTF-8&p=";
	url += encodeURL(sp2han(document.getElementById('search_str').value));
	wopen(url);
}
function search_enter(keyCode) {
	if (keyCode === 13) {
		YahooSch();
	}
}
</script>
<table id="index_search"><tr><td nowrap>
	<div class="search_button_box">
		<a id="suggest_on" class="suggest_onoff" href="javascript:suggest('off');" style="color:#EACC8F;<?= $_SESSION['suggest_on'] ?>">●</a><a id="suggest_off" class="suggest_onoff" href="javascript:suggest('on');" style="color:#EACC8F;<?= $_SESSION['suggest_off'] ?>">○</a><input class="text" type="text" id="search_str" value="<?= $keystring ?>" onkeypress="search_enter(event.keyCode);">
		<input type="button" value="Yahoo" class="btn-yellow" onClick="YahooSch()">
		<input type="button" value="Google" class="btn-yellow" onClick="GoogleSch()">
		<input type="button" value="Naver" class="btn-yellow" onClick="NaverSch()">
		<input type="button" value="Bing" class="btn-yellow" onClick="BingSch()">
		<input type="button" value="Fresh" class="btn-yellow" onClick="FresheyeSch()">
		<input type="button" value="百度" class="btn-yellow" onClick="BaiduSch()">
		<input type="button" value="ブログ" class="btn-yellow" onClick="GoogleBlogSch()">
	</div>
	<div class="search_button_box">
		<input type="button" value="MyIndex" class="btn-white" onClick="MyIndexSch()">
		<input type="button" value="Myメモ" class="btn-white" onClick="MyMemoSch()"">
		<input type="button" value="Myカレンダー" class="btn-white" onClick="MyCalendarSch()">
		<input type="button" value="ニュース" class="btn-blue" onClick="NewsSch()">
		<input type="button" value="天気" class="btn-blue" onClick="TenkiSch()">
		<input type="button" value="時刻表" class="btn-orange" onClick="TrainTimeSch()">
		<input type="button" value="乗換(駅探)" class="btn-orange" onClick="TrainChangeSch()">
		<input type="button" value="経路(Google)" class="btn-orange" onClick="TrainChangeGoogle()">
	</div>
	<div class="search_button_box">
		<input type="button" value="辞書Alc" class="btn-yellow" onClick="DicAlcSch()">
		<input type="button" value="辞書Yahoo" class="btn-yellow" onClick="DicYahooSch()">
		<input type="button" value="百科Weblio" class="btn-yellow" onClick="WeblioSch()">
		<input type="button" value="百科Yahoo" class="btn-yellow" onClick="Yahoo100Sch()">
		<input type="button" value="ブック" class="btn-yellow" onClick="GoogleBooksSch()">
		<input type="button" value="地図" class="btn-blue" onClick="MapSch()">
		<input type="button" value="●" class="btn-blue" onClick="MyMapSch()">
		<input type="button" value="〒番号" class="btn-yellow" onClick="ZipSch()">
		<input type="button" value="電話帳" class="btn-yellow" onClick="PhoneSch()">
	</div>
	<div class="search_button_box">
		<input type="button" value="料理(G)" class="btn-pink" onClick="googleRecipeSch()">
		<input type="button" value="料理(ク)" class="btn-pink" onClick="CookpadSch()">
		<input type="button" value="料理(キ)" class="btn-pink" onClick="KikkomanSch()">
		<input type="button" value="価格" class="btn-orange" onClick="KakakuSch()">
		<input type="button" value="価格(G)" class="btn-orange" onClick="ShoppingSch()">
		<input type="button" value="楽天" class="btn-orange" onClick="RakutenSch()">
		<input type="button" value="Amazon" class="btn-orange" onClick="AmazonSch()">
		<input type="button" value="ヤフオク" class="btn-orange" onClick="YahooAuctions()">
		<input type="button" value="YouTube" class="btn-blue" onClick="YoutubeSch()">
		<input type="button" value="Twitter" class="btn-blue" onClick="TwitterSch()">
		<input type="button" value="リアルタイム" class="btn-blue" onClick="YahooRealtimeSch()">
	</div>
</td></tr></table>
