/*
* @author: Azim Zakhidov a.k.a. 3oxa
* @email: azakhidov@gmail.com
* @email: azim.zakhidov@cyberplex.com
* @icq:   62472200
*/
window.addEvent('domready',function(){
    var H2IMG = new zxH2IMG();  
});
var zxH2IMG = new Class({
    options : {
        skipClass:'zxSkip', 
        src:'/make_image.jpg?',
        elms:{
        
        '#content_ir h1':8,
		'#container_news h1':8,
		'#container_news #contentpage h1':6,
		'#container_news #contentpage h2':6,
		'#news-header a':2,
		'#analyst_coverage #title':2,
        '#thumbs a':3,
		'#container_clients h1':6,
		'#contentpage h1, #contentregular h1':6,
		'#content_home h2':6,
        '#column1 h2':6,
		'#column1 h3':2
        } 
    },
    setOptions:function(options){
        this.options = Object.extend(this.options, options || {} );
    },

    initialize:function(options){
        this.setOptions(options);
        $each(this.options.elms,function(style,sel){
            $$(sel).each(function(el){
                if (!el.hasClass(this.options.skipClass)&&el.getChildren().length==0){
                	el.addClass(this.options.skipClass);
                    var txt = el.getText();
                    var w = el.getSize().size.x;
                    var src = this.options.src+'s='+style+'&t='+encodeURIComponent(txt);
                    el.setHTML('');
                    var img = new Element('img').setProperties({'src':src,'alt':txt,'title':txt}).injectInside(el);
                }
            },this);
        },this);
    }
});