public function jsonProductInfoAction()
 {
     $response = new Varien_Object();
     $id = $this->getRequest()->getParam('id');
     if (intval($id) > 0) {
         $product = Mage::getModel('catalog/product')->load($id);
         $response->setId($id);
         $response->addData($product->getData());
         $response->setError(0);
     } else {
         $response->setError(1);
         $response->setMessage(Mage::helper('catalog')->__('Unable to get the product ID.'));
     }
     $this->getResponse()->setBody($response->toJSON());
 }
 public function loginAjaxAction()
 {
     $response = $this->getResponse();
     $request = $this->getRequest();
     $result = new Varien_Object();
     $session = $this->_getSession();
     if ($this->_getSession()->isLoggedIn() || !$this->isAjax()) {
         $result->redirect = $this->_getCheckoutRedirectUrl();
         $result->response = 'success';
         //$result->redirect = Mage::getUrl('*/*/');
         return $response->setBody($result->toJSON());
     }
     $login = $request->getPost('login');
     if (empty($login['username']) || empty($login['password'])) {
         $result->error = Mage::helper('aitcheckout')->__('Login and password are required.');
         return $response->setBody($result->toJSON());
     }
     try {
         $session->login($login['username'], $login['password']);
         /*if ($session->getCustomer()->getIsJustConfirmed()) {
               $this->_welcomeCustomer($session->getCustomer(), true);
           }*/
     } catch (Mage_Core_Exception $e) {
         switch ($e->getCode()) {
             case Mage_Customer_Model_Customer::EXCEPTION_EMAIL_NOT_CONFIRMED:
                 $value = Mage::helper('customer')->getEmailConfirmationUrl($login['username']);
                 $message = Mage::helper('customer')->__('This account is not confirmed. <a href="%s">Click here</a> to resend confirmation email.', $value);
                 break;
             case Mage_Customer_Model_Customer::EXCEPTION_INVALID_EMAIL_OR_PASSWORD:
                 $message = $e->getMessage();
                 break;
             default:
                 $message = $e->getMessage();
         }
         $result->error = $message;
         Mage::helper('aitcheckout/captcha')->renewCaptcha($result);
         $session->setUsername($login['username']);
     } catch (Exception $e) {
     }
     /*if (!$session->getBeforeAuthUrl() || $session->getBeforeAuthUrl() == Mage::getBaseUrl()) {
           // Set default URL to redirect customer to
           $session->setBeforeAuthUrl(Mage::helper('customer')->getAccountUrl());
           // Redirect customer to the last page visited after logging in
           if ($session->isLoggedIn()) {
               if (!Mage::getStoreConfigFlag('customer/startup/redirect_dashboard')) {
                   $referer = $this->getRequest()->getParam(Mage_Customer_Helper_Data::REFERER_QUERY_PARAM_NAME);
                   if ($referer) {
                       $referer = Mage::helper('core')->urlDecode($referer);
                       if ($this->_isUrlInternal($referer)) {
                           $session->setBeforeAuthUrl($referer);
                       }
                   }
               } else if ($session->getAfterAuthUrl()) {
                   $session->setBeforeAuthUrl($session->getAfterAuthUrl(true));
               }
           } else {
               $session->setBeforeAuthUrl(Mage::helper('customer')->getLoginUrl());
           }
       } else if ($session->getBeforeAuthUrl() == Mage::helper('customer')->getLogoutUrl()) {
           $session->setBeforeAuthUrl(Mage::helper('customer')->getDashboardUrl());
       } else {
           if (!$session->getAfterAuthUrl()) {
               $session->setAfterAuthUrl($session->getBeforeAuthUrl());
           }
           if ($session->isLoggedIn()) {
               $session->setBeforeAuthUrl($session->getAfterAuthUrl(true));
           }
       }*/
     $result->redirect = $this->_getCheckoutRedirectUrl();
     if ($session->isLoggedIn()) {
         $result->response = 'success';
     }
     return $response->setBody($result->toJSON());
 }