function isSpace(str) {
	var i;

	for(i = 0; i < str.length; i++) {
		if (str.charAt(i) != ' ' && str.charAt(i) != '　') return false;
	}
	return true;
}

function isNumber(str) {
	if (str.match(/^[0-9\.]+$/)) return true;
	return false;
}

function isTelNum(str) {
	if (str.match(/^[0-9-]+$/)) return true;
	return false;
}

function isURL(str) {
	var tmp, ary;

	if (str.toLowerCase().substr(0, 7) == 'http://') {
		tmp = str.substr(7);
	} else if (str.toLowerCase().substr(0, 8) == 'https://') {
		tmp = str.substr(8);
	} else {
		tmp = str;
	}
	ary = tmp.split('/');
	tmp = ary[0];
	if (tmp.match(/^[\w\.-]+\.\w{2,}$/)) return true;
	return false;
}

function isEmail(str) {
	if (str.match(/^[\w_\.-]+@[\w\.-]+\.\w{2,}$/)) return true;
	return false; 
}

function isPWD(str) {
	if (str.length < 4 || str.length > 20) return false;
	if (str.match(/^[\w]+$/)) return true;
	return false;
}

function timeoutCheck() {
}

function httpRequest(target_url, functionReference) {
	var useragent = navigator.userAgent.toLowerCase();

	try {
		if (window.XMLHttpRequest) {
			httpObj = new XMLHttpRequest();
		} else if (window.ActiveXObject) {
			httpObj = new ActiveXObject("Microsoft.XMLHTTP");
		} else {
			httpObj = false;
		}
	} catch (e) {
		httpObj = false;
		
	}
	if (!httpObj) {
		httpObjGenerateFail();
	}
	
	timerId = setInterval('timeoutCheck()', 1000);

	httpObj.open("GET", target_url, true);
	if (useragent.indexOf("firefox") != -1 || useragent.indexOf("opera") != -1 || useragent.indexOf("safari") != -1) {
		httpObj.onload = function() {
			functionReference(httpObj.responseText);
		}
	} else {
		httpObj.onreadystatechange = function() {
			if (httpObj.readyState == 4) {
				clearInterval(timerId);
				if (httpObj.status == 200) {
					functionReference(httpObj.responseText);
				} else {
					return false;
				}
			}
		}
	}
	
	httpObj.send('');
}

function httpRequestSync(target_url) {
	var response = '';
	var useragent = navigator.userAgent.toLowerCase();

	try {
		if (window.XMLHttpRequest) {
			httpObj = new XMLHttpRequest();
		} else if (window.ActiveXObject) {
			httpObj = new ActiveXObject("Microsoft.XMLHTTP");
		} else {
			httpObj = false;
		}
	} catch (e) {
		httpObj = false;
	}
	if (!httpObj) {
		httpObjGenerateFail();
	}

	httpObj.open("GET", target_url, false);
	if (useragent.indexOf("firefox") != -1 || useragent.indexOf("opera") != -1 || useragent.indexOf("safari") != -1) {
		httpObj.onload = function() {
			response = httpObj.responseText;
		}
	} else {
		httpObj.onreadystatechange = function() {
			if (httpObj.readyState == 4) {
				if (httpObj.status == 200) {
					response = httpObj.responseText;
				}
			}
		}
	}

	httpObj.send('');
	
	return response;
}

function MM_preloadImages() { //v3.0
	var d = document;
	
	if (d.images) {
		if (!d.MM_p) d.MM_p=new Array();
		var i, j = d.MM_p.length, a = MM_preloadImages.arguments;
		for (i = 0; i < a.length; i++) {
			if (a[i].indexOf("#") != 0) {
				d.MM_p[j] = new Image;
				d.MM_p[j++].src = a[i];
			}
		}
	}
}

function fncSearch() {
	if (isSpace(document.searchform.keyword.value)) {
		alert('キーワードを指定してください。');
		document.searchform.keyword.focus();
	} else {
		return true;
	}

	return false;
}

function fncArea(n) {
	if (document.searchform.area[n].checked) {
		document.searchform.area[n].checked = false;
	} else {
		document.searchform.area[n].checked = true;
	}
}
