// var NhanDanMenus = new Array();
// var SiteLogos = new Array();
 var RefCurrentDate = '';
 var err1 = 'Ban can phai chon Chuyen muc can xem !!!';

 function ViewByDate(theDate, theMonth, theYear, theCat)
 {
 	if (theDate == 0) {
 		theDate = RefCurrentDate.substring(0, 2);
 	}
 	if (theMonth == 0) {
 		theMonth = RefCurrentDate.substring(2, 4);
 	}
 	if (theYear == 0) {
 		theYear = RefCurrentDate.substring(4, 6);
	}

	var homepage = 1;
	for(var i=0; i < NhanDanBar.length; i++) {
		if (window.location.href.indexOf(NhanDanBar[i]) >= 0) {
			hompage = 0;
		}
	}

	if (theCat == 0 && homepage) {
		alert(err1);
		return false;
	}

	theURL = '/english/' + theCat + '/' + theDate + theMonth + theYear + '/' + 'list.htm';
	window.open(theURL,'_self');
}

// function DrawLinkBox()
// {
//
// for(var i=0; i < NhanDanBar.length; i++) {
//	if (window.location.href.indexOf(NhanDanBar[i]) >= 0) {
//		document.Reverse.fCat.selectedIndex = i+1;
//	}
// }
// }

function DisplayNhanDanSymbols(theArray)
{
	var theleftmenu = '/english/images/left_menu/';
	
	document.write('<table border="0" cellpadding="0" cellspacing="0" widh="100%">');

	for(var i=0; i < theArray.length; i++) {
		var theImg = theleftmenu + theArray[i][1];
		if (theArray[i][2] != '')
		{
			var theOver= theleftmenu + theArray[i][2];
		}
		else
		{
			var theOver = '';
		}
		var theURL = theArray[i][3];
		DisplayMenuImage(theImg,theOver,theURL);
	}
	document.write("</table>");
//	DrawLinkBox();
}

function DisplayNhanDanMenus(thePage,theArray)
{
	var thePath = '/english/images/left_menu/';

	document.write('<table border="0" cellpadding="0" cellspacing="0" widh="100%">');

	for(var i=0; i < theArray.length; i++) {
		if (theArray[i][0] != '')
		{
			if(thePage == theArray[i][0]) {
				var theImg = thePath + theArray[i][3];
			}
			else
			{
				var theImg = thePath + theArray[i][1];
			}
			
			if (theArray[i][2] != '')
			{
				var theOver= thePath + theArray[i][2];
			}
			else
			{
				var theOver= '';
			}
			if(theArray[i][5]) {
				if(theArray[i].length < 6) {
					var theURL = nhandan_URL(theArray[i][4]);
				} else {
					var theURL = nhandan_URL(theArray[i][4],theArray[i][6]);
				}
			} else {
				var theURL = theArray[i][4];
			}
			DisplayMenuImage(theImg,theOver,theURL);
		}
		else
		{
			var theImg = thePath + theArray[i][1];

			if (theArray[i][2] != '')
			{
				var theOver= thePath + theArray[i][2];
			}
			else
			{
				var theOver= '';
			}

			DisplayMenuImage(theImg,theOver,'');
		}
	}
	document.write("</table>");
}

function nhandan_URL(theSubdir,theFile)
{
	if (theSubdir == "")
	{
		return("");
	} else {
		return("/english/" + theSubdir + RefCurrentDate + "/" + theFile);
	}
/*
	} else if (theSubdir == "homepage/")
	{
			return("/");
	}
	else if (theSubdir ==  "ykien/")
	{
		return ("/" + theSubdir);
	}
	else if (theSubdir == "english/today/")
	{
		return(theSubdir);
	}
*/
}

function DisplayMenuImage(theImg,theOnOver,theURL)
{
	if(theURL != '')
	{
		if (theURL == "english/today/")
		{
			var theHref = "<a href='http://www.nhandan.org.vn/" + escape(theURL) + "'>";
		}
		else
		{
			var theHref = "<a href='" + escape(theURL) + "'>";
		}
	}
	else
	{
		var theHref = '';
	}

	var theOv = "<img border='0' src='" + escape(theImg) + "'";
	if (theOnOver != '')
	{
		theOv = theOv + " onMouseOver=\"this.src='" + theOnOver + "'\""
				+ " onMouseOut=\"this.src='" + theImg + "'\"";
	}
	theOv += ">";

	document.write('<tr><td>' + theHref + theOv);
	if(theHref != '') document.write("</a></td></tr>");
	else document.write("</td></tr>");
}

function DisplayBar(theMenu)
{
	// theMenu == kinhte, chinhtri...
	if (theMenu != '')
	{
		document.write('<table border="0" cellpadding="0" cellspacing="0"><tr><td>');
		for (var i=0; i < NhanDanBar.length; i++)
		{
			if (NhanDanBar[i] == theMenu)
			{
				document.write('<table width="100%" border="0" cellpadding="0" cellspacing="0" ');
				document.write(' background="' + NhanDanBar_tags_mics[i][4] + '"><tr>');
				
				// Loop for display tags on menubar
				for (var j=0; j < NhanDanBar_tags[i].length; j++)
				{
					var hasAnchor = NhanDanBar_tags[i][j].indexOf("#");
					if (hasAnchor != -1)
					{
						// var thisLink = NhanDanBar_tags[i][j] + "/" + NhanDanBar_tags[i][j];
						var thisLink = NhanDanBar_tags[i][j];
						var thisText = NhanDanBar_tags[i][j].substring(hasAnchor + 1);
					}
					else
					{
						// var thisLink = NhanDanBar_tags[i][j] + "/" + NhanDanBar_tags[i][j] + ".htm";
						var thisLink = NhanDanBar_tags[i][j] + ".htm";
						var thisText = NhanDanBar_tags[i][j];						
					}
					
					
					if (window.location.href.indexOf(NhanDanBar_tags[i][j]) != -1)
					{
						var thisStyle = NhanDanBar_tags_mics[i][3];
						var thisImg = NhanDanBar_tags_mics[i][1];
					}
					else
					{
						if (NhanDanBar_tags_default.indexOf(NhanDanBar_tags[i][j]) != -1)
						{
							if (window.location.href.indexOf("htm") < 0)
							{
								var thisStyle = NhanDanBar_tags_mics[i][3];
								var thisImg = NhanDanBar_tags_mics[i][1];
							}
							else
							{
								var thisStyle = NhanDanBar_tags_mics[i][2];
								var thisImg = NhanDanBar_tags_mics[i][1];							
							}
						}
						else
						{
							var thisImg = NhanDanBar_tags_mics[i][0];
							var thisStyle = NhanDanBar_tags_mics[i][2];
						}
					}
					
          document.write('<td nowrap>&nbsp;<a href="');
					document.write("/" + theMenu + "/" + RefCurrentDate + "/" + thisLink + '" ');
					document.write('class="' + thisStyle + '">');
					document.write(NhanDanBar_tags_text[i][j]);
					document.write('</a>&nbsp;</td><td align="right"><img src="');
					document.write(thisImg + '" width="2"></td>');
				}
       document.write('</tr></table></td>');
			}
		}
		document.write('</tr></table>');
	}
}

// var NhanDanSubMenuBar = new Array();
function DisplaySubMenuBar(theMenu,theSubMenu)
{
	// Find correct theMenu
	for(var i=0; i < NhanDanSubMenuBar.length;i++) {
		if(NhanDanSubMenuBar[i][0] == theMenu) break;
	}
	if(i == NhanDanSubMenuBar.length) return; // theMenu not found

	document.write('<table border="0" cellpadding="0" cellspacing="0"><tr><nobr>');
	for (j=1;j<NhanDanSubMenuBar[i].length;j++)
	{
		var theText = NhanDanSubMenuBar[i][j][1];

		if(NhanDanSubMenuBar[i][j][3]){
			var theURL = nhandan_URL(theMenu + '/', NhanDanSubMenuBar[i][j][2]);
		}else{
			var theURL  = NhanDanSubMenuBar[i][j][2];
		}

		if((theSubMenu == '' && window.location.pathname.indexOf('/' + NhanDanSubMenuBar[i][j][0]) != -1)
			|| theSubMenu == NhanDanSubMenuBar[i][j][0]) // the Active SubMenu
		{
			var theClass = NhanDanSubMenuBar[i][j][4];
			var theBgImg = NhanDanSubMenuBar[i][j][6];
			var theImg = NhanDanSubMenuBar[i][j][8];
		}else{ // nonActive SubMenu
			var theClass = NhanDanSubMenuBar[i][j][5];
			var theBgImg = NhanDanSubMenuBar[i][j][7];
			var theImg = NhanDanSubMenuBar[i][j][9];
		}

		if(theClass != '') theClass = ' class="' + theClass + '"';
		if(theBgImg != '') theBgImg = ' background="' + theBgImg + '"';
		if(theImg != '') theImg = '<img src="' + theImg + '">';

		document.write('<td><table border="0" cellpadding="0" cellspacing="0"><tr>');
		document.write('<td ' + theBgImg + '>');
		document.write('<a href="' + theURL + '"' + theClass + '>' + theText + '</a>');
		document.write('</td><td>' + theImg + '</td></tr></table></td>');
	}
	document.write('</nobr></tr></table>');
}

function DisplayNhanDanFooter(theArray,thePage)
{
	document.write('<table width="100%" border="0" cellpadding="0" cellspacing="0" height="22"><tr>');
	for(var i=0; i < theArray.length; i++)
	{
		if(!theArray[i][2]) {
			var theURL = theArray[i][3];
		}else{
			var theURL = nhandan_URL(theArray[i][3],theArray[i][4]);
		}
		
		document.write('<td>');
		if(i > 0) document.write('l&nbsp;');
		if(thePage == theArray[i][0]) {
			document.write('<a href="' + theURL + '" class="footer_active">');
			document.write(theArray[i][1]);
			document.write('</a>');
		}else{
			document.write('<a href="' + theURL + '" class="footer">');
			document.write(theArray[i][1]);
			document.write('</a>');
		}
		document.write('</td>');
	}
	document.write('</tr></table>');
}

function DisplayNhanDanNotes()
{
	document.write(NhanDanBrowserNotes);
}
