             self.toolbar?.frame = CGRectMake(0, self.view.bounds.size.height - 44.0, self.toolbar!.frame.size.width, self.toolbar!.frame.size.height)
         }
     }
+    
+    func scrollViewDidEndDragging(scrollView: UIScrollView, willDecelerate decelerate: Bool) {
+        println("ended scroll")
+        
+        var interval : NSTimeInterval = 0.2
+        
+        if (toolbarVisibleHeight > 22.0) { // fully open toolbar
+            UIView.animateWithDuration(0.2, animations: {
+                self.toolbar!.frame = CGRectMake(0, self.view.bounds.size.height - 44.0, self.toolbar!.frame.size.width, self.toolbar!.frame.size.height)
+            })
+        } else { // fully close toolbar
+            UIView.animateWithDuration(0.2, animations: { () -> Void in
+                self.toolbar!.frame = CGRectMake(0, self.view.frame.height, self.toolbar!.frame.size.width, self.toolbar!.frame.size.height)
+            })
+        }
+    }
 }

        println("content height \(self.webView?.scrollView.contentSize.height)")
    }
    
    @IBAction func didSelectBackButton(sender: AnyObject)
    {
        self.webView?.goBack()
    }
    
    @IBAction func didSelectForwardButton(sender: AnyObject)
    {
        self.webView?.goForward()
    }
    
    func reloadPage()
    {
        var url = self.webView?.URL

        forwardButton!.enabled = false
        
        var flexibleSpace = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.FlexibleSpace, target: self, action: nil)
        var actionButton = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.Action, target: self, action: "openActionSheet")
        
        toolbar = UIToolbar(frame: CGRectMake(0, self.view.bounds.height - 44.0, 320, 44))
        toolbar!.items = [backButton!, fixedSpace, forwardButton!, flexibleSpace, actionButton, fixedSpace, reloadButton]
