protected void Page_Load(object sender, EventArgs e)
        {
            using (TriglavBL temp = new TriglavBL())
            {
                Directory lc = Data.Lucene.Indexing.GetDirectoryClanci(); // ovo brisati samo indeksiranje proba
                Directory lp = Data.Lucene.Indexing.GetDirectoryPitanja(); // ovo brisati samo indeksiranje proba

                txt_TrenutnoUredjujemo.Text = "Trenutno uređujemo " + temp.getCountAllPosts(1) + " članaka!";

                if (Request.QueryString["Pretraga"] != null)
                {
                    //Pretraga Wiki preporuke term & call function
                    string term = Request.QueryString["Pretraga"];
                    string func = "searchWithClick('" + term + "');";
                    ClientScript.RegisterStartupScript(this.GetType(), term, func, true);

                    dl_Clanci.DataSource = Data.Lucene.Pretraga.searchClanci(Request.QueryString["Pretraga"]);
                    dl_Clanci.DataBind();
                    dl_Pitanja.DataSource = Data.Lucene.Pretraga.searchPitanja(Request.QueryString["Pretraga"]);
                    dl_Pitanja.DataBind();
                    lbl_TrazenaRijec.Text = "Tražili ste pojam: " + Request.QueryString["Pretraga"];
                    lbl_BrojRezlutataPretrage.Text = "Za vas smo pronašli " + dl_Clanci.Items.Count + " rezultata ";
                    btn_Posljednje.BackColor = Color.LightGray;
                    btn_Istaknuti.BackColor = Color.LightGray;
                    btn_Hot.BackColor = Color.LightGray;
                    btn_OveSedmice.BackColor = Color.LightGray;
                    btn_OvogMjeseca.BackColor = Color.LightGray;
                }
                else if (Request.QueryString["TagID"] != null)
                {
                    //Tag Wiki preporuke term & call function
                    string term = temp.getTagByID(Convert.ToInt32(Request.QueryString["TagID"])).Naziv;
                    string func = "searchWithClick('" + term + "');";
                    ClientScript.RegisterStartupScript(this.GetType(), term, func, true);

                    dl_Clanci.DataSource = Data.Lucene.Pretraga.getClanciByTag(Convert.ToInt32(Request.QueryString["TagID"]));
                    dl_Clanci.DataBind();
                    dl_Pitanja.DataSource = Data.Lucene.Pretraga.getPitanjaByTag(Convert.ToInt32(Request.QueryString["TagID"]));
                    dl_Pitanja.DataBind();
                    lbl_TrazenaRijec.Text = "Tražili ste poveznicu: " + temp.getTagByID(Convert.ToInt32(Request.QueryString["TagID"])).Naziv;
                    lbl_BrojRezlutataPretrage.Text = "Za vas smo pronašli " + dl_Clanci.Items.Count + " rezultata";
                }
                else if (Request.QueryString["PodKategorijaID"] != null)
                {
                    //Pretraga Wiki preporuke term & call function
                    string term = temp.getPodKategorijaByID(Convert.ToInt32(Request.QueryString["PodKategorijaID"])).Naslov;
                    string func = "searchWithClick('" + term + "');";
                    ClientScript.RegisterStartupScript(this.GetType(), term, func, true);

                    dl_Clanci.DataSource = temp.GetClanciByPodKategorija(Convert.ToInt32(Request.QueryString["PodKategorijaID"]));
                    dl_Clanci.DataBind();
                    dl_Pitanja.DataSource = temp.GetPitanjaByPodKategorija(Convert.ToInt32(Request.QueryString["PodKategorijaID"]));
                    dl_Pitanja.DataBind();
                    lbl_TrazenaRijec.Text = "Tražili ste članke sa podkategorijom: " + temp.getPodKategorijaByID(Convert.ToInt32(Request.QueryString["PodKategorijaID"])).Naslov;
                    lbl_BrojRezlutataPretrage.Text = "Za vas smo pronašli " + dl_Clanci.Items.Count + " rezultata";
                }
                else if (Request.QueryString["KategorijaID"] != null)
                {
                    //Pretraga Wiki preporuke term & call function
                    string term = temp.getPodKategorijaByID(Convert.ToInt32(Request.QueryString["KategorijaID"])).Naslov;
                    string func = "searchWithClick('" + term + "');";
                    ClientScript.RegisterStartupScript(this.GetType(), term, func, true);

                    dl_Clanci.DataSource = temp.GetClanciByKategorija(Convert.ToInt32(Request.QueryString["KategorijaID"]));
                    dl_Clanci.DataBind();
                    dl_Pitanja.DataSource = temp.GetPitanjaByKategorija(Convert.ToInt32(Request.QueryString["KategorijaID"]));
                    dl_Pitanja.DataBind();
                    lbl_TrazenaRijec.Text = "Tražili ste članke sa kategorijom: " + temp.getKategorijaByID(Convert.ToInt32(Request.QueryString["KategorijaID"])).Naslov;
                    lbl_BrojRezlutataPretrage.Text = "Za vas smo pronašli " + dl_Clanci.Items.Count + " rezultata";
                }
                else
                {
                    korisnik = (Data.EntityFramework.DAL.Korisnik)Session["LogiraniKorisnik"];
                        if (korisnik != null)
                        {
                            //Sistem preporuke
                            listaMojihClanaka = temp.GetPreporukaClanaka(korisnik.id);
                            listaMojihPitanja = temp.GetPreporukaPitanja(korisnik.id);

                            if (listaMojihClanaka != null || listaMojihPitanja != null)
                            {
                                //Pretraga Wiki preporuke term & call function
                                string term = "Knowledge management";
                                string func = "searchWithClick('" + term + "');";
                                ClientScript.RegisterStartupScript(this.GetType(), term, func, true);

                                dl_Clanci.DataSource = listaMojihClanaka.Take(5);
                                dl_Clanci.DataBind();
                                dl_Pitanja.DataSource = listaMojihPitanja.Take(5);
                                dl_Pitanja.DataBind();
                            }
                            else
                            {
                                //Pretraga Wiki preporuke term & call function
                                string term = "Knowledge management";
                                string func = "searchWithClick('" + term + "');";
                                ClientScript.RegisterStartupScript(this.GetType(), term, func, true);

                                listaMojihClanaka = temp.getClanciByDate();
                                listaMojihPitanja = temp.getPitanjaByDate();

                                dl_Clanci.DataSource = listaMojihClanaka.Take(5);
                                dl_Clanci.DataBind();
                                dl_Pitanja.DataSource = listaMojihPitanja.Take(5);
                                dl_Pitanja.DataBind();
                            }
                        }
                        else
                        {
                            //Pretraga Wiki preporuke term & call function
                            string term = "Knowledge management";
                            string func = "searchWithClick('" + term + "');";
                            ClientScript.RegisterStartupScript(this.GetType(), term, func, true);

                            listaMojihClanaka = temp.getClanciByDate();
                            listaMojihPitanja = temp.getPitanjaByDate();

                            dl_Clanci.DataSource = listaMojihClanaka.Take(5);
                            dl_Clanci.DataBind();
                            dl_Pitanja.DataSource = listaMojihPitanja.Take(5);
                            dl_Pitanja.DataBind();
                        }

                        lbl_NaslovStranice.Text = "Za vas smo izabrali ";
                        btn_Posljednje.BackColor = Color.LightGray;
                        btn_Istaknuti.BackColor = Color.LightGray;
                        btn_Hot.BackColor = Color.LightGray;
                        btn_OveSedmice.BackColor = Color.LightGray;
                        btn_OvogMjeseca.BackColor = Color.LightGray;

                }

                //DATA LISTE
                rpt_Tagovi.DataSource = temp.getTagoviClanciPopularni().Take(10);
                rpt_Tagovi.DataBind();

                rpt_TagoviQA.DataSource = temp.getTagoviPitanjaPopularni().Take(10);
                rpt_TagoviQA.DataBind();

                dl_Kategorije.DataSource = temp.getKategorijeAllPopular().Take(10);
                dl_Kategorije.DataBind();

                dl_Podkategorije.DataSource = temp.getPodKategorijaAllPopular().Take(10);
                dl_Podkategorije.DataBind();
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            //Button btn_Pitanja = (Button)Master.FindControl("btn_Pitanja");
            //btn_Pitanja.BackColor = Color.LightGreen;

            using (TriglavBL temp = new TriglavBL())
            {

                if (Request.QueryString["Pretraga"] != null)
                {
                    dl_Pitanja.DataSource = Data.Lucene.Pretraga.searchPitanja(Request.QueryString["Pretraga"]);
                    dl_Pitanja.DataBind();
                }
                else if (Request.QueryString["TagID"] != null)
                {
                    dl_Pitanja.DataSource = Data.Lucene.Pretraga.getPitanjaByTag(Convert.ToInt32(Request.QueryString["TagID"]));
                    dl_Pitanja.DataBind();
                }
                else
                {
                    korisnik = (Data.EntityFramework.DAL.Korisnik)Session["LogiraniKorisnik"];
                        if (korisnik != null)
                        {
                            //Sistem preporuke
                            List<Post> listaMojihClanaka = temp.GetPreporukaClanaka(korisnik.id);
                            List<Post> listaMojihPitanja = temp.GetPreporukaPitanja(korisnik.id);

                            if (listaMojihClanaka != null || listaMojihPitanja != null)
                            {
                                dl_Pitanja.DataSource = listaMojihPitanja.Take(5);
                                dl_Pitanja.DataBind();
                            }
                            else
                            {
                                dl_Pitanja.DataSource = temp.getPitanjaByDate();
                                dl_Pitanja.DataBind();
                            }
                        }
                        else
                        {
                            dl_Pitanja.DataSource = temp.getPitanjaByDate();
                            dl_Pitanja.DataBind();
                        }
                }

                if (!IsPostBack)
                {
                    //ovdje ide sistem preporuke
                    lbl_NaslovStranice.Text = "Najnovija pitanja";
                    btn_Posljednje.BackColor = Color.LightGray;
                    btn_Istaknuti.BackColor = Color.LightGray;
                    btn_Hot.BackColor = Color.LightGray;
                    btn_OveSedmice.BackColor = Color.LightGray;
                    btn_OvogMjeseca.BackColor = Color.LightGray;
                }
                rpt_Tagovi.DataSource = temp.getTagoviClanciPopularni();
                rpt_Tagovi.DataBind();

                rpt_TagoviQA.DataSource = temp.getTagoviPitanjaPopularni();
                rpt_TagoviQA.DataBind();

                dl_Kategorije.DataSource = temp.getKategorijeAllPopular().Take(10);
                dl_Kategorije.DataBind();

                dl_Podkategorije.DataSource = temp.getPodKategorijaAllPopular().Take(10);
                dl_Podkategorije.DataBind();
            }
        }