public function validateAction()
 {
     $response = new Varien_Object();
     $response->setError(0);
     if ($data = $this->getRequest()->getPost()) {
         $template = $this->_initTemplate('template_id');
         try {
             if (isset($data['template'])) {
                 $template->addData($data['template']);
             }
             $template->parse($template->getBody());
         } catch (Mzax_Emarketing_Model_Template_Exception $e) {
             $seesion = $this->_getSession();
             foreach ($e->getErrors() as $error) {
                 switch ($error->level) {
                     case LIBXML_ERR_WARNING:
                         $seesion->addWarning("Line {$error->line}/{$error->column}: {$error->message} (#{$error->code})");
                         break;
                     case LIBXML_ERR_ERROR:
                         $seesion->addError("Line {$error->line}/{$error->column}: {$error->message} (#{$error->code})");
                         break;
                     case LIBXML_ERR_FATAL:
                         $seesion->addError("Line {$error->line}/{$error->column}: {$error->message} (#{$error->code})");
                         break;
                 }
             }
             $this->_initLayoutMessages('adminhtml/session');
             $response->setError(true);
             $response->setHtmlTemplateErrors($e->getErrors());
             $response->setMessage($this->getLayout()->getMessagesBlock()->getGroupedHtml());
         } catch (Exception $e) {
             $this->_getSession()->addError($e->getMessage());
             $this->_initLayoutMessages('adminhtml/session');
             $response->setError(true);
             $response->setMessage($this->getLayout()->getMessagesBlock()->getGroupedHtml());
         }
     }
     $this->getResponse()->setBody($response->toJson());
 }