var ichiTabs = new Class({
    Implements: [Events, Options],
    options: {
        wrapperID: 'wrapper',
        contentsID: 'contents',
        wrapperItemClass: 'item',
        contentItemClass: 'content',
        currentIndex: 1,
        mouseEvent:    'mouseover'
    },
    initialize: function(options){
        this.setOptions(options);
        this.build();
    },

    build: function(){

        var wrapperItems = $$('#' + this.options.wrapperID + ' .' + this.options.wrapperItemClass);    // #wrapper .item
        var contentsItems = $$('#' + this.options.contentsID + ' .' + this.options.contentItemClass);     // #contents .content

        wrapperItems.each(function(currentItem){

            currentItem.addEvent(this.options.mouseEvent, function(){

                var index = wrapperItems.indexOf(currentItem);

                contentsItems.each(function(currentContentItem){
                    currentContentItem.removeClass('show');
                });

                contentsItems[ index ].addClass('show');

            }.bind(this));
        }.bind(this));


        /* set current index */
      if(this.options.currentIndex && contentsItems[ this.options.currentIndex ]){
            contentsItems[ this.options.currentIndex ].addClass('show');
      }
    }

});
/*
window.addEvent('domready', function(){
    var abc = new ichiTabs();
});*/


var ichiAccordion = new Class({

    Extends: Accordion,

    addSection: function(toggler, element, pos){
        toggler = $(toggler);
        element = $(element);
        var test = this.togglers.contains(toggler);
        var len = this.togglers.length;
        this.togglers.include(toggler);
        this.elements.include(element);
        if (len && (!test || pos)){
            pos = $pick(pos, len - 1);
            toggler.inject(this.togglers[pos], 'before');
            element.inject(toggler, 'after');
        } else if (this.container && !test){
            toggler.inject(this.container);
            element.inject(this.container);
        }
        var idx = this.togglers.indexOf(toggler);
        toggler.addEvent('mouseover', this.display.bind(this, idx));
        if (this.options.height) element.setStyles({'padding-top': 0, 'border-top': 'none', 'padding-bottom': 0, 'border-bottom': 'none'});
        if (this.options.width) element.setStyles({'padding-left': 0, 'border-left': 'none', 'padding-right': 0, 'border-right': 'none'});
        element.fullOpacity = 1;
        if (this.options.fixedWidth) element.fullWidth = this.options.fixedWidth;
        if (this.options.fixedHeight) element.fullHeight = this.options.fixedHeight;
        element.setStyle('overflow', 'hidden');
        if (!test){
            for (var fx in this.effects) element.setStyle(fx, 0);
        }
        return this;
    }
});



