public function changelayoutvisibilityAction()
 {
     if ($datas = $this->getRequest()->getPost()) {
         try {
             if (empty($datas['layout_id'])) {
                 throw new Exception($this->_('An error occurred while changing your layout.'));
             }
             $layout = new Application_Model_Layout_Homepage();
             $layout->find($datas['layout_id']);
             if (!$layout->getId()) {
                 throw new Exception($this->_('An error occurred while changing your layout.'));
             }
             $html = array();
             if ($layout->getId() == $this->getApplication()->getLayoutId()) {
                 $html["success"] = 1;
                 $visibility = $layout->getVisibility();
                 if ($layout->getVisibility() == Application_Model_Layout_Homepage::VISIBILITY_ALWAYS) {
                     $visibility = !empty($datas["layout_is_visible_in_all_the_pages"]) ? Application_Model_Layout_Homepage::VISIBILITY_ALWAYS : Application_Model_Layout_Homepage::VISIBILITY_HOMEPAGE;
                 }
                 $this->getApplication()->setLayoutId($datas['layout_id'])->setLayoutVisibility($visibility)->save();
                 $html['reload'] = 1;
                 $html["display_layout_options"] = $layout->getVisibility() == Application_Model_Layout_Homepage::VISIBILITY_ALWAYS;
                 $html["layout_id"] = $layout->getId();
                 $html["layout_visibility"] = $this->getApplication()->getLayoutVisibility();
             }
         } catch (Exception $e) {
             $html = array('message' => $e->getMessage(), 'message_button' => 1, 'message_loader' => 1);
         }
         $this->getLayout()->setHtml(Zend_Json::encode($html));
     }
 }