using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class SubPages_Calendar : System.Web.UI.Page {
    //the function code for localization on this page
    protected override void InitializeCulture() {
        ProfileCommon p = (ProfileCommon)this.Context.Profile;

        if (Request.Form.Get("ctl00$selLanguage") != null)
            p.lang = Request.Form.Get("ctl00$selLanguage").ToString();
        if (p.lang == String.Empty)
            p.lang = Session["Localization"].ToString();

        if (p.lang.Length > 0) {
            this.Culture = p.lang;
            this.UICulture = System.Globalization.CultureInfo.CreateSpecificCulture(p.lang).Name;
        }
    }
    //select theme
    protected void Page_PreInit(object sender, EventArgs e) {
        Page.Theme = Profile.UI.Theme;
    }


    protected void Calendar1_SelectionChanged(object sender, EventArgs e) {
        string sDate = Calendar1.SelectedDate.ToString("yyyy/MM/dd");

        string sScript = "";
        sScript = "<script>\r\n";
        // RegisterClientScriptBlock  的因素, 所以無法利下以下這一行
        //sScript += "window.opener.document.getElementById(" + Request["DialogClientID"].ToString().Trim() + ").value='" + sDate + "';\r\n";
        sScript += "window.opener.document.forms(0)." + Request["DialogClientID"].ToString().Trim() + ".value='" + sDate + "';\r\n";
        sScript += "window.close();\r\n";
        sScript += "</script>\r\n";
        //RegisterClientScriptBlock("Calendar_ChangeDate", sScript);
        Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "Calendar_ChangeDate", sScript);


        //if (Request.QueryString["DialogClientID"] != "") {
        //    string strScript = "<script>window.opener.document.forms(0)." + Request.QueryString["DialogClientID"].ToString() + ".value = '";
        //    strScript += sDate;
        //    strScript += "';self.close()";
        //    strScript += "</" + "script>";
        //    RegisterClientScriptBlock("Calendar_ChangeDate", strScript);
        //}
    }
    protected void txtHidden_Load(object sender, EventArgs e) {

    }
    protected void Page_Load(object sender, EventArgs e) {

    }
}
