function boutonTransform(what){
    if(!what)what="btn";
    jQuery('.'+what).each(function(){
        var obj = jQuery(this);
        var tt = jQuery(this).html() || jQuery(this).val();
        jQuery(this).html('');
        var img = '';
        var styl = '';
        if(obj.attr('image')){
            img = '<img src="'+obj.attr('image')+'" />';
            styl = 'style="line-height:25px;margin-left:3px;margin-right:3px;"';
        }
        
        jQuery(this).after('<a class="'+this.className+'" id="'+obj.attr('id')+'" style="padding-right:3px;"><div class="hg"></div><div class="bg"></div>'+img+'<span '+styl+'>'+tt+'</span><div class="hd"></div><div class="bd"></div></a>').remove();
        
        if(obj.attr('href')){jQuery('#'+obj.attr('id')).attr('href',obj.attr('href'));}
        if(obj.attr('title')){jQuery('#'+obj.attr('id')).attr('title',obj.attr('title'));}
        if(obj.attr('alt')){jQuery('#'+obj.attr('id')).attr('alt',obj.attr('alt'));}
        if(obj.attr('rel')){jQuery('#'+obj.attr('id')).attr('rel',obj.attr('rel'));}
        if(obj.attr('target')){jQuery('#'+obj.attr('id')).attr('target',obj.attr('target'));}
        
        if (this.tagName=="INPUT") {
            if(obj.attr('type')=="submit") {
                jQuery('#'+obj.attr('id')).bind('click',function(){jQuery('#'+obj.attr('id')).parents('form').submit();});
            }else if(jQuery(this).attr('type')=="reset"){
                jQuery('#'+obj.attr('id')).bind('click',function(){jQuery('#'+obj.attr('id')).parents('form').reset();});
            }else if(jQuery(this).attr('type')=="button"){
                if(obj.attr("onclick")){jQuery('#'+obj.attr('id')).bind('click',obj.attr("onclick"));}
            }
        }else{
            if(obj.attr("onclick")){jQuery('#'+obj.attr('id')).bind('click',obj.attr("onclick"));}
        }
    });
}

jQuery(document).ready(function(){
    boutonTransform();
});

document.observe('lightview:opened', function(event) {
    boutonTransform("btn_popup");
});

