protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            string st_subnum;
            GoogleAnalytics.EasyTracker.GetTracker().SendView("SubjectDetailsPage");
            NavigationContext.QueryString.TryGetValue("selectedItem", out st_subnum);
            DataHandler dat = new DataHandler();

            sub = dat.getSubject(st_subnum);
            InitializeComponent();
            t1 = 0.0;
            t2 = 0.0;
            Control_Pan.Title = sub.title;
            attended = sub.attended;
            conducted = sub.conducted;
            setPer(getPer());
            loadAll();

            MarksAdapter m = new MarksAdapter();
            Mark mrk = dat.loadMarks(st_subnum);
            double q_tot = 0.0, c_tot=0.0 , tot = 0.0;
            if (!mrk.islab) {
                
                Brush brsh = new System.Windows.Media.SolidColorBrush(Colors.White);
                
                m.title = mrk.cat[0].name;
                m.mrks = mrk.cat[0].marks + "/50";
                c_tot += get_sum (mrk.cat[0].marks,0);
                m.ac_mrk = get_sum(mrk.cat[0].marks, 0).ToString("#.0") + "/15";
                m.clour = brsh;
                marks.Items.Add(m);


                m = nm();
                m.title = mrk.cat[1].name;
                m.mrks = mrk.cat[1].marks + "/50";
                c_tot += get_sum(mrk.cat[1].marks, 0);
                m.ac_mrk = get_sum(mrk.cat[1].marks, 0).ToString("#.0") + "/15";
                m.clour = brsh;
                marks.Items.Add(m);

                m = nm();
                m.title = mrk.quiz[0].name;
                q_tot += get_sum(mrk.quiz[0].marks, 1);
                m.mrks = mrk.quiz[0].marks + "/5";
                m.ac_mrk = "";
                m.clour = brsh;
                marks.Items.Add(m);

                m = nm();
                m.title = mrk.quiz[1].name;
                q_tot += get_sum(mrk.quiz[1].marks, 1);
                m.mrks = mrk.quiz[1].marks + "/5";
                m.ac_mrk = "";
                m.clour = brsh;
                marks.Items.Add(m);

                m = nm();
                m.title = mrk.quiz[2].name;
                q_tot += get_sum(mrk.quiz[2].marks, 1);
                m.mrks = mrk.quiz[2].marks + "/5";
                m.ac_mrk = "";
                m.clour = brsh;
                marks.Items.Add(m);

                m = nm();
                m.title = "Assignment";
                m.mrks = mrk.asgn.marks + "/5";
                m.ac_mrk = "";
                m.clour = brsh;
                marks.Items.Add(m);

                tot = c_tot + q_tot + get_sum(mrk.asgn.marks, 1);
                m = nm();
                m.title = "Total";
                m.mrks = tot.ToString("#.0") + "/50";
                m.ac_mrk = "";
                m.clour = new System.Windows.Media.SolidColorBrush(Colors.Orange);
                marks.Items.Add(m);
            }

            else
            {
                m = nm();
                m.title = "PBL/Lab not supported.";
                m.mrks = "";
                m.ac_mrk = "";
                m.clour = new System.Windows.Media.SolidColorBrush(Colors.Orange);
                marks.Items.Add(m);

            }
        }
        public List<Subject> loadSubjects() {
            List<Subject> Temp = new List<Subject>();
            try
            {
                String json = ((string)Settings["ATTJSON"]);
                String ttjson = "";
                if(isVellore())
                    ttjson = ((string)Settings["TTJSON"]);
                
                //READ JSON
                JsonTextReader reader = new JsonTextReader(new System.IO.StringReader(json));
                JArray root = JArray.Load(reader);
                foreach (JObject j in root)
                {
                    Subject s = new Subject();
                    s.code = ((string)j["code"]);
                    s.title = ((string)j["title"]);
                    s.type = ((string)j["type"]);
                    s.slot = ((string)j["slot"]);
                    s.attended = ((int)j["attended"]);
                    s.conducted = ((int)j["conducted"]);
                    s.percentage = ((string)j["percentage"]);
                    s.regdate = ((string)j["regdate"]);
                    s.classnbr = ((string)j["classnbr"]);
                    
                    //Get venue from TTJSON
                    if (isVellore())
                    {
                        JsonTextReader reader2 = new JsonTextReader(new System.IO.StringReader(ttjson));
                        JArray root2 = JArray.Load(reader2);

                        foreach (JObject js in root)
                        {
                            if ((string)js["class_nbr"] == s.classnbr)
                                s.venue = ((string)js["venue"]);
                        }
                    }
                    JArray details = (JArray)j["details"];
                    s.attendance = new List<DayByDay>();
                    for (int i = 0; i < details.Count; ) {s.attendance.Add(new DayByDay(details[i].ToString(), details[i+1].ToString())); i += 2; }
                    Temp.Add(s);
                }
            }
            catch (Exception e) { Console.Out.WriteLine("LOADSUBJECTS() ERROR: " + e.ToString()); }
            return Temp;
        }