function infraUpload(form,url){
 var me = this;
 this.frm = document.getElementById(form);
 this.url = url;
 this.ifr = document.getElementById('ifr'+form);
 this.bolExecutando = false;
 
 if (this.ifr==null){
 
   this.ifr = document.createElement("iframe");
   this.ifr.setAttribute("id","ifr"+this.frm.id);
   this.ifr.setAttribute("name","ifr"+this.frm.id);
   this.ifr.setAttribute("width","0");
   this.ifr.setAttribute("height","0");
   this.ifr.setAttribute("border","0");
   this.ifr.setAttribute("style","width:0;height:0;border:none;");
   //this.frm.parentNode.appendChild(this.ifr);
   this.frm.appendChild(this.ifr);
   window.frames['ifr'+form].name="ifr"+this.frm.id;
   
   infraAdicionarEvento(this.ifr,'load', 
     function(){   
       if (typeof(me.finalizou)=='function'){
       
         if (INFRA_IE == 0){
           ret = this.contentWindow.document.body.innerHTML;
         }else{
           ret = window.frames['ifr'+me.frm.id].document.body.innerHTML;
         }

         var arr = null;
         
         if (me.bolExecutando){
         
           arr = ret.split("#");
           
           infraOcultarAviso()
           
           if (arr.length!=2 && arr.length!=5){
             //alert(ret);
             //alert('Erro desconhecido realizando upload de arquivo.');
             alert('Erro desconhecido realizando upload de arquivo:' + ret);
           }else{
             if (arr[0]=='ERRO'){
               alert(arr[1]);
             }else{
               var ret = Array();
               ret['nome_upload'] = arr[0].infraReplaceAll('\\\'','');
               ret['nome'] = arr[1].infraReplaceAll('\\\'','');
               ret['tipo'] = arr[2];
               ret['tamanho'] = arr[3];
               ret['data_hora'] = arr[4];
               me.finalizou(ret);
             }
           }
           
           if (INFRA_IE > 0){
             window.status='Finalizado.';	
           }
           
           me.bolExecutando = false;
         }
       }       
     }
   );
  
   //setando propriedades do form
   this.frm.setAttribute("target","ifr"+this.frm.id);
   this.frm.setAttribute("method","post");
   this.frm.setAttribute("enctype","multipart/form-data");
   this.frm.setAttribute("encoding","multipart/form-data");
   this.frm.setAttribute("action", me.url);
 }

 
 this.executar = function(){
 
   if (typeof(me.validar)=='function'){
     if (!me.validar()){
       return;
     }
   }
   
   infraExibirAviso();
   
   me.bolExecutando = true;
   
   //submetendo
   me.frm.submit();
 }
 
 if (window.attachEvent) { //Limpar as referências do IE
    window.attachEvent("onunload", function(){
      me.ifr = null;
      me.frm = null;
      me = null;
    });
 } 
}
