function Platform() { }
var fload = true;
Platform.SetUndock = function() {
    Global.SetIsDock("N");
    Platform.SetSize();
}
Platform.SetDock = function() {
    Global.SetIsDock("Y");
    Platform.SetSize();
}
Platform.SetSize = function() {
    if (!fload) {
        UI.SetSize();
        wdth = parseInt(UI.Width) - 2 * Theme.Side;
        hght = parseInt(UI.Height) - Theme.Top - Theme.Bottom;
        for (var i = 1; i <= 10; i++) {
            $("#Layer" + i).css("top", Theme.Top + "px");
            $("#Layer" + i).css("left", Theme.Side + "px");
            $("#Layer" + i).css("width", wdth + "px");
            $("#Layer" + i).css("height", hght + "px");
        }
    }
    else {
        fload = false;
    }
}
//WINDOWS SPECIFIC CODE
System.Gadget.Flyout.file = "flyout.htm";
System.Gadget.settingsUI = "settings.htm";
System.Gadget.onSettingsClosed = settingsClosed;
System.Gadget.Flyout.onShow = showFlyout;
System.Gadget.Flyout.onHide = closeFlyout;
System.Gadget.onDock = Platform.SetDock;
System.Gadget.onUndock = Platform.SetUndock;

var flyIntervalId = 0;
function showFlyout() {
    System.Gadget.Settings.write("FlyOpen", "1");
    flyIntervalId = setInterval('hideFlyout()', 30);
}
function closeFlyout() {
    
    System.Gadget.Settings.write("FlyOpen", "0");
    hideFlyout();
} 
function hideFlyout() {
    if (System.Gadget.Settings.readString("FlyOpen") == "0") {
        System.Gadget.Flyout.show = false;
        clearInterval(flyIntervalId);
    }
}

function settingsClosed(p_event) {
    if (fload) {
        fload = false;
        UI.Init();
        return;
    }
    if (p_event.closeAction == p_event.Action.commit) {
        Global.SettingsInit();
        
        UI.SetSize();
        UI.ShowLoader(Strings.GetloadControl(), null);
        UI.RemoveTheme();
        UI.LoadTheme();
        tempSettingsId = setTimeout('UI.LoadSettings()', 300);
        UI.ClearUpdateKey(true);
        return;
        
        try {//CHECK ONLY FOR WINDOWS
            if (System.Gadget != null) {
                UI.LoadTheme();
                tempSettingsId = setTimeout('UI.LoadSettings()', 300);
                return;
            }

        } catch (err) { }

        jQuery.getScript("Themes/" + Global.GetTheme() + "/default.js", UI.LoadSettings);
    }
}



//END WINDOWS SPECIFIC CODE
Platform.ShowWelcome = function() {
    System.Gadget.Settings.write("flyval", "w");
    System.Gadget.Flyout.show = true;
}

Platform.ShowRegister = function() {
    System.Gadget.Settings.write("flyval", "r");
    System.Gadget.Flyout.show = true;
}

Platform.ShowLogin = function() {
    System.Gadget.Settings.write("flyval", "l");
    System.Gadget.Flyout.show = true;
}

Platform.ShowForgot = function() {
    System.Gadget.Settings.write("flyval", "f");
    System.Gadget.Flyout.show = true;
}
Platform.ShowSync = function() {
    System.Gadget.Settings.write("flyval", "s");
    System.Gadget.Flyout.show = true;
}
Platform.ShowLogOut = function() {
    System.Gadget.Settings.write("flyval", "o");
    System.Gadget.Flyout.show = true;
}
Platform.ShowTry = function() {
    System.Gadget.Settings.write("flyval", "t");
    System.Gadget.Flyout.show = true;
}

Platform.ShowEmail = function() {
    System.Gadget.Settings.write("flyval", "m");
    System.Gadget.Flyout.show = true;
}

Platform.ShowMessage = function() {
    System.Gadget.Settings.write("flyval", "a");
    System.Gadget.Flyout.show = true;
}
