/* This script and many more are available free online at
The JavaScript Source :: http://javascript.internet.com
Created by: Travis Beckham :: http://www.squidfingers.com | http://www.podlob.com
version date: 06/02/03 :: If want to use this code, feel free to do so,
but please leave this message intact. (Travis Beckham) */

// Node Functions

if(!window.Node){
  var Node = {ELEMENT_NODE : 1, TEXT_NODE : 3};
}

function checkNode(node, filter){
  return (filter == null || node.nodeType == Node[filter] || node.nodeName.toUpperCase() == filter.toUpperCase());
}

function getChildren(node, filter){
  var result = new Array();
  var children = node.childNodes;
  for(var i = 0; i < children.length; i++){
    if(checkNode(children[i], filter)) result[result.length] = children[i];
  }
  return result;
}

function getChildrenByElement(node){
  return getChildren(node, "ELEMENT_NODE");
}

function getFirstChild(node, filter){
  var child;
  var children = node.childNodes;
  for(var i = 0; i < children.length; i++){
    child = children[i];
    if(checkNode(child, filter)) return child;
  }
  return null;
}

function getFirstChildByText(node){
  return getFirstChild(node, "TEXT_NODE");
}

function getNextSibling(node, filter){
  for(var sibling = node.nextSibling; sibling != null; sibling = sibling.nextSibling){
    if(checkNode(sibling, filter)) return sibling;
  }
  return null;
}

function getPreviousSibling(node, filter){
  for(var sibling = node.previousSibling; sibling != null; sibling = sibling.previousSibling){
    if(checkNode(sibling, filter)) return sibling;
  }
  return null;
}

function getNextSiblingByElement(node){
        return getNextSibling(node, "ELEMENT_NODE");
}
function getPreviousSiblingByElement(node){
        return getPreviousSibling(node, "ELEMENT_NODE");
}

// Menu Functions & Properties

var activeMenu = null;


function showMenu() {
  if(activeMenu){
	//alert(activeMenu + "%%%")
    activeMenu.className = "";
	//alert("ShowMenu:" + activeMenu.parentNode.innerHTML);
    getNextSiblingByElement(activeMenu).style.display = "none";
  }
  if(this == activeMenu){
    activeMenu = null;
  } else {
   // alert(activeMenu + "****")
    this.className = "active";
    getNextSiblingByElement(this).style.display = "block";
    activeMenu = this;
  }
  return false;
}

function initMenu(){
  var menus, menu, text, a, i;
  menus = getChildrenByElement(document.getElementById("menu"));
  try{
  for(i = 0; i < menus.length; i++){
    menu = menus[i];
    text = getFirstChildByText(menu);
    a = document.createElement("a");
	try{
		menu.replaceChild(a, text);
	}catch(e){
		//alert(e)
	}
    a.appendChild(text);
    a.href = "#";
    a.onclick = showMenu;
    a.onfocus = function(){this.blur()};
  }
  }catch(e){
	//alert("one more" + e)
  }
}

// if(document.createElement) window.onload = initMenu;


function changeText(indice,date){
	document.getElementById('cindice').innerHTML = indice;
	document.getElementById('asof').innerHTML = date;
}

//p465889 Junxiang Ji 
function showElement(id){

	document.getElementById(id).style.display = "";
}

function hideAllTopten(){
	document.getElementById('msas1').style.display = "none";
	document.getElementById('msas2').style.display = "none";
	document.getElementById('msas3').style.display = "none";
	document.getElementById('msas4').style.display = "none";
}
// end of modification

  // get flash movie object
      var flashMovie;
      function initMe() {
         if (document.getElementById) {
            flashMovie = document.getElementById("amline");
         }
      }
      // wait for the page to fully load before initializing

      // get zoom
      function getZoom(from, to){
          document.getElementById("from").value = from;
          document.getElementById("to").value = to;
      }      
      // set zoom
      function setZoom(from, to){
         if (flashMovie) {
            var from = document.getElementById("from").value;
            var to = document.getElementById("to").value;  
            flashMovie.setZoom(from, to); 
         }
      } 
	  // reload data
    //  function reloadData(txt) {
	  
	  //p465889 Junxiang modify it for Topten list function
	 // hideAllTopten();
	  
	  
      //   if (flashMovie) {            
      //      flashMovie.reloadData(txt);       // you can pass new data file name: reloadData(new_data_file_name)
      //   }
     // } 
   // ]]>
   
//      window.onload = initMe; 
	  
	  function initAll(){
initMe();
initMenu();

var objtemp = document.getElementById("menuactive");
//alert(objtemp);
if (!objtemp) {
	//alert("objtemp is null");
 activeMenu = null;
} else {
	//alert("objtemp is not nulll");
	//alert("INIT:" + objtemp.parentNode.innerHTML);
 activeMenu =getPreviousSiblingByElement(objtemp);
	//alert(getPreviousSiblingByElement(objtemp).innerHTML);
	//alert(objtemp.innerHTML);
}
}

window.onload=initAll;