/**
 * def_common.js
 *  共通関数スクリプト
*/

/** 全選択／全解除ボタン押下時処理
 * @param flg:check|uncheck
 * @param field:document.form.checkboxElement
 * 
 * ex. checkALL('check', document.myForm.check1)
*/ 
function checkALL(flg, field) {     
    // checkboxが一つしか存在しない場合 
    if(field.length == undefined) {
        if (flg == "check") { 
            field.checked = true; 
            return true; 
        } 
        else if (flg == "uncheck"){ 
            field.checked = false; 
            return false; 
        } 
    // checkboxが複数存在する場合   
    } else if(field.length > 1){
        if (flg == "check") { 
            for (i = 0; i < field.length; i++) { 
                field[i].checked = true; 
            } 
            return true; 
        } 
        else if (flg == "uncheck"){ 
            for (i = 0; i < field.length; i++) { 
                field[i].checked = false; 
            } 
            return false; 
        } 
    }
}

/** 全選択／全解除ボタン押下時処理（トブルボタンパターン）
 * @param field:document.form.checkboxElement
 * 
 * ex. checkALLS('check', document.myForm.check1)
*/ 
function checkALLS(field) {     
    // checkboxが一つしか存在しない場合 
    if(field.length == undefined) {
        if (field.checked == true) { 
            field.checked = false; 
            return true; 
        } 
        else if (field.checked == false){ 
            field.checked = false; 
            return true; 
        } 
    // checkboxが複数存在する場合   
    } else if(field.length > 1){
        for (i = 0; i < field.length; i++) { 
            if(field[i].checked == true){
                field[i].checked = false; 
            } else {
                field[i].checked = true; 
            }
        } 
            return true; 
    } 
}
function toggleCheckBox(checkBoxObj, target){

	if (checkBoxObj.checked) {

		checkALL('check',target);

	} else {

		checkALL('uncheck',target);

	}

}

/** モーダルウィンドウopen処理
 * @param srcPath:url
 * @param winWidth:width
 * @param winHeight:height
 * 
 * ex. openModalWindow('index.htlm', 700, 450)
*/ 
var winFindAddr;
function openModalWindow(srcPath, winWidth, winHeight){
	winFindAddr = null;
	winFindAddr = new Window(
	{
		className: "alphacube",
		width: winWidth,
		height: winHeight,
		// 2010/07/07 一部変更 "true"⇒"false"
		destroyOnClose: false,
		resizable: false,
		closable: false,
		minimizable: false,
		maximizable: false,
		recenterAuto:true,
		showEffect: Effect.Appear, 
		showEffectOptions: {duration:0, delay:0},
		hideEffect: Effect.Fade,
		hideEffectOptions: {duration:0, delay:0},
		url:srcPath
	});
	winFindAddr.setCloseCallback;
	winFindAddr.showCenter(true);
}

/** モーダルウィンドウclose処理
 * 
 * ex. parent.closeModalWindow()
*/ 
function closeModalWindow(){
      winFindAddr.close();
}

