function showDateVN()
{
	var strdate;
	var dt = new Date();
              var strarrDay = new Array("Chủ nhật", "Thứ hai", "Thứ ba", "Thứ tư", "Thứ năm", "Thứ sáu", "Thứ bảy"); 
              var strarrMonth = new Array("01","02","03","04","05","06","07","08","09","10","11","12"); 
              var strThu = dt.getDay();
              strThu = strarrDay[strThu] + ", ";
              var strDay=dt.getDate();
              if (strDay<10) strDay="0" + strDay
              var strMonth= dt.getMonth();
              strMonth= strarrMonth[strMonth] ;
              var strYears = dt.getYear();
              if (strYears<1900) strYears += 1900;
              strdate=strThu + " " + strDay + "/" + strMonth + "/" + strYears
              window.document.write (strdate);
}
function showDateEN()
{
	var strdate;
	var dt = new Date();
              var strarrDay = new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"); 
              var strarrMonth = new Array("01","02","03","04","05","06","07","08","09","10","11","12"); 
              var strThu = dt.getDay();
              strThu = strarrDay[strThu] + ", ";
              var strDay=dt.getDate();
              if (strDay<10) strDay="0" + strDay
              var strMonth= dt.getMonth();
              strMonth= strarrMonth[strMonth] ;
              var strYears = dt.getYear();
              if (strYears<1900) strYears += 1900;
              strdate=strThu + " " + strMonth + "/" + strDay + "/" + strYears
              window.document.write (strdate);
}
function showDateCN()
{
	var strdate;
	var dt = new Date();
              var strarrDay = new Array("星 期 日", "星 期 一", "星 期 二", "星 期 三", "星 期 四", "星 期 五", "星 期 六"); 
              var strarrMonth = new Array("01","02","03","04","05","06","07","08","09","10","11","12"); 
              var strThu = dt.getDay();
              strThu = strarrDay[strThu] + ", ";
              var strDay=dt.getDate();
              if (strDay<10) strDay="0" + strDay
              var strMonth= dt.getMonth();
              strMonth= strarrMonth[strMonth] ;
              var strYears = dt.getYear();
              if (strYears<1900) strYears += 1900;
              strdate=strThu + " " + strDay + "/" + strMonth + "/" + strYears
              window.document.write (strdate);
}
function openpage(pageurl, pagename, pagewidth, pageheight) 
{                                          
	var attr;                                          
	attr="width="+pagewidth+",height="+pageheight+",scrollbars=yes,status=no,title=yes,toolbars=yes,resizable=no";
	window.open(pageurl, pagename, attr);                                          
}

function GetPage(C,P)
{
	var frmSubmit=document.frmWebsite;
	frmSubmit.action="default.aspx?c=" + C + "&p=" + P + "#content";
	frmSubmit.submit();
}

function GetPage1(P)
{
	var frmSubmit=document.frmWebsite;
	frmSubmit.action="default.aspx?s=1&st=1&p=" + P + "#content";
	frmSubmit.submit();
}

function GetPage2(T,P)
{
	var frmSubmit=document.frmWebsite;
	frmSubmit.action="default.aspx?topic_id=" + T + "&p=" + P + "#content";
	frmSubmit.submit();
}

function GetPage3(P)
{
	var frmSubmit=document.frmWebsite;
	frmSubmit.action="default.aspx?s=1" + "&p=" + P + "#content";
	frmSubmit.submit();
}

function doAdvanceSearch()
{
	frmWebsite.action="default.aspx?s=1&st=1#content";
	frmWebsite.submit();
}

function trim(text)
{
	pos1=0;
	pos2=text.length-1;
	for(i=0;i<=text.length-1;i++)
		if(text.substr(i,1)==" ") pos1=i;
		else break;
	for(i=length-1;i>=0;i--)
		if(text.substr(i,1)==" ") pos2=i;
		else break;
	if (pos2<pos1) return "";
	return text.substr(pos1,pos2-pos1);
}

function trimstring(strin)
{ 
	var strtemp;
	var i; 
	strtemp="";
	i=0;
	if (strin.charAt(i)!=" "){strtemp=strtemp+strin.charAt(i);}
	for (var i=1;i<strin.length-1;i++){
		if (strin.charAt(i)==" "){
			if (strin.charAt(i+1)!=" ") {strtemp=strtemp+strin.charAt(i)}
		}
		else {strtemp=strtemp+strin.charAt(i)} 
	}
	i=strin.length;
	if (strin.charAt(i)!=" "){strtemp=strtemp+strin.charAt(i)}
	return strtemp; 
}

function image_change(objImg, strImgPath, intProID, intCount, strArr)
{   
	var a = new Array();
	var k;
	//l=strArr.length;
	a=strArr.split(",");

	var objText;
	objImg.src=strImgPath;
	
	for (k=1;k<=intCount;k++) 
	{	
		objText = 'tbd_' + a[k];
		var g=document.all(objText);
		if (a[k]==intProID)
		{
			g.style.display='block';
		}
		else
		{
			g.style.display='none';
		}
	}	
	return true;
}

function image_firstshow(objImg, strImgPath, intProID, intCount, strArr, intCurProID)
{   
	if (intCurProID==intProID)
	{
		var a = new Array();
		var k;
		//l=strArr.length;
		a=strArr.split(",");

		var objText;
		objImg.src=strImgPath;

		for (k=1;k<=intCount;k++) 
		{	
			objText = 'tbd_' + a[k];
			var g=document.all(objText);
			if (a[k]==intProID)
			{
				g.style.display='block';
			}
			else
			{
				g.style.display='none';
			}
		}
	}	
	return true;
}

function menu_show(intCatID ,intCount, strArr)
{   
		var a = new Array();
		var k;
		//l=strArr.length;
		a=strArr.split(",");

		var objText;
		for (k=1;k<=intCount;k++) 
		{	
			objText = 'tbcat_' + a[k];
			var g=document.all(objText);
			if (a[k]==intCatID)
			{	//if (g.style.display=='none')
				//{
					g.style.display='block';										
				}
				else
				{
					g.style.display='none';					
				//}				
			}			
		}				
	return true;
}

function menu_showfirst(intCatID)
{   
	var objText;
	objText = 'tbcat_' + intCatID;
	var g=document.all(objText);		
	g.style.display='block';		
	return true;
}


		function doClick(ctrlName, e)
		{
			var key;
			if (window.event)
				key=window.event.keyCode;
			else
				key=e.which;					
			
			if (key == 13)
			{
				//Get the button the user wants to have clicked
				var ctrl = document.getElementById(ctrlName);
				if (ctrl != null)
				{ //If we find the button click it
					ctrl.focus();
					event.keyCode = 0;
				}				
			}
		}
		
		function doSubmit(btnName, e)
		{
			var key;
			if (window.event)
				key=window.event.keyCode;
			else
				key=e.which;
			 if (key == 13)
			{
				//Get the button the user wants to have clicked
				var btn = document.getElementById(btnName);
				if (btn != null)
				{ //If we find the button click it
					btn.click();
					event.keyCode = 0;
				}
			}
		}						
		
function popupImage(src, note, title, css, border) 
{
    var ppimgNW;
    if (border==null) border = 0;
    if (note==null) note = '';
    if (ppimgNW != null) ppimgNW.close();
    ppimgNW = window.open('','_blank','width=500,height=500');
    var doc = ppimgNW.document;
    doc.write('<html>');
    doc.write('<head>');
    if (title!=null) doc.write('<title>'+ title +'</title>');
    doc.write('<style> body {'+css+'} #ppImgText{'+ css +'} #ppImg{cursor:hand}</style></head>');
    doc.write('<body leftmargin="0" topmargin="' + border + '" onload="doResize();">');
    doc.write('<div align="center" >');
    doc.write('<img src="' + src + '" id="ppImg" onclick="self.close();" title="Close">');
    doc.write('</div>');
    doc.write('<div style="height:1; width:' + border + '; font-size:4pt;">');
    doc.write('</div>');
    doc.write('<div id="ppImgText" align="center" >');
    doc.write(note);
    doc.write('</div>');
    doc.write('</body>');
    doc.write('</html>');
    doc.write('<' + 'script>');
    doc.write('function doResize() {');
    doc.write('  var imgW = ppImg.width, imgH = ppImg.height;');   
    doc.write('  window.resizeTo(imgW + 24 +' + border*2 +', imgH + ppImgText.offsetHeight + 54 + '+ border*2 +');');
    doc.write('  setTimeout(\'doResize()\', 1000);');
    doc.write('}');
    doc.write('doResize(); ');
    doc.write('</' + 'script>');
}

function checkSearch(MyForm) 
{
	var keyword=trimstring(MyForm.keyword.value);
	if (keyword=="") 
	{ 
		alert("Vui long nhap thong tin de tim kiem"); 
		MyForm.keyword.focus();
		return false; 
	}
	if ((keyword.search("scrip")>=0)||(keyword.search("objec")>=0)||(keyword.search("apple")>=0)||(keyword.search("embe")>=0))
	{
		alert("Thong tin tim kiem khong hop le.");
		MyForm.keyword.focus();
		return false; 
	}
	return true;
}

function checkSearchEN(MyForm) 
{
	var keyword=trimstring(MyForm.keyword.value);
	if (keyword=="") 
	{ 
		alert("Please input your keyword"); 
		MyForm.keyword.focus();
		return false; 
	}
	if ((keyword.search("scrip")>=0)||(keyword.search("objec")>=0)||(keyword.search("apple")>=0)||(keyword.search("embe")>=0))
	{
		alert("Your keyword is not valid.");
		MyForm.keyword.focus();
		return false; 
	}
	return true;
}

function checkSearch_Detail(MyForm) 
{
	var keyword=trimstring(MyForm.keyword.value);
	
	if ((keyword.search("scrip")>=0)||(keyword.search("objec")>=0)||(keyword.search("apple")>=0)||(keyword.search("embe")>=0))
	{
		alert("Thong tin tim kiem khong hop le.");
		MyForm.keyword.focus();
		return false; 
	}
	return true;
}

function doMouseOverMenuLevel2(item)
{
	for(i=0;i<item.children.length;i++) 
	{
		item.children(i).style.cursor='hand'; 
		item.children(i).style.backgroundColor='#FCF8D4'
	}
}
	
function doMouseOutMenuLevel2(item,strBgcolor)
{
	for(i=0;i<item.children.length;i++) 
		item.children(i).style.backgroundColor=strBgcolor
}
	
function doMouseClick(item)
{
	item.firstChild.firstChild.click();
}

function checkFeedbackForm(frmForm)
{
	var fullname;
	var content;
	fullname=trimstring(frmForm.fullname.value);
	if (fullname=="") {
		alert("Vui long nhap ho ten.");
		frmForm.fullname.focus();
		return false;
	}
	if ((fullname.search("scrip")>=0)||(fullname.search("objec")>=0)||(fullname.search("apple")>=0)||(fullname.search("embe")>=0))
	{
		alert("Ho ten khong hop le.");
		frmForm.fullname.focus();
		return false; 
	}
	content=trimstring(frmForm.content.value);
	if (content=="") {
		alert("Vui long nhap noi dung.");
		frmForm.content.focus();
		return false;
	}
	if ((content.search("scrip")>=0)||(content.search("objec")>=0)||(content.search("apple")>=0)||(content.search("embe")>=0))
	{
		alert("Noi dung khong hop le.");
		frmForm.content.focus();
		return false; 
	}
		
	return true;
}

function checkFeedbackFormEN(frmForm)
{
	var fullname;
	var content;
	fullname=trimstring(frmForm.fullname.value);
	if (fullname=="") {
		alert("Please input your fullname.");
		frmForm.fullname.focus();
		return false;
	}
	if ((fullname.search("scrip")>=0)||(fullname.search("objec")>=0)||(fullname.search("apple")>=0)||(fullname.search("embe")>=0))
	{
		alert("Your fullname is not valid.");
		frmForm.fullname.focus();
		return false; 
	}
	content=trimstring(frmForm.content.value);
	if (content=="") {
		alert("Please input your content.");
		frmForm.content.focus();
		return false;
	}
	if ((content.search("scrip")>=0)||(content.search("objec")>=0)||(content.search("apple")>=0)||(content.search("embe")>=0))
	{
		alert("Your content is not valid.");
		frmForm.content.focus();
		return false; 
	}
		
	return true;
}

function Submit_onclick(MyForm)
{ 
	var txtfullname_sender=trimstring(MyForm.fullname_sender.value);
	var txtemail_sender=trimfullstring(MyForm.email_sender.value); 
	var txtfullname_receiver=trimstring(MyForm.fullname_receiver.value); 
	var txtemail_receiver=trimfullstring(MyForm.email_receiver.value); 
	if (txtfullname_sender=="") 
	{ 
		alert ("Vui long cung cap ho ten nguoi gui."); 
		MyForm.fullname_sender.value="";
		MyForm.fullname_sender.focus();
		return false; 
	}
	if (txtemail_sender=="") 
	{ 
		alert ("Vui long cung cap email cua nguoi gui."); 
		MyForm.email_sender.value="";
		MyForm.email_sender.focus(); 
		return false; 
	} 
	if (!isEmail(txtemail_sender))
	{ 
		alert ("Email cua nguoi gui khong hop le."); 
		MyForm.email_sender.focus(); 
		return false; 
	} 
	if (txtfullname_receiver=="") 
	{ 
		alert ("Vui long cung cap ho ten nguoi nhan."); 
		MyForm.fullname_receiver.value="";
		MyForm.fullname_receiver.focus(); 
		return false; 
	} 
	if (txtemail_receiver=="") 
	{ 
		alert ("Vui long cung cap email cua nguoi nhan."); 
		MyForm.email_receiver.value="";
		MyForm.email_receiver.focus(); 
		return false; 
	} 
	if (!isEmail(txtemail_receiver))
	{  
		alert ("Email cua nguoi nhan khong hop le."); 
		MyForm.email_receiver.focus(); 
		return false; 
	} 
	return true; 
} 


function doVoteVN()
{
	alert("Chân thành cám ơn sự quan tâm của bạn!");
	//window.document.frmVoteDetail.action="vote_detail.aspx?action=1";
	//window.document.frmVoteDetail.submit();
	//window.close();
	//return true;
}

function submitVoteVN(intVote_id)
{
	var strItemList;
	window.document.frmWebsite.VoteItem.value = '';
	for (i=0; i < frmWebsite.elements.length - 1; i++)
	{
		if (frmWebsite.elements[i].checked)
			window.document.frmWebsite.VoteItem.value=window.document.frmWebsite.VoteItem.value + ',' + frmWebsite.elements[i].value;
	}
	openpage_noresize('../vi-vn/vote_detail.aspx?vote_id=' + intVote_id + '&action=1' + '&itemlist=' + window.document.frmWebsite.VoteItem.value ,'itemvote','520','310');
}

function doVoteEN()
{
	alert("Thanks for your care!");
	//window.document.frmVoteDetail.action="vote_detail.aspx?action=1";
	//window.document.frmVoteDetail.submit();
	//window.close();
	//return true;
}

function submitVoteEN(intVote_id)
{
	var strItemList;
	window.document.frmWebsite.VoteItem.value = '';
	for (i=0; i < frmWebsite.elements.length - 1; i++)
	{
		if (frmWebsite.elements[i].checked)
			window.document.frmWebsite.VoteItem.value=window.document.frmWebsite.VoteItem.value + ',' + frmWebsite.elements[i].value;
	}
	openpage_noresize('../en/vote_detail.aspx?vote_id=' + intVote_id + '&action=1' + '&itemlist=' + window.document.frmWebsite.VoteItem.value ,'itemvote','520','310');
}

function doVoteCN()
{
	alert("Thanks for your care!");
	//window.document.frmVoteDetail.action="vote_detail.aspx?action=1";
	//window.document.frmVoteDetail.submit();
	//window.close();
	//return true;
}

function submitVoteCN(intVote_id)
{
	var strItemList;
	window.document.frmWebsite.VoteItem.value = '';
	for (i=0; i < frmWebsite.elements.length - 1; i++)
	{
		if (frmWebsite.elements[i].checked)
			window.document.frmWebsite.VoteItem.value=window.document.frmWebsite.VoteItem.value + ',' + frmWebsite.elements[i].value;
	}
	openpage_noresize('../cn/vote_detail.aspx?vote_id=' + intVote_id + '&action=1' + '&itemlist=' + window.document.frmWebsite.VoteItem.value ,'itemvote','520','310');
}