/*
* @author: Azim Zakhidov a.k.a. 3oxa
* @email: azakhidov@gmail.com
* @email: azim.zakhidov@cyberplex.com
* @icq:   62472200
*/
window.addEvent('domready',function(){
    var zxCWSplashPageOpt = { };
    var CWSplashPage = new zxCWSplashPage(zxCWSplashPageOpt);
});

var zxCWSplashPage = new Class({

    link:{},
    divs:{},
    curr:'',

    options : {
        liClass:'on',
        fx:null,
        sets:{
            res:{
                link:'residentialButton',
                div: 'contentbox-residential'
            },
            cor:{
                link:'businessButton',
                div: 'contentbox-business'
            },
            bus:{
                link:'corporateButton',
                div: 'contentbox-corporate'
            },
            hlp:{
                link:'helpButton',
                div: 'contentbox-help'
            }
        }
    },

    setOptions:function(options){
        this.options = Object.extend(this.options, options || {} );
    },

    initialize:function(options){
        this.setOptions(options);
        var found = false;
        $each(this.options.sets,function(set,key){
            if ( $(set.link) && $(set.div) ) {
                if ($(set.link).hasClass(this.options.liClass) ) this.curr = key;
                this.link[key] = $(set.link);
                this.divs[key] = $(set.div) ;
                this.link[key].addEvent('click',this.bindLink.pass([key],this));
            }
        },this);
    },

    bindLink:function(key){
        if (key!=this.curr){
            this.link[this.curr].removeClass(this.options.liClass);
            this.link[key].addClass(this.options.liClass);

            this.closeDiv(this.curr);
            this.openDiv(key);

            this.curr=key;
        }
    },

    closeDiv:function(key){
        this.divs[key].setStyle('display','none');
    },

    openDiv:function(key){
        this.divs[key].setStyle('display','block');
    }

});