// xmlhttp オブジェクトを作るのだ
var xmlhttp = false;
if(typeof ActiveXObject != "undefined"){
  try{
    xmlhttp  = new ActiveXObject("Microsoft.XMLHTTP");
  }catch(e){
    xmlhttp = false;
  }
}
if(!xmlhttp && typeof XMLHttpRequest != "undefined") {
  xmlhttp  = new XMLHttpRequest();
}


// ページ切り替え
function page(id){
  var menu = document.getElementById('menu');
  var objs = menu.getElementsByTagName('span');
  
  for (i=0; i < objs.length; i++){
    if(objs[i].id == id){
      objs[i].className = 'select';
    
    }else{
      objs[i].className = 'item';
    }
  }
  
  var file = pages[id];
  if(!file){
    return;
  }
  
  xmlhttp.open("GET", file);
  xmlhttp.onreadystatechange = function() {
    if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
        var content = document.getElementById('content');
        while (content.hasChildNodes()) {
          content.removeChild(content.firstChild);
        }
        content.innerHTML = xmlhttp.responseText;
    }
  }
  xmlhttp.send(null);
  return false;
}

