// продукт



var Catalog = Class.create();
Catalog.prototype = {

    flash: null, // ссылка на эмбед
    cur_link: null, // текущий линк


    initialize: function(params){

        var fl = new SWFObject('/media/flash/catalog.swf', 'fl_catalog', '690px', '60px', '8', '#30a1ab');
        fl.addParam('wmode', 'opaque');
        fl.addVariable('to_js', params.this_name + '.from_flash');
        fl.write( params.box );

        this.flash = $('fl_catalog');

        // назначаем на ссылки события
        var as = $(params.links_in).getElementsBySelector('a[href="#category"]');
        for(var i = 0; i < as.length; i++){
            var a = as[i];
            a.cat_id = a.title;
            a.title = 'Показать товары этой категории';
            a.onclick = Delegate.create(this, this.to_flash, a);
        }
    },


    to_flash: function (event, el){
        if( !el ) el = event; // IE

        if( this.cur_link) this.cur_link.className = '';
        el.className = 'active';
        this.cur_link = el;

        // добавляем анкор в url
        //location.hash = 'category_' + el.cat_id;


        // отправляем параметр во флеш
        //this.flash.to_flash('/catalog.php?id=' + el.cat_id);
		this.flash.to_flash('/ajax/product?action=get_list&id=' + el.cat_id);

        cur.attach('/media/img/loader.gif');

        return false;// for link
    },


    from_flash: function (com, param){
        switch(com){
            case 'loaded':
                cur.reset();
             break;
            case 'product':
                prdct.load_product(param);
        }
        return true;
    }


}// end class
