title: remove pop up box only if login successfull
body: <p>we are hiding the pop up once we click on login "button", but we want to hide only if the login is successfull. [ if user enter correct email id &amp; password ]</p>
  
  <blockquote>
    <p>Login Form</p>
  </blockquote>
  
  <pre><code>&lt;form action="&lt;?php echo $this-&gt;getUrl('example/amasty/createSimpleProductAndRedirect.....&gt;
  
  &lt;label&gt;Email Address&lt;/label&gt;
  &lt;input type="text" name="login[username]" value="&lt;?php echo $this-&gt;htmlEscape($this-&gt;getUsername()) ?&gt;" id="email" /&gt;
  &lt;label&gt;password&lt;/label&gt;
  &lt;input type="password" name="login[password]"  id="pass" /&gt;
  
  &lt;button onclick="hideWindow()" id="send2"&gt;&lt;?php echo $this-&gt;__('Login') ?&gt;&lt;/button&gt;
  </code></pre>
  
  <blockquote>
    <p>controllers</p>
  </blockquote>
  
  <pre><code>protected function _createProduct($type, $doSave = true, $originalProduct, $newImagePath = "")
      {
  
          Mage::register('isSecureArea',true);    
          $session = Mage::getSingleton('customer/session');
  
          $result = array(
              'success' =&gt; false
          );
  
          $login ="";
          $productId ="";
          if ($this-&gt;getRequest()-&gt;isPost()) {
              $login     = $this-&gt;getRequest()-&gt;getPost('login');
              $productId = $this-&gt;getRequest()-&gt;getPost('product_id');
          }
              // echo $login['product_id'];die;
              // if (!empty($login['username']) &amp;&amp; !empty($login['password'])) {
                  try {
                      if(isset($login) &amp;&amp; (is_array($login) &amp;&amp; !empty($login)) || ($login!="")){
                          $session-&gt;login($login['username'], $login['password']);
                          $result['redirect'] = $this-&gt;_getRefererUrl() ? $this-&gt;_getRefererUrl() : Mage::getUrl('customer/account', array(
                              '_secure' =&gt; true
                          ));
                          $result['success']  = true;
                          $customerId         = Mage::getSingleton('customer/session')-&gt;getCustomerId();
                      }
                      else{
                          $customerId = "";
                      }
  
                      $product-&gt;setName($originalProduct-&gt;getName());
  
  
                      $customerId = Mage::getSingleton('customer/session')-&gt;getCustomerId();
                      $product-&gt;setCreatedByCustomerId($customerId);
  
                      if ($doSave)
                          $product-&gt;save();
                      // To save inside my_designs
  
                      return $product;                   
  
                  }
                  catch (Mage_Core_Exception $e) {
                      switch ($e-&gt;getCode()) {
                          case Mage_Customer_Model_Customer::EXCEPTION_EMAIL_NOT_CONFIRMED:
                              $message = Mage::helper('customer')-&gt;__('This account is not confirmed. &lt;a href="%s"&gt;Click here&lt;/a&gt; to resend confirmation email.', Mage::helper('customer')-&gt;getEmailConfirmationUrl($login['username']));
                              break;
                          case Mage_Customer_Model_Customer::EXCEPTION_INVALID_EMAIL_OR_PASSWORD:
                              $message = $e-&gt;getMessage();
                              break;
                          default:
                              $message = $e-&gt;getMessage();
                      }
                      $result['error'] = $message;
                      $session-&gt;setUsername($login['username']);
  
                  }
                  catch (Exception $e) {
                      $result = "ERROR :".$e-&gt;getMesage();
                      /
                  }
              // } else {
              //     $result['error'] = Mage::helper('customer')-&gt;__('Login and password are required.');
              // }
          // }
  
          Mage::unregister('isSecureArea');
          $this-&gt;getResponse()-&gt;setBody(Mage::helper('core')-&gt;jsonEncode($result));
  
          // code for guest end
      }
  </code></pre>
  
  <p>please help me for this
  Thanks in Advance</p>
  
  <blockquote>
    <p>update</p>
  </blockquote>
  
  <pre><code>function hideWindow() 
  { 
  document.getElementById('something').style.display = 'none'; 
  
  document.getElementById('ajaxlogin-mask').style.display = 'none';
   }
  </code></pre>