                 
                 let alert = UIAlertController(title: title, message: message, preferredStyle: UIAlertControllerStyle.Alert)
                 
-                alert.addAction(UIAlertAction(title: buttonText, style: UIAlertActionStyle.Default, handler: nil))
+                alert.addAction(UIAlertAction(title: buttonText, style: UIAlertActionStyle.Default, handler: { (UIAlertAction) -> Void in
+                    if(params["callback"] != nil) {
+                        let callback = params["callback"] as! String
+                        self.uiWebView.stringByEvaluatingJavaScriptFromString("\(callback)()")
+                    }
+                }));
                 
                 self.presentViewController(alert, animated: true, completion: nil)
             }
             
-            if params["showDatePicker"] != nil {
-                let datePicker = RHYCustomPickerView();
-                
-                datePicker.translatesAutoresizingMaskIntoConstraints = false
-                self.view!.addSubview(datePicker)
-                
-                let horizontalContraint = NSLayoutConstraint(item: datePicker, attribute: NSLayoutAttribute.CenterX, relatedBy: NSLayoutRelation.Equal, toItem: self.view, attribute: NSLayoutAttribute.CenterX, multiplier: 1, constant: 0)
-                view.addConstraint(horizontalContraint)
-                
-                let verticalConstraint = NSLayoutConstraint(item: datePicker, attribute: NSLayoutAttribute.CenterY, relatedBy: NSLayoutRelation.Equal, toItem: self.view, attribute: NSLayoutAttribute.CenterY, multiplier: 1, constant: 0)
-                view.addConstraint(verticalConstraint)
-                
-                let widthConstraint = NSLayoutConstraint(item: datePicker, attribute: NSLayoutAttribute.Width, relatedBy: NSLayoutRelation.Equal, toItem: nil, attribute: NSLayoutAttribute.NotAnAttribute, multiplier: 1, constant: 100)
-                view.addConstraint(widthConstraint)
-                
-                let heightConstraint = NSLayoutConstraint(item: datePicker, attribute: NSLayoutAttribute.Height, relatedBy: NSLayoutRelation.Equal, toItem: nil, attribute: NSLayoutAttribute.NotAnAttribute, multiplier: 1, constant: 100)
-                view.addConstraint(heightConstraint)
-                
-                self.view.layoutIfNeeded();
-            }
-            
-            if params["showAlert"] != nil {
-                let message = params["showAlert"] as! String;
-                var title : String? = params["title"] as? String
-                var buttonText : String? = params["button_text"] as? String
-                
-                if(title == nil) {
-                    title = "Mensaje";
-                }
-                
-                if(buttonText == nil) {
-                    buttonText = "Aceptar";
+            if params["logout"] != nil {
+    
+                let indexViewController = self.storyboard!.instantiateViewControllerWithIdentifier("RHYWebViewControllerStoryboardID") as! RHYWebViewController
+                let loginViewController = self.storyboard!.instantiateViewControllerWithIdentifier("RHYWebViewControllerStoryboardID") as! RHYWebViewController
+                indexViewController.HTMLFile = "index.html"
+                loginViewController.HTMLFile = "login.html"
+                
+                navigationController!.setViewControllers([indexViewController, loginViewController], animated: true)
+            }
+            
+            if params["showConfirmDialog"] != nil {
+                let message = params["showConfirmDialog"] as! String;
+                var title = "Mensaje"
+                var buttonOk = "Aceptar"
+                var buttonCancel = "Cancelar"
+                
+                if let passedTitle = params["title"] as? String {
+                    title = passedTitle
+                }
+                
+                if let passedButtonOk = params["buttonOk"] as? String {
+                    buttonOk = passedButtonOk
+                }
+                
+                if let passedButtonCancel = params["buttonCancel"] as? String {
+                    buttonCancel = passedButtonCancel
                 }
                 
                 let alert = UIAlertController(title: title, message: message, preferredStyle: UIAlertControllerStyle.Alert)
                 
-                alert.addAction(UIAlertAction(title: buttonText, style: UIAlertActionStyle.Default, handler: nil))
+                alert.addAction(UIAlertAction(title: buttonOk, style: UIAlertActionStyle.Default, handler: { (UIAlertAction) -> Void in
+                    if(params["callback"] != nil) {
+                        let callback = params["callback"] as! String
+                        self.uiWebView.stringByEvaluatingJavaScriptFromString("\(callback)()")
+                    }
+                }));
+                
+                alert.addAction(UIAlertAction(title: buttonCancel, style: UIAlertActionStyle.Default, handler: { (UIAlertAction) -> Void in
+                    debugPrint("cancelado")
+                }));
                 
                 self.presentViewController(alert, animated: true, completion: nil)
             }
             
-            if params["showDatePicker"] != nil {
-                let datePicker = RHYCustomPickerView();
-                
-                datePicker.translatesAutoresizingMaskIntoConstraints = false
-                self.view!.addSubview(datePicker)
-                
-                let horizontalContraint = NSLayoutConstraint(item: datePicker, attribute: NSLayoutAttribute.CenterX, relatedBy: NSLayoutRelation.Equal, toItem: self.view, attribute: NSLayoutAttribute.CenterX, multiplier: 1, constant: 0)
-                view.addConstraint(horizontalContraint)
-                
-                let verticalConstraint = NSLayoutConstraint(item: datePicker, attribute: NSLayoutAttribute.CenterY, relatedBy: NSLayoutRelation.Equal, toItem: self.view, attribute: NSLayoutAttribute.CenterY, multiplier: 1, constant: 0)
-                view.addConstraint(verticalConstraint)
-                
-                let widthConstraint = NSLayoutConstraint(item: datePicker, attribute: NSLayoutAttribute.Width, relatedBy: NSLayoutRelation.Equal, toItem: nil, attribute: NSLayoutAttribute.NotAnAttribute, multiplier: 1, constant: 100)
-                view.addConstraint(widthConstraint)
-                
-                let heightConstraint = NSLayoutConstraint(item: datePicker, attribute: NSLayoutAttribute.Height, relatedBy: NSLayoutRelation.Equal, toItem: nil, attribute: NSLayoutAttribute.NotAnAttribute, multiplier: 1, constant: 100)
-                view.addConstraint(heightConstraint)
-                
-                self.view.layoutIfNeeded();
-            }
             // We handled JavaScript communication, so there is no page to be loaded.
             return false
         }

                if(enabled == "true") {
                    self.navigationController!.setNavigationBarHidden(false, animated: false)
                    self.uiWebView.removeConstraint(self.uiWebViewStatusBarConstraint)
                    self.uiWebView.addConstraint(self.uiWebViewNavigationBarConstraint)
                    
                    
                } else {
                    self.navigationController!.setNavigationBarHidden(true, animated: false)
                    self.uiWebView.removeConstraint(self.uiWebViewNavigationBarConstraint)
                    self.uiWebView.addConstraint(self.uiWebViewStatusBarConstraint)
                }
            }
            

        
        
        // Set the default status bar text color (remember to set 'View controller-based status bar' to 'NO' in the target's plist).
        UIApplication.sharedApplication().setStatusBarStyle(.Default, animated:false)
        
        // Hide the navigation bar (we have our own navigation bar in HTML).
        self.navigationController?.setNavigationBarHidden(true, animated: false)
