// JavaScript Document
function bindEvent(element, name, func) {
if (element.addEventListener) {
element.addEventListener(name, func, false);
} else if (element.attachEvent) {
element.attachEvent("on" + name, func);
}
}
function bindFunc() {
var func = arguments[0], _this = arguments[1], args = [];
for (var i=2; i<arguments.length; i++) 
args.push(arguments[i]);
return function() {
for (var i=0; i<arguments.length; i++) 
args.push(arguments[i]);
return func.apply(_this, args);
};
}
function bindTabs(tabName, tabPageName, eventName) {
bindEvent(window, "load", function() {new Tabs(tabName, tabPageName, eventName);});
}
function bindActives(name) {
bindEvent(window, "load", function () {new Actives(name);});
}
function Actives(name) {
this.actives = document.getElementsByName(name);
this.activeNow = null;
this.setActive = function (index) {
if (this.actives[index] != this.activeNow) {
if (this.activeNow != null) {
this.activeNow.className = "";
}
this.activeNow = this.actives[index];
this.activeNow.className = "span_j on";
}
return false;
};
for (var i=0; i<this.actives.length; i++) {
bindEvent(this.actives[i], "click", bindFunc(this.setActive, this, i));
if (this.actives[i].className && this.actives[i].className == "span_j on") {
this.activeNow = this.actives[i];
}
}
}
function Tabs(tabName, tabPageName, eventName) {
this.tabs = document.getElementsByName(tabName);
this.tabPages = document.getElementsByName(tabPageName);
this.eventName = eventName || "click";
this.tabNow = null;
this.tabPageNow = null;
this.sohTab = function (index) {
if (this.tabNow != null) {
this.tabNow.className = "span_j";
this.tabPageNow.style.display = "none";
}
this.tabNow = this.tabs[index];
this.tabPageNow = this.tabPages[index];
this.tabNow.className = "span_j on";
this.tabPageNow.style.display = "";
};
for (var i=0; i<this.tabs.length; i++) {
bindEvent(this.tabs[i], this.eventName, bindFunc(this.sohTab, this, i));
if (this.tabs[i].className && this.tabs[i].className == "span_j on") {
this.tabNow = this.tabs[i];
this.tabPageNow = this.tabPages[i];
}
}
}
bindTabs("tab1","tab1Page", "click");
bindTabs("tab2","tab2Page", "click");
bindTabs("tab3","tab3Page", "click");
bindTabs("tab4","tab4Page", "click");
bindTabs("tab5","tab5Page", "click");
