/**
 * @author efimochkin
 */
function fileInputEvent(){
        $(this).siblings(".fakefile").children(".text")
            .val($(this).val());
} 
       
$(
    function()
    {
        // browser-specific input enhancements
        if(jQuery.browser.opera && /^(7|8)/.test(jQuery.browser.version)){
            
            // fix quirky text and password inputs 
            $(":text, :password")
                .css(
                    {
                        height: "2em"
                    });
            
            // cancel the file input enhancement -- Opera below v.9 doesn't know 
            // of required opacity property
            return;
        }
        
        $(":file")
            .wrap(
                    "<div class='fileinput' style='position: relative'></div>"
                 )
            .css(
                    {   opacity: 0,
                        position: "absolute",
                        "z-index": 2
                    }
                )
            .bind("change",fileInputEvent)
            .bind("keyup",fileInputEvent)
            .bind("mouseout", fileInputEvent);
            
        $(".fileinput")
            .append('<div class="fakefile"><input class="text" type="text" value="" style="width: 134px;margin: 0px 4px 0 0; position: relative; top: -7px;"><input type="image" value="" class="fakebrowse browse submit" src="/bitrix/templates/Ecookna_inner/images/button_browse.gif" style="margin: 0;height: 23px; width: 66px; border:none;"></div>')
            .css(
                    {
                        
                    }
                );
                        
        $(".fakefile")
            .css(
                    {  
                        position: "relative",
                        "z-index": 1
                        
                    }
                );
         
    }
);