10/10/2018, 10:48

Giúp đỡ code javascript

Mình đang làm một website có sử dụng module thời tiết, tỷ giá. Demo tại đây http://vccicantho.edu.vn/utxivn/ .

Mặc định phần Thời tiết, Tỷ giá và Giá vàng tự xổ ra khi load trang, click vào dấu + thì nó sẽ thu lại .

Bây giờ mình muốn sửa code cho nó thu lại mặc định và xổ ra khi ta bấm vào dấu + .

Đã xăm soi cái file js nhưng mà ko mò được. Bạn nào biết giúp mình với nhé. Dưới đây là mã của file Lib.js .

Code:
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 RefColumn = new Array();
var RefAdLeft = new Array();
var RefURight = new Array();
var RefUColum = new Array();
var RefDRight = new Array();
var RefDiLeft = new Array();
var RefFlLeft = new Array();
var RefAtDate = new Array();
var RefAtQuan = new Array();
var RefAPopup = new Array();
var RefUPopup = new Array();
var RefNormal = new Array();
var RefExpand = new Array();

var LastChild = 0;
var LComplete = 0;

if (typeof(PageHost) == 'undefined') var PageHost = ';
var objXML;
var aFlag=true;

function loadXMLDoc(url, callbackFunction, desc, QUERY_STRING) 
{
	aFlag=false;
	if(desc) window.status = desc;
    // branch for native XMLHttpRequest object
    if (window.XMLHttpRequest) {
        objXML = new XMLHttpRequest();
		objXML.onreadystatechange =	function()
									{
										// only if req shows "complete"
										if (objXML.readyState == 4) {
											eval(callbackFunction);
										}
									}
		if(QUERY_STRING)
		{
		    objXML.open("POST", url, true);
			objXML.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
			objXML.send(QUERY_STRING);
		}
        else
        {
	        objXML.open("GET", url, true);
	        objXML.send(null);
	    }
    // branch for IE/Windows ActiveX version
    } else if (window.ActiveXObject) {
        objXML = new ActiveXObject("Microsoft.XMLHTTP");
        if (objXML) {
        	objXML.onreadystatechange =	function()
										{
											// only if req shows "complete"
											if (objXML.readyState == 4) {
												eval(callbackFunction);
											}
										}
			if(QUERY_STRING)
			{
			    objXML.open("POST", url, true);
				objXML.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
				objXML.send(QUERY_STRING);
			}
			else
			{
			    objXML.open("GET", url, true);
			    objXML.send(null);
			}
        }
    }
}


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 AddHeader(Name, Header, Buttons, Symbol, AddChildTable)
{
	document.writeln('<table width="100%" border=0 cellspacing=0 cellpadding=1 class="title_forex"><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="'+theme+'minus.gif" name="IDI_', Name, '" border=0 alt="Xem|Đóng">');
			document.write('</a></td>');
		}

		document.writeln('</tr></table>');
	}

	//document.writeln('<table width="100%" border=0 cellspacing=0 cellpadding=0 id="tIDM_', Name, '"><tr><td><div class=BreakLine id="IDM_', Name, '">');
	document.writeln('<table width="100%" border=0 cellspacing=0 cellpadding=0><tr><td 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></td></tr></table></td></tr></table>');
	}
	else
	{
		document.writeln('</td></tr></table></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.style.display!=')
	{
		//MItem.setAttribute('style','display:""');
		MItem.style.display=';
		Image.src=theme+'minus.gif';
	}
	else
	{
		//MItem.setAttribute('style','display:none');
		MItem.style.display='none';
		Image.src=theme+'plus.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');
	
	if (RelatedFolder < 1000 )
	{
		location.replace(CurrentFolder.concat('/Default.Asp?d=').concat(escape(LastDate)));
	}
	else
	{
		location.href = SetParameter(location.href, 'd', escape(LastDate));
	}	
	
}

function ShowNextFolderItem(LastDate)
{
	if (RelatedFolder < 1000 )
	{
		location.href = SetParameter(location.href + 'Default.Asp', 'd', escape(LastDate));
	}
	else
	{
		location.href = SetParameter(location.href, 'd', escape(LastDate));
	}	
}

function UnderConst()
{
	alert('Sorry!
This Page is under construction!
Please 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 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) ? 'Đ***243;ng lạ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 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 AddVote(SubjectID, PageID, VoteID, Align, VoteTitle, Color, BgColor, Width, NumItem, ItemArray, Description, Column)
{
	if (RelatedFolder!=500){
		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="ffolder" value="', CurrentFolder, '">');
		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 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="', 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], ' 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ểu quyết" name="Vote" class=VoteButton style="width: 60" onClick="SubmitVote(this.form, 0)">&nbsp;<input type="button" value="Kết quả" name="View" class=VoteButton style="width: 60" 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 height=2 cellspacing=0 cellpadding=0 border=0><tr><td class=BreakLine>&nbsp;</td></tr></table>');
	}
	else{
		document.writeln('<table width="90%" border=0 cellspacing=0 cellpadding=0 align=center bgcolor=white>');
		document.writeln('<tr><td><img src="/Images/Motor-show/VoteTopLeft.gif"></td><td width=100%></td><td><img src="/Images/Motor-show/VoteTopRight.gif"></td></tr>');
		if (VoteTitle!=')
		{
			document.writeln('<tr><td></td><td><p class=BoxTitle style="margin-left: 3; color: #113868">', VoteTitle, '</p></td><td></td></tr>');
		}

		if (typeof(Description)=='undefined')
		{
			Description = ';
		}

		if (typeof(Column)=='undefined')
		{
			Column = 1;
		}

		document.writeln('<tr><td></td>');
		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="ffolder" value="', CurrentFolder, '">');
		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 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="', 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], ' 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ểu quyết" name="Vote" class=VoteButton style="width: 60" onClick="SubmitVote(this.form, 0)">&nbsp;<input type="button" value="Kết quả" name="View" class=VoteButton style="width: 60" onClick="SubmitVote(this.form, 1)"></td></tr>');

		document.writeln('</table>');
		document.writeln('</td>');
		document.writeln('</form>');
		document.writeln('<td></td></tr>');
		document.writeln('<tr><td><img src="/Images/Motor-show/VoteBottomLeft.gif"></td><td width=100%></td><td><img src="/Images/Motor-show/VoteBottomRight.gif"></td></tr>');
		document.writeln('</table>');
		document.writeln('<table height=10 cellspacing=0 cellpadding=0 border=0><tr><td class=BreakLine>&nbsp;</td></tr></table>');
	}
}

function Showsurvey(){
	vWH = 500;
	vWW = 440;
	vWN = 'ContactUs';
	winDef = 'status=no,resizable=no,scrollbars=yes,toolbar=no,location=no,fullscreen=no,titlebar=yes,height='.concat(vWH).concat(',').concat('width=').concat(vWW).concat(',');
	winDef = winDef.concat('top=').concat((screen.height - vWH)/2).concat(',');
	winDef = winDef.concat('left=').concat((screen.width - vWW)/2);
	newwin = open('/Customize/ADSLSurvey/', vWN, winDef);
}

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 Left(str, n)
{
	if (n <= 0)
	    return "";
	else if (n > String(str).length)
	    return str;
	else
	    return String(str).substring(0,n);
}


function Right(str, n)
{
    if (n <= 0)
       return "";
    else if (n > String(str).length)
       return str;
    else {
       var iLen = String(str).length;
       return String(str).substring(iLen, iLen - n);
    }
}

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;
	}
thanks
abcddbca viết 12:52 ngày 10/10/2018
Phần 2 của Code: (dài quá nên tớ phải tách ra)

Code:
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)
{
	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 ShowPopupAd()
{
	if (RefAPopup.length==0) return;
	var alPopupBanner = new adlistshow(RefAPopup,'PopupBanner',0,5,0,0,0);
}

function ShowPopupUnder()
{
	if (RefUPopup.length==0) return;
	//if(VirtualFolder != CurrentFolder) return;
	var alPopUnderBanner = new adlistshow(RefUPopup,'PopUnderBanner',0,6,0,0,0);
}

function AddLineSpace(height)
{
	document.writeln('<tr><td class=BreakLine height=', (typeof(height)=='undefined' ? 1 : height), '></td></tr>');
}

function ShowMenuAd(vAd)
{
	if (typeof(RefAdMenu) == 'undefined') return;
	if (RefAdMenu.length==0) return;
	if (typeof(vAd) == 'undefined') vAd = 0;
	var vCheckShow = 0;
	
	var alMenuBanner = new adlistshow(RefAdMenu,'MenuBanner',vAd,1,0,130,180);
}

function ShowFooterAd(vAd)
{
	if (typeof(RefFooter) == 'undefined') return;
	if (typeof(vAd) == 'undefined') vAd = 0;
	var alFooterBanner = new adlistshow(RefFooter,'FooterBanner',vAd,0,0,770,150);
}

function ShowArticleLogoDate()
{
	if (RefAtDate.length==0) return;
	if (typeof(vAd) == 'undefined') vAd = 0;
	var alArticleDateBanner = new adlistshow(RefAtDate,'ArticleDateBanner',vAd,1,0,400,150);
}

function ShowArticleLogoQuantity()
{
	if (RefAtQuan.length==0) return;
	var alArticleQuantityBanner = new adlistshow(RefAtQuan,'ArticleQuantityBanner',vAd,7,0,400,150);
}
function DisplayBanner(rbn,vAd)
{
	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 class=LeadFront><a href="http://vnexpress.net/Advertising" class=AdTop>D***224;nh cho Quảng c***225;o</a><br>Điện thoại: 091 244 9324  (HN) / 090 810 7277  (HCM)<br><span class=Time>(Th***244;ng tin <b>Rao vặt</b> vui l***242;ng kh***244;ng li***234;n hệ theo số n***224;y)</span></td></tr></table></td></tr></table>');
		return;
	}
	var alTopBanner = new adlistshow(RefBanner,'TopBanner',vAd,0,0,468,60);
}

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(vAd)
{
	if (typeof(vAd) == 'undefined') vAd = 0;
	if (RefAdLeft.length==0){
		document.write('<table width=130 cellspacing=0 cellpadding=0 border=0 bgcolor="#808080">');
		document.write('<tr>');
		document.write('<td valign=top>');
		document.write('<table cellspacing=1 cellpadding=4 border=0 width="100%">');
		document.write('<tr><td height=60 align=center bgcolor="#ffffff"><a href="http://vnexpress.net/Advertising" class=AdTitle>D***224;nh cho <BR>Quảng c***225;o</a></td></tr>');
		document.write('</table>');	
		document.write('</td>');
		document.write('</tr>');
		document.write('</table>');
		return;
	}
	var alLeftBanner = new adlistshow(RefAdLeft,'LeftLogo',vAd,1,0,130,180);
}

function ShowDivLogoLeft()
{
	//if (RefDiLeft.length==0) return;
	if (typeof(vAd) == 'undefined') vAd = 0;
	var slBottomUp = new adlistshow(RefDiLeft,'LeftBottomUp',vAd,4,0,100,180);
}

function ShowDivLogoRight()
{
	if (typeof(vAd) == 'undefined') vAd = 0;
	//if (RefDRight.length==0) return;
	var alRightFloatBanner = new adlistshow(RefDRight,'RightFloatLogo',vAd,3,0,115,500,'showtest');
}

function ShowDivLogoLeftFloat(){
	if (typeof(vAd) == 'undefined') vAd = 0;
	//if (RefFlLeft.length==0) return;
	var alLeftFloatBanner = new adlistshow(RefFlLeft,'LeftFloatLogo',vAd,2,0,100,180);
}

function ShowAdLogoRight(vAd)
{
	var alBigRight = new adlistshow(RefAdLBox,'RightBigLogo',vAd,1,0,210,130);
	var alNormal = new adlistshow(RefNormal,'RightNormal',vAd,9,0,180,150);
	
	if (RefAdLogo.length!=0){
		document.write('<table border="1" width="100%" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#808080">');
		document.write('	<tr>');
		document.write('		<td valign=top>');
		document.write('		<table border="0" width="136" cellspacing="0" cellpadding="0">');
		var alSmallRight = new adlistshow(RefAdLogo,'RightSmallLogo',vAd,1,1,130,100);
		document.write('		</table>');
		document.write('		</td>');
		document.write('		<td width="100%" align="center" valign="top" style="padding-top:4px;" >');
		if (RefColumn.length==0){
			document.write('<table border="0" cellpadding="0" cellspacing="0"><tr><td width=60 height=60 align=center bgcolor="#CC0000"><a href="/Advertising" class=PnDTitle>D***224;nh<BR>cho<BR>Quảng<BR>c***225;o</a></td></tr></table>');
		}
		else{
			var alColumnRight = new adlistshow(RefColumn,'RightColumnLogo',vAd,1,0,60,300);
		}
		document.write('		</td>');
		document.write('	</tr>');
		document.write('</table>');
	}

	/*
	if (RefURight.length!=0){
		document.write('<table border="1" width="100%" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#808080">');
		document.write('	<tr>');
		document.write('		<td valign=top>');
		document.write('		<table border="0" width="136" cellspacing="0" cellpadding="0">');
		var alUnderRight = new adlistshow(RefURight,'UnderRightLogo',vAd,1,0,130,100);
		document.write('		</table>');
		document.write('		</td>');
		document.write('		<td width="100%" align="center" valign="top" style="border-right: 1px solid #808080; border-top: 1px solid #808080; border-bottom: 1px solid #808080; padding-top:4px;" >');
		if (RefColumn.length==0){
			document.write('<table border="0" cellpadding="0" cellspacing="0"><tr><td width=60 height=60 align=center bgcolor="#CC0000"><a href="/Advertising" class=PnDTitle>D***224;nh<BR>cho<BR>Quảng<BR>c***225;o</a></td></tr></table>');
		}
		else{
			var alUnderRightColumn = new adlistshow(RefUColum,'UnderRightColumn',vAd,1,0,60,300);
		}
		document.write('		</td>');
		document.write('	</tr>');
		document.write('</table>');
	}
	*/
	var alUnderRight = new adlistshow(RefURight,'UnderRightLogo',vAd,1,0,210,150);
	
	if (RefAdLBox.length+RefNormal.length+RefAdLogo.length+RefURight.length==0){
		document.write('<table width=210 cellspacing=0 cellpadding=0 border=0 bgcolor="#808080">');
		document.write('<tr>');
		document.write('<td valign=top>');
		document.write('<table cellspacing=1 cellpadding=4 border=0 width="100%">');
		document.write('<tr><td height=64 align=center bgcolor="#ffffff"><a href="/Advertising" class=TopStory>D***224;nh cho Quảng c***225;o</a></td></tr>');
		document.write('</table>');	
		document.write('</td>');
		document.write('</tr>');
		document.write('</table>');
	}
}

[=========> Bổ sung bài viết <=========]

Nhìn có vẻ quá dài nhưng đây là cái Function: ItemMinimize

Code:
 
function ItemMinimize(Name)
{
	if (!fDSp)
	{
		return;
	}

	var MItem=document.getElementById('IDM_'.concat(Name));
	var Image=document.getElementById('IDI_'.concat(Name));
	
	if (MItem.style.display!='')
	{
		//MItem.setAttribute('style','display:""');
		MItem.style.display='';
		Image.src=theme+'minus.gif';
	}
	else
	{
		//MItem.setAttribute('style','display:none');
		MItem.style.display='none';
		Image.src=theme+'plus.gif';
	}
}

[=========> Bổ sung bài viết <=========]

Đây là đoạn code gọi cái Function đó:
Code:
if ((Buttons & 1) && fDSp)
		{
			document.write('<td width=15 align=right>');
			document.write('<a href="JavaScript:ItemMinimize(\x27', Name, '\x27)">');
			document.write('<img src="'+theme+'minus.gif" name="IDI_', Name, '" border=0 alt="Xem|Đóng">');
			document.write('</a></td>');
		}
thuyduongcd viết 12:51 ngày 10/10/2018
Thêm vào cuối trang (trước thẻ </body>) đoạn code sau:
Code:
<script language="javascript">
ItemMinimize('Weather');
ItemMinimize('Gold');
ItemMinimize('Forex');
</script>
abcddbca viết 12:56 ngày 10/10/2018
Cám ơn bạn, mình đã thêm vào nhưng chỉ thấy phần Thời tiết là thu lại . Còn 2 phần kia vẫn mở ra ??

demo: http://vccicantho.edu.vn/utxivn/
thuyduongcd viết 12:50 ngày 10/10/2018
Cách 2:
Mở file Gold.js, thêm dòng:
Code:
ItemMinimize('Gold');
Vào phía dưới dòng:
ShowGoldPrice();
Cách 3:
Trong hàm AddHeader(), tìm dòng:
document.writeln('<table width="100%" border=0 cellspacing=0 cellpadding=0><tr><td id="IDM_', Name, '">');
Thay bằng:
Code:
document.writeln('<table width="100%" border=0 cellspacing=0 cellpadding=0><tr><td id="IDM_', Name, '" style="display:none">');
abcddbca viết 12:51 ngày 10/10/2018
Cám ơn ThuyDuongCD nhé .

working well .

all the best to you .
Bài liên quan
0