var controller = Class.create({
    initialize: function()
    {
        this.numenu  = null;
        this.numenu2 = null;
        this.langfx  = null;
        this.loginfx = null;
        this.baseurl = null;
        this.AAjax   = null;
    },
    start: function()
    {
      Event.observe(window, 'load', function(e){

        //Old
        window.closef(-1,this.numenu);

        //New

        //IE6 detection var
        var IE6 = (typeof document.body.style.maxHeight == "undefined");

        //Autoajax
        this.AAjax = new autoAjax();
        this.AAjax.applyAjax(this.baseurl);

        //Languaje efect
        this.langfx = new Fx.Opacity('langbox',{duration: 350, fps: 24});
        this.langfx.hide();

        $('language').onclick   = function(){
            this.langfx.toggle();
        }.bindAsEventListener(this);

        //Login efect
        this.loginfx = new Fx.Opacity('loginbox',{duration: 350, fps: 24});
        this.loginfx.hide();

        $('loginclose').onclick = function(){ this.loginfx.custom(1,0); }.bindAsEventListener(this);
        this.setLoginLink();

        $$('body').each(function(v){v.onclick = function(){if(this.langfx.now > 0) this.langfx.custom(1,0)}.bindAsEventListener(this);}.bind(this));

      }.bindAsEventListener(this))
    },
    setLoginLink: function()
    {
        if($('loginlink')) $('loginlink').onclick = function(){ this.loginfx.toggle(); }.bindAsEventListener(this);
    },
    setNumenu: function(n)
    {
        this.numenu = n;
    },
    setNumenu2: function(n)
    {
        this.numenu2 = n;
    },
    setBaseUrl: function(url)
    {
        var re = new RegExp('http://[www.]*');
        this.baseurl = url.replace(re,'');
    }
});

//Controller var
var ctrl = new controller();