// Homepage

function CorrectPage()
{
	var comment, elTags, elTag;
	
	elTag = document.getElementById("homepage_ver2-body");
	ClearTableSpacing(elTag);
	
	elTags = elTag.getElementsByTagName("TABLE");
	
	// Find all tags with comments
	for (var i=0; i<elTags.length; i++)
	{
		if (elTags[i].firstChild && ((elTags[i].firstChild.tagName && elTags[i].firstChild.tagName == "!") || elTags[i].firstChild.nodeType==8))
		{
			comment = elTags[i].firstChild.data || elTags[i].firstChild.text || elTags[i].firstChild.innerHTML || " ";	// Html comment tag
			if (comment.indexOf(" table 1 ") != -1)
			{
				elTags[i].rows[0].style.display = "none";
				elTags[i].rows[1].cells[0].className = "hpPromoGamesPlace";
				elTags[i].rows[2].style.display = "none";
				elTags[i].rows[3].style.display = "none";
				elTags[i].rows[4].style.display = "none";
				elTags[i].rows[5].cells[0].className = "hpGamesUnderPromosPlace";
			}
			
			// Top Promo Table with 6 Games
			if (comment.indexOf(" table 2 ") != -1)
			{
				elTags[i].id = "promoGamesHPTbl";
				elTags[i].rows[0].style.display = "none";
				elTags[i].rows[1].cells[0].className = "hpHorSpaceBetweenPromos";
				elTags[i].rows[1].cells[1].className = "hpHorSpaceBetweenPromos";
				elTags[i].rows[2].cells[0].className = "hpHorSpaceBetweenPromos";
				elTags[i].rows[2].cells[1].className = "hpHorSpaceBetweenPromos";
				elTags[i].rows[3].cells[0].className = "hpHorSpaceBetweenPromos";
				elTags[i].rows[3].cells[1].className = "hpHorSpaceBetweenPromos";

				elTags[i].rows[4].style.display = "none";

				elTags[i].rows[5].cells[0].className = "hpHorSpaceBetweenPromos";
				elTags[i].rows[5].cells[1].className = "hpHorSpaceBetweenPromos";
				elTags[i].rows[6].cells[0].className = "hpHorSpaceBetweenPromos";
				elTags[i].rows[6].cells[1].className = "hpHorSpaceBetweenPromos";
				elTags[i].rows[7].cells[0].className = "hpHorSpaceBetweenPromos";
				elTags[i].rows[7].cells[1].className = "hpHorSpaceBetweenPromos";
			}
			
			// Top Promo Table with 6 Games > Game Description
			if (comment.indexOf(" table 3 ") != -1)
			{
				elTags[i].style.width = "100%";
				elTags[i].rows[0].cells[0].style.display = "none";
				elTags[i].rows[0].cells[1].className = "hpPromoGameDescriptionPlace";
			}
			
			// Top Promo Table with 6 Games > Game Bottom Links
			if (comment.indexOf(" table 4 ") != -1)
			{
			}

			// Common table for Top Games, New Games and Top Online Games 
			if (comment.indexOf(" table 5 ") != -1)
			{
				elTags[i].rows[0].cells[0].id = "hpGamesLeftColumn";
				elTags[i].rows[0].cells[1].style.display = "none";
				elTags[i].rows[0].cells[2].id = "hpGamesRightColumn";
				
			}

			// Common table for Top Games
			if (comment.indexOf(" table 6 ") != -1)
			{
				elTags[i].className = "hpTopGamesTable";
				
				// Title
				elTags[i].getElementsByTagName("IMG")[0].className = "hpTopGamesTitleImg";
				elTags[i].rows[0].cells[0].className = "hpTopGamesTitlePlace";
				
				for (var j=1; j<elTags[i].rows.length; j=j+2)
				{
					elTags[i].rows[j].cells[0].className = "gameItemMainContentPlace1";
				}
				for (var j=2; j<elTags[i].rows.length; j=j+2)
				{
					if (j == elTags[i].rows.length-1) elTags[i].rows[j].cells[0].className = "gameItemBottomLinksLastPlace1";
					else elTags[i].rows[j].cells[0].className = "gameItemBottomLinksPlace1";
					elTags[i].rows[j].cells[0].style.backgroundImage = "";
				}
			}

			// Game Item Main Content table of Top Games
			if (comment.indexOf(" table 7 ") != -1)
			{
				elTags[i].style.width = "100%";
			}

			// Game Item of Top Games > Bottom Links
			if (comment.indexOf(" table 9 ") != -1)
			{
				elTags[i].getElementsByTagName("IMG")[0].className = "hpTopGamesItemBottomDownlImg";
				elTags[i].rows[0].cells[1].getElementsByTagName("IMG")[0].style.display = "none";
				elTags[i].rows[0].cells[1].style.padding = "0px";
				elTags[i].rows[0].cells[1].style.margin = "0px";
				elTags[i].rows[0].cells[1].style.fontSize = "0px";
			}

			// Common table for New Games and Top Online Games 
			if (comment.indexOf(" table 10 ") != -1)
			{
				elTags[i].className = "hpRightGameListColumnTable";
				
				// Title New Games
				elTags[i].rows[0].cells[0].getElementsByTagName("IMG")[0].className = "hpNewGamesTitleImg";
				elTags[i].rows[0].cells[0].className = "hpNewGamesTitlePlace";

				// Title Top Online Games
				elTags[i].rows[2].cells[0].getElementsByTagName("IMG")[0].className = "hpTOnlineGamesTitleImg";
				elTags[i].rows[2].cells[0].className = "hpTOnlineGamesTitlePlace";

				elTags[i].rows[3].cells[0].getElementsByTagName("IMG")[0].style.display = "none";
				elTags[i].rows[3].cells[0].getElementsByTagName("FONT")[0].style.display = "none";
			}

			// Common table for New Games
			if (comment.indexOf(" table 11 ") != -1)
			{
				//elTags[i].cellSpacing="0";
				elTags[i].style.width = "100%";

				for (var j=0; j<elTags[i].rows.length; j++)
				{
					if (j == elTags[i].rows.length-1) elTags[i].rows[j].cells[0].className = "gameItemMainContentLastPlace2";
					else elTags[i].rows[j].cells[0].className = "gameItemMainContentPlace2";
				}
			}
			// Game Item Main Content table of New Games
			if (comment.indexOf(" table 12 ") != -1)
			{
				elTags[i].style.width = "100%";
				elTags[i].rows[0].style.display = "none";
				elTags[i].rows[1].cells[0].className = "hpNewGThumbPlace";
				elTags[i].rows[1].cells[1].style.width = "100%";
				
				// Hide Game description
				elTags[i].rows[2].style.display = "none";

				// Bottom Links
				elTags[i].rows[3].cells[0].getElementsByTagName("IMG")[0].style.display = "none";
				elTags[i].rows[3].cells[1].getElementsByTagName("IMG")[0].style.display = "none";

				elTags[i].rows[3].cells[0].className = "hpNewGBotLeftLinkPlace";
				elTags[i].rows[3].cells[1].className = "hpNewGBotRightLinkPlace";

				elTags[i].rows[3].cells[0].getElementsByTagName("A")[0].className = "downloadLink1";
				
			}
			// Game Item > Game Name table of New Games
			if (comment.indexOf(" table 13 ") != -1)
			{
				elTags[i].style.width = "100%";
				elTags[i].rows[0].style.display = "none";
				elTags[i].rows[1].cells[0].style.width = "100%";
			}

			// Common table for Top Online Games
			if (comment.indexOf(" table 14 ") != -1)
			{
				//elTags[i].cellSpacing="0";
				elTags[i].style.width = "100%";

				for (var j=0; j<elTags[i].rows.length; j++)
				{
					if (j == elTags[i].rows.length-1) elTags[i].rows[j].cells[0].className = "gameItemMainContentLastPlace2";
					else elTags[i].rows[j].cells[0].className = "gameItemMainContentPlace2";
				}
			}
			// Game Item Main Content table of New Games
			if (comment.indexOf(" table 15 ") != -1)
			{
				elTags[i].style.width = "100%";
				elTags[i].rows[0].style.display = "none";
				elTags[i].rows[1].cells[0].className = "hpTOnlineGThumbPlace";
				elTags[i].rows[1].cells[1].style.width = "100%";

				// Hide Game description
				elTags[i].rows[2].style.display = "none";

				// Bottom Links
				elTags[i].rows[3].cells[0].getElementsByTagName("IMG")[0].style.display = "none";
				elTags[i].rows[3].cells[1].getElementsByTagName("IMG")[0].style.display = "none";

				elTags[i].rows[3].cells[0].className = "hpTOnlineGBotLeftLinkPlace";
				elTags[i].rows[3].cells[1].className = "hpTOnlineGBotRightLinkPlace";

				elTags[i].rows[3].cells[0].getElementsByTagName("A")[0].className = "downloadLink1";
			}
			// Game Item > Game Name table of New Games
			if (comment.indexOf(" table 16 ") != -1)
			{
				elTags[i].style.width = "100%";
				elTags[i].rows[0].style.display = "none";
				elTags[i].rows[1].cells[0].style.width = "100%";
			}

		}
	}
}

