// 



var text4icons = Class.create();
text4icons.prototype = {

    div: null, // сюда подгружаем текст
    current: null, // выделенный элемент

    initialize: function(some_icons_id, out_id){

        this.div = $(out_id);
        var as = $(some_icons_id).getElementsBySelector('a');

        for(var i = 0; i < as.length; i++){
            var a = as[i];
            a.param = a.title;
            a.title = '';
            a.onclick = Delegate.create(this, this.load_text, {a:a});
        }

    },



    load_text: function(event, params){

        if( this.current ) this.current.className = '';

        if( !params ){ // IE
            params = event;
        }
        this.current = params.a;
        this.current.className = 'active';

        var key = this.current.param;


        var obj = this;
        new Ajax.Request('/text4icons.php?key=' + key, {
            //method: 'get',
            //params: {key: key},
            onSuccess: function(transport) {
                obj.div.innerHTML = transport.responseText;
            },
            onFailure: function(transport) {
                obj.div.innerHTML = 'onFailure';
            },
            onException: function(transport) {
                obj.div.innerHTML = 'Exception';
            }
        });
        return false;
    }

}

