/* ConfirmLink */

function linkConfirm(string) {
	if (confirm(string + "を本当に削除しますか？")) {
		return true;
	} else {
		return false;
	}
}

/* Ajax */
function getPage() {
	xmlhttp = createXMLHttp();
	
	if (xmlhttp) {
		var keyword = document.getElementById("keyword");
		var range1 = document.getElementById("range1");
		var range2 = document.getElementById("range2");
		
		if (range1 == null) {
			alert("no range");
		}
		xmlhttp.onreadystatechange = setPageData;
		xmlhttp.open('GET', "bbs.cgi?mode=ajax_search");
		xmlhttp.send(null);
	} else {
	
		alert("XMLHttpRequest失敗");
	
	}
}

function setPageData() {
	if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
		document.getElementById("search_result").innerHTML = xmlhttp.responseText;
	
	}
}

// XMLHttpsオブジェクト作成

function createXMLHttp() {
	try {
		return new ActiveXObject ("Microsoft.XMLHTTP");
		} catch(e) {
			try {
				return new XMLHttpRequest();
			}catch(e) {
				return null;
			}
		}
	return null;
}

var xmlhttp=false;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
// JScript gives us Conditional compilation, we can cope with old IE versions.
// and security blocked creation of the objects.
 try {
  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
 } catch (e) {
  try {
   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  } catch (E) {
   xmlhttp = false;
  }
 }
@else
 xmlhttp=false
@end @*/
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
 try {
  xmlhttp = new XMLHttpRequest();
 } catch (e) {
  xmlhttp=false
 }
}

var oldkey = "";
function load() {
  key = encodeURI(document.imeform.query.value);
  if (oldkey != key) {
    oldkey = key;
    var element = document.getElementById("imeresult");    
    if (!xmlhttp) return;
    if (xmlhttp.readyState == 1 || 
      xmlhttp.readyState == 2 || xmlhttp.readyState == 3){ 
      return; 
    }
    xmlhttp.open("GET", "bbs.cgi?function=ajax_search&amp;keyword="+key+"&amp;range1=0&amp;range2=content", true);
    xmlhttp.onreadystatechange=function() {
       if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
         element.innerHTML = xmlhttp.responseText;
       }
     }
     xmlhttp.send(null)
  }
  
  setTimeout("load()", 800);
}