    $.ContactHelper = function()
    {
       this.imgLoader1 = null;
       this.init();
    }

    $.extend($.ContactHelper.prototype,{
    init: function(){

        this.imgLoader1 = new Image();
        this.imgLoader1.src="/img/loader.gif";
    },
    getFormContact: function(login, pid){
            $("#dialog").html('<div style="margin:100px 220px;"><img src="'+this.imgLoader1.src+'" /></div>');
            $("#dialog").dialog('option', 'title', 'Связаться с пользователем');
            $("#dialog").dialog('open');
           // if(login.length=='') return false;
             $.ajax({
                url: '/users/contact',
                type: 'POST',
                dataType: 'html',
               data: 'login='+login,
               success : function(data){
                  if(data){
                     $("#dialog").html(data).find('#prodid').val(pid);
                   }
                   else{
                       alert('ошибка при передаче');
                   }
               }
           });

       },

       sendMesssage: function(pid){
         var form = $('#fcontact');
         me = this;     
         if(validForm()){
         $('#cancel').hide();
         $.ajax({
                    url: '/users/sendmessage',
                    type: 'POST',
                    dataType: 'json',
                    data: form.serialize(),
                    success: function(data)
                    {
                      if(data.error == 1){
                           $('#regError').text(data.msg);
                           $('#progress').hide();
                        }
                      else{
                           if(data.msg === 'ok'){
                            $('#progress').html('<div style="color:#66CC33;">Ваше письмо успешно отправлено</div>');

                            $('#send').hide();
                            $('#close').show();
                            setTimeout(function(){ me.autoCloseDlg(); },2000);
                           }
                      }
                    },
                    error: function() {
                        alert('Ошибка предачи данных');
                    },
                    beforeSend: function() {
                       $('#progress').show();
                    }
                });
         }
       },
       autoCloseDlg: function(){
            $('#dialog').dialog('close'); return false;
       }
    });

   var contact_helper = new $.ContactHelper();
