﻿//创建并返回对象
function $() {
  var elements = new Array();

  for (var i = 0; i < arguments.length; i++) {
    var element = arguments[i];
    if (typeof element == 'string')
      element = document.getElementById(element);

    if (arguments.length == 1)
      return element;

    elements.push(element);
  }

  return elements;
}
//创建并返回Ajax对象
function Ajax(){
	return (window.XMLHttpRequest)?new XMLHttpRequest() :new  ActiveXObject("Microsoft.XMLHTTP");
}

function makeHistory(newHash)
{
  window.location.hash = newHash;
  expectedHash = window.location.hash;
  alert(expectedHash);
  return true;
}
//检查浏览器历史记录中的URI
function handleHistory()
{ 
  if ( window.location.hash != expectedHash )
  {
     alert(window.location.hash + "|" + expectedHash);
    expectedHash = window.location.hash;
    var newoption = expectedHash;
    setOptionValue( newoption );
  }
  return true;
}

function pollHash() {
  handleHistory();
  //window.setInterval("handleHistory()", 1000);
  return true;
}

//获取碎片中的内容，可进行任何操作
function setOptionValue(value)
{
//  var myForm = document.make_history;
//  var mySelect = myForm.change_year;
//  mySelect.options[value-1].selected = true;
    document.getElementById("testDiv").innerHTML = value.replace('#','');
    Test(value.replace('#',''));
    alert(value.replace('#',''));
  return true;
}
