protected void Page_Load(object sender, EventArgs e)
        {
            facade = new BusinessFacade(myConn);
            if (!IsPostBack)
            {
                try
                {
                    if (Request.Params["view"] == "preview")
                    {
                        Job = (DetailJob)Session["Preview"];
                        ViewState["dj"] = Job;
                        if (Session["execJob"] != null)
                        {
                            ViewState["execJob"] = Session["execJob"];
                        }
                        btn_Apply.Visible = false;
                        hpl_PreviousUrl.Visible = false;
                        btn_SaveJob.Visible = false;
                        btn_Edit.Visible = true;
                        Panel_Additional.Visible = false;
                    }
                    else
                    {
                        id = Convert.ToInt16(Request.QueryString["jId"]);
                        Job = facade.GetDetailJobById(id);

                        Repeater_SameEmployerJob.DataSource = facade.GetJobByEmployer(facade.GetGuidByJobId(id));
                        Repeater_SameEmployerJob.DataBind();
                        Repeater_InterestedJob.DataSource = facade.GetJobBySameCate(Job.Category, Job.Category2, Job.Category3);
                        Repeater_InterestedJob.DataBind();

                        ViewState["detailedJob"] = Job;
                        ViewState["jid"] = id;
                        facade.PlusView(id);            //Plus 1 for viewcount
                    }
                }
                catch (NullReferenceException ex)
                {
                    Page.ClientScript.RegisterClientScriptBlock(GetType(), "PopupScript", "<script>alert('"+ex.Message+"');</script>");
                    //Response.Redirect("~/publicArea/errorpages/Error404.aspx");
                }
                catch (IndexOutOfRangeException outofrange)
                {
                    Page.ClientScript.RegisterClientScriptBlock(GetType(), "PopupScript", "<script>alert('" + outofrange.Message + "');</script>");
                    //Response.Redirect("~/publicArea/errorpages/Error404.aspx");
                }
            }
            if (!IsPostBack)
            {
                try
                {
                    if (Job.OrgLogo != "" && Job.OrgLogo != null)
                    {
                        OrgLogo_img.ImageUrl = General.EMP_LOGO + Job.Username + "/" + Job.OrgLogo;
                    }
                    else
                    {
                        OrgLogo_img.ImageUrl = "~/images/companyLogo/no_image.jpg";
                    }

                    TimeSpan addago = DateTime.Now.Subtract(Job.UploadDate);
                    if (addago.Days == 0 || addago.Days == 1)
                    {
                        UploadDate_lbl.Text = Convert.ToString(addago.Days) + " day ago";
                    }
                    else
                    {
                        UploadDate_lbl.Text = Convert.ToString(addago.Days) + " days ago";
                    }
                    ClosingDate_lbl.Text = string.Format("{0:MMM} {0:dd}, {0:yyyy}", Job.ClosingDate);

                    //Description
                    lbl_Description.Text = HttpUtility.HtmlDecode(Job.Description.ToString().Replace(Environment.NewLine, "<br />"));
                    lbl_BriefInfo.Text = HttpUtility.HtmlDecode(Job.OrgInfo.ToString().Replace(Environment.NewLine, "<br />"));
                    //Salary
                    if (job.SalaryType == false)
                    {
                        lbl_Salary.Text = "negotiable";
                    }
                    else if (Job.Salary == 0 && Job.SalaryTo == 0)
                    {
                        lbl_Salary.Text = "negotiable";
                    }
                    else
                    {
                        lbl_Salary.Text = Job.Salary + " - " + Job.SalaryTo + " " + Job.SalaryCurrency + "/" + Job.SalaryPaymentType;
                    }
                }
                catch (Exception)
                { }
            }
            if (!IsPostBack)
            {
                try
                {
                    ViewState["PreviousPageUrl"] = Request.UrlReferrer.ToString();
                    hpl_PreviousUrl.NavigateUrl = ViewState["PreviousPageUrl"].ToString();
                }
                catch (Exception)
                {
                }
            }
        }