function formmailer(idForm){
         var theF = document.forms['webform_'+idForm];
         if (theF){
            var i, e, arrRequired, theFld, alias, errMsg;
            if (typeof(errMsgForm) == 'undefined') errMsgForm = 'Fields marked with an asterisk (*) are required. To fill in field';
            errMsg = errMsgForm; e = 0;
            try {arrRequired=eval("required_"+idForm);}catch(e){}
            if (arrRequired && typeof(arrRequired) == 'object'){
               // проверка полей, отмеченные как обязательные
               for (i=0; i<arrRequired.length; i++) {
                   theFld=theF.elements['d['+arrRequired[i]+']'];
                   alias=theF.elements['r['+arrRequired[i]+']'];
                   if (theFld){
                      switch (theFld.type.toUpperCase()) {
                             case 'TEXT': case 'TEXTAREA':
                             if (theFld.value == '' || theFld.value.replace(/^\s+/,'').replace(/\s+$/,'') == '') {
                                theFld.value = '';
                                e=1;
                             }
                             break;
                             case 'CHECKBOX':if (!theFld.checked)  e=2; break;
                             case 'SELECT-ONE': if (!theFld[theFld.selectedIndex].value) e=2; break;
                      }
                      if (e){
                         if (alias && alias.value)errMsg += ':  '+alias.value+'';
                         alert(errMsg);
                         if (e != 2) theFld.focus();
                         return false;
                      }
                   }
               }
            }
            if (theF.target == 'pop')
            {
               try {
                   var x = (screen.width/2-500/2);
                   var y = (screen.height/2-400/2); //  formmailer
                   var w = window.open(theF.action, 'pop', "scrollbars=no,width=500,height=550,screenX="+(x)+",screenY="+y+",left="+x+",top="+y);
                   w.focus();
               }
               catch(e){alert('Allowed new (pop-up) windows');}
            }
         }
         return true;
}
/*очищаем и "прячем" форму если сообщение отправлено без ошибок*/
function cleanForm(idForm){
         try{
            if (opener && opener.document && opener.document.forms['webform_'+idForm]){
               opener.document.forms['webform_'+idForm].reset();
               var oA = opener.document.getElementById('sendform_'+idForm);
               var oB = opener.document.getElementById('webform_'+idForm);
               if (oA && oB) {
                  if (oA.offsetHeight) oA.style.height = oA.offsetHeight+'px';
                  oB.style.display = 'none';
               }
            }
         }
         catch(e){}
}
