﻿var home =
{
	initialize: function()
	{
    this.scrollLayer = document.getElementById("scrollLayer");
    this.topicLayer = document.getElementById("11");
    this.templayer = document.getElementById("scrollBackLayer");

    this.scrollWidth = this.topicLayer.scrollWidth;
    this.scrollHeight = this.topicLayer.scrollHeight;

	  $("#switchBox").switchTab();
	},

  load: function()
  {
    $.get("data/chinese.xml", null, function(dom)
    {
      $(".InfoLayer").each(function(i, o)
      {
        var id = $(o).attr("prntId");
        var node = null;
        
        if (id)
          node = $(dom).find("ul[prntId='" + id + "']");
        else
        {
          id = $(o).attr("id");

          if (id == "202")
            node = $(dom).find("table[id='" + id + "']");
          else
            node = $(dom).find("ul[id='" + id + "']");
        }

        if (node.length)
          $(o).empty().html(node[0].xml);
        
        node = null;
      });
      
      $(".ScrollLayer").each(function(i, o)
      {
        var id = $(o).attr("prntId");
        var node = null;
        
        if (id)
          node = $(dom).find("ul[prntId='" + id + "']");
        else
        {
          id = $(o).attr("id");
          node = $(dom).find("ul[id='" + id + "']");
        }

        if (node.length)
          $(o).empty().html(node[0].xml);
        
        node = null;
      });

      $(".topic_layer").each(function(i, o)
      {
        var name = $(o).attr("id");
        var node = $(dom).find("table[columnId='" + name + "']");
        
        if (node.length)
          $(o).empty().html(node[0].xml);
        
        node = null;
      });
      
      new Marquee({id: "9", mode: "y", delay: 0, mousePause: true, speed: 20});
      new Marquee({id: "11", mode: "y", delay: 1000, mousePause: false});
    });
  },
  
  topic: function(obj)
  {
    window.open("topic.chinese.htm?topicId=" + $(obj).attr("topicId"));
  }
};

$(function()
{
  $(document).bind("contextmenu", function(e)
	{
		if (!window.event)
			e.preventDefault();
		else
		{
			e = window.event;
			e.returnValue = false;
		}
	});

	home.initialize();
	home.load();
});

