 import AVFoundation
 
 class MyWebView : WKWebView {
+	var appDelegate: AppDelegate = NSApp.delegate as! AppDelegate
 	internal func menuClicked(sender: AnyObject) {
 		if let menuItem = sender as? NSMenuItem {
 			Swift.print("Menu \(menuItem.title) clicked")

    
    var lastStyle : Int = 0
    var lastTitle = "Helium"
    var autoHideTitle : Bool = NSUserDefaults.standardUserDefaults().boolForKey(UserSetting.AutoHideTitle.userDefaultsKey)

    override func mouseExited(theEvent: NSEvent) {
        if autoHideTitle {
            if lastStyle == 0 { lastStyle = (self.view.window?.styleMask)! }
            self.view.window!.titleVisibility = NSWindowTitleVisibility.Hidden;
            self.view.window?.styleMask = NSBorderlessWindowMask
        }
    }
    override func mouseEntered(theEvent: NSEvent) {
        if autoHideTitle {
            if lastStyle == 0 { lastStyle = (self.view.window?.styleMask)! }
            self.view.window!.titleVisibility = NSWindowTitleVisibility.Visible;
            self.view.window?.styleMask = lastStyle

		let subOpacity = NSMenu()
		item.submenu = subOpacity

		item = NSMenuItem(title: "10%", action: #selector(HeliumPanelController.percentagePress(_:)), keyEquivalent: "")
		item.state = (10 == opacity ? NSOnState : NSOffState)
		item.target = wc
		subOpacity.addItem(item)
		item = NSMenuItem(title: "20%", action: #selector(HeliumPanelController.percentagePress(_:)), keyEquivalent: "")
		item.state = (20 == opacity ? NSOnState : NSOffState)
		item.target = wc
		subOpacity.addItem(item)
		item = NSMenuItem(title: "30%", action: #selector(HeliumPanelController.percentagePress(_:)), keyEquivalent: "")
		item.state = (30 == opacity ? NSOnState : NSOffState)
		item.target = wc
		subOpacity.addItem(item)
		item = NSMenuItem(title: "40%", action: #selector(HeliumPanelController.percentagePress(_:)), keyEquivalent: "")
		item.state = (40 == opacity ? NSOnState : NSOffState)
		item.target = wc
		subOpacity.addItem(item)
		item = NSMenuItem(title: "50%", action: #selector(HeliumPanelController.percentagePress(_:)), keyEquivalent: "")
		item.state = (50 == opacity ? NSOnState : NSOffState)
		item.target = wc
		subOpacity.addItem(item)
		item = NSMenuItem(title: "60%", action: #selector(HeliumPanelController.percentagePress(_:)), keyEquivalent: "")
		item.state = (60 == opacity ? NSOnState : NSOffState)
		item.target = wc
		subOpacity.addItem(item)
		item = NSMenuItem(title: "70%", action: #selector(HeliumPanelController.percentagePress(_:)), keyEquivalent: "")
		item.state = (70 == opacity ? NSOnState : NSOffState)
		item.target = wc
		subOpacity.addItem(item)
		item = NSMenuItem(title: "80%", action: #selector(HeliumPanelController.percentagePress(_:)), keyEquivalent: "")
		item.state = (80 == opacity ? NSOnState : NSOffState)
		item.target = wc
		subOpacity.addItem(item)
		item = NSMenuItem(title: "90%", action: #selector(HeliumPanelController.percentagePress(_:)), keyEquivalent: "")
		item.state = (90 == opacity ? NSOnState : NSOffState)
		item.target = wc
		subOpacity.addItem(item)
		item = NSMenuItem(title: "100%", action: #selector(HeliumPanelController.percentagePress(_:)), keyEquivalent: "")
		item.state = (100 == opacity ? NSOnState : NSOffState)
		item.target = wc
		subOpacity.addItem(item)
