﻿var fBrw=(navigator.userAgent.indexOf('MSIE')!= -1 && navigator.userAgent.indexOf('Windows')!= -1);
var fDSp=(typeof(document.getElementById)!='undefined');
var RefVal1 = new Array();
var RefVal2 = new Array();
var RefVal3 = new Array();
var RefVal4 = new Array();
var RefVal5 = new Array();
var RefVal6 = new Array();
var RefVal7 = new Array();
var RefVal8 = new Array();
var RefVal9 = new Array();
var RefVal10 = new Array();
var RefVal11 = new Array();
var RefVal12 = new Array();
var RefVal13 = new Array();
var RefVal14 = new Array();
var RefVal15 = new Array();
var RefVal16 = new Array();
var RefVal17 = new Array();
var RefVal18 = new Array();
var RefVal19 = new Array();
var RefVal20 = new Array();
var RefVal21 = new Array();
var RefVal22 = new Array();
var RefVal23 = new Array();
var RefVal24 = new Array();
var RefVal25 = new Array();
var RefVal26 = new Array();
var RefVal27 = new Array();
var RefVal28 = new Array();
var RefVal29 = new Array();
var RefVal30 = new Array();


var RelatedFolder=PageFolder;
var RefAdStay = 0;
var SkpFolder = true;

var LastChild = 0;

var LComplete = 0;
var sDomain	  = 'DoThi.net'; 

var req;

if (typeof(PageHost) == 'undefined')
{
	var PageHost = '';
}

if (typeof(SkipTopWindow) == 'undefined')
{
	if (window.parent!=window)
	{	
		alert('This website violate "The '+sDomain+' © Copyright Notice".\r\nClick OK to Access '+sDomain+'!');
		window.open(location.href, '_top', '');
	}
}

function TextOnFocusChange(field, item)
{
	//alert(document.getElementById(field).value);
	//document.getElementById(field).value ='';
	var arrText=new Array(13);
	arrText[0]="Tên doanh nghiệp";
	arrText[1]="Người đại diện đăng";
	arrText[2]="Địa chỉ";
	arrText[3]="Điện thoại";
	arrText[4]="Fax";
	arrText[5]="Email";
	arrText[6]="Website";
	arrText[7]="Thông tin khác";
	arrText[8]="Tên đầy đủ";
	arrText[9]="Địa chỉ";
	arrText[10]="Điện thoại";
	arrText[11]="Email";
	arrText[12]="Câu hỏi";
	if(document.getElementById(field).value=='' || document.getElementById(field).value==arrText[item])
	{
		//alert(document.getElementById("Name").value);
		//alert(field);
		document.getElementById(field).value="";
	}		
}

function TextOnFocus(field)
{
	//alert(document.getElementById(field).value);
	//document.getElementById(field).value ='';
	var arrText=new Array(13);
	arrText[0]="Tên doanh nghiệp";
	arrText[1]="Người đại diện đăng";
	arrText[2]="Địa chỉ";
	arrText[3]="Điện thoại";
	arrText[4]="Fax";
	arrText[5]="Email";
	arrText[6]="Website";
	arrText[7]="Thông tin khác";
	arrText[8]="Tên đầy đủ";
	arrText[9]="Địa chỉ";
	arrText[10]="Điện thoại";
	arrText[11]="Email";
	arrText[12]="Câu hỏi";
	if(document.getElementById(field).value=='' || document.getElementById(field).value==arrText[item])
	{
		//alert(document.getElementById("Name").value);
		//alert(field);
		document.getElementById(field).value=arrText[item];
	}		
}

function DisplayBanner(rbn,vAd)
{
	if (RefVal16.length ==0)
	{
		if ((RefVal7.length ==0)||(RefVal8.length ==0))
		{
			var header1 = document.getElementById("header1");
			header1.style.display = "none";				
		}	
		if ((RefVal7.length ==0)&&(RefVal8.length ==0))
		{
			document.write('<table cellspacing=0 cellpadding=1 border=0 width=736 height=90 bgcolor="#c0c0c0"><tr><td valign=top><table cellspacing=0 cellpadding=0 border=0 width="734" height="88"><tr><td bgcolor="#ffffff" align=center class=Hotnew_lead><a href="/Advertising" class=Hotnew_lead>D&#224;nh cho Qu&#7843;ng c&#225;o</a></td></tr></table></td></tr></table>');
			return;		
		}
		if ((RefVal7.length >0)||(RefVal8.length >0))
		{
			var header1 = document.getElementById("header1");
			header1.style.display = "none";				
		}	
	}
	
	var alTopBanner = new adlistshow(RefVal16,'Top Banner',vAd,0,0,736,90);
}
function DisplayTopGroup13Banner(rbn,vAd)
{
	if (RefVal16.length ==0)
	{
		document.write('<table cellspacing=0 cellpadding=1 border=0 width=736 height=90 bgcolor="#c0c0c0"><tr><td valign=top><table cellspacing=0 cellpadding=0 border=0 width="734" height="88"><tr><td bgcolor="#ffffff" align=center class=Hotnew_lead><a href="/Advertising" class=Hotnew_lead>D&#224;nh cho Qu&#7843;ng c&#225;o</a></td></tr></table></td></tr></table>');
		return;
	}
	if (RefVal16.length >0)
	{
		var alTopBanner = new adlistshow(RefVal16,'Top Banner',vAd,0,0,736,90);
	}		
}
function DisplayTopLeftBanner(rbn,vAd)
{
	if (RefVal16.length >0)
	{
		
	}
	else
	{
		if (RefVal7.length ==0)
		{
			document.write('<table cellspacing=0 cellpadding=1 border=0 width=365 height=90 bgcolor="#c0c0c0"><tr><td valign=top><table cellspacing=0 cellpadding=0 border=0 width="363" height="89"><tr><td bgcolor="#ffffff" align=center class=Hotnew_lead><a href="/Advertising" class=Hotnew_lead>D&#224;nh cho Qu&#7843;ng c&#225;o</a></td></tr></table></td></tr></table>');
			return;
		}		
		var alTopLeftBanner = new adlistshow(RefVal7,'Top Lelf Banner',vAd,0,0,365,90);		
	}
}
function DisplayTopRightBanner(rbn,vAd)
{
	if (RefVal16.length >0)
	{
		
	}
	else
	{
		if (RefVal8.length ==0)
		{
			document.write('<table cellspacing=0 cellpadding=1 border=0 width=365 height=90 bgcolor="#c0c0c0"><tr><td valign=top><table cellspacing=0 cellpadding=0 border=0 width="363" height="89"><tr><td bgcolor="#ffffff" align=center class=Hotnew_lead><a href="/Advertising" class=Hotnew_lead>D&#224;nh cho Qu&#7843;ng c&#225;o</a></td></tr></table></td></tr></table>');
			return;
		}	
		var alTopRightBanner = new adlistshow(RefVal8,'Top Right Banner',vAd,0,0,365,90);	
	}
}

function DisplayUnderHotTopBanner(rbn,vAd)
{
	if (RefVal9.length ==0)
	{	
	
		document.write('<table cellspacing=0 cellpadding=1 border=0 width=500 height=60 bgcolor="#c0c0c0"><tr><td valign=top><table cellspacing=0 cellpadding=0 border=0 width="498" height="58"><tr><td bgcolor="#ffffff" align=center class=Hotnew_lead><a href="/Advertising" class=Hotnew_lead>D&#224;nh cho Qu&#7843;ng c&#225;o</a></td></tr></table></td></tr></table>');

		return;
	}
	
	var alTopRightBanner = new adlistshow(RefVal9,'Top Right Banner',vAd,0,0,500,60);	
}

function DisplayFooterHomeBanner(rbn,vAd)
{
	if (RefVal22.length ==0)
	{		
		//document.write('<table cellspacing=0 cellpadding=1 border=0 width=955 height=90 bgcolor="#c0c0c0"><tr><td valign=top><table cellspacing=0 cellpadding=0 border=0 width="953" height="89"><tr><td bgcolor="#ffffff" align=center class=Hotnew_lead><a href="/Advertising" class=Hotnew_lead>D&#224;nh cho Qu&#7843;ng c&#225;o</a></td></tr></table></td></tr></table>');
		return;
	}
	
	var alTopRightBanner = new adlistshow(RefVal22,'Footer Banner',vAd,0,0,955,90);	
}


function DisplayGroupFooterBanner(rbn,vAd)
{
	if (RefVal22.length ==0)
	{		
		document.write('<table cellspacing=0 cellpadding=1 border=0 width=955 height=90 bgcolor="#c0c0c0"><tr><td valign=top><table cellspacing=0 cellpadding=0 border=0 width="953" height="89"><tr><td bgcolor="#ffffff" align=center class=Hotnew_lead><a href="/Advertising" class=Hotnew_lead>D&#224;nh cho Qu&#7843;ng c&#225;o</a></td></tr></table></td></tr></table>');
		return;
	}
	
	var alTopRightBanner = new adlistshow(RefVal22,'Footer Banner',vAd,0,0,955,90);	
}



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 = '', i = 0, j = 0;
	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
	{
		if ((i=cookie.toLowerCase().indexOf(Name.concat('='))) != -1)
		{
			if ((j = cookie.indexOf(';', i)) > i + Name.length + 1)
			{
				return ReplaceAll(unescape(cookie.substr(i + Name.length + 1, j - i - Name.length - 1)), '+', ' ');
			}
			else
			{
				j = cookie.length;
				return ReplaceAll(unescape(cookie.substr(i + Name.length + 1, j - i - Name.length - 1)), '+', ' ');
			}
		}

		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 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 '+sDomain+'</font></b>, All rights reserved. <a href="', PageHost, '/ContactUs/?d=webmaster@'+sDomain+'">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 '+sDomain+' 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 '+sDomain+'</font></b>, All rights reserved.<td></tr>');
	}
	document.writeln('</table>');
}

function AddHeader(Name, Header, Buttons, Symbol, AddChildTable)
{
	document.writeln('<table width="138" border=0 cellspacing=0 cellpadding=0 bgcolor="#848484"><tr><td width=6 background="/Images/bg_leftleftheader.gif"></td><td>');

	if (Header!='')
	{
		document.writeln('<table width="128" border=0 cellspacing=0 cellpadding=0>');
		document.writeln('<tr>');

		if (typeof(Symbol)!='undefined')
		{
			document.writeln('<td height=16 width="17" class=BoxHeader><img src="', Symbol, '" border=0></td>');
		}

		document.writeln('<td height=16 width="94" align=left class=BoxHeader>&nbsp;', Header, '</td>');

		if ((Buttons & 1) && fDSp)
		{
			document.write('<td width=17 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="127" cellspacing=0 cellpadding=0 border=1>');
		LastChild = 1;
	}
	else
	{
		LastChild = 0;
	}
	return true;
}

function AddFooter()
{
	if (LastChild)
	{
		document.writeln('</table></div></td><td width=4 background="/Images/bg_leftrightheader.gif"></td></tr></table>');
	}
	else
	{
		document.writeln('</div></td><td width=4 background="/Images/bg_leftrightheader.gif"></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, 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(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(vID) == 'undefined')
	{
		vID = 0;
	}
	
	if (vCounter)
	{
		sLink = 'http://srv.dothi.net/Counter/?n='.concat(vID).concat('&u=').concat(escape(sLink)).concat('&r=').concat(Math.random());
	}

	open(sLink, '_blank', winDef);

	if (typeof(vLink.href) != 'undefined')
	{
		return false;
	}
}

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=yes,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('<body topmargin="0" leftmargin="0" marginheight="0" marginwidth="0">');
	newwin.document.writeln('<a href="" onClick="window.close(); return false;"><img src="', sLink, '" alt="', (fBrw) ? '&#272;&#243;ng l&#7841;i' : 'Dong lai', '" border=0></a>');
	newwin.document.writeln('</body>');

	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 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 SearchMuaBanHome(ex,tl,et,pt,pv,ma,fp,tp,up)
{
	while (tl.length > 0 && tl.charAt(0) <= ' ')
	{
		tl = tl.substr(1);
	}

	while ((i=tl.length) > 0 && tl.charAt(i - 1) <= ' ')
	{
		tl = tl.substr(0, i - 1);
	}

	tl = escape(UnicodeSet(tl));
	r = '/User/Mua-ban/?ex=1&et='.concat(et).concat('&pt=').concat(pt).concat('&pv=').concat(pv).concat('&ma=').concat(ma).concat('&fp=').concat(fp).concat('&tp=').concat(tp).concat('&up=').concat(up).concat('&tl=').concat(tl);
	

	if (location.pathname.toLowerCase()=='/User/Mua-Ban/')
	{
		location.replace(r);
	}
	else
	{
		location.href=r;
	}
	return false;
}

function SearchMuaBan(ex,tl,et,pt,pv,ma,fp,tp,up)
{
	while (tl.length > 0 && tl.charAt(0) <= ' ')
	{
		tl = tl.substr(1);
	}

	while ((i=tl.length) > 0 && tl.charAt(i - 1) <= ' ')
	{
		tl = tl.substr(0, i - 1);
	}
	tl = escape(UnicodeSet(tl));
	r = '/User/Mua-ban/?ex=1&et='.concat(et).concat('&pt=').concat(pt).concat('&pv=').concat(pv).concat('&ma=').concat(ma).concat('&fp=').concat(fp).concat('&tp=').concat(tp).concat('&up=').concat(up).concat('&tl=').concat(tl);
	

	if (location.pathname.toLowerCase()=='/User/Mua-Ban/')
	{
		location.replace(r);
	}
	else
	{
		location.href=r;
	}
	return false;
}

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 (Trim(s)=='')
	{
		document.Search.TSearch.value ='Tìm kiếm';
	}
	
	//f = GetPostVariable('r', RelatedFolder);
	s = escape(UnicodeSet(s));
	r = '/Search/?p=1&r=1'.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=='Tìm kiếm')
	{
		field.value = '';
	}
}

function SearchOnBlur(field)
{
	if(field.value=='')
	{
		field.value='Tìm kiếm';
	}
}

function TextOnBlur(field,item)
{
	//alert(document.getElementById(field).value);
	var arrText=new Array(13);
	arrText[0]="Tên doanh nghiệp";
	arrText[1]="Người đại diện đăng";
	arrText[2]="Địa chỉ";
	arrText[3]="Điện thoại";
	arrText[4]="Fax";
	arrText[5]="Email";
	arrText[6]="Website";
	arrText[7]="Thông tin khác";
	arrText[8]="Tên đầy đủ";
	arrText[9]="Địa chỉ";
	arrText[10]="Điện thoại";
	arrText[11]="Email";
	arrText[12]="Câu hỏi";
	if(document.getElementById(field).value=='' || document.getElementById(field).value==arrText[item])
	{
		//alert(document.getElementById("Name").value);
		//alert(field);
		document.getElementById(field).value=arrText[item];
	}
	//arrText[12]="";
}

function ShowSearch()
{
	if ((s=GetPostVariable('s', ''))!='')
	{
		s = unescape(s);
	}

	s=UnicodeGet(s);

	document.writeln('<Table width="177" cellpadding=0 cellspacing=0 border=0 background="/Images/Exchange/bg_body.gif" align=center>')
	document.writeln('<tr height=1><td width="100%" bgcolor="#8e908f"></td></tr>');
	document.writeln('<Table>');	
	document.writeln('<Table width="100%" height=24 cellpadding=0 cellspacing=0 border=0>');
	document.writeln('<form method="POST" name="Search" onSubmit="return SearchMe(document.Search.TSearch.value, 1)">');	
	document.writeln('<tr>');
	document.writeln('<td width=1 background="/Images/bg_rightleftheader.gif"></td>');
	document.writeln('<td valign=middle>');
	document.writeln('<Table width="177" cellpadding=0 cellspacing=0 border=0 >')	
	document.writeln('<tr>')
	document.writeln('<td width="100%"><input type=text name="TSearch" id="TSearch" class="SearchBox" onfocus="SearchOnFocus(this)" onkeyup="initTyper(this)" onblur="SearchOnBlur(this)" value="Tìm kiếm"></td>');
	document.writeln('<td align="right"><a href="javascript:SearchMe(document.Search.TSearch.value, 1)"><img src="/Images/Exchange/SearchMuaBan.gif" border=0></a></td>');
	document.writeln('</tr><tr><td height="1" bgcolor="#000000" colspan=2 width="100%"></td></tr>');
	document.writeln('</Table>');
	document.writeln('</td>');
	document.writeln('<td width=6 background="/Images/bg_rightrightheader.gif"></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(formname, saction) {
    sform = document.forms[formname];
    if (saction == 0) {
        if (sform.fvotefor.value == '') {
            alert('Hay chon mot trong cac muc truoc khi bieu quyet');
            return;
        }
    }

    var form = sform;
    var j = 0
    for (i = 0; i < form.elements.length - 2; i++) {
        if (form.elements[i].type == 'checkbox') {
            j = j + 1
        }
    }
    var sheight = (j * 30) + 80;
	//alert(sheight);
    if (sheight < 280) {
        sheight = 280;
    }
    open('', sform.name, 'scrollbars=yes,resizeable=no,locationbar=no,width=550,height=' + sheight + ',left='.concat((screen.width - 500) / 2).concat(',top=').concat((screen.height - 250) / 2));
    sform.faction.value = saction;
    sform.action = 'http://srv.dothi.net/user/vote/';
    sform.submit();
}


function CheckThisVote(field)
{

	form = field.form;
	
	form.fvotefor.value = field.value;
	
	for (var i=0; i < form.elements.length; i++)
	{
		if(form.elements[i].type=='checkbox')
			if (form.elements[i] != field)
				if (form.elements[i].checked)
					form.elements[i].checked = false;
	}
}


function AddVote(SubjectID, PageID, VoteID, Align, VoteTitle, Color, BgColor, Width, NumItem, ItemArray, Description, Column) {
    var strHTML = "";
	RelatedFolder=1;
    if (RelatedFolder == 1) {
		strHTML += '<div class="voteDiv">';
		strHTML += '<table cellpadding="0" cellspacing="0" width="100%">';
		strHTML += '<form method="POST" style=""margin:0px; padding:0px;"" target="Frm_' + VoteID + '" name="Frm_' + VoteID + '">';
		strHTML += '	<tr class="VoteTop">';
		strHTML += '		<td class="VoteTopLeft"></td>';
		strHTML += '		<td class="VoteTopCenter">';
		strHTML += '			<div class="Title">Thăm dò ý kiến</div>';
		strHTML += '			<div class="lineVote"></div>';
		strHTML += '			<div class="voteQuestion"><Table cellspacing=0 cellpadding=3 width="100%"><tr><td class=BoxTitle style="color: ' + Color + '">' + VoteTitle + '</td></tr></Table></div>';
		strHTML += '		</td>';
		strHTML += '		<td class="VoteTopRight"></td>';
		strHTML += '	</tr>';
		strHTML += '	<tr>';
		strHTML += '		<td class="VoteMidLeft"></td>';
		strHTML += '		<td bgcolor="#FFFFFF">';
		strHTML += '<table border=0 cellpadding=0 cellspacing=0 width="100%" >';

        strHTML += '<input type="hidden" name="fsubjectid" value=' + SubjectID + '>';
        strHTML += '<input type="hidden" name="fpageid" value=' + PageID + '>';
        strHTML += '<input type="hidden" name="fvoteid" value=' + VoteID + '>';
        strHTML += '<input type="hidden" name="fvotetitle" value="' + ReplaceAll(VoteTitle, '"', '&quot;') + '">';
        strHTML += '<input type="hidden" name="fvotefor" value="">';
        strHTML += '<input type="hidden" name="faction" value="0">';
        strHTML += '<input type="hidden" name="fDescription" value="' + ReplaceAll(Description, '"', '&quot;') + '">';

        strHTML += '<input type="hidden" name="fnumitem" value=' + NumItem + '>';
        strHTML += '<tr><td>';
        strHTML += '<table width="100%" cellspacing=0 cellpadding=0 border=0>';

        var i, j, k;

        for (i = 0; i < NumItem; ) {
            strHTML += '<tr>';

            for (j = 0; j < Column && i < NumItem; j++, i++) {
                strHTML += '<input type="hidden" name="fT_' + i + '" value="' + ReplaceAll(ItemArray[i][0] + '"', '&quot;') + '">\n';
                strHTML += '<input type="hidden" name="fI_' + i + '" value="' + ItemArray[i][1] + '">';
                strHTML += '<input type="hidden" name="fN_' + i + '" value="' + ItemArray[i][2] + '">\n';
                strHTML += '<td valign=top width=20 align=right class="inputRadio"><input type="checkbox" name="fC_' + i + '" value=' + ItemArray[i][2] + '  onClick="CheckThisVote(this)"></td>';
                if (i + 1 < NumItem || Column == 1) {
                    strHTML += '<td class=RadioVote>' + ItemArray[i][0] + '</td>\n';

                }
                else {
                    strHTML += '<td colspan=' + (Column - j - 1) * 2 + ' class="RadioVote">' + ItemArray[i][0] + '</td>';
                }
            }

            strHTML += '</tr>';
        }

        strHTML += '</table>';
        strHTML += '</td></tr>';

        strHTML += '<tr><td width="100%" height=10px></td></tr>';
        strHTML += '<tr><td width="100%" height=40 align="center">&nbsp;<img style="cursor:pointer" src="/Images/Home/CommentVote.gif" onClick="SubmitVote(\'Frm_' + VoteID + '\', 0) "/> <img  style="cursor:pointer"  src="/Images/Home/ViewResult.gif" onClick="SubmitVote(\'Frm_' + VoteID + '\', 1) " /></td></tr>';
        strHTML += '</table>';
		strHTML += '		</td>';
		strHTML += '		<td class="VoteMidRight"></td>';
		strHTML += '	</tr>';
		strHTML += '	<tr>';
		strHTML += '		<td class="VoteBottomLeft"></td>';
		strHTML += '		<td class="VoteBottomMid"></td>';
		strHTML += '		<td class="VoteBottomRight"></td>';
		strHTML += '	</tr>';
		 strHTML += '</form>';
		strHTML += '</table>';
		strHTML += '</div>';
		document.writeln(strHTML);
    }
    else {
        document.writeln('<table border="0" width="', Width, '" cellpadding="0" cellspacing="0">');
        document.writeln('<tr>');
        document.writeln('<td class="tblVoteTopLeft"></td>');
        document.writeln('<td class="tblVoteTopBg"><div class="DivIconBinhChon"></div></td>');
        document.writeln('<td class="tblVoteTopRight"></td>');
        document.writeln('</tr>');
        document.writeln('<tr>');
        document.writeln('<td class="tblVoteLeftBg"></td>');
        document.writeln('<td class="tblVoteBg">');
        document.writeln('<table border=0 cellspacing=0 cellpadding=1', (Align == '') ? '' : ' align='.concat(Align), '>');
        if (VoteTitle != '') {
            document.writeln('<tr><td><Table cellspacing=0 cellpadding=3 width="100%"><tr><td><p class=BoxTitle style="color: ', Color, '">', VoteTitle, '</p></td></tr></Table></td></tr>');
        }

        if (typeof (Description) == 'undefined') {
            Description = '';
        }

        if (typeof (Column) == 'undefined') {
            Column = 1;
        }

        document.writeln('<tr border=1>');
        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%">');

        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="', ReplaceAll(VoteTitle, '"', '&quot;'), '">');
        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="', ReplaceAll(Description, '"', '&quot;'), '">');

        document.writeln('<input type="hidden" name="fnumitem" value=', NumItem, '>');
        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="', ReplaceAll(ItemArray[i][0], '"', '&quot;'), '">');
                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], '  onClick="CheckThisVote(this)"></td>');
                if (i + 1 < NumItem || Column == 1) {
                    document.writeln('<td class=VoteItem>', ItemArray[i][0], '</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%" height=15px></td></tr>');
        document.writeln('<tr><td width="100%" height=40>&nbsp;<img style="cursor:pointer" src="/Images/Bottom/btnBieuQuyet.gif" width="60" height="22" onClick="SubmitVote(\'Frm_', VoteID, '\', 0) "/> <img  style="cursor:pointer"  src="/Images/Bottom/btnXemKetQua.gif" width="68" height="22" onClick="SubmitVote(\'Frm_', VoteID, '\', 1) " /></td></tr>');
        document.writeln('</table>');
        document.writeln('</td>');
        document.writeln('</form>');
        document.writeln('</tr>');
        document.writeln('</table>');        
        document.writeln('</td>');
        document.writeln('<td class="tblVoteRightBg"></td>');
        document.writeln('</tr>');
        document.writeln('<tr>');
        document.writeln('<td class="tblVoteBottomLeft"></td>');
        document.writeln('<td class="tblVoteBottomBg">&nbsp;</td>');
        document.writeln('<td class="tblVoteBottomRight"></td>');
        document.writeln('</tr>');
        document.writeln('</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 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 ShowAdWordByCate(Field)
{
	
	if (Field>0)
	{
	 location.replace(SetParameter('/User/Mua-ban/Source/List.Asp', 'c', Field.options[Field.selectedIndex].value));
	}
	else	
	{
		location.replace("http://dothi.net/User/Mua-ban/");
	}
}

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(location.href.concat('?q=1'), '_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://'+sDomain+'/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.dothi.net/User/EmailSubject/?u='.concat(escape(location.href)), 0, 0, 0, 0, 0, 0, 1, 1, 500, 480, 0, 0, '', 0);
	openMeExt('http://'+sDomain+'/Service/EmailSubject/?u='.concat(escape(location.href)), 0, 0, 0, 0, 0, 0, 1, 1, 500, 480, 0, 0, '', 0);
	return false;
}

function openPopup(vImage, vLink, vTitle, vHeight, vWidth, vTop, vLeft, vHide)
{
	if (typeof(vHide) == 'undefined')
	{
		vHide = 0;
	}

	if (vHide)
	{
		var pw = open('/Library/Popup.Asp?vImage='.concat(escape(vImage)).concat('&vLink=').concat(escape(vLink)).concat('&vTitle=').concat(escape(vTitle)), 'Popup_'.concat(ReplaceAll(vTitle, ' ', '_')), 'status=no,resizable=no,scrollbars=no,toolbar=no,location=no,fullscreen=no,titlebar=yes,height='.concat(vHeight).concat(',').concat('width=').concat(vWidth).concat(',').concat('top=').concat(screen.height).concat(',').concat('left=').concat(screen.width));
		//window.focus();
		pw.moveTo(vLeft, vTop);
		return pw;
	}
	else
	{
		return open('/Library/Popup.Asp?vImage='.concat(escape(vImage)).concat('&vLink=').concat(escape(vLink)).concat('&vTitle=').concat(escape(vTitle)), 'Popup_'.concat(ReplaceAll(vTitle, ' ', '_')), 'status=no,resizable=no,scrollbars=no,toolbar=no,location=no,fullscreen=no,titlebar=yes,height='.concat(vHeight).concat(',').concat('width=').concat(vWidth).concat(',').concat('top=').concat(vTop).concat(',').concat('left=').concat(vLeft));
	}
}

function ShowPopupAd()
{
	if (typeof(RefAPopup) == 'undefined')
		return;
	
	if (RefAPopup.length==0)
		return;
	
	vIndex = RefAPopup[0][2].lastIndexOf(',');
	vID = RefAPopup[0][2].substr(vIndex + 2);
	sLink = 'http://srv.dothi.net/Counter/?n='.concat(vID).concat('&u=').concat(escape(RefAPopup[0][1])).concat('&r=').concat(Math.random());
	openPopup(RefAPopup[0][0], sLink, 'Advertisment', 120, 130, screen.height - 120 - 80, (screen.width - 770)/2 + 130 + 410 - 5 - 130);
	//parent.document.focus();
}

function AddLineSpace(height)
{
	document.writeln('<tr><td class=BreakLine height=', (typeof(height)=='undefined' ? 1 : height), '></td></tr>');
}

function ShowMenuAd()
{
	var i;
	if (typeof(RefAdMenu) == 'undefined')
		return;

	if (RefAdMenu.length==0)
		return;
	
	for (i=0; i < RefAdMenu.length; i++)
	{
		w = 130;
		h = RefAdMenu[i][4];
		document.writeln('<tr>');
		document.writeln('<td colspan=2>');
		document.writeln('<a href="', RefAdMenu[i][1], '" onClick="return openMeExt(this, ', RefAdMenu[i][2], ', 1)"><img align=center src="', PageHost.concat(RefAdMenu[i][0]), '" width=', w, ' height=', h, ' border=0></a>');
		document.writeln('</td></tr>');
		AddLineSpace();	
	}
}

/*
function ShowFooterAd()
{
	function FooterAdRef(vID)
	{
		if (typeof(RefFooter) == 'undefined')
		{
			return '<table border=1 cellpadding=10 width="100%" height='.concat((vID==0 || vID==4) ? 130: 60).concat('><tr><td class=ColTitle><a href="http://'+sDomain+'/Advertising" class=PnLTitle>D&#224;nh cho Qu&#7843;ng c&#225;o</a></td></tr></table>');
		}

		if (RefFooter[vID][1] != '')
		{
			return '<a href="'.concat(RefFooter[vID][1]).concat('" onClick="return openMeExt(this, ').concat(RefFooter[vID][2]).concat(', 1)"><img src="').concat(PageHost).concat(RefFooter[vID][0]).concat('" border=0 width=130 height=60></a>');
		}
		else
		{
			return '<img src="'.concat(PageHost).concat(RefFooter[vID][0]).concat('" border=0 width=130 height=60>');
		}
	}

	document.writeln('<table border=0 cellpadding=0 cellspacing=0 width=770 height=136>');
	document.writeln('<tr>');
	document.writeln('<td>');
	document.writeln('<table border=0 cellpadding=0 cellspacing=0 width=770 height=130>');
	document.writeln('<tr>');
	document.writeln('<td rowspan=2 width=130>', FooterAdRef(0), '</td>');
	document.writeln('<td class=BreakLine rowspan=2 width=10>&nbsp;</td>');
	document.writeln('<td width=130 valign=top>', FooterAdRef(1), '</td>');
	document.writeln('<td class=BreakLine rowspan=2 width=10>&nbsp;</td>');
	document.writeln('<td width=130 valign=top>', FooterAdRef(2), '</td>');
	document.writeln('<td class=BreakLine rowspan=2 width=10>&nbsp;</td>');
	document.writeln('<td width=130 valign=top>', FooterAdRef(3), '</td>');
	document.writeln('<td class=BreakLine rowspan=2 width=10>&nbsp;</td>');
	document.writeln('<td rowspan=2 width=210>', FooterAdRef(4), '</td>');
	document.writeln('</tr>');
	document.writeln('<tr>');
	document.writeln('<td width=130 valign=bottom>', FooterAdRef(5), '</td>');
	document.writeln('<td width=130 valign=bottom>', FooterAdRef(6), '</td>');
	document.writeln('<td width=130 valign=bottom>', FooterAdRef(7), '</td>');
	document.writeln('</tr>');
	document.writeln('</table>');
	document.writeln('</td>');
	document.writeln('</tr>');
	document.writeln('</table>');
}
*/
function ShowFooterAd()
{
	if (typeof(RefFooter) == 'undefined')
		return;
	
	alert	

	function FooterAdRef(vID)
	{
		if (RefFooter[vID][1] != '')
		{
			return '<a href="'.concat(RefFooter[vID][1]).concat('" onClick="return openMeExt(this, ').concat(RefFooter[vID][2]).concat(', 1)"><img src="').concat(PageHost).concat(RefFooter[vID][0]).concat('" border=0></a>');
		}
		else
		{
			return '<img src="'.concat(PageHost).concat(RefFooter[vID][0]).concat('" border=0>');
		}
	}

	document.writeln('<table border=0 cellpadding=2 cellspacing=0 width=770>');
	document.writeln('<tr>');
	document.writeln('<td>', FooterAdRef(0), '</td>');
	document.writeln('</td>');
	document.writeln('</tr>');
	document.writeln('</table>');
}

function formatNumber(iVal)

{

		var iStr=iVal.toString();
		var aStr='';
		var oStr='';
		var rPos=0;
		
		while (((rPos=iStr.indexOf(',')) >= 0))
		iStr=iStr.substr(0, rPos) + iStr.substr(rPos + 1);

		if ((rPos=iStr.indexOf('.')) >= 0)
		{
			pStr=iStr.substr(rPos + 1);
			iStr=iStr.substring(0, rPos);
		}
		else

		{
			pStr='';
		}

		if (iStr.substr(0, 1)=='-')
		{
			aStr='-';
			iStr=iStr.substr(1);
		}

		while (iStr.length > 0)
		{
			oStr=(oStr.length==0) ? iStr.substr(iStr.length - 3) : iStr.substr(iStr.length - 3) + ',' + oStr;
			iStr=iStr.substr(0, iStr.length - 3);
		}
		return (pStr=='') ? aStr + oStr : aStr + oStr + '.' + pStr;

}
function ShowDivLogoLeft()
{
	if (RefDiLeft.length==0) return;
	var alLeftFloatBanner = new adlistshow(RefDiLeft,'LeftFloatLogo',0,2,0,115,500);
}
function ShowDivLogoRight()
{
	if (RefDRight.length==0) return;	
	var alRightFloatBanner = new adlistshow(RefDRight,'RightFloatLogo',0,3,0,115,500);
}

function gmobj(o){
	if(document.getElementById){ m=document.getElementById(o); }
	else if(document.all){ m=document.all[o]; }
	else if(document.layers){ m=document[o]; }
	return m;
}
function Refresh() {
    var str = location.href;
    var pos = str.indexOf('?');
    if (pos == -1) {
        pos = str.length;
    }
    location.href = str.substring(0, pos);
    return false;
}
function SearchClick() {
    if (document.SearchForm.KeySearch.value == "") {
        alert("Hay nhap tu khoa tim kiem");
        return false;
    }
    var s = escape(UnicodeSet(document.SearchForm.KeySearch.value))
    var str = "?p=1&ps="+document.getElementById("RowsSelect").value+"&r=1&a=1&sD=" + document.SearchForm.fStartDate.value + "&eD=" + document.SearchForm.fEndDate.value + "&s=" + s
    location.href = str
    return false;
}
function Search() {
    //escape(UnicodeSet(s))
    var str = location.href;
    var pos = str.indexOf('ps=')
    if (pos == -1) {
        pos = str.indexOf('&');
        str = str.replace(str.substring(0, pos), "?p=1&ps=" + document.NumberOfRow.RowsSelect.value);
    }
    else {
        var posnext = str.indexOf('&r');
        var posprev = str.indexOf('?p');
        str = str.replace(str.substring(posprev, posnext), "?p=1&ps=" + document.NumberOfRow.RowsSelect.value);
    }
    location.href = str
    return false;
}
function XMLHTTPRequest(url) 
{
	// Nếu dành cho trình duyệt Mozilla 
	if (window.XMLHttpRequest) 
	{
		req = new XMLHttpRequest();
		req.onreadystatechange = processReqChange;
		req.open("GET", url, true);
		req.send(null);
	// Dùng cho IE
	} 
	else 
	if (window.ActiveXObject) 
	{
		req = new ActiveXObject("Microsoft.XMLHTTP");
		if (req) {
			req.onreadystatechange = processReqChange;
			req.open("GET", url, true);
			req.send();
		}
	}
}
function processReqChange() 
{
	if (req.readyState == 4) // Nếu máy chủ trả về dữ liệu
	{
		if (req.status == 200) 
		{
			response  = req.responseText;
			//alert(response);
			//if (response=="1") 
			//{
				//document.getElementById('username').focus();
				document.getElementById('trProvinceList').innerHTML=response;
			//}
			//else
			//{
				//document.getElementById('Message').style.display='none';
			//}					
			
		} 
		else 
		{
			alert("Có vấn đề ở phía máy chủ :\n" + req.statusText);
		}
	}
}
function checkProvince(input)
{
	//alert(input);
	//return;
	if(input!='')
	{
	    url = '/User/Mua-ban/Source/Check/CheckProvince.asp?Id=' + input;
	    //alert(url);
		XMLHTTPRequest(url);
	}
	else
	{
	
	}	  	
}

function DisplayUnderTopBanner(rbn,vAd)
{
            if (RefVal10.length ==0)
            {           
            
                        document.write('<table cellspacing=0 cellpadding=1 border=0 width=500 height=60 bgcolor="#c0c0c0"><tr><td valign=top><table cellspacing=0 cellpadding=0 border=0 width="498" height="58"><tr><td bgcolor="#ffffff" align=center class=Hotnew_lead><a href="/Advertising" class=Hotnew_lead>D&#224;nh cho Qu&#7843;ng c&#225;o</a></td></tr></table></td></tr></table>');

                        return;
            }
            
            var alTopRightBanner = new adlistshow(RefVal10,'Top Right Banner',vAd,0,0,468,60);          
}


var Url = {

    // public method for url encoding
    encode: function(string) {
        return escape(this._utf8_encode(string));
    },

    // public method for url decoding
    decode: function(string) {
        return this._utf8_decode(unescape(string));
    },

    // private method for UTF-8 encoding
    _utf8_encode: function(string) {
        string = string.replace(/\r\n/g, "\n");
        var utftext = "";

        for (var n = 0; n < string.length; n++) {

            var c = string.charCodeAt(n);

            if (c < 128) {
                utftext += String.fromCharCode(c);
            }
            else if ((c > 127) && (c < 2048)) {
                utftext += String.fromCharCode((c >> 6) | 192);
                utftext += String.fromCharCode((c & 63) | 128);
            }
            else {
                utftext += String.fromCharCode((c >> 12) | 224);
                utftext += String.fromCharCode(((c >> 6) & 63) | 128);
                utftext += String.fromCharCode((c & 63) | 128);
            }

        }

        return utftext;
    },

    // private method for UTF-8 decoding
    _utf8_decode: function(utftext) {
        var string = "";
        var i = 0;
        var c = c1 = c2 = 0;

        while (i < utftext.length) {

            c = utftext.charCodeAt(i);

            if (c < 128) {
                string += String.fromCharCode(c);
                i++;
            }
            else if ((c > 191) && (c < 224)) {
                c2 = utftext.charCodeAt(i + 1);
                string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
                i += 2;
            }
            else {
                c2 = utftext.charCodeAt(i + 1);
                c3 = utftext.charCodeAt(i + 2);
                string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
                i += 3;
            }

        }

        return string;
    }

}