﻿var fBrw=(navigator.userAgent.indexOf('MSIE')!= -1 && navigator.userAgent.indexOf('Windows')!= -1);
var fDSp=(typeof(document.getElementById)!='undefined');
var RefBanner = new Array();
var RefAdLogo = new Array();
var RefAdLBox = new Array();
var RefAdLBar = new Array();
var RefAdStay = 0;
var SkpFolder = true;
var CurBanner = 0;
var LastChild = 0;
var BannerLnk = 0;

if (typeof(PageHost) == 'undefined')
{
	var PageHost = '';
}

/*
if (typeof(MasterWindow)!='undefined')
{
	if (window.parent!=window && window.parent!=MasterWindow)
	{
		window.open(location.href, '_top', '');
	}
}
else
{
	if (window.parent!=window)
	{
		window.open(location.href, '_top', '');
	}
}

if (fBrw)
{
	document.onselectstart = new Function ('return false');
}
else
{
	document.captureEvents(Event.MOUSEUP | Event.MOUSEDOWN);
	IsOnSP_Skip = (navigator.userAgent.indexOf('Netscape6') != -1) ? IsOnSP_Skip6 : IsOnSP_Skip4;
	document.onmousedown = IsOnSP_Skip;
	document.onmouseup = IsOnSP_Skip;
}
*/



function IsOnSP_Skip6(e)
{
	return (e.which != 1) ? true : false;
}

function IsOnSP_Skip4(e)
{
	return (e.which != 1) ? true : ((e.target != '') ? true : false);
}

function setCookie(Name, Path, Expires, Value)
{
	var cstr = Name.concat('=').concat(Value);
	
	if (Path=='')
		path='/';

	cstr=cstr.concat(';path=').concat(Path);


	if (Expires=='')
		Expires=(new Date(2020, 11, 14)).toGMTString();

	document.cookie=cstr.concat(';expires=').concat(Expires);
}

function getCookie(Name, Default)
{
	var cookie = document.cookie;
	var ir = 0, ie = 0, sf = '';
	Name = Name.toLowerCase();

	if (typeof(Default) == 'undefined')
		Default = '';

	if (cookie.length == 0)
		return Default;

	if ((ir = Name.indexOf('.')) == -1)
	{
		if (cookie.substr(0, Name.length + 1).toLowerCase() == Name.concat('='))
		{
			if ((ie = cookie.indexOf(';')) != -1)
			{
				cookie = cookie.substr(0, ie);
			}
		}
		else
		{
			if ((ie = cookie.toLowerCase().indexOf('; '.concat(Name).concat('='))) == -1)
				return Default;

			cookie = cookie.substr(ie + 2);

			if ((ie = cookie.indexOf(';')) != -1)
			{
				cookie = cookie.substr(0, ie);
			}
		}
		sf = ';';
	}
	else
	{
		var Root = Name.substr(0, ir);
		Name = Name.substr(ir + 1);

		if (cookie.substr(0, Root.length + 1).toLowerCase() == Root.concat('='))
		{
			if ((ie = cookie.indexOf(';')) != -1)
			{
				cookie = cookie.substr(0, ie);
			}
		}
		else
		{
			if ((ie = cookie.toLowerCase().indexOf('; '.concat(Root).concat('='))) == -1)
				return Default;

			cookie = cookie.substr(ie + 2);

			if ((ie = cookie.indexOf(';')) != -1)
			{
				cookie = cookie.substr(0, ie);
			}
		}

		cookie = cookie.substr(Root.length + 1);
		sf = '&';
	}

	if (cookie.substr(0, Name.length + 1).toLowerCase() == Name.concat('='))
	{
		ir = Name.length + 1;
	}
	else
	{
		if ((ir = cookie.toLowerCase().indexOf('&'.concat(Name).concat('='))) == -1)
			return Default;

		ir+=Name.length + 2;
	}

	if ((ie=cookie.indexOf(sf, ir)) == -1)
	{
		return ReplaceAll(unescape(cookie.substr(ir)), '+', ' ');
	}
	else
	{
		return ReplaceAll(unescape(cookie.substring(ir, ie)), '+', ' ');
	}
}

function ReplaceChar(iStr)
{
	var	r1=/&/g;
	var	r2=/ /g;
	var	r3=/"/g;

	iStr	=iStr.replace(r1, '%26');
	iStr	=iStr.replace(r2, '%20');
	iStr	=iStr.replace(r3, '%22');

	return iStr;
}

function CharReplace(iStr)
{
	var	r1=/%26/g;
	var	r2=/%20/g;
	var	r3=/%22/g;

	iStr	=iStr.replace(r1, '&');
	iStr	=iStr.replace(r2, ' ');
	iStr	=iStr.replace(r3, '"');

	return iStr;
}

function GetPostVariable(vName, vDef)
{
	var	str=location.href;
	var	pos=str.indexOf('?'.concat(vName).concat('='));

	if (pos==-1)
	{
		pos=str.indexOf('&'.concat(vName).concat('='));
		if (pos==-1) return vDef;
	}
	
	str=str.substring(pos + vName.length + 2);
	pos=str.indexOf('&');

	if (pos==-1)
	{
		pos=str.length;
	}	

	if (pos > 0)
	{
		str=str.substring(0, pos);
	}

	return (typeof(vDef)=='number') ? parseInt(str) : CharReplace(str);
}

function GoNothing()
{
}

function ChangeBanner()
{
	if (RefBanner.length==0)
		return;

	CurBanner++;
	if (CurBanner >= RefBanner.length)
	{
		CurBanner=0;
	}

	document.links[BannerLnk].href= RefBanner[CurBanner][1];
	document.images['TopBanner'].src = PageHost.concat(RefBanner[CurBanner][0]);
	if (RefBanner[CurBanner][1] == '')
	{
		document.links[BannerLnk].onclick = function() { return false; };
	}
	else
	{
		document.links[BannerLnk].onclick = function() { return eval('openMeExt(this, '.concat(RefBanner[CurBanner][2]).concat(', 1)')); };
	}
}

function DisplayBanner(rbn)
{
	if (RefBanner.length==0)
	{
		document.write('<table cellspacing=0 cellpadding=1 border=0 width=468 height=60 bgcolor="#c0c0c0"><tr><td><table cellspacing=0 cellpadding=0 border=0 width="466" height="58"><tr><td bgcolor="#ffffff" align=center><a href="http://vnexpress.net/Advertising" class=AdTop>D&#224;nh cho Qu&#7843;ng c&#225;o</a></td></tr></table></td></tr></table>');
		return;
	}

	CurBanner=Math.floor(Math.random()*12321) % RefBanner.length;
	BannerLnk=document.links.length;
	if (RefBanner[CurBanner][1]=='')
	{
		document.write('<a href="', RefBanner[CurBanner][1], '" onClick="return false"><img name="TopBanner" src="', PageHost.concat(RefBanner[CurBanner][0]), '" width=468 height=60 border=0></a>');
	}
	else
	{
		document.write('<a href="', RefBanner[CurBanner][1], '" onClick="return openMeExt(this, ', RefBanner[CurBanner][2], ', 1)"><img name="TopBanner" src="', PageHost.concat(RefBanner[CurBanner][0]), '" width=468 height=60 border=0></a>');
	}

	if (typeof(rbn) == 'undefined')
	{
		rbn = 1;
	}

	if (rbn)
	{
		setInterval('ChangeBanner()', 15000);
	}
}

function AddBreakSpace(Pixel)
{
	if (typeof(Pixel)=='undefined')
	{
		Pixel=3;
	}
	document.writeln('<table cellspacing=0 cellpadding=0 border=0 width="100%" bgcolor="#FFFFFF"><tr><td height=', Pixel, '><img src="/Images/White.gif" border=0 height=1 width=1></td></tr></table>');
}

function DisplayCopyright(showType)
{
	if (typeof(showType)=='undefined')
	{
		showType=1;
	}

	document.writeln('<table cellspacing=0 cellpadding=0 border=0>');
	if (showType)
	{
		document.writeln('<tr><td width=1 class=Symbol><b>&#169;&nbsp;</b></td><td class=Copyright nowrap><b><font color=#000000>Copyright 1997-2002 VnExpress.net</font></b>, All rights reserved. <a href="', PageHost, '/ContactUs/?d=webmaster@VnExpress.net">Contact us</a><td></tr>');
		document.writeln('<tr><td height=1 colspan=2 class=BreakLine>&nbsp;</td></tr>');
		document.writeln('<tr><td width=1 class=Symbol><b>&#174;&nbsp;</b></td><td class=Copyright nowrap>Y&#234;u c&#7847;u m&#7885;i t&#7893; ch&#7913;c khi s&#7917; d&#7909;ng th&#244;ng tin c&#7911;a VnExpress.net ph&#7843;i ghi r&#245; ngu&#7891;n tin.</td></tr>');
	}
	else
	{
		document.writeln('<tr><td width=1 class=Symbol><b>&#169;</b></td><td class=Copyright nowrap><b><font color=#000000>Copyright 1997-2002 VnExpress.net</font></b>, All rights reserved.<td></tr>');
	}
	document.writeln('</table>');
}

function AddHeader(Name, Header, Buttons, Symbol, AddChildTable)
{
	document.writeln('<table width="100%" border=0 cellspacing=0 cellpadding=1 bgcolor="#6868A6"><tr><td>');

	if (Header!='')
	{
		document.writeln('<table width="100%" border=0 cellspacing=0 cellpadding=0>');
		document.writeln('<tr>');

		if (typeof(Symbol)!='undefined')
		{
			document.writeln('<td height=16 class=BoxHeader><img src="', Symbol, '" border=0></td>');
		}

		document.writeln('<td height=16 width="100%" align=left class=BoxHeader>&nbsp;', Header, '</td>');

		if ((Buttons & 1) && fDSp)
		{
			document.write('<td width=15 align=right>');
			document.write('<a href="JavaScript:ItemMinimize(\x27', Name, '\x27)">');
			document.write('<img src="/Images/min.gif" name="IDI_', Name, '" border=0 alt="Minimize | Maximize">');
			document.write('</a></td>');
		}

		document.writeln('</tr></table>');
	}

	document.writeln('<div class=BreakLine id="IDM_', Name, '">');
	if (typeof(AddChildTable)=='undefined')
	{
		document.writeln('<table align=center width="100%" cellspacing=0 cellpadding=0 border=1>');
		LastChild = 1;
	}
	else
	{
		LastChild = 0;
	}
	return true;
}

function AddFooter()
{
	if (LastChild)
	{
		document.writeln('</table></div></td></tr></table>');
	}
	else
	{
		document.writeln('</div></td></tr></table>');
	}
}

function ItemMinimize(Name)
{
	if (!fDSp)
	{
		return;
	}

	var MItem=document.getElementById('IDM_'.concat(Name));
	var Image=document.getElementById('IDI_'.concat(Name));
	
	if (MItem.innerHTML=='')
	{
		MItem.innerHTML = MItem.abbr;
		MItem.abbr = '';
		Image.src='/Images/min.gif';
	}
	else
	{
		MItem.abbr = MItem.innerHTML;
		MItem.innerHTML = '';
		Image.src='/Images/max.gif';
	}
}

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 ReverseFolderByDate()
{
	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(' 23:59:59');
	location.replace(CurrentFolder.concat('/?d=').concat(escape(LastDate)));
}

function ShowNextFolderItem(LastDate)
{
	location.href = SetParameter(location.href, 'd', escape(LastDate));
}

function UnderConst()
{
	alert('Sorry!\nThis Page is under construction!\nPlease try latter!');
}

function openMe(url, inNew, winDef)
{
	if (url == '')
		return;

	if (typeof(inNew)=='undefined')
		inNew = 0;

	if (typeof(winDef)=='undefined')
		winDef = 'scrollbars=yes,status=yes,toolbar=yes,location=yes,menubar=yes,resizable=yes,height=300,width=400,top='.concat((screen.height - 400)/2).concat(',left=0');

	if (inNew)
	{
		open(url, 'Advertising', winDef);
	}
	else
	{
		location.href = url;
	}
}

function openMeExt(vLink, vStatus, vResizeable, vScrollbars, vToolbar, vLocation, vFullscreen, vTitlebar, vCentered, vHeight, vWidth, vTop, vLeft, vName, 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(vHeight).concat(',');
	winDef = winDef.concat('width=').concat(vWidth).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(vName) == 'undefined')
	{
		vName = 'Unknow';
	}
	
	if (vCounter)
	{
		sLink = 'http://srv.vnexpress.net/Counter/?n='.concat(vName).concat('&u=').concat(sLink);
	}

	open(sLink, '_blank', winDef);

	if (typeof(vLink.href) != 'undefined')
	{
		return false;
	}
}
function SetFont()
{
	if (fBrw)
	{
		rs=window.showModalDialog('/SetFont.htm', '', 'dialogHeight:215px;dialogWidth:385px;status:no;help:no');
		if (typeof(rs)!='undefined')
		{
			if (rs)
			{
				location.reload(true);
			}
		}
	}
	else
	{
		open('/SetFont.htm', 'SetFont', 'toolbar=no,height=185,width=370,top='.concat((screen.height - 185)/2).concat(',left=').concat((screen.width - 370)/2));
	}
}

function PageSet(vPage)
{
	location.replace(SetParameter(location.href, 'p', vPage));
}

function ShowAdBox()
{
	if (RefAdLBox.length==0)
		return;

	document.writeln('<table width="100%" cellspacing=0 cellpadding=0 border=0 bgcolor=red>');
	document.writeln('<tr>');
	document.writeln('<td width=190>');
	if (RefAdLBox[0][1] != '')
	{
		document.writeln('<a href="javascript:openMe(\'', RefAdLBox[0][1], '\', ', RefAdLBox[0][2], ')"><img src="', RefAdLBox[0][0], '" border=0></a>');
	}
	else
	{
		document.writeln('<img src="', RefAdLBox[0][0], '" border=0>');
	}
	document.writeln('</td>');
	document.writeln('<td width=1 bgcolor="#FFFFFF"><img src="/Images/white.gif" border=0></td>');
	document.writeln('<td><img src="/Images/Advertising.gif" border=0></td>');
	document.writeln('</tr>');
	document.writeln('</table>');
}

function ShowAdLogoNew(sType)
{
	if (typeof(sType)=='undefined')
		sType = 2;

	switch (sType)
	{
	case 1:
		ShowAdLogoLeft();
		break;
	case 2:
		ShowAdLogoRight();
		break;
	}
}

function ShowAdLogoLeft(MaxHeight)
{
	if (RefAdLogo.length==0)
		return;

	if (typeof(MaxHeight) == 'undefined')
		MaxHeight = 0;

	var MaxShow, THeight;
	if (MaxHeight == 0)
	{
		MaxShow = RefAdLogo.length;
		THeight = '';
	}
	else
	{
		MaxShow = parseInt(MaxHeight / 64);
		THeight = (MaxHeight > 2) ? ' height='.concat((MaxHeight - 2)) : '';
	}

	CurAdLogo=RefAdStay + (Math.floor(Math.random()*12311) % (RefAdLogo.length - RefAdStay));

	document.writeln('<table width=130 cellspacing=0 cellpadding=0 border=0 bgcolor="#c0c0c0">');
	document.writeln('<tr><td align=center>');
	document.writeln('<table', THeight, ' width="100%" cellspacing=1 cellpadding=2 border=0>');

	var AdPost = new Array(new Array(0, RefAdStay), new Array(CurAdLogo, RefAdLogo.length), new Array(RefAdStay, CurAdLogo));
	var k, i, j;

	for (k=0, j=0; j < MaxShow && k < 3; k++)
	{
		for (i=AdPost[k][0]; j < MaxShow && i < AdPost[k][1]; i++, j++)
		{
			document.write('<tr>');
			document.write('<td bgcolor="#FFFFFF">');
			if (RefAdLogo[i][1] != '')
			{
				document.write('<a href="', RefAdLogo[i][1], '" onClick="return openMeExt(this, ', RefAdLogo[i][2], ', 1)"><img src="', PageHost.concat(RefAdLogo[i][0]), '" border=0 width=130 height=60></a>');
			}
			else
			{
				document.write('<img src="', PageHost.concat(RefAdLogo[i][0]), '" border=0 width=130 height=60>');
			}
			document.write('</td>');
			document.write('</tr>');
		}
	}

	document.writeln('</table>');	
	document.writeln('</td></tr>');
	document.writeln('</table>');
}

function ShowAdLogoRight()
{
	if (RefAdLBox.length > 0)
	{
		document.writeln('<table cellspacing=0 cellpadding=0 border=0>');
		document.writeln('<tr><td height=134>');

		if (RefAdLBox[0][1] != '')
		{
			document.writeln('<a href="', RefAdLBox[0][1], '" onClick="return openMeExt(this, ', RefAdLBox[0][2], ', 1)"><img src="', PageHost.concat(RefAdLBox[0][0]), '" width=210 height=130 border=0></a>');
		}
		else
		{
			document.writeln('<img src="', PageHost.concat(RefAdLBox[0][0]), '" border=0>');
		}

		document.writeln('</td></tr>');
		document.writeln('</table>');
	}

	document.write('<table width=210 cellspacing=0 cellpadding=0 border=0 bgcolor="#808080">');
	document.write('<tr><td>');
	document.write('<table width="100%" cellspacing=1 cellpadding=4 border=0>');

	if (RefAdLogo.length==0)
	{
		document.write('<tr><td height=64 align=center bgcolor="#ffffff"><a href="http://vnexpress.net/Advertising" class=TopStory>D&#224;nh cho Qu&#7843;ng c&#225;o</a></td></tr>');
	}
	else
	{
		CurAdLogo=RefAdStay + (Math.floor(Math.random()*12311) % (RefAdLogo.length - RefAdStay));
	
		var AdPost = new Array(new Array(0, RefAdStay), new Array(CurAdLogo, RefAdLogo.length), new Array(RefAdStay, CurAdLogo));

		for (k=0, j=0; k < 3; k++)
		{
			for (i=AdPost[k][0]; i < AdPost[k][1]; i++, j++)
			{
				document.write('<tr>');
				if (RefAdLogo[i][1] != '')
				{
					document.write('<td width="1%" bgcolor="#FFFFFF"><a href="', RefAdLogo[i][1], '" onClick="return openMeExt(this, ', RefAdLogo[i][2], ', 1)"><img src="', PageHost.concat(RefAdLogo[i][0]), '" border=0 width=130 height=60></a></td>');
				}
				else
				{
					document.write('<td width="1%" bgcolor="#FFFFFF"><img src="', PageHost.concat(RefAdLogo[i][0]), '" border=0 width=130 height=60></td>');
				}

				switch (RefAdLogo.length)
				{
				case 1:
				case 2:
				case 3:
					if (j == 0)
						document.write('<td width="99%" bgcolor="#FFFFFF" rowspan=', RefAdLogo.length, ' valign=top><table cellspacing=0 cellpadding=4 border=0 width="100%" bgcolor="#CC0000" height=60><tr><td><a href="http://vnexpress.net/Advertising" class=PnDTitle>&nbsp;D&#224;nh<br>&nbsp;cho<br>&nbsp;Qu&#7843;ng<br>&nbsp;c&#225;o</a></td></tr></table></td>');
					break;
				case 4:
				case 5:
					if (j == 0)
						document.write('<td width="99%" bgcolor="#FFFFFF" rowspan=', 2, ' valign=top><a href="http://www.fpt.vn/services/fps/fps.asp" onClick="return openMeExt(this, 0, 0, 1, 0, 0, 0, 0, 1, 600, 800, 0, 0, 1)"><img src="/AdImages/fps.gif" border=0 height=129 width=61></a></td>');

					if (j == 2)
						document.write('<td width="99%" bgcolor="#FFFFFF" rowspan=', RefAdLogo.length - 2, ' valign=top><table cellspacing=0 cellpadding=4 border=0 width="100%" bgcolor="#CC0000" height=60><tr><td><a href="http://vnexpress.net/Advertising" class=PnDTitle>&nbsp;D&#224;nh<br>&nbsp;cho<br>&nbsp;Qu&#7843;ng<br>&nbsp;c&#225;o</a></td></tr></table></td>');
					break;
				case 6:
				case 7:
				case 8:
				default:
					if (j == 0)
						document.write('<td width="99%" bgcolor="#FFFFFF" rowspan=', 2, ' valign=top><a href="http://www.fpt.vn/services/fps/fps.asp" onClick="return openMeExt(this, 0, 0, 1, 0, 0, 0, 0, 1, 600, 800, 0, 0, 1)"><img src="/AdImages/fps.gif" border=0 height=129 width=61></a></td>');

					if (j == 2)
						document.write('<td width="99%" bgcolor="#FFFFFF" rowspan=', RefAdLogo.length - 2, ' valign=top><a href="http://vnexpress.net/Advertising"><img src="/Images/AdBanner.gif" border=0></a></td>');
					break;
				}
				document.write('</tr>');
			}
		}
	}

	document.write('</table>');	
	document.write('</td></tr>');
	document.write('</table>');
}

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 UnicodeGet(iStr)
{
	for (i=0, oStr=''; i < iStr.length; )
	{
		if (iStr.charCodeAt(i)==38)
		{
			if (iStr.charCodeAt(i + 1)==35)
			{
				p=iStr.indexOf(';', i  + 2);
				if (p!=-1)
				{
					if (p - i <= 7)
					{
						if (isFinite(iStr.substr(i + 2, p - i - 2)))
						{
							oStr = oStr.concat(String.fromCharCode(iStr.substr(i + 2, p - i - 2)));
							i = p + 1;
							continue;
						}
					}
				}
			}
			else
			{
				p=iStr.indexOf(';', i  + 1);
				if (p!=-1)
				{
					switch (iStr.substr(i + 1, p - i - 1))
					{
					case 'amp':
						oStr = oStr.concat('&');
						i = p + 1;
						break;
					case 'quot':
						oStr = oStr.concat('"');
						i = p + 1;
						break;
					case 'lt':
						oStr = oStr.concat('<');
						i = p + 1;
						break;
					case 'gt':
						oStr = oStr.concat('>');
						i = p + 1;
						break;
					}
				}
			}
		}
	
	
		oStr=oStr.concat(iStr.charAt(i));
		i++;
	}
	
	return oStr;
}

function SearchMe(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=='')
	{
		document.Search.TSearch.value = s;
		return false;
	}
	
	f = GetPostVariable('r', RelatedFolder);
	s = escape(UnicodeSet(s));
	r = '/Search/?p=1&r='.concat(f).concat('&a=').concat(a).concat('&s=').concat(s);

	if (location.pathname.toLowerCase()=='/search/')
	{
		location.replace(r);
	}
	else
	{
		location.href=r;
	}
	return false;
}

function SearchOnFocus(field)
{
	if(field.value=='Search')
	{
		field.value = '';
	}
}

function SearchOnBlur(field)
{
	if(field.value=='')
	{
		field.value='Search';
	}
}

function ShowSearch()
{
	if ((s=GetPostVariable('s', ''))!='')
	{
		s = unescape(s);
	}

	s=UnicodeGet(s);

	document.writeln('<table height=30 cellspacing=0 cellpadding=0 border=0 align=center>');
	document.writeln('<form method="POST" name="Search" onSubmit="return SearchMe(document.Search.TSearch.value, 1)">');
	document.writeln('<tr>');
	document.writeln('<td><div><input type="text" name="TSearch" size=9 value="Search" class=SearchBox onfocus="SearchOnFocus(this)" onkeyup="initTyper(this)" onblur="SearchOnBlur(this)"></div></td>');
	document.writeln('<td class=BreakLine width=3>&nbsp;</td>');
	document.writeln('<td><a href="javascript:SearchMe(document.Search.TSearch.value, 1)"><img src="/Images/Go.gif" border=0></a></td>');
	document.writeln('</tr>');
	document.writeln('</form>');
	document.writeln('</table>');

	if (s!='')
	{
		document.Search.TSearch.value = s;
	}
}

function CheckThisVote(field)
{
	form = field.form;
	if (field.checked)
	{
		form.fvotefor.value = field.value;
	}
	else
	{
		form.fvotefor.value = '';
		return;
	}

	for (i=0; i < form.elements.length - 2; i++)
	{
		if(form.elements[i].type=='checkbox')
			if (form.elements[i] != field)
				if (form.elements[i].checked)
					form.elements[i].checked = false;
	}
}

function SubmitVote(sform, saction)
{
	if (saction==0)
	{
		if (sform.fvotefor.value=='')
		{
			alert('Hay chon mot trong cac muc truoc khi bieu quyet');
			return;
		}
	}

	open('', sform.name, 'scrollbars=yes,resizeable=no,locationbar=no,width=500,height=250,left='.concat((screen.width - 500)/2).concat(',top=').concat((screen.height - 250)/2));
	sform.faction.value = saction;
	sform.action = 'http://srv.vnexpress.net/User/Vote/Default.Asp';
	sform.submit();
}

function AddVote(SubjectID, PageID, VoteID, Align, VoteTitle, Color, BgColor, Width, NumItem, ItemArray, Description, Column)
{
	document.writeln('<table width="', Width, '" border=0 cellspacing=0 cellpadding=2 bgcolor="', BgColor, '"', (Align=='') ? '' : ' align='.concat(Align), '>');
	if (VoteTitle!='')
	{
		document.writeln('<tr><td><p class=BoxTitle style="margin-left: 3; color: ', Color, '">', VoteTitle, '</p></td></tr>');
	}

	if (typeof(Description)=='undefined')
	{
		Description = '';
	}

	if (typeof(Column)=='undefined')
	{
		Column = 1;
	}

	document.writeln('<tr>');
	document.writeln('<form method="POST" target="Frm_', VoteID, '" name="Frm_', VoteID, '">');
	document.writeln('<td>');
	document.writeln('<table border=0 cellpadding=0 cellspacing=0 width="100%" bgcolor="#FFFFFF">');
    
	document.writeln('<input type="hidden" name="fsubjectid" value=', SubjectID, '>');
	document.writeln('<input type="hidden" name="fpageid" value=', PageID, '>');
	document.writeln('<input type="hidden" name="fvoteid" value=', VoteID, '>');
	document.writeln('<input type="hidden" name="fvotetitle" value="', VoteTitle, '">');
	document.writeln('<input type="hidden" name="fvotefor" value="">');
	document.writeln('<input type="hidden" name="faction" value="0">');
	document.writeln('<input type="hidden" name="fDescription" value="', Description, '">');

	document.writeln('<input type="hidden" name="fnumitem" value=', NumItem, '>');
	document.writeln('<tr><td width="100%" height=5><img src="/Images/White.gif" border=0></td></tr>');
    
	document.writeln('<tr><td>');
	document.writeln('<table width="100%" cellspacing=0 cellpadding=0 border=0>');

	var i, j, k;

	for (i=0; i < NumItem; )
	{
		document.writeln('<tr>');
		
		for (j=0; j < Column && i < NumItem; j++, i++)
		{
			document.writeln('<input type="hidden" name="fT_', i, '" value="', ItemArray[i][0], '">');
			document.writeln('<input type="hidden" name="fI_', i, '" value="', ItemArray[i][1], '">');
			document.writeln('<input type="hidden" name="fN_', i, '" value="', ItemArray[i][2], '">');
			document.writeln('<td valign=top width=20 align=right><input type="checkbox" name="fC_', i, '" value=', ItemArray[i][2], ' class=VoteField onClick="CheckThisVote(this)"></td>');
			if (i + 1 < NumItem || Column==1)
			{
				document.writeln('<td><p  class=VoteItem>', ItemArray[i][0], '</p></td>');
			}
			else
			{
				document.writeln('<td colspan=', (Column - j - 1)*2,'><p  class=VoteItem>', ItemArray[i][0], '</p></td>');
			}
		}		

		document.writeln('</tr>');
	}

	document.writeln('</table>');
	document.writeln('</td></tr>');

	document.writeln('<tr><td width="100%" class=BreakLine height=4>&nbsp;</td></tr>');
	document.writeln('<tr><td width="100%" class=BreakLine height=1 bgcolor="', BgColor, '"></td></tr>');
	document.writeln('<tr><td width="100%" height=32>&nbsp;<input type="button" value="Bi&#7875;u quy&#7871;t" name="Vote" class=SForm style="width: 85" onClick="SubmitVote(this.form, 0)">&nbsp;<input type="button" value="Xem k&#7871;t qu&#7843;" name="View" class=SForm style="width: 85" onClick="SubmitVote(this.form, 1)"></td></tr>');
	document.writeln('</table>');
	document.writeln('</td>');
	document.writeln('</form>');
	document.writeln('</tr>');
	document.writeln('</table>');
	document.writeln('<table cellspacing=0 cellpadding=0 border=0><tr><td height=2><img src="/Images/White.gif" border=0></td></tr></table>');
}

function ShowExpand(sobj1, sobj2)
{
	sobj1.style.display = 'none';
	sobj2.style.display = '';
}

function SetSelectValue(Field, iStr)
{
	if (iStr=='')
	{
		iStr=' ';
	}

	for (i=0; i < Field.options.length; i++)
	{
		if (Field.options[i].value==iStr)
		{
			Field.selectedIndex=i;
			return;
		}
	}
}

function LTrim(iStr)
{
	while (iStr.charCodeAt(0) <= 32)
	{
		iStr=iStr.substr(1);
	}
	return iStr;
}

function RTrim(iStr)
{
	while (iStr.charCodeAt(iStr.length - 1) <= 32)
	{
		iStr=iStr.substr(0, iStr.length - 1);
	}
	return iStr;
}

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 ShowAdWordByCate(Field)
{
	location.replace(SetParameter('/User/Rao-vat/Source/List.Asp', 'c', Field.options[Field.selectedIndex].value));
}

function ReplaceAll(iStr, v1, v2)
{
	var i = 0, oStr = '', j = v1.length;

	while (i < iStr.length)
	{
		if (iStr.substr(i, j) == v1)
		{
			oStr+=v2;
			i+=j
		}
		else
		{
			oStr+=iStr.charAt(i);
			i++;
		}
	}

	return oStr;
}

function TrimAndRDS(iStr)
{
	function IsHyperLink(iStr)
	{
		var i = 0, c = ' ';

		if (iStr.charAt(0) == '.')
			return false;

		for (i=0; i < iStr.length; i++)
		{
			c = iStr.charAt(i).toLowerCase();
			if (c >= '0' && c <= '9')
				continue;
		
			if (c >= 'a' && c <= 'z')
				continue;
		
			if ('@_-&.?#+-/:'.indexOf(c) != -1)
				continue;

			return false;
		}
	
		return true;
	}

	function GetLastBreak(iStr, s)
	{
		var f = new Array('(', ')', '<', '>', ' ', '\r', '\n', '\t', ',', ';', '!'), p = 0, i = 0, r = -1;
	
		for (i = 0; i < f.length; i++)
			if ((p = iStr.lastIndexOf(f[i], s)) != -1)
				if (r == -1 || p > r)
					r = p;
		return r;
	}

	function GetNextBreak(iStr, s)
	{
		var f = new Array('(', ')', '<', '>', ' ', '\r', '\n', '\t', ',', ';', '!'), p = 0, i = 0, r = -1;
	
		for (i = 0; i < f.length; i++)
			if ((p = iStr.indexOf(f[i], s)) != -1)
				if (r == -1 || p < r)
					r = p;
		return r;
	}

	function CheckDotAfter(iStr)
	{
		var p0 = 0, p1 = 0, p2 = 0, p3 = 0;

		while ((p1 = iStr.indexOf('.', p0)) != -1)
		{
			if (iStr.charAt(p1 - 1) == ' ')
			{
				iStr = iStr.substr(0, p1 - 1).concat(iStr.substr(p1));
				p0 = p1;
			}
			else
			{
				p0 = p1 + 1;
			}

			if (iStr.charAt(p0) != ' ')
			{
				if ((p3 = GetLastBreak(iStr, p0)) == -1)
				{
					p3 = p0;
				}
				else
				{
					p3 = p3 + 1;
				}
		
				if ((p2 = GetNextBreak(iStr, p3)) == -1)
				{
					if (IsHyperLink(iStr.substr(p3)))
					{
						iStr = iStr.substr(0, p3).concat(iStr.substr(p3).toLowerCase())
						break;
					}
					else
					{
						if (iStr.charAt(p0) < '0' || iStr.charAt(p0) > '9')
						{
							iStr = iStr.substr(0, p0).concat(' ').concat(iStr.substr(p0, 1).toUpperCase()).concat(iStr.substr(p0 + 1));
							p0++;
						}
					}
				}
				else
				{
					if (IsHyperLink(iStr.substring(p3, p2)))
					{
						iStr = iStr.substr(0, p3).concat(iStr.substring(p3, p2).toLowerCase()).concat(iStr.substr(p2));
						p0 = p2 + 1;
					}
					else
					{
						if (iStr.charAt(p0) < '0' || iStr.charAt(p0) > '9')
						{
							iStr = iStr.substr(0, p0).concat(' ').concat(iStr.substr(p0, 1).toUpperCase()).concat(iStr.substr(p0 + 1));
							p0++;
						}
					}
				}
			}
			else
			{
				iStr = iStr.substr(0, p0 + 1).concat(iStr.substr(p0 + 1, 1).toUpperCase()).concat(iStr.substr(p0 + 2));
			}
		}	

		return iStr;
	}

	function CheckCharAfter(iStr, iChar, iUp)
	{
		var p0 = 0, p1 = 0;

		while ((p1 = iStr.indexOf(iChar, p0)) != -1)
		{
			if (iStr.charAt(p1 - 1) == ' ')
			{
				iStr = iStr.substr(0, p1 - 1).concat(iStr.substr(p1));
				p0 = p1;
			}
			else
			{
				p0 = p1 + 1;
			}

			if (iStr.charAt(p0) != ' ')
			{
				if (iStr.charAt(p0) < '0' || iStr.charAt(p0) > '9')
				{
					if (iUp)
					{
						iStr = iStr.substr(0, p0).concat(' ').concat(iStr.substr(p0, 1).toUpperCase()).concat(iStr.substr(p0 + 1));
					}
					else
					{
						iStr = iStr.substr(0, p0).concat(' ').concat(iStr.substr(p0));
					}
					p0++;
				}
			}
			else
			{
				if (iUp)
				{
					iStr = iStr.substr(0, p0 + 1).concat(iStr.substr(p0 + 1, 1).toUpperCase()).concat(iStr.substr(p0 + 2));
				}
			}
		}

		return iStr;
	}

	function CheckScope(iStr, s1, s2)
	{
		var p0 = 0, p1 = 0;

		for (p0 = 0; (p1 = iStr.indexOf(s1, p0)) != -1; )
		{
			if (iStr.charAt(p1 + 1) == ' ')
				iStr = iStr.substr(0, p1 + 1).concat(iStr.substr(p1 + 2));

			if (p1 > 0)
				if (iStr.charAt(p1 - 1) != ' ')
				{
					iStr = iStr.substr(0, p1).concat(' ').concat(iStr.substr(p1));
					p1++;
				}
			
			p0 = p1 + 1;
		}

		for (p0 = 0; (p1 = iStr.indexOf(s2, p0)) != -1; )
		{
			var SkipChar = ':,.;!?'.concat(s2);

			if (p1 > 0)
				if (iStr.charAt(p1 - 1) == ' ')
				{
					iStr = iStr.substr(0, p1 - 1).concat(iStr.substr(p1));
					p1--;
				}

			if (iStr.charAt(p1 + 1) != ' ' && SkipChar.indexOf(iStr.charAt(p1 + 1)) == -1)
				iStr = iStr.substr(0, p1 + 1).concat(' ').concat(iStr.substr(p1 + 1));

			p0 = p1 + 1;
		}		

		return iStr;
	}
	
	iStr = ReplaceAll(iStr, '  ', ' ');
	iStr = ReplaceAll(iStr, ' \r\n', '\r\n');
	iStr = ReplaceAll(iStr, '\r\n ', '\r\n');

	iStr = CheckCharAfter(iStr, ',', false);
	iStr = CheckCharAfter(iStr, ':', false);
	iStr = CheckCharAfter(iStr, ';', false);
	iStr = CheckCharAfter(iStr, '?', true);
	iStr = CheckCharAfter(iStr, '!', true);

	iStr = CheckScope(iStr, '(', ')');
	iStr = CheckScope(iStr, '[', ']');

	iStr = ReplaceAll(iStr, 'http: //', 'http://');
	iStr = CheckDotAfter(iStr);

	iStr = ReplaceAll(iStr, ', \r\n', ',\r\n');
	iStr = ReplaceAll(iStr, ': \r\n', ':\r\n');
	iStr = ReplaceAll(iStr, '; \r\n', ';\r\n');
	iStr = ReplaceAll(iStr, '? \r\n', '!\r\n');
	iStr = ReplaceAll(iStr, '! \r\n', '!\r\n');
	iStr = ReplaceAll(iStr, '. \r\n', '.\r\n');


	if (iStr.charAt(0) == ' ')
		iStr = iStr.substr(1);

	if (iStr.charAt(iStr.length - 1) == ' ')
		iStr = iStr.substr(0, iStr.length - 1);

	return iStr.substr(0, 1).toUpperCase().concat(iStr.substr(1));
}

function dw(wstr)
{
	document.writeln(unescape(wstr));
}

function ShowFooterAd()
{
	if (RefAdLogo.length==0)
	{
		return;
	}

	CurAdLogo=RefAdStay + (Math.floor(Math.random()*12311) % (RefAdLogo.length - RefAdStay));

	document.writeln('<table width="100%" cellspacing=0 cellpadding=0 border=0 bgcolor="#c0c0c0">');
	document.writeln('<tr><td align=center>');
	document.writeln('<table width="100%" cellspacing=1 cellpadding=4 border=0>');
	document.writeln('<tr>');	

	var AdPost = new Array(new Array(0, RefAdStay), new Array(CurAdLogo, RefAdLogo.length), new Array(RefAdStay, CurAdLogo));

	for (k=0, c=0; c < 4 && k < 3; k++)
	{
		for (i=AdPost[k][0]; c < 4 && i < AdPost[k][1]; i++, c++)
		{
			document.writeln('<td height=64 align=center valign=middle align=right bgcolor="#FFFFFF">');
			if (RefAdLogo[i][1] != '')
			{
				document.writeln('<a href="', RefAdLogo[i][1], '"><img src="', PageHost.concat(RefAdLogo[i][0]), '" border=0 width=130 height=60></a>');
			}
			else
			{
				document.writeln('<img src="', PageHost.concat(RefAdLogo[i][0]), '" border=0 width=130 height=60>');
			}
			document.writeln('</td>');
		}
	}

	document.writeln('</tr>');
	document.writeln('</table>');	
	document.writeln('</td></tr>');
	document.writeln('</table>');
}

function PrintSubject()
{
	w=open('/Resource/View.Asp', '_blank', '');
return false;
	w.document.writeln('<html>');
	w.document.writeln('<head>');
	w.document.writeln('<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">');
	w.document.writeln('<link rel="stylesheet" href="http://vnexpress.net/Resource/Default.css" type="text/css">');
	w.document.writeln('</head>');
	w.document.writeln('<body topmargin=3 leftmargin=0 marginheight=3 marginwidth=0>');
	w.document.writeln('<table cellspacing=0 cellpadding=0 border=0 width=420 align=center>');
	w.document.writeln('<tr>');
	w.document.writeln('<td>');
	w.document.writeln(document.getElementById('CContainer').innerHTML);
	w.document.writeln('</td>');
	w.document.writeln('</tr>');
	w.document.writeln('</table>');
	w.document.writeln('</body>');
	w.document.writeln('</html>');
	w.document.title = document.title;
	return false;
}

function EmailSubject(PageID)
{
	openMeExt('http://srv.vnexpress.net/User/EmailSubject/?ID='.concat(PageID), 0, 0, 0, 0, 0, 0, 1, 1, 355, 480, 0, 0, '', 0);
	return false;
}

function ViewStockLive()
{
newWindow=window.open('aspCode/nothing.asp','','menubar=no,width=300,height=200')
if (newWindow != null && newWindow.opener == null)
newWindow.opener=window
}
<!-- Begin
function ScrollWelcome(seed) {
var m1  = "Chao mung ban den voi He thong cong bo thong tin cua TTGDCK Ha Noi!  ";
var m2  = "..:: Tel: 0913318445 ";
var m3  = "::..";
var m4  = "";
var msg=m1+m2+m3+m4;
var out = " ";
var c   = 1;
if (seed > 100) {
seed--;
cmd="scrollit("+seed+")";
timerTwo=window.setTimeout(cmd,100);
}
else if (seed <= 100 && seed > 0) {
for (c=0 ; c < seed ; c++) {
out+=" ";
}
out+=msg;
seed--;
window.status=out;
cmd="scrollit("+seed+")";
timerTwo=window.setTimeout(cmd,100);
}
else if (seed <= 0) {
if (-seed < msg.length) {
out+=msg.substring(-seed,msg.length);
seed--;
window.status=out;
cmd="scrollit("+seed+")";
timerTwo=window.setTimeout(cmd,100);
}
else {
window.status=" ";
timerTwo=window.setTimeout("scrollit(100)",75);
      }
   }
}

function LogOutExp(timeEx) 
{
window.setTimeout("window.navigate('aspCode/LogOutExpires.asp')", timeEx); 
}

// Mo 1 cua so moi de post bai
function WindowInputNews()
{
newWindow=window.open('aspCode/postnews.asp','','menubar=no,width=460,height=340')
if (newWindow != null && newWindow.opener == null)
newWindow.opener=window
}
// End -->

// Ham chuyen doi mau nen cua dong trong bang khi MouseOver
// Vidu: <TR onMouseover="chgBg(this,'EEEEEE')" onMouseout="chgBg(this,'')">
function chgBg(obj,color){
if (document.all || document.getElementById)
  obj.style.backgroundColor=color;
else if (document.layers)
  obj.bgColor=color;
}
//-->
//<script language="JavaScript" >
var blank = "/image2/blank.gif";
topedge = 115;  // location of news box from top of page
leftedge = 167;  // location of news box from left edge
boxheight = 190;  // height of news box
boxwidth = 82;  // width of news box
scrollheight = 70; // total height of all data to be scrolled

stop = 0;  // status scroll
function scrollstop(status){
stop = status;
}

function scrollnews(cliptop) {
if (stop){
 setTimeout("scrollnews(" + cliptop + ")", 120);
 return;
}
if (document.layers) {
newsDiv = document.news;
newsDiv.clip.top = cliptop;
newsDiv.clip.bottom = cliptop + boxheight;
newsDiv.clip.left = 0;
newsDiv.clip.right = boxwidth + leftedge;
newsDiv.left = leftedge;
newsDiv.top = topedge - cliptop;
}
else {
newsDiv = news.style;
newsDiv.clip = "rect(" + cliptop + "px " + (boxwidth + leftedge) + "px " + (cliptop + boxheight) + "px 0px)";
newsDiv.pixelLeft = leftedge;
newsDiv.pixelTop = topedge - cliptop;
}
cliptop = (cliptop + 1) % (scrollheight + boxheight);
newsDiv.visibility='visible';
setTimeout("scrollnews(" + cliptop + ")", 120);
}

//Ham dung hien thi ngay thang he thong
function displaydate(){
var mydate=new Date()
var year=mydate.getYear()
if (year < 1000)
year+=1900
var day=mydate.getDay()
var month=mydate.getMonth()
var daym=mydate.getDate()
if (daym<10)
daym="0"+daym
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")
var montharray=new Array("01","02","03","04","05","06","07","08","09","10","11","12")
document.write(dayarray[day]+", "+daym+"."+montharray[month]+"."+year)
}

// Ham dung so sanh giua 2 moc ngay thang voi nhau: True - Date1<Date2, False - Date1>Date2
function Compare2Date(strDate1, strDate2)
{
	var str1= strDate1;
	var str2= strDate2;
    	var strDay, strMonth, strYear, nMonth1, nDay1, nYear1,nMonth2, nDay2, nYear2, nPos1, nPos2;
	
	// Xu ly moc ngay thang 1	
	    if (str1.length > 10) return false;
	    if (str1 =="") return false;
		
	    //Lay vi tri ky tu "/" cua NGAY
	    nPos1 = str1.indexOf( "/" );
	    if ( nPos1 < 0 ) return false;

   	    //Lay vi tri ky tu "/" cua THANG
	    nPos2 = str1.lastIndexOf( "/" );
	    if ( nPos2 < 0 ) return false;

	    //Kiem tra hop le
	    if ( nPos1 == nPos2 ) return false;

	    //Lay tu 1 xau ra ngay, thang, nam
	    strDay = str1.substring( 0, nPos1);
	    strMonth = str1.substring( nPos1 + 1, nPos2 );
	    strYear = str1.substring( nPos2 + 1 );

	    //Chuyen xau sang dang so
  	    nMonth1 = parseInt(strMonth,10);
	    nDay1 = parseInt(strDay,10);
	    nYear1 = parseInt(strYear,10);
	// Ket thuc moc 1    
	    
	// Xu ly moc ngay thang 2
	    if (str2.length > 10) return false;
	    if (str2 =="") return false;
		
	    //Lay vi tri ky tu "/" cua NGAY
	    nPos1 = str2.indexOf( "/" );
	    if ( nPos1 < 0 ) return false;

   	    //Lay vi tri ky tu "/" cua THANG
	    nPos2 = str2.lastIndexOf( "/" );
	    if ( nPos2 < 0 ) return false;

	    //Kiem tra hop le
	    if ( nPos1 == nPos2 ) return false;

	    //Lay tu 1 xau ra ngay, thang, nam
	    strDay = str2.substring( 0, nPos1);
	    strMonth = str2.substring( nPos1 + 1, nPos2 );
	    strYear = str2.substring( nPos2 + 1 );

	    //Chuyen xau sang dang so
	    nMonth2 = parseInt(strMonth,10);
	    nDay2 = parseInt(strDay,10);
	    nYear2 = parseInt(strYear,10);
	// Ket thuc moc 2
	    
	// So sanh hai moc ngay thang	
	    //So sanh nam
	    if (nYear1 > nYear2)
		{
		    return false;
		}
	   				
	    //So sanh nam, thang
	    if (nYear1 == nYear2)
		{ 
		   if (nMonth1 > nMonth2)
			{
	     		    return false;
			}
		}
	   
	    //So sanh nam, thang, ngay
	    if (nYear1 == nYear2)
		{
		   if (nMonth1 == nMonth2) 
			{
		   	    if (nDay1 >= nDay2)
				{
				    return false;
				}
			}
		}
}

// Ham kiem tra dia chi e-mail co hop le hay khong
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;
}

//Ham thuc hien viec kiem tra xem gia tri nhap vao co phai dang ngay/thang/nam hay khong
// Output:  True  -  False
function isDate( s )
{
	var sDay, sMonth, sYear, nMonth, nDay, nYear, nSep1, nSep2;
	nSep1 = s.indexOf( "/" );	if ( nSep1 < 0 ) return false;
	nSep2 = s.lastIndexOf( "/" );	if ( nSep2 < 0 ) return false;
	if ( nSep1 == nSep2 ) return false;

	sDay = s.substring( 0, nSep1  );
	sMonth = s.substring( nSep1 + 1, nSep2 );
	sYear = s.substring( nSep2+1 );
	if ( !sMonth.length || !sDay.length || sYear.length <4) return false;
	
	// isNaN(empty) is false
	if ( isNaN(sMonth) || isNaN(sDay) || isNaN(sYear) ) return false;
	nMonth = parseInt(sMonth,10); nDay = parseInt(sDay,10); nYear = parseInt(sYear,10);
	if ( nMonth<=0 || nDay<=0 || nYear<0 ) return false;
	if ( nMonth > 12 ) return false;
	if (nMonth==1 || nMonth==3 || nMonth==5 || nMonth==7 || nMonth==8 || nMonth==10 || nMonth==12 )
		if ( nDay > 31 ) return false;
	if (nMonth==4 || nMonth==6 || nMonth==9 || nMonth==11 )
		if ( nDay > 30 ) return false;
	if (nMonth==2) {
		if ( (nYear % 4 == 0) && (nYear % 100 != 0)) { // leap year
			if ( nDay > 29 ) return false;
		} else if ( nDay > 28 ) return false;
	}
	return true;
}

// Kiem soat cac gia tri nhap vao co hop le khong
function	FilterInput(value)
{
	if (window.event.keyCode >=48 && window.event.keyCode<=57)
	{
	}
	else{
	var b = true;
	var a = new Array();
	a = value.split(",");
		for (var i = 0; i < a.length;i++)
		{
			if (window.event.keyCode == a[i])
				b =	false;
		}
		if(b) window.event.keyCode = 0;
	}
}

// Kiem tra gia tri nhap la kieu so
function	FilterIntegerDigits()
{
	if (window.event.keyCode >=48 && window.event.keyCode<=57)
	{
	}
	else
		window.event.keyCode =	0;
}

// Hien thi menu
function DISC_navBar( tableCellRef, hoverFlag, navStyle ) {
	if ( hoverFlag ) {
		switch ( navStyle ) {
			case 1:
				tableCellRef.style.backgroundColor = '#69c';
				break;
			default:
				if ( document.getElementsByTagName ) {
					tableCellRef.getElementsByTagName( 'a' )[0].style.color = '#c00';
				}
		}
	} else {
		switch ( navStyle ) {
			case 1:
				tableCellRef.style.backgroundColor = '#036';
				break;
			default:
				if ( document.getElementsByTagName ) {
					tableCellRef.getElementsByTagName( 'a' )[0].style.color = '#000';
				}
		}
	}
}

function DISC_navBarClick( tableCellRef, navStyle, url ) {
	DISC_navBar( tableCellRef, 0, navStyle );
	CNN_goTo( url );
}
function openImage(vLink, vHeight, vWidth)
{
	var sLink = (typeof(vLink.href) == 'undefined') ? vLink : vLink.href;

	if (sLink == '')
	{
		return false;
	}

	winDef = 'status=no,resizable=no,scrollbars=no,toolbar=no,location=no,fullscreen=no,titlebar=no,height='.concat(vHeight).concat(',').concat('width=').concat(vWidth).concat(',');
	winDef = winDef.concat('top=').concat((screen.height - vHeight)/2).concat(',');
	winDef = winDef.concat('left=').concat((screen.width - vWidth)/2);
	newwin = open('', '_blank', winDef);

	newwin.document.writeln('<head><TITLE>View Picture</TITLE></head><body topmargin="0" leftmargin="0" marginheight="0" marginwidth="0"><div align=center>');
	newwin.document.writeln('<a href="" onClick="window.close(); return false;"><img src="', sLink, '" alt="', (fBrw) ? 'Close picture!' : 'Close', '" border=0></a></div>');
	newwin.document.writeln('</body>');

	if (typeof(vLink.href) != 'undefined')
	{
		return false;
	}
}
function showDialog(vLink, vWidth, vHeight)
{
return showWindow(vLink, false, false, false, false, false, false, true, true, vWidth, vHeight, 0, 0);
}

function showWindow(vLink, vStatus, vResizeable, vScrollbars, vToolbar, vLocation, vFullscreen, vTitlebar, vCentered, vWidth, vHeight, vTop, vLeft)
{
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(vHeight).concat(',');
winDef = winDef.concat('width=').concat(vWidth).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);
}

open(sLink, '_blank', winDef);

if (typeof(vLink.href) != 'undefined')
{
	return false;
}
}

function displayDate(dDate) {
	var today;	
	today = new Date(); 
	var dow = new Array('Chủ nhật','Thứ Hai','Thứ Ba','Thứ Tư','Thứ Năm','Thứ Sáu','Thứ Bảy');
	var d = new Array('01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','29','30','31');
	var months = new Array('01','02','03','04','05','06','07','08','09','10','11','12');
	var year = today.getYear();
	year = (year <= 1888) ? (1900 + year) : year;
	document.write(dow[today.getDay()] + ', ngày  ' + today.getDate() + '/' + months[today.getMonth()] + '/' + year );
}


// Day la popup tu 1 con link chu deo phai tu image, button
var popup = null;

function CreateWnd (file, width, height, resize)
{
	var doCenter = false;

	if((popup == null) || popup.closed)
	{
		attribs = "";

		if(resize) size = "yes"; else size = "no";

		
		for(var item in window)
			{ if(item == "screen") { doCenter = true; break; } }

		if(doCenter)
		{	
			if(screen.width <= width || screen.height <= height) size = "yes";

			WndTop  = (screen.height - height) / 2;
			WndLeft = (screen.width  - width)  / 2;

			attribs = "width=" + width + ",height=" + height + ",resizable=" + size + ",scrollbars=" + size + "," + 
			"status=no,toolbar=no,directories=no,menubar=no,location=no,top=" + WndTop + ",left=" + WndLeft;
		}
		else
		{
			if(navigator.appName=="Netscape" && navigator.javaEnabled())
			{	
				var toolkit = java.awt.Toolkit.getDefaultToolkit();
				var screen_size = toolkit.getScreenSize();

				if(screen_size.width <= width || screen_size.height <= height) size = "yes";

				WndTop  = (screen_size.height - height) / 2;
				WndLeft = (screen_size.width  - width)  / 2;

				attribs = "width=" + width + ",height=" + height + ",resizable=" + size + ",scrollbars=" + size + "," + 
				"status=no,toolbar=no,directories=no,menubar=no,location=no,top=" + WndTop + ",left=" + WndLeft;
			}
			else
			{	
				size = "yes";

				attribs = "width=" + width + ",height=" + height + ",resizable=" + size + ",scrollbars=" + size + "," + 
				"status=no,toolbar=no,directories=no,menubar=no,location=no";
			}
		}

		popup = open(file, "", attribs);
	}
	else
	{
		DestroyWnd();
		// recurse, just once, to display the new window
		CreateWnd(file, width, height, resize);
	}
}

function DestroyWnd ()
{
	// close the current window
	if(popup != null)
	{
		popup.close();
		popup = null;
	}
}

function isIn(onechar,str){
	if (str.indexOf(onechar)==-1) return false;
	return true;
}

function isDate(orgDate){
	if (orgDate=="") return true;
	var d="";
	for (i=0;i<orgDate.length;i++){
		onechar=orgDate.charAt(i);
		if  (!isIn(onechar,"0123456789:-/")) return false;
		if ( (onechar=="/") || (onechar==":") ) {
		d=d+"-";
		} else {
		d=d+onechar;
		}
	}
	p=d.indexOf("-");
	if (p<2) d="0"+d;
	else if (p>2) return false;
	day=d.substr(0,2);
	d=d.substr(3);
	p=d.indexOf("-");
	if (p<2) d="0"+d;
	else if (p>2) return false;
	mon=d.substr(0,2);
	year=d.substr(3);
	if (year.length==2) year="19"+year;
	if (	(day<1) || (day>31) || (mon<1) || (mon>12) || (year<1900) || (year>2222) ) return false;
	if ( (day>29) && (mon==2) ) return false;
	return day+"-"+mon+"-"+year;
}


//end