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 getNew(FID) {
	target_url = '/getnew.php?FID=' + FID;
	httpRequest(target_url, setNew);
}

function setNew(text_data) {
	if (text_data.length > 0) document.getElementById('new').innerHTML = text_data;
}

function timeoutCheck() {
}

function httpRequest(target_url, functionReference) {
	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);
	httpObj.onreadystatechange = function() {
		if (httpObj.readyState == 4) {
			clearInterval(timerId);
			if (httpObj.status == 200) {
				functionReference(httpObj.responseText);
			} else {
				return false;
			}
		}
	}
	
	httpObj.send('');
}

var timeID = setTimeout("", 1)

function fncNext() {
	getNew(document.getElementById('newfid').value);
	clearTimeout(timeID);
	timeID = setTimeout("fncNext()", 10000);
}
