/* function GotoPage_post(iPage) {
	document.search_text.curPg.value = iPage;
	document.search_text.submit();
	}
*/
function UnicodeCodePoint(iStr)
{
	var next = '', tam = 0, j ='';
	for (i=0, oStr=''; i < iStr.length; i++)
	{
		j=iStr.charCodeAt(i);
		
		if (j > 127)
		{
			if (0xD800 <= j && j <= 0xDFFF) {				
				next = iStr.charCodeAt(i+1);
				if (0xDC00 <= next && next <= 0xDFFF) {
					tam = 65536 + (j -55296)*1024 + (iStr.charCodeAt(i+1) - 56320);					
					oStr=oStr.concat('&#').concat(tam).concat(';');
					i++;
				}
			}else{
				oStr=oStr.concat('&#').concat(j).concat(';');
			}
		}else{
			if (j == 10) {
			} else if (j == 13) {
				oStr=oStr.concat('<br>');
			} else {
				oStr=oStr.concat(iStr.charAt(i)); 
			}
		}
	}
	return oStr;
}
function trim(strText) { 
    // this will get rid of leading spaces 
    while (strText.substring(0,1) == ' ') 
        strText = strText.substring(1, strText.length);
    // this will get rid of trailing spaces 
    while (strText.substring(strText.length-1,strText.length) == ' ')
        strText = strText.substring(0, strText.length-1);
   return strText;
}
function enregistrer(x)
{
  if (trim(document.fInput.inputText.value) != '')  {
  	s = UnicodeCodePoint(document.fInput.inputText.value);
  	document.fInput.hiddenText.value = s;
	document.fInput.action = "index.php" + location.search;
  	document.fInput.submit();
  }
}
function venregistrer(x)
{
  if (trim(document.fInput.inputText.value) != '')  {
  	s = UnicodeCodePoint(document.fInput.inputText.value);
  	document.fInput.hiddenText.value = s;
	document.fInput.action = "vindex.php" + location.search;
  	document.fInput.submit();
  }
}

function GotoPage_post(iPage) {
		
	document.search_en.curPg.value = iPage;
	document.search_en.submit();
	}
function GotoPage_view(iPage) {
		
	document.view.curPg.value = iPage;
	document.view.submit();
	}

function GotoPage(iPage) {
	document.show.curPg.value = iPage;
	document.show.submit();
	}
function Goto(iPage) {
	document.show.curPg.value = iPage;
	document.show.submit();
	}

function Check_Input() {
	if (document.input.title_qn.value=="")
	{
		alert("Bạn hãy nhập nhan đề");
		document.input.title_qn.focus();
		return false;
	}
	if (document.input.title_hn.value=="")
	{
		alert("Bạn hãy nhập nhan đề");
		document.input.title_hn.focus();
		return false;
	}
	if (document.input.nlv.value=="")
	{
		alert("Bạn hãy nhập mã số");
		document.input.nlv.focus();
		return false;
	}
	if (document.input.vnpf.value=="")
	{
		alert("Bạn hãy nhập mã số");
		document.input.vnpf.focus();
		return false;
	}
	if (document.input.width_.value=="")
	{
		alert("Bạn hãy nhập chiều rộng");
		document.input.width_.focus();
		return false;
	}
	if (document.input.height_.value=="")
	{
		alert("Bạn hãy nhập chiều cao");
		document.input.height_.focus();
		return false;
	}
	if (document.input.sheet.value=="")
	{
		alert("Bạn hãy nhập số tờ");
		document.input.sheet.focus();
		return false;
	}
	if (document.input.date_now.value=="")
	{
		alert("Bạn hãy nhập ngày");
		document.input.date_now.focus();
		return false;
	}
	return true;
	}

function Check_update() {
	if (document.update.title_qn.value=="")
	{
		alert("Bạn hãy nhập nhan đề");
		document.update.title_qn.focus();
		return false;
	}
	if (document.update.title_hn.value=="")
	{
		alert("Bạn hãy nhập nhan đề");
		document.update.title_hn.focus();
		return false;
	}
	if (document.update.nlv.value=="")
	{
		alert("Bạn hãy nhập mã số");
		document.update.nlv.focus();
		return false;
	}
	if (document.update.vnpf.value=="")
	{
		alert("Bạn hãy nhập mã số");
		document.update.vnpf.focus();
		return false;
	}
	if (document.update.width_.value=="")
	{
		alert("Bạn hãy nhập chiều rộng");
		document.update.width_.focus();
		return false;
	}
	if (document.update.height_.value=="")
	{
		alert("Bạn hãy nhập chiều cao");
		document.update.height_.focus();
		return false;
	}
	if (document.update.sheet.value=="")
	{
		alert("Bạn hãy nhập số tờ");
		document.update.sheet.focus();
		return false;
	}
	if (document.update.date_now.value=="")
	{
		alert("Bạn hãy nhập ngày");
		document.update.date_now.focus();
		return false;
	}
	return true;
	}

function checkinput_post() {
	if (document.re_post.txtname.value == "") {
		alert("Invalid. Please enter your name.");
		//document.upload.fulname.focus();
		return false;
	}
	if (document.re_post.txtmail.value == "") {
		alert("Invalid. Please enter your email.");
		//document.upload.fulname.focus();
		return false;
	}
	if (document.re_post.txtcheck.checked == false) {
		alert("You should agree to terms.");
		//document.upload.fulname.focus();
		return false;
	}
//	if (document.quote_post.check_ask.value == 1) {
//		alert("Invalid. Please enter your email.");
		//document.upload.mail.focus();
//		return window.open("faqs.php");
//	}
		
	return true;
	}
