
function Global() { }
OnGlobalNoteUpdatedEvent = new YAHOO.util.CustomEvent('NoteUpdated');
Global.SiteURL = "http://www.sharpra.com/";
Global.EmailURL = "http://www.sharpra.com/Contact.aspx";
Global.OtherURL = "http://www.sharpra.com/notes.aspx";
Global.PassURL = "http://www.sharpra.com/ManageAccount/Account.aspx";
Global.Paypal = "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5089525";
Global.GetReport = function() {
    return "http://www.sharpra.com/login/reports/NoteReport.aspx?reportid=" + Global.GUID;
}
Global.GetFacebook = "http://www.facebook.com/pages/Sticky-Notes-Online/141912902503320";
Global.IsOpen = false;
Global.Client = "1";        //SET Client ID
Global.Autosize = false;
Global.Sizes = new Array(new Array(130, 170), new Array(197, 258), new Array(264, 345), new Array(331, 433));
Global.ClientMaxNoteLength = 10240; //All Notes Combined
Global.ServerMaxNoteLength = 10240; //Per Note
Global.ClientHasDiffLength = false; //Does Note have diff max length when not logged in
Global.Version = "2.0.0.1";
Global.HelpPage = "StickyVista.aspx";
Global.UseSync = false;
Global.Themes = new Array("Default","Plank", "Paper", "NotePad", "New1", "New2", "New3", "New4", "New5", "New6", "New7");

 //"Black", "Board", "Celestial", "Flower", "Frame", "Fruits", "Wooden", "Xmas", "Notebook", "Page", 
Global.SetValue = function(identifier, value) {
    try { GetterSetter.SetValue(identifier, value); } //PLATFORM SPECIFIC
    catch (err) { }
}

Global.SetExactValue = function(identifier, value) {
    try { GetterSetter.SetExactValue(identifier, value); } //PLATFORM SPECIFIC
    catch (err) { }
}

Global.GetValue = function(identifier) {
    try { return GetterSetter.GetValue(identifier); } //PLATFORM SPECIFIC
    catch (err) { return ""; }
}

Global.GetExactValue = function(identifier) {
    try { return GetterSetter.GetExactValue(identifier); } //PLATFORM SPECIFIC
    catch (err) { return ""; }
}


Global.setAllNotes = function(paramsval) {
    for (var i = 1; i <= 10; i++) {
        if (Global.setAllNotes.arguments[0].indexOf((i == 10) ? "0" : i) > -1) {

            Global.SetNote(i, Global.setAllNotes.arguments[i])
        }
    }
    OnGlobalNoteUpdatedEvent.fire({ Code: "1", Text: "" });
}



Global.UpdateNotesandPosition = function(note1, note2, note3, note4, note5, note6, note7, note8, note9, note10, current, notesArray, lastUpdate) {
    var e = new NoteEvent(1, "");
    try {
        Global.SetNote(0, note10);
        Global.SetNote(1, note1);
        Global.SetNote(2, note2);
        Global.SetNote(3, note3);
        Global.SetNote(4, note4);
        Global.SetNote(5, note5);
        Global.SetNote(6, note6);
        Global.SetNote(7, note7);
        Global.SetNote(8, note8);
        Global.SetNote(9, note9);
        Global.SetNotesArray(notesArray);
        Global.SetCurrentPosition(current);
        Global.SetClientLastUpdated(lastUpdate);

    }
    catch (exp) {
        e.MsgId = -2;
        e.Message = Strings.GetGloabalErr();
    }
    return e;

}
Global.InitAllValues = function() {
    var e = new NoteEvent(0, Strings.GetWelcome());
    try {
        var dt = new Date().toString("MM/dd/yyyy");
        for (var i = 0; i < 10; i++) {
            Global.SetNote(i, "")
        }
        Global.SetCurrentPosition(1);
        Global.SetNotesArray("1");
        Global.SetGUID("");
        Global.SetTheme(Global.Themes[0]);
        Global.SetSliderSpeed(20);
        Global.SetSliderAnimatedType(1);

        Global.SetFontStyle(Strings.GetFonts()[0][1]);
        Global.SetFontSize(10);
        Global.SetFontColor(Strings.GetColors()[0]);
        Global.SetShowScroll(true);
        Global.SetClientLastUpdated(dt);
        Global.SetSyncMinutes(10);
        Global.SetPromptDelete(true);
        Global.SetLastVersionShown(Global.LastVersionShown);
        Global.SetLastClientShownDate(dt);
        Global.SetLastAlertShownDate(dt);
        Global.SetTextAlign("left");
        Global.SetLoginType(1);
        Global.SetActivateType(0);
        Global.SetExitPrompt(true);
        Global.SetLogoutPrompt(true);
        Global.SetNoteSize(1);
        Global.SetIsDock("Y");

    }
    catch (exp) {
        e.MsgId = -2;
        e.Message = Strings.GetGloabalErr();
    }
    return e;
}

Global.Init = function() {
    var e = new NoteEvent(1, "");
    try {

        if (Global.GetFirstLoad() == "") {
            e = Global.InitAllValues();
        }
        else {
            for (var i = 0; i < 10; i++) {
                Global.Note[i] = Global.GetExactValue("Note" + ((i == 0) ? "10" : i));
            }
            Global.Current = parseInt(Global.GetValue("Current"));
            Global.NotesArray = Global.GetValue("NotesArray");
            Global.GUID = Global.GetValue("GUID");
            Global.ClientLastUpdated = Global.GetValue("ClientLastUpdated");
            Global.LastVersionShown = Global.GetValue("LastVersionShown");
            Global.LastClientShownDate = Global.GetValue("LastClientShownDate");
            Global.LastAlertShownDate = Global.GetValue("LastAlertShownDate");
           Global.IsDock = Global.GetValue("IsDock");
            Global.SettingsInit();
        }
    }
    catch (exp) {
        e.Message = Strings.GetGloabalErr();
        e.MsgId = -2;

    }
    return e;
}

Global.SettingsInit = function() {
    Global.Theme = Global.GetValue("Theme");
    Global.SliderSpeed = parseInt(Global.GetValue("SliderSpeed"));
    Global.SliderAnimatedType = parseInt(Global.GetValue("SliderAnimatedType"));
    Global.FontStyle = Global.GetValue("FontStyle");
    Global.FontSize = parseInt(Global.GetValue("FontSize"));
    Global.FontColor = Global.GetValue("FontColor");
    Global.ShowScroll = Global.GetValue("ShowScroll").bool();
    Global.SyncMinutes = parseInt(Global.GetValue("SyncMinutes"));
    Global.PromptDelete = Global.GetValue("PromptDelete").bool();
    Global.TextAlign = Global.GetValue("TextAlign");
    Global.LoginType = parseInt(Global.GetValue("LoginType"));
    Global.ActivateType = parseInt(Global.GetValue("ActivateType"));
    Global.ExitPrompt = Global.GetValue("ExitPrompt").bool();
    Global.LogoutPrompt = Global.GetValue("LogoutPrompt").bool();
    Global.NoteSize = parseInt(Global.GetValue("NoteSize"));
    Global.GUID = Global.GetValue("GUID");
}
Global.Note = new Array("", "", "", "", "", "", "", "", "", "");
Global.GetNote = function(index) {
    return Global.Note[(index == 10) ? 0 : index];
}
Global.SetNote = function(index, val) {
    Global.Note[(index == 10) ? 0 : index] = val;
    Global.SetExactValue("Note" + index, val, true);
}
Global.Current = 1;
Global.GetCurrentPosition = function() { return parseInt(Global.Current); }
Global.SetCurrentPosition = function(val) {
    Global.Current = parseInt(val);
    Global.SetValue("Current", val, false);
}
Global.AddToCurrentPosition = function(val) {
    Global.Current = parseInt(Global.Current) + val;
    Global.SetValue("Current", Global.Current, false);
}
Global.NotesArray = "1";
Global.GetNotesArray = function() { return Global.NotesArray; }
Global.SetNotesArray = function(val) {
    Global.NotesArray = val;
    Global.SetValue("NotesArray", val + '', true);
}
Global.GUID = "";
Global.GetGUID = function() { return Global.GUID; }
Global.SetGUID = function(val) {
    Global.GUID = val;
    Global.SetValue("GUID", val, true);
}
Global.Theme = "Default";
Global.GetTheme = function() { return Global.Theme; }
Global.SetTheme = function(val) {
    Global.Theme = val;
    Global.SetValue("Theme", val, true);
}
Global.SliderSpeed = 20;
Global.GetSliderSpeed = function() { return Global.SliderSpeed; }
Global.SetSliderSpeed = function(val) {
    Global.SliderSpeed = val;
    Global.SetValue("SliderSpeed", val, false);
}
Global.SliderAnimatedType = 1;
Global.GetSliderAnimatedType = function() { return Global.SliderAnimatedType; }
Global.SetSliderAnimatedType = function(val) {
    SliderAnimatedType = val;
    Global.SetValue("SliderAnimatedType", val, false);
}
Global.FirstLoad = "";
Global.GetFirstLoad = function() {
    retval = "";
    try {
        retval = GetterSetter.GetValue("FirstLoad");

    }
    catch (err) { }
    return retval;
}
Global.SetFirstLoad = function(val) {
    Global.FirstLoad = val;
    Global.SetValue("FirstLoad", val);
}
Global.FontStyle = "System Default";
Global.GetFontStyle = function() { return Global.FontStyle; }
Global.SetFontStyle = function(val) {
    Global.FontStyle = val;
    Global.SetValue("FontStyle", val, true);
}
Global.FontSize = 10;
Global.GetFontSize = function() { return Global.FontSize; }
Global.SetFontSize = function(val) {
    Global.FontSize = val;
    Global.SetValue("FontSize", val, false);
}

Global.NoteSize = 1;
Global.GetNoteSize = function() { return Global.NoteSize; }
Global.SetNoteSize = function(val) {
    Global.NoteSize = val;
    Global.SetValue("NoteSize", val, true);
}

Global.IsDock = "Y";
Global.GetIsDock = function() { return Global.IsDock; }
Global.SetIsDock = function(val) {
    Global.IsDock = val;
    Global.SetValue("IsDock", val, true);
}

Global.FontColor = "Black";
Global.GetFontColor = function() { return Global.FontColor; }
Global.SetFontColor = function(val) {
    Global.FontColor = val;
    Global.SetValue("FontColor", val, true);
}
Global.ShowScroll = true;
Global.GetShowScroll = function() { return Global.ShowScroll; }
Global.SetShowScroll = function(val) {
    Global.ShowScroll = val;
    Global.SetValue("ShowScroll", val, false);
}
Global.ClientLastUpdated = new Date();
Global.GetClientLastUpdated = function() { return Global.ClientLastUpdated; }
Global.SetClientLastUpdated = function(val) {
    Global.ClientLastUpdated = val;
    Global.SetValue("ClientLastUpdated", val, true);
}
Global.SyncMinutes = 10;
Global.GetSyncMinutes = function() { return Global.SyncMinutes; }
Global.SetSyncMinutes = function(val) {
    Global.SyncMinutes = val;
    Global.SetValue("SyncMinutes", val, false);
}
Global.PromptDelete = true;
Global.GetPromptDelete = function() { return Global.PromptDelete; }
Global.SetPromptDelete = function(val) {
    Global.PromptDelete = val;
    Global.SetValue("PromptDelete", val, false);
}
Global.LastVersionShown = "2.0.0.1";
Global.GetLastVersionShown = function() { return Global.LastVersionShown; }
Global.SetLastVersionShown = function(val) {
    Global.LastVersionShown = val;
    Global.SetValue("LastVersionShown", val, true);
}
Global.LastClientShownDate = new Date();
Global.GeLastClientShownDate = function() { return Global.LastClientShownDate; }
Global.SetLastClientShownDate = function(val) {
    Global.LastClientShownDate = val;
    Global.SetValue("LastClientShownDate", val, true);
}
Global.LastAlertShownDate = new Date();
Global.GetLastAlertShownDate = function() { return Global.LastAlertShownDate; }
Global.SetLastAlertShownDate = function(val) {
    Global.LastAlertShownDate = val;
    Global.SetValue("LastAlertShownDate", val, true);
}
Global.TextAlign = "left";
Global.GetTextAlign = function() { return Global.TextAlign; }
Global.SetTextAlign = function(val) {
    Global.TextAlign = val;
    Global.SetValue("TextAlign", val, true);
}
Global.LoginType = 1;
Global.GetLoginType = function() { return Global.LoginType; }
Global.SetLoginType = function(val) {
    Global.LoginType = val;
    Global.SetValue("LoginType", val, false);
}
Global.ActivateType = 1;
Global.GetActivateType = function() { return Global.ActivateType; }
Global.SetActivateType = function(val) {
    Global.ActivateType = val;
    Global.SetValue("ActivateType", val, false);
}
Global.ExitPrompt = true;
Global.GetExitPrompt = function() { return Global.ExitPrompt; }
Global.SetExitPrompt = function(val) {
    Global.ExitPrompt = val;
    Global.SetValue("ExitPrompt", val, false);
}
Global.LogoutPrompt = true;
Global.GetLogoutPrompt = function() { return Global.LogoutPrompt; }
Global.SetLogoutPrompt = function(val) {
    Global.LogoutPrompt = val;
    Global.SetValue("LogoutPrompt", val, false);
}
Global.AllNotesCount = function() {
    var retval = 0;
    for (var i = 0; i < 10; i++) {
        retval += Global.Note[i].length;
    }
    return retval;
}