var BO_CATALOG = new Class.create();

Object.extend(BO_CATALOG.prototype, {
    initialize: function(container,options) {
        /* defaults options */
        this.options = {
            oveloadClassName: 'bo_catalog_overload',
            pager: 'bo_catalog_pager'
        };

        Object.extend(this.options, options || {});

        this.container = container;

        /* events handlers */
        this.events = {
            showCatalogs: this.showCatalogs.bindAsEventListener(this)
        };
    },

    showWaiting: function(){
        this.showOverload(this.container);
    },

    showOverload: function(el){
        if(typeof this.overload == 'undefined')
        this.createOverload();

        if ($(el))
        {
            Position.clone(el,this.overload);
            Element.show(this.overload);
        }
    },

    hideWaiting: function(){
        if (typeof this.overload != 'undefined')
        Element.hide(this.overload);
    },

    createOverload: function(){
        this.overload = document.createElement('div');
        document.body.appendChild(this.overload);
        this.hideWaiting();
        if(this.options.oveloadClassName && !Element.hasClassName(this.overload, this.options.oveloadClassName))
        Element.addClassName(this.overload, this.options.oveloadClassName);
        Element.setOpacity(this.overload,0.5);
    },

    showCatalogs: function(){
        this.showWaiting();
        var url = 'php/consultaeventos.php';
        var myAjax = new Ajax.Updater({success: this.container},url,
        {
            method: 'get',
            encoding: 'ISO-8859-1',
            onComplete: this.hideWaiting.bind(this),
            onFailure: this.hideWaiting.bind(this)
        });
    },
    
    showPrograma: function(id,path,cod){
		var win = new Window('wincat'+id, {className: "alphacube", title: "Codigo:" + cod , width:600, height:400, resizable: false, url: path + id, showEffectOptions: {duration:1}});
		win.setDestroyOnClose();
		win.showCenter(false,100);
    	}

})
/**
* class initialization
*/
var BO_Catalog = new BO_CATALOG('container');
Event.observe(window, 'load', BO_Catalog.events.showCatalogs, false);
