         
         /* Attached to the top most window (make sure we are using the right orientation) */
         let interfaceOrientation = UIApplication.sharedApplication().statusBarOrientation
+        
+        switch(interfaceOrientation) {
+        case UIInterfaceOrientation.LandscapeLeft:
+            let t: Double = M_PI * 270 / 180
+            self.transform = CGAffineTransformMakeRotation(CGFloat(t))
+            break
             
-        switch(interfaceOrientation) {
-            case UIInterfaceOrientation.LandscapeLeft:
-                let t: Double = M_PI * 270 / 180
-                self.transform = CGAffineTransformMakeRotation(CGFloat(t))
-                break
+        case UIInterfaceOrientation.LandscapeRight:
+            let t: Double = M_PI * 90 / 180
+            self.transform = CGAffineTransformMakeRotation(CGFloat(t))
+            break
             
-            case UIInterfaceOrientation.LandscapeRight:
-                let t: Double = M_PI * 90 / 180
-                self.transform = CGAffineTransformMakeRotation(CGFloat(t))
-                break
-                
-            case UIInterfaceOrientation.PortraitUpsideDown:
-                let t: Double = M_PI * 180 / 180
-                self.transform = CGAffineTransformMakeRotation(CGFloat(t))
-                break
-                
-            default:
-                break
-        }
+        case UIInterfaceOrientation.PortraitUpsideDown:
+            let t: Double = M_PI * 180 / 180
+            self.transform = CGAffineTransformMakeRotation(CGFloat(t))
+            break
             
+        default:
+            break
+        }
+        
         self.frame = CGRectMake(0, 0, self.frame.width, self.frame.size.height)
         UIApplication.sharedApplication().windows.first!.addSubview(self)
         

                }
                
                self.removeFromSuperview()
            }
    }
    
    /* Creates the container view here: create the dialog, then add the custom content and buttons */

    private var datePickerMode: UIDatePickerMode!
    private var callback: ((date: NSDate) -> Void)!
    
    
    /* Overrides */
    init() {
        super.init(frame: CGRectMake(0, 0, UIScreen.mainScreen().bounds.size.width, UIScreen.mainScreen().bounds.size.height))
        
        NSNotificationCenter.defaultCenter().addObserver(self, selector: "deviceOrientationDidChange:", name: UIDeviceOrientationDidChangeNotification, object: nil)
    }
    
    required init(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    /* Handle device orientation changes */
