//-----------------------------------------------------------------
//二重クリック防止
function pageLoad() {

  var mng = Sys.WebForms.PageRequestManager.getInstance();

  if (mng == null) return;

  mng.add_initializeRequest(
    function(sender, args) {

      // 現在、実行中の非同期通信が存在するかを判定
      if (mng.get_isInAsyncPostBack()) {

        // 後続の処理をキャンセル
        args.set_cancel(true);

      }
    }
  );
  
  mng.add_beginRequest(
    function(sender, args) {
      FuncDocumentDisabledChanger(true);
    }
  );
  
  mng.add_endRequest(
    function(sender, args) {
      FuncDocumentDisabledChanger(false);
    }
  );
  
}
//-----------------------------------------------------------------


//-----------------------------------------------------------------
//二重クリック防止 全関連コントロール操作不可
function FuncDocumentDisabledChanger(boolObj)
{
    imgElements = document.getElementsByTagName("img");

    selectElements = document.getElementsByTagName("select");

    inputElements = document.getElementsByTagName("input");

    aElements = document.getElementsByTagName("a");


    for (i = 0; i < imgElements.length; i++) {
        oElement = imgElements[i];
        oElement.disabled = boolObj;
    }

    for (i = 0; i < selectElements.length; i++) {
        oElement = selectElements[i];
        oElement.disabled = boolObj;
    }

    for (i = 0; i < inputElements.length; i++) {
        oElement = inputElements[i];
        oElement.disabled = boolObj;
    }

    for (i = 0; i < aElements.length; i++) {
        oElement = aElements[i];
        oElement.disabled = boolObj;
    }
}
//-----------------------------------------------------------------

//-----------------------------------------------------------------
//Topics PopUp表示
//as_frame:画面名(.aspx)
function FuncOpenTopicsPopUp(as_frame,as_cd)
{
    var option = "width=500, height=400, left=200, top=200, toolbar=NO, location=NO, status=NO, menubar=NO, scrollbars=YES, resizable=YES";

    var lo_win	=	window.open(as_frame + "?TopicsCode=" + as_cd, "_blank", option);
    
    lo_win.focus();
}
//-----------------------------------------------------------------

//-----------------------------------------------------------------
//Topics PopUp 戻値SET
function FuncRedirect(new_form)
{
	window.open(new_form, "_self");
	return  false;
}
//-----------------------------------------------------------------

//-----------------------------------------------------------------
//Calendar PopUp 表示
//as_frame:画面名(.aspx)
function FuncOpenCalendarPopUp(as_frame, mObj, dObj)
{
    mSelect = mObj;
    dSelect = dObj;

    var option = "width=240, height=205, left=300, top=300, toolbar=NO, location=NO, status=NO, menubar=NO, scrollbars=NO, resizable=NO";

    var lo_win	=	window.open(as_frame, "_blank", option);
    
    lo_win.focus();
}
//-----------------------------------------------------------------

//-----------------------------------------------------------------
//Calendar PopUp 変数
var mSelect;
var dSelect;
//-----------------------------------------------------------------

//-----------------------------------------------------------------
//Calendar PopUp 戻値SET
function FuncSetMD(month, day)
{
    for( i=0; i<=mSelect.options.length -1; i++)
    {
        if(mSelect.options[i].text == month)
        {
            mSelect.options[i].selected = true;
        }
    }

    for( i=0; i<=dSelect.options.length -1; i++)
    {
        if(dSelect.options[i].value == day)
        {
            dSelect.options[i].selected = true;
        }
    }
    
    return;
}
//-----------------------------------------------------------------

//-----------------------------------------------------------------
//PopUp 表示
//as_frame:画面名(.aspx)
function FuncOpenAdressSerchPopUp(as_frame, zip1Obj, zip2Obj, preObj, citObj)
{
    preSelect = preObj;
    citTextBox = citObj;
    zip1Text = zip1Obj;
    zip2Text = zip2Obj;
    zipData = zip1Obj.value + '-' + zip2Obj.value
    
    if (zip1Obj.value == null && zip2Obj.value == null)
    {   
        //郵便番号が空白時のエラー出力
        alert('郵便番号前半、3桁を入力してください。');
        return;
    }
    else if (zip1Obj.value.length != 3)
    {
        //郵便番号の桁数以上時のエラー出力
        alert('郵便番号前半、3桁を入力してください。');
        return;
    }
    else
    {
        var option = "width=500, height=500, left=300, top=300, toolbar=NO, location=NO, status=NO, menubar=NO, scrollbars=NO, resizable=NO";

        var lo_win	=	window.open(as_frame+ "?Zip=" + zipData , "_blank", option);

        lo_win.focus();
    }
    
}
//-----------------------------------------------------------------

//-----------------------------------------------------------------
//AdressPopUp 変数
var preSelect;
var citTextBox;
var zip1Text;
var zip2Text;
//-----------------------------------------------------------------

//-----------------------------------------------------------------
//PopUp 戻値SET
function FuncSet(prefecture, city, zip)
{
    if (prefecture.length == 0 || city.length == 0 || zip.length == 0)
    {
        alert('該当するデータが存在しません。');
        return;
    }
    
    for( i=0; i<=preSelect.options.length -1; i++)
    {
        if(preSelect.options[i].value == prefecture)
        {
            preSelect.options[i].selected = true;
        }
    }

    citTextBox.value = city;
    
    zip1Text.value = zip.substr(0,3);
    zip2Text.value = zip.substr(3,4);
    
    return;
}
//-----------------------------------------------------------------

//-----------------------------------------------------------------
//トピックスPopUpからParentPageClose
function FuncSetItemParent(new_form)
{
	parent.opener.FuncRedirect(new_form);
	parent.focus();
	parent.window.close();
	return  true;

}
//-----------------------------------------------------------------

//-----------------------------------------------------------------
//カレンダ選択日付 呼出元Formへセット
function FuncSetItemCalendarParent(month, day)
{
	parent.opener.FuncSetMD(month, day);
	parent.focus();
	parent.window.close();
	return  true;

}
//-----------------------------------------------------------------

//-----------------------------------------------------------------
//住所検索 呼出元Formへセット
function FuncSetItemAddresseeParent(prefecCode, cityValue, zipValue)
{
	parent.opener.FuncSet(prefecCode, cityValue, zipValue);
	parent.focus();
	parent.window.close();

	return  true;

}
//-----------------------------------------------------------------