//
// Escape Codec Library: ecl.js (Ver.041208)
//
// Copyright (C) http://nurucom-archives.hp.infoseek.co.jp/digital/
//

EscapeUTF8=function(str){
	return str.replace(/[^*+.-9A-Z_a-z-]/g,function(s){
		var c=s.charCodeAt(0);
		return (c<16?"%0"+c.toString(16):c<128?"%"+c.toString(16):c<2048?"%"+(c>>6|192).toString(16)+"%"+(c&63|128).toString(16):"%"+(c>>12|224).toString(16)+"%"+(c>>6&63|128).toString(16)+"%"+(c&63|128).toString(16)).toUpperCase()
	})
};

function common_search(){
	var uri = 'http://'+location.host+'/searches/' + document.getElementById('common_search_target').value + '/all/' + EscapeUTF8(document.getElementById('common_search_query').value);
	top.location.href=uri;
}

function common_search_cat(){
	var uri_cat = 'http://'+location.host+'/searches/' + document.getElementById('common_search_site').value + '/' + document.getElementById('common_search_category').value + '/' + EscapeUTF8(document.getElementById('common_search_cat_query').value) + '/' + document.getElementById('common_search_cat_target').value;
	document.location.href=uri_cat;
}

function common_keycheck(evt) {
	if (evt.keyCode == 13){
		common_search();
	}
}

function common_keycheck_cat(evt) {
	if (evt.keyCode == 13){
		common_search_cat();
	}
}

function clear_searchQuery(){
	var searchBoxDefaultText="サイト内検索";
	if( document.getElementById("common_search_query").value == searchBoxDefaultText )
	{
		document.getElementById("common_search_query").value = "";
	}
}

function clear_searchCatQuery(){
	var searchBoxDefaultText="カテゴリー内フリーワード検索";
	if( document.getElementById("common_search_cat_query").value == searchBoxDefaultText )
	{
		document.getElementById("common_search_cat_query").value = "";
	}
}
