/*
* @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:{
        '#columns h1, #columns_full h1':1,
		'#columns_home h1':1,
		'#columns h2, #columns_full h2':2,
		'#columns_home h2':3,
		'#application_form a': 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);
    }
});