// (c) 2008 Avvax
var Tabs = Class.create();

Tabs.prototype = {
    initialize: function() {
        this.tab1 = $('tab1');
        this.tab2 = $('tab2');
        this.tab1_data = $('tab1_data');
        this.tab2_data = $('tab2_data');
        this.current = 1;
        this.tab1.onclick = this.toggle.bindAsEventListener(this);
        this.tab2.onclick = this.toggle.bindAsEventListener(this);
        this.tab1.onfocus = this.tab1.blur;
        this.tab2.onfocus = this.tab2.blur;
    },

    toggle: function(e) {
        var target = (e.target) ? e.target : e.srcElement;
        if (target.id == 'tab2' && this.current == 1) {
            this.current = 2;
            this.tab1.className = 'tab';
            this.tab2.className = 'tab_hover';
            this.tab1_data.hide();
            this.tab2_data.show();
        } else if (target.id == 'tab1' && this.current == 2) {
            this.current = 1;
            this.tab2.className = 'tab';
            this.tab1.className = 'tab_hover';
            this.tab2_data.hide();
            this.tab1_data.show();
        }
        return false;
    }

};

new Tabs();