//to display Calendar at top of page
	var today = new Date();
	var thisHours = today.getHours();
	var thisMinutes = today.getMinutes();
	var weekdayNames = ['Ch&#x1EE7; nh&#x1EAD;t', 'Th&#x1EE9; Hai', 'Th&#x1EE9; Ba', 'Th&#x1EE9; T&#x1B0;', 'Th&#x1EE9; N&#x103;m', 'Th&#x1EE9; S&#xE1;u', 'Th&#x1EE9; B&#x1EA3;y'];
	var monthNames = ['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12'];
	var thisDay = today.getDay();
	var thisDate = today.getDate();
	var thisMonth = today.getMonth();
	var thisYear = today.getFullYear();
	if(today.getMinutes() < 10) {thisMinutes = "0" + today.getMinutes()};
	if(today.getHours() < 10) {thisHours = "0" + today.getHours()};
	
	function dateTime() {
		document.write(thisDate + "-" + monthNames[thisMonth] + "-" + thisYear + ", " + thisHours + ":" + thisMinutes);
	}
	
	function dayName() {
		document.write(weekdayNames[thisDay] + ", ");
	}
	
	function CheckEmailAddress(Email)
{
	Email = Trim(Email);

	while (Email != '')
	{
		c = Email.charAt(0);	
		if (c==' ' || c=='<' || c==39 || c==':' || c=='.')
		{
			Email = Email.substr(1);
		}
		else
		{
			break;
		}
	}

	i = Email.indexOf('>');
	if (i==-1)
	{
		while (Email != '')
		{
			c = Email.charAt(Email.length - 1);
			if (c==' ' || c==39 || c=='.')
			{
				Email = Email.substr(0, Email.length - 1);
			}
			else
			{
				break;
			}
		}
	}
	else
	{
		Email = Email.substr(0, i);
	}

	if (Email.length > 96)
		return '';

	i = Email.lastIndexOf('@');
	j = Email.lastIndexOf('.');
	if (i < j)
		i = j;

	switch (Email.length - i - 1)
	{
	case 2:
		break;
	case 3:
		switch (Email.substr(i))
		{
		case '.com':
		case '.net':
		case '.org':
		case '.edu':
		case '.mil':
		case '.gov':
		case '.biz':
		case '.pro':
		case '.int':
			break;
		default:
			return '';
		}
		break;
	default:
		switch (Email.substr(i))
		{
		case '.name':
		case '.info':
			break;
		default:
			return '';
		}
		break;
	}

	Email = Email.toLowerCase();

	if (Email == '')
		return '';

	if (Email.indexOf(' ') != -1)
		return '';

	if (Email.indexOf('..') != -1)
		return '';

	if (Email.indexOf('.@') != -1)
		return '';

	if (Email.indexOf('@.') != -1)
		return '';

	if (Email.indexOf(':') != -1)
		return '';

	for (i=0; i < Email.length; i++)
	{
		c = Email.charAt(i);

		if (c >= '0' && c <= '9')
			continue;
		
		if (c >= 'a' && c <= 'z')
			continue;
		
		if ('`~!#$%^&*-_+=?/\\|@.'.indexOf(c) != -1)
			continue;

		return '';
	}

	if ((i=Email.indexOf('@'))==-1)
		return '';

	if (Email.substr(i + 1).indexOf('@')!=-1)
		return '';

	if (Email.charAt(0)=='.' || Email.charAt(Email.length - 1)=='.')
		return '';

	return Email;
	}
	
	function Trim(iStr)
{
	while (iStr.charCodeAt(0) <= 32)
	{
		iStr=iStr.substr(1);
	}

	while (iStr.charCodeAt(iStr.length - 1) <= 32)
	{
		iStr=iStr.substr(0, iStr.length - 1);
	}

	return iStr;
}

   function pageSet(page)
   {
	   location.replace(SetParameter(location.href, 'pageId', page));
   }
   
   function SetParameter(pFile, pName, pVal)
   {
		if ((cPost=pFile.indexOf('&'.concat(pName).concat('=')))==-1)
			cPost=pFile.indexOf('?'.concat(pName).concat('='));
	
		if (cPost >= 0)
		{
			if ((pPost=pFile.indexOf('&', cPost + 1))==-1)
			{
				pFile=pFile.substring(0, cPost + pName.length + 2).concat(pVal);
			}
			else
			{
				pFile=pFile.substring(0, cPost + pName.length + 2).concat(pVal).concat(pFile.substr(pPost));
			}
		}
		else
		{
			if (pFile.indexOf('?')==-1)
			{
				pFile=pFile.concat('?').concat(pName).concat('=').concat(pVal);
			}
			else
			{
				pFile=pFile.concat('&').concat(pName).concat('=').concat(pVal);
			}
		}
		
		return pFile;		
   }

	function SearchMeEx(s, a)
	{
		while (s.length > 0 && s.charAt(0) <= ' ')
		{
			s = s.substr(1);
		}

		while ((i=s.length) > 0 && s.charAt(i - 1) <= ' ')
		{
			s = s.substr(0, i - 1);
		}

		if (s=='')
		{
			var objTSearch = document.getElementById("searchText");
			if (objTSearch) document.searchForm.searchText.value = s;
			return false;
		}	
	
		s = escape(UnicodeSet(s));
		r = '&query='.concat(s);

	return r;
	}
	   
	function UnicodeSet(iStr)
	{
	for (i=0, oStr=''; i < iStr.length; i++)
	{
		switch ((j=iStr.charCodeAt(i)))
		{
		case 34:
			oStr=oStr.concat('&quot;');
			break;
		case 38:
			oStr=oStr.concat('&amp;');
			break;
		case 39:
			oStr = oStr.concat('&#39;');
			break;
		case 60:
			oStr = oStr.concat('&lt;');
			break;
		case 62:
			oStr = oStr.concat('&gt;');
			break;
		default:
			if (j < 32 || j > 127 || j==34 || j==39)
			{
				oStr=oStr.concat('&#').concat(j).concat(';');
			}
			else
			{
				oStr=oStr.concat(iStr.charAt(i)); 
			}
			break;
		}
	}
	
	return oStr;
}

function writeTime(s, full)
{
	var mydate=new Date(s)
	
	var year = mydate.getYear()
	if (year < 1000)
		year += 1900
	var month = mydate.getMonth() + 1
	if (month < 10)
		month = "0" + month
	var day = mydate.getDate()
	if (day < 10)
		day = "0" + day

	var dayw = mydate.getDay()
	
	var hour = mydate.getHours()
	if (hour < 10)
		hour = "0" + hour
	
	var minute=mydate.getMinutes()
	if (minute < 10)
		minute = "0" + minute
	var dayarray=new Array("Ch&#7911; Nh&#7853;t","Th&#7913; Hai","Th&#7913; Ba","Th&#7913; T&#432;","Th&#7913; N&#259;m","Th&#7913; S&#225;u","Th&#7913; B&#7843;y")
	if (full == "t")
		document.write(dayarray[dayw]+", "+day+"/"+month+"/"+year+",&nbsp;"+hour+":"+minute+" (GMT+7)")
	else 
		document.write(day+"/"+month+"/"+year+",&nbsp;"+hour+":"+minute)	
}

function ReverseFolderByDate(fHms)
{
	Ryear = document.Reverse.fYear.options[document.Reverse.fYear.selectedIndex].value;
	Rmonth = document.Reverse.fMonth.options[document.Reverse.fMonth.selectedIndex].value;
	Rday = document.Reverse.fDay.options[document.Reverse.fDay.selectedIndex].value;

	for (; Rday > 0; Rday--)
	{
		Rdate = new Date(Ryear, Rmonth - 1, Rday);
		if (Rdate.getDate() == Rday)
		{
			break;
		}
	}

	LastDate = Ryear.concat('-').concat(Rmonth).concat('-').concat(Rday).concat(fHms);
	location.href = SetParameter(location.href, 'd', escape(LastDate));	
}

function SetParameter(pFile, pName, pVal)
{
	if ((cPost=pFile.indexOf('&'.concat(pName).concat('=')))==-1)
		cPost=pFile.indexOf('?'.concat(pName).concat('='));

	if (cPost >= 0)
	{
		if ((pPost=pFile.indexOf('&', cPost + 1))==-1)
		{
			pFile=pFile.substring(0, cPost + pName.length + 2).concat(pVal);
		}
		else
		{
			pFile=pFile.substring(0, cPost + pName.length + 2).concat(pVal).concat(pFile.substr(pPost));
		}
	}
	else
	{
		if (pFile.indexOf('?')==-1)
		{
			pFile=pFile.concat('?').concat(pName).concat('=').concat(pVal);
		}
		else
		{
			pFile=pFile.concat('&').concat(pName).concat('=').concat(pVal);
		}
	}

	return pFile;
}

function Trim(s)
{
    var i = 0;
    while ((i < s.length) && (s.charCodeAt(i) == 32))
	    i++;

    var j = s.length - 1;
    while ((j > i) && (s.charCodeAt(j) == 32))
	    j--;

    return s.substr(i, j - i + 1);
	}
	
function emailArticle(sId)
{
	openMeExt('/emailSubject.jhtml?id='.concat(sId), '_blank', 0, 0, 0, 0, 0, 0, 1, 1, 375, 480, 0, 0, '', 0);
	return false;
}

function openMeExt(vLink, vStatus, vResizeable, vScrollbars, vToolbar, vLocation, vFullscreen, vTitlebar, vCentered, vHeight, vWidth, vTop, vLeft, vID, vCounter)
{
	var sLink = (typeof(vLink.href) == 'undefined') ? vLink : vLink.href;

	winDef = '';
	winDef = winDef.concat('status=').concat((vStatus) ? 'yes' : 'no').concat(',');
	winDef = winDef.concat('resizable=').concat((vResizeable) ? 'yes' : 'no').concat(',');
	winDef = winDef.concat('scrollbars=').concat((vScrollbars) ? 'yes' : 'no').concat(',');
	winDef = winDef.concat('toolbar=').concat((vToolbar) ? 'yes' : 'no').concat(',');
	winDef = winDef.concat('location=').concat((vLocation) ? 'yes' : 'no').concat(',');
	winDef = winDef.concat('fullscreen=').concat((vFullscreen) ? 'yes' : 'no').concat(',');
	winDef = winDef.concat('titlebar=').concat((vTitlebar) ? 'yes' : 'no').concat(',');
	winDef = winDef.concat('height=').concat(255).concat(',');
	winDef = winDef.concat('width=').concat(500).concat(',');

	if (vCentered){
		winDef = winDef.concat('top=').concat((screen.height - vHeight)/2).concat(',');
		winDef = winDef.concat('left=').concat((screen.width - vWidth)/2);
	}
	else{
		winDef = winDef.concat('top=').concat(vTop).concat(',');
		winDef = winDef.concat('left=').concat(vLeft);
	}

	if (typeof(vCounter) == 'undefined'){
		vCounter = 0;
	}

	if (typeof(vID) == 'undefined')	{
		vID = 0;
	}
	
	if (vCounter){
		sLink = buildLink(vID,sLink);
	}

	open(sLink, '_blank', winDef);

	if (typeof(vLink.href) != 'undefined')	{
		return false;
	}
}	

function printArticle(sId)
{	
	w=open('/printItem.jhtml?itemId='.concat(sId).concat('&a=p'), '_blank', '');
	return false;	
}

	function writeImageType(type)
	{
		if (type == 0)
			return;
		else if (type == 1){
			return document.write('<img border="0" src="images/icon/audio.gif" alt=""/>');	
		}
		else if (type == 2) {
			return document.write('<img border="0" src="images/icon/video.gif" alt=""/>');
		}
		else if (type == 3) {
			return document.write('<img border="0" src="images/icon/download.gif" alt=""/>');
		}
		else if (type == 4) {
			return document.write('<img border="0" src="images/icon/ppt.gif" alt=""/>');
		}
		else if (type == 5) {
			return document.write('<img border="0" src="images/icon/photo.gif" alt=""/>');
		}
		
	}
