// Homepage

function CorrectPage()
{
	var comment, elTags, elTag;
	var FreeDownloadLinkTranslatedText;
	FreeDownloadLinkTranslatedText = document.getElementById('FreeDownloadLinkTranslatedText').innerHTML;
	elTag = document.getElementById("homepage_ver2-body");
	ClearTableSpacing(elTag);
	
	elTags = elTag.getElementsByTagName("TABLE");

	document.getElementById("homepage_ver2-body").getElementsByTagName("IMG")[document.getElementById("homepage_ver2-body").getElementsByTagName("IMG").length-1].className = "s_i_oberonsamsung";

	// 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].rows[0].cells[1].innerHTML = elTags[i].rows[0].cells[1].innerHTML.replace(/\>([^\/\<]+)\/.*\</g, ">$1<");
				elTags[i].id = "promoGamesHPTbl";
				if (typeof elTags[i].rows[0] != "undefined") elTags[i].rows[0].style.display = "none";
				if (typeof elTags[i].rows[1] != "undefined")
				{
					if (typeof elTags[i].rows[1].cells[0] != "undefined") elTags[i].rows[1].cells[0].className = "hpHorSpaceBetweenPromos";
					if (typeof elTags[i].rows[1].cells[1] != "undefined") elTags[i].rows[1].cells[1].className = "hpHorSpaceBetweenPromos";
					if (typeof elTags[i].rows[1].cells[2] != "undefined") elTags[i].rows[1].cells[2].className = "hpHorSpaceBetweenPromosLast";
				}
				if (typeof elTags[i].rows[2] != "undefined")
				{
					if (typeof elTags[i].rows[2].cells[0] != "undefined") elTags[i].rows[2].cells[0].className = "hpHorSpaceBetweenPromos";
					if (typeof elTags[i].rows[2].cells[1] != "undefined") elTags[i].rows[2].cells[1].className = "hpHorSpaceBetweenPromos";
					if (typeof elTags[i].rows[2].cells[2] != "undefined") elTags[i].rows[2].cells[2].className = "hpHorSpaceBetweenPromosLast";
				}
				if (typeof elTags[i].rows[3] != "undefined")
				{
					if (typeof elTags[i].rows[3].cells[0] != "undefined") elTags[i].rows[3].cells[0].className = "hpHorSpaceBetweenPromosLinks";
					if (typeof elTags[i].rows[3].cells[1] != "undefined") elTags[i].rows[3].cells[1].className = "hpHorSpaceBetweenPromosLinks";
					if (typeof elTags[i].rows[3].cells[2] != "undefined") elTags[i].rows[3].cells[2].className = "hpHorSpaceBetweenPromosLinksLast";
					for (j=0; j<elTags[i].rows[3].getElementsByTagName('A').length; j++) {
						//var temp = elTags[i].rows[3].getElementsByTagName['A'].innerHTML;
						if (elTags[i].rows[3].getElementsByTagName('A')[j].innerHTML.indexOf('/') != -1) {
							elTags[i].rows[3].getElementsByTagName('A')[j].innerHTML = elTags[i].rows[3].getElementsByTagName('A')[j].innerHTML.substring(0, elTags[i].rows[3].getElementsByTagName('A')[j].innerHTML.indexOf('/'));
						}
					}
				}

				if (typeof elTags[i].rows[4] != "undefined") elTags[i].rows[4].style.display = "none";

				if (typeof elTags[i].rows[5] != "undefined")
				{
					if (typeof elTags[i].rows[5].cells[0] != "undefined") elTags[i].rows[5].cells[0].className = "hpHorSpaceBetweenPromos";
					if (typeof elTags[i].rows[5].cells[1] != "undefined") elTags[i].rows[5].cells[1].className = "hpHorSpaceBetweenPromos";
					if (typeof elTags[i].rows[5].cells[2] != "undefined") elTags[i].rows[5].cells[2].className = "hpHorSpaceBetweenPromosLast";
				}
				if (typeof elTags[i].rows[6] != "undefined")
				{
					if (typeof elTags[i].rows[6].cells[0] != "undefined") elTags[i].rows[6].cells[0].className = "hpHorSpaceBetweenPromos";
					if (typeof elTags[i].rows[6].cells[1] != "undefined") elTags[i].rows[6].cells[1].className = "hpHorSpaceBetweenPromos";
					if (typeof elTags[i].rows[6].cells[2] != "undefined") elTags[i].rows[6].cells[2].className = "hpHorSpaceBetweenPromosLast";
				}
				if (typeof elTags[i].rows[7] != "undefined")
				{
					if (typeof elTags[i].rows[7].cells[0] != "undefined") elTags[i].rows[7].cells[0].className = "hpHorSpaceBetweenPromosLinks";
					if (typeof elTags[i].rows[7].cells[1] != "undefined") elTags[i].rows[7].cells[1].className = "hpHorSpaceBetweenPromosLinks";
					if (typeof elTags[i].rows[7].cells[2] != "undefined") elTags[i].rows[7].cells[2].className = "hpHorSpaceBetweenPromosLinksLast";
					for (j=0; j<elTags[i].rows[7].getElementsByTagName('A').length; j++) {
						//var temp = elTags[i].rows[3].getElementsByTagName['A'].innerHTML;
						if (elTags[i].rows[7].getElementsByTagName('A')[j].innerHTML.indexOf('/') != -1) {
							elTags[i].rows[7].getElementsByTagName('A')[j].innerHTML = elTags[i].rows[7].getElementsByTagName('A')[j].innerHTML.substring(0, elTags[i].rows[7].getElementsByTagName('A')[j].innerHTML.indexOf('/'));
						}
					}
				}
			}
			
			// Top Promo Table with 6 Games > Game Description
			if (comment.indexOf(" table 3 ") != -1)
			{
				//elTags[i].style.width = "100%";
				elTags[i].width = "";
				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)
			{
				if(elTags[i].rows.length == 3)
				{
					elTags[i].className = "hpPromoGameLinksByRows"
					elTags[i].rows[1].style.display = "none";
					elTags[i].rows[0].appendChild(elTags[i].rows[2].firstChild);
					elTags[i].rows[2].parentNode.removeChild(elTags[i].rows[2]);
				}
			}

			// 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%";
			}

			if (comment.indexOf(" table 8 ") != -1)
			{
				elTags[i].rows[0].cells[0].getElementsByTagName("IMG")[0].vspace= "0px";
			}

			// Game Item of Top Games > Bottom Links
			if (comment.indexOf(" table 9 ") != -1)
			{
				/* elTags[i].getElementsByTagName("IMG")[0].className = "hpTopGamesItemBottomDownlImg";
				elTags[i].getElementsByTagName("IMG")[0].removeAttribute("width");
				elTags[i].getElementsByTagName("IMG")[0].removeAttribute("height");*/
				elTags[i].rows[0].cells[1].getElementsByTagName("IMG")[0].style.display = "none";
				elTags[i].rows[0].cells[0].className = "hpTopGamesExeDl";
				elTags[i].rows[0].cells[0].getElementsByTagName('A')[0].innerHTML = FreeDownloadLinkTranslatedText;
				elTags[i].rows[0].cells[1].className = "hpTopGamesExeD2";
				/*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";
				elTags[i].rows[0].cells[1].style.visibility = "hidden";*/
			}

			// 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].className = "hpNewGNamePlace";
				
				// Hide Game description
				//elTags[i].rows[2].style.display = "none";
				
				// Game description
				elTags[i].rows[2].cells[0].className = "hpNewGDescPlace";

				// 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].width = elTags[i].rows[3].cells[1].width = "";

				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%";
				elTags[i].rows[1].cells[0].className = "hpNewGName";
			}

			// 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";

				//Game description
				elTags[i].rows[2].cells[0].className="hpTOnlineGDescPlace";
				
				// 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].width = elTags[i].rows[3].cells[1].width = "";

				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%";
			}

		}
	}
}


