var dsRTE_insertAudio=function()
{  this.ExecuteCommand=function(a,b,c){
    c.slideToggle();return true};
   this.PrepareCommand=function(b,c,d,f){
       var g=c;
     $('#dsrte-audio-url-ok').click(function(){
          b.frame.focus();
//          $('#'+c).val('');
          d.slideUp();
          var object_content ='<img class="Itemaudio" height="20" align="" width="20" title="src:'+$("#dsrte-audio-url").val()+'"  src="./images/WAV.png" _moz_resizing="true"/>';
          b.doc.execCommand('inserthtml',false,object_content);
          $('#'+c).val('');
          $("#dsrte-audio-url").val('');
      });

      $('#'+b.iframe.id+'-'+c+'-ok').click(function(){
               b.frame.focus();
               $.ajaxFileUpload( 
                   {  url:f.attr('path'),
                      secureuri:false,
                      fileElementId:b.iframe.id+'-'+g+'-file',
                      dataType:'json',
                      success:function(a,s){
                         
                        if(a.error){
                           alert(a.error)
                         }
                         else
                         {
                           
                           var object_content ='<img class="Itemaudio" height="20" align="" width="20" title="src:'+a.path+'/'+encodeURIComponent(a.file)+'"  src="./images/WAV.png" _moz_resizing="true"/>';
                           b.frame.focus();
                           b.doc.execCommand('inserthtml',false,object_content);
                           $('#'+c).val('');
                           d.slideUp();
                           
                         }
                      },
                      error:function(a,s,e){  alert(e+': '+a.responseText)  }
                   })
       });
       return true
   }

};

editor.RegisterPlugin(new dsRTE_insertAudio(),'audio');
