document.write('<form id="searchbox" action="search/" onsubmit="return searchboxSubmit();"><input type="search" name="q" id="q" autocomplete="off" value="サイト内検索" onfocus="searchbox_init();" style="color:#999999;font-size: 12px;padding: 0px;display: block;margin: 0px auto;" /></form>');
var timer_handle = null;

function searchbox_init(){
	var d = window.document;
	if(d.getElementById('q').value == d.getElementById('q').defaultValue){
		d.getElementById('q').value = "";
		d.getElementById('q').style.color = "#000000";
	}
}
function searchbox_close(){
	var d = window.document;
	//d.getElementById('search_result').style.display = 'none';
	//d.getElementById('searchbox_background').style.display = 'none';
}
function incremental(){
	var d = window.document;
	if(d.getElementById('q').value != ""){
		clearTimeout(timer_handle);
		timer_handle = setTimeout("searchboxSubmit()",2000);
	}
}
function searchboxSubmit(){
	//clearTimeout(timer_handle);
	var d = window.document;
	//d.getElementById('search_result').style.display = 'block';
	//d.getElementById('searchbox_background').style.display = 'block';
	searchboxObj = createXMLHttpRequest();
	searchboxObj.onreadystatechange = getSearchbox;
	searchboxObj.open("GET",d.getElementById('searchbox').action+"?"+encodeURI(d.getElementById('q').value),true);
	searchboxObj.send(null);
	return false;
}
function getSearchbox(){
	var d = window.document;
	if ((searchboxObj.readyState == 4) && (searchboxObj.status == 200)){
		d.getElementById("search_result").innerHTML = searchboxObj.responseText;
		//clearTimeout(timer_handle);
	}
	else
		d.getElementById("search_result").innerHTML = "検索中...";
}
function createXMLHttp() {
	try {
		return new ActiveXObject ("Microsoft.XMLHTTP");
	}catch(e){
		try {
			return new XMLHttpRequest();
		}catch(e) {
			return null;
		}
	}
	return null;
}
function createXMLHttpRequest(){
	var XMLsearchboxObject = null;
	try{
		XMLsearchboxObject = new XMLHttpRequest();
	}
	catch(e){
		try{
			XMLsearchboxObject = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e){
			try{
				XMLsearchboxObject = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch(e){
				return null;
			}
		}
	}
	return XMLsearchboxObject;
}

