/*
* @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 h2,.leftheadline2,#content_page h2':1,
        '#news-header a,#feeds .header':2,
        '#eventsID-header a, #column2 h2,h2.pagetitle':3,
        '#content h3':4,
		'.Left h3, .Right h3':7,
		'#content_page':4
        }
    },
    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){
                    var txt = el.getText();
                    var w = el.getSize().size.x;
                    var src = this.options.src+'s='+style+'&t='+encodeURIComponent(txt)+'&w='+w;
                    el.setHTML('');
                    var img = new Element('img').setProperties({'src':src,'alt':txt,'title':txt}).injectInside(el);
                }
            },this);
        },this);
    }
});