﻿function movePage(page){
	if(!isNaN(page)){
		document.frmMovePage.Page.value = page;
		document.frmMovePage.submit();
	}
}
function isEmail(str) {
   // EMAIL address validity checker
  // are regular expressions supported?
  var supported = 0;
  if (window.RegExp) {
    var tempStr = "a";
    var tempReg = new RegExp(tempStr);
    if (tempReg.test(tempStr)) supported = 1;
  }
  if (!supported) 
    return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
  var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
  var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
  return (!r1.test(str) && r2.test(str));
}
function isValid(frmId, msg, flag)
{
	if (document.frm[frmId].value == '')
	{
		alert(msg);
		document.frm[frmId].focus();
		return false;
	}
		return true;
}

function modalDialog(URL,title,width,height){
	var top=(screen.height - height)/2;
	var left=(screen.width - width)/2;
	
	window.showModalDialog(URL, title, "dialogHeight: " + height + "px; dialogWidth: " + width + "px; dialogTop: " + top + "px; dialogLeft: " + left + "px; edge: Raised; center: Yes; help: No; resizable: No; status: No; scrollbar: No");
//	window.open(URL,"","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, copyhistory=no, width=" + width + ", height=" + height)
//	if(strAlert != null && strAlert != ""){
//		alert(strAlert);
//	}
}
function checkSearchDate(frm){
	var day = frm.SDay.value;
	var month = frm.SMonth.value;
	var year = frm.SYear.value;
	
	if(day == ""&&month == ""&&year == ""){
		alert("Bạn phải nhập ngày hoặc tháng hoặc năm");
		return false;
	}
	return true;
}
function openwindow(url,width,height)
{
	var top=(screen.height - height)/2;
	var left=(screen.width - width)/2;
	
	window.open(url,"","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no,left=" + left + ", top=" + top + ", width=" + width + ", height=" + height)
}
function openwindow1(url,width,height)
{
	var top=(screen.height - height)/2;
	var left=(screen.width - width)/2;
	
	window.open(url,"","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no,left=" + left + ", top=" + top + ", width=" + width + ", height=" + height)
}

function modalDialog(URL,objWindow,width,height){
	var top=(screen.height - height)/2;
	var left=(screen.width - width)/2;
	
	return window.showModalDialog(URL, window, "dialogHeight: " + height + "px; dialogWidth: " + width + "px; dialogTop: " + top + "px; dialogLeft: " + left + "px; edge: Raised; center: Yes; help: No; resizable: No; status: No; scroll: yes");
}

function wrDot(number){
	var strTemp = '';
	var intCount = 0;
	number = String(number);
	for(var i=number.length;i>=0;i--){
		strTemp = number.charAt(i) + strTemp;
		if(intCount==3 && i!=0){
			strTemp = " " + strTemp;
			intCount = 0;
		}
		intCount = intCount + 1;
	}
	
	return strTemp;
}

function wrhundred(number){
	var strTemp = '';
	var arr = new Array("","Một","Hai","Ba","Bốn","Năm","Sáu","Bảy","Tám","Chín","Mười");
	var tram='';
	var chuc='';
	var donvi='';
	
	if(!isNaN(number)){
		tram = number / 100;
	}
	return strTemp;
}