WineCellar = new Class({
    Implements: [Options],
    
    options: {
        urls: { catalogue: /^\/price-list\/region\/[-\w]+\/$/,
                portfolio: /^\/portfolio\/$/,
                search:    /^\/search\/$/,
                dashboard: /^\/portfolio\/dashboard\/$/ }
    },
    
    initialize: function (options) {
        this.setOptions(options);
        this.url = window.location.pathname;
        
        this.notify = new Notify();
        this.activate_sign_in_form();
        
        switch(true) {
            case this.url.test(this.options.urls.catalogue): new Catalogue(); break;
/*            case this.url.test(this.options.urls.portfolio): new Portfolio(); break; */
            case this.url.test(this.options.urls.dashboard): new Dashboard(); break;

            case this.url.test(this.options.urls.search): $$('#winelist tbody tr.details').each(function(row){ new WineInfo(row); }); break;
        }
        
        if ($('featured')){
             var featured = new SlideShow('featured',{delay: 10000, duration: 1500, autoplay:true, transition:'pushRight'});
             $("featureNext").addEvent("click", function(){
                featured.showNext();
             });
        }

        if ($('catalogue-widget')) { new CatalogueWidget(); }
    },
    
    activate_sign_in_form: function () {
        if ($('sign_in')) {
            $('sign_in').addEvent('click',function(e){
                e.stop();
                form = $('sign_in-form');
                this.getParent().set('tween',{duration: 400}).tween('opacity',0);
                (function(){form.set('tween', {duration:600, transition:Fx.Transitions.Expo.easeOut}).tween('top', 12);}).delay(400);
                $('form-close').addEvent('click', function(){
                    form.tween('top', -100);
                    (function(){ e.target.getParent().tween('opacity',1);}).delay(300)
                });
            });
        }
    }
});


