/*
* @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:{
		'#contentpage h1':9,
        '#news-header a':2,
        '#thumbs a':3,
		'#SearchQueryDiv label':10,
		'#SearchConditionDiv label':10,
		'#ForgotFormLoginDiv label':10,
		'#ForgotFormEmailDiv label':10,
		'.FAQSetTitle':7
        }
    },
    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);
    }
});
