function locked() {
  if (document.getElementById('ResearchType_no').checked) {
    // 施設すべて、チェックを外す
    for (i=1;i<=8;i++) {
      document.getElementById('ResearchType0'+i).checked = false;
    }
    document.getElementById('ResearchType99').checked = false;
    // 施設すべて、チェック出来ないようにする
    for (i=1;i<=8;i++) {
      document.getElementById('ResearchType0'+i).disabled = true;
    }
    document.getElementById('ResearchType99').disabled = true;
  } else {
    // 施設すべて、チェック出来るようにする
    for (i=1;i<=8;i++) {
      document.getElementById('ResearchType0'+i).disabled = false;
    }
    document.getElementById('ResearchType99').disabled = false;
  }
}

function areaGroupPulldown() {
  if (document.getElementById('daysearchArea').value == 20) {
    // 長野
    for (i=document.getElementById('argAreaGroupList').options.length; i>=0; i--) {
      if (document.getElementById('argAreaGroupList').options[i]) {
        document.getElementById('argAreaGroupList').options[i] = null;
      }
    }
    document.getElementById('argAreaGroupList').disabled = false;
    document.getElementById('argAreaGroupList').options[0] = new Option("安曇野・大町・松本・乗鞍高原 他",98);
    document.getElementById('argAreaGroupList').options[1] = new Option("蓼科・諏訪湖・木曽福島・伊那 他",99);
    document.getElementById('argAreaGroupList').options[2] = new Option("志賀高原・湯田中 他",100);
    document.getElementById('argAreaGroupList').options[3] = new Option("軽井沢・佐久・菅平・長野・別所 他",101);
    document.getElementById('argAreaGroupList').options[4] = new Option("白馬・八方・乗鞍・岩岳・五竜 他",105);
    document.getElementById('argAreaGroupList').options[5] = new Option("野沢・野尻湖・木島平・戸隠 他",108);
    for (i=0;i<document.getElementById('argAreaGroupList').options.length;i++) {
      if (document.getElementById('argAreaGroupList').options[i]) {
        if (document.getElementById('argAreaGroupList').options[i].value == getCookie('argAreaGroupList')) {
          document.getElementById('argAreaGroupList').options[i].selected = true;
        }
      }
    }
    document.getElementById('argAreaGroupList').style.visibility = "visible";
  } else if (document.getElementById('daysearchArea').value == 22) {
    // 静岡
    for (i=document.getElementById('argAreaGroupList').options.length; i>=0; i--) {
      if (document.getElementById('argAreaGroupList').options[i]) {
        document.getElementById('argAreaGroupList').options[i] = null;
      }
    }
    document.getElementById('argAreaGroupList').disabled = false;
    document.getElementById('argAreaGroupList').options[0] = new Option("熱海・伊東・伊豆高原・熱川 他",114);
    document.getElementById('argAreaGroupList').options[1] = new Option("土肥・修善寺・伊豆長岡・下田 他",116);
    document.getElementById('argAreaGroupList').options[2] = new Option("御殿場・静岡・浜松・浜名湖 他",115);
    for (i=0; i<document.getElementById('argAreaGroupList').options.length; i++) {
      if (document.getElementById('argAreaGroupList').options[i]) {
        if (document.getElementById('argAreaGroupList').options[i].value == getCookie('argAreaGroupList')) {
          document.getElementById('argAreaGroupList').options[i].selected = true;
        }
      }
    }
    document.getElementById('argAreaGroupList').style.visibility = "visible";
  } else {
    for (i=document.getElementById('argAreaGroupList').options.length; i>=0; i--) {
      if (document.getElementById('argAreaGroupList').options[i]) {
        document.getElementById('argAreaGroupList').options[i] = null;
      }
    }
    document.getElementById('argAreaGroupList').options[0] = new Option("----------------------",'');
    document.getElementById('argAreaGroupList').disabled = true;
    document.getElementById('argAreaGroupList').style.visibility = "hidden";
  }
}

function getCookie(key) {
  tmp = document.cookie+";";
  tmp1 = tmp.indexOf(key,0);
  if (tmp1 != -1) {
    tmp = tmp.substring(tmp1,tmp.length);
    start = tmp.indexOf("=",0);
    end = tmp.indexOf(";",start);
    return(unescape(tmp.substring(start+1,end)));
  }
  return("");
}

function initDaySearch() {
	if (document.getElementById('daysearchType01').checked) {
		document.getElementById('daysearchType04day').disabled = true;
	} else if (document.getElementById('daysearchType04').checked) {
		document.getElementById('daysearchType04day').disabled = false;
	} else {
		document.getElementById('daysearchType02').checked = true;
		document.getElementById('daysearchType04day').disabled = true;
	}
}

function uTop10_SearchDateSel(argSelRadio)
{
	// 変数初期値
	var f = 'yyyy/MM/dd';
	var date1 = '';
	var date2 = '';
	var YMD1  = '';
	var YMD2  = '';

	// 今日の日付を取得
	date1 = new Date();
	YMD1 = comDateFormat(date1, f);

	// 明日の日付を取得
	date2 = new Date(date1.getFullYear(), (date1.getMonth()), (date1.getDate() + 1));
	YMD2 = comDateFormat(date2, f);

	// 日付設定
	if (argSelRadio != 'daysearchType04') {
		if (argSelRadio == 'daysearchType01') {
			document.getElementById('daysearchType04day').value = YMD1;
		} else {
			document.getElementById('daysearchType04day').value = YMD2;
		}
	}

	if (argSelRadio == 'daysearchType01') {
		document.getElementById('daysearchType01').checked = true;
		document.getElementById('daysearchType04day').disabled = true;
	} else if (argSelRadio=='daysearchType04') {
		document.getElementById('daysearchType04').checked = true;
		document.getElementById('daysearchType04day').disabled = false;
	} else {
		document.getElementById('daysearchType02').checked = true;
		document.getElementById('daysearchType04day').disabled = true;
	}
}

/**
 * 文字列から日付オブジェクトに変換処理
 *
 * @author  H.Kikuuchi<kikuuchi@anagram-works.jp>
 * @param   string $date   日付文字列（処理前）
 * @param   string $format フォーマット
 * @return  string         日付文字列（処理後）
 * @version 1.0
 */
function comDateFormat(date, format)
{
	var result = format;
	var f;
	var rep;
	var yobi = new Array('日', '月', '火', '水', '木', '金', '土');

	f = 'yyyy';
	if (result.indexOf(f) > -1) {
		rep = date.getFullYear();
		result = result.replace(/yyyy/, rep);
	}

	f = 'MM';
	if (result.indexOf(f) > -1) {
		rep = comPadZero(date.getMonth() + 1, 2);
		result = result.replace(/MM/, rep);
	}

	f = 'ddd';
	if (result.indexOf(f) > -1) {
		rep = yobi[date.getDay()];
		result = result.replace(/ddd/, rep);
	}

	f = 'dd';
	if (result.indexOf(f) > -1) {
		rep = comPadZero(date.getDate(), 2);
		result = result.replace(/dd/, rep);
	}

	f = 'HH';
	if (result.indexOf(f) > -1) {
		rep = comPadZero(date.getHours(), 2);
		result = result.replace(/HH/, rep);
	}

	f = 'mm';
	if (result.indexOf(f) > -1) {
		rep = comPadZero(date.getMinutes(), 2);
		result = result.replace(/mm/, rep);
	}

	f = 'ss';
	if (result.indexOf(f) > -1) {
		rep = comPadZero(date.getSeconds(), 2);
		result = result.replace(/ss/, rep);
	}

	f = 'fff';
	if (result.indexOf(f) > -1) {
		rep = comPadZero(date.getMilliseconds(), 3);
		result = result.replace(/fff/, rep);
	}

	return result;
}

/**
 * 0埋め処理
 *
 * @author  H.Kikuuchi<kikuuchi@anagram-works.jp>
 * @param   string  $value  文字列（処理前）
 * @param   integer $length 0埋め後桁数
 * @return  string          文字列（処理後）
 * @version 1.0
 */
function comPadZero(value, length) {
	return new Array(length - ('' + value).length + 1).join('0') + value;
}

