/*--setup--*/
window.onload=function() {
tab.setup = {
   tabs: document.getElementById('tab').getElementsByTagName('li'),
   
   pages: [
      document.getElementById('box01'),
      document.getElementById('box02'),
      document.getElementById('box03')
   ]
}

tab.init();

tab.dive = function(){
	var hash = window.location.search;
	hash = hash.split("=");
	//hash = hash[0].split("#");

	if(hash[1] == 'box02') tab.showpage(tab.setup.tabs[1]);
	if(hash[1] == 'box03') tab.showpage(tab.setup.tabs[2]);
	if(hash[1] == 'box04') tab.showpage(tab.setup.tabs[3]);
}
tab.dive();

}
/*--setup end--*/

var tab = {
   init: function(){
      var tabs = this.setup.tabs;
      var pages = this.setup.pages;
      
      for(i=0; i<pages.length; i++) {
         if(i !== 0) pages[i].style.display = 'none';
         tabs[i].onclick = function(){ tab.showpage(this); return false; };
      }
   },
   
   showpage: function(obj){
      var tabs = this.setup.tabs;
      var pages = this.setup.pages;
      var num;
      
      for(num=0; num<tabs.length; num++) {
         if(tabs[num] === obj) break;
      }
      
      for(var i=0; i<pages.length; i++) {
         if(i == num) {
            pages[num].style.display = 'block';
            tabs[num].className = 'selected';
         }
         else{
            pages[i].style.display = 'none';
            tabs[i].className = null;
         }
      }
   }
}
