/*
 * MethodChain
 * Copyright(c) 2008-2009, 김영보(YoungBo Kim). All rights reserved.
 * Licensed under the GPLv3 license.
 * http://www.MethodChain.com/
 * version: 2.0.0
 */
mc.siteGuide.examples = function(){
    this.mainExamples();
};

mc.siteGuide.examples.prototype = {

    overoutClass: 'mouse-overout',
    noneClass: 'mc-display-none',

    mainExamples: function(){
        this.getChilds();
        this.setEvents();
    },

    getChilds: function(){
        var doc = document;
        mc.select('.example-class', 'imageBox')
            .setThis(this, 'exampleNodes')
            .gets(['showFirst', 'showSecond', 'imageBox', 'listBox'])
            .setThis(this, '_showNodes')
            .getX(this._showNodes[2])
            .setThis(this, 'boxX');
    },

    setEvents: function(){
       mc.on(['menuBox', 'mousedown', this.menuBoxMousedown, this],
                 ['showList', 'mousedown', this.viewMousedown, this]);  
 
        mc.eachArray(this.exampleNodes, function(tab, ix){
                mc.widget.Event.overOut(this, tab, tab, this.overoutClass);
            }, this)
    },

    viewMousedown: function(e, tg){
        if (tg.id ==  this._showNodes[0].id) {
            mc.removeClass(this.noneClass, this._showNodes[2])
                .addClass(this.noneClass, this._showNodes[3]);
        } else {
            mc.removeClass(this.noneClass, this._showNodes[3])
                .addClass(this.noneClass, this._showNodes[2]);
        }
    },

    menuBoxMousedown: function(e, tg){
        var x = this.boxX - mc.getX(tg.id).chain;
        mc.scrollElement(x, tg);
    }

};

//----------------
mc.exec(function() {
    new mc.siteGuide.examples();
});