﻿var DefaultProductsPage = 
{
	isMapLink : true,
	
	/* ***************************** Create Map Link *************************************/
	createMapLink : function(e)
	{
		if (this.isMapLink)
		{
			MapLink.resetList();
			MapLink.addNode("Sản phẩm", "callDefaultProductsPage_Click();");
			MapLink.addNode("Trang chủ", "otherLink_Click('#Home', false);");
			MapLink.buildMapLink();
		}
		else
		{
			MapLink.hide();
		}
	},
	/* ***************************** Create Map Link *************************************/

	/* ************************* Create All Category ID by TreeView List ****************************/
	getAllCatID : function()
	{
		var result = "";
		for (var i = 0; i < listItemsCat.length; i++)
		{
			if (i != 0) result += "*";
			result += listItemsCat[i].id + ":";
			result += this.getAllChildID(listItemsCat[i].listChild).substring(1);
		}
		return result;
	},
	
	getAllChildID : function(list)
	{
		var result = "";
		for (var i = 0; i < list.length; i++)
		{
			result += ",";
			var tempArr = list[i].id.split("*");
			result += tempArr[tempArr.length - 1];
			result += this.getAllChildID(list[i].listChild);
		}
		return result;
	},
	/* ************************ Create All Category ID by TreeView List ***************************/
	
	writeCatTitle : function()
	{
		this.createMapLink();
		for (var i = 0; i < listItemsCat.length; i++)
		{
			var o = utilObj.getElById("categoryTitle_" + listItemsCat[i].id);
			if (o != null)
			{
				try
				{
					this.createCatTitle(o, listItemsCat[i]);
				}
				catch (ex) { }
			}
		}
	},
	
	createCatTitle : function(o, item)
	{
		o.innerHTML = item.content;
		o.style.cursor = "pointer";
		utilObj.addEvent(o, "click", function(e)
		{
			MapLink.resetList();
			MapLink.addNode(item.content, item.url);
			MapLink.addNode("Sản phẩm", "callDefaultProductsPage_Click();");
			MapLink.addNode("Trang chủ", "otherLink_Click('#Home', false);");
			MapLink.buildMapLink();
			eval(item.url);
		});
	}
};
