/**
 * function
 */

/**
 * パンくず作成
 */
var makeTopicPath = function(){
    
  var tp = '<li class="first-child">';
  for (var i = 0; i < arguments.length; i++) {
    var element = arguments[i];

    if(i != 0)
      tp += '<li>';
    if(i == arguments.length - 1){
      tp += TPmsg[element] + '</li>';
    }else{
      tp += '<a href="' + TPurl[element] + '">' + TPmsg[element] + '</a></li>';
    }
  }
  document.write(tp);
}

/**
 * ウェザーニュース設定変更メインページ
 */
var changeMWSSettingAttribute = function(id, text, flag){

  var img = '/my/setting/images/internet_btn0' + id + flag + '.gif';
  var key = 'btn' + id;

  $(key).setAttribute('src', img);
  $("exText").innerHTML = text;
}

/**
 * 天気Plus設定変更メインページ
 */
var changeMobileSettingAttribute = function(id, text, flag){

  var img = '/my/setting/images/ktai_icon0' + id + flag + '.gif';
  var key = 'icon' + id;
  var img2;
  if(flag == 'on'){ 
    img2 = '/my/setting/images/ktai_preview0' + id + '.gif';
  }else{
    img2 = '/my/setting/images/0.gif';
  }

  $(key).setAttribute('src', img);
  $("pre").setAttribute('src', img2);
  $("exText").innerHTML = text;
}

/**
 * ログイン画面
 */
function checkFormLogin() {

  var checkLogin = new checkForm('login');
  if(checkLogin.emptyCheck('0','0','1','1')){
    var myRegistData = new registData('mylogin', 'form');
    
  }
  return false;
}

/**
 * 設定変更用呼出し
 */
function loadDataChange(url,menu){

  var myCheckForm = new checkForm(menu);
  var myRegistData = new registData(menu, 'form');
  switch(menu){
    case 'login':
      if(myCheckForm.emptyCheck('0','0','1','1') && checkCookie()){
	document.form.submit();
      }
      break;
    case 'idchange_confirm':
      if(myCheckForm.emptyCheck('0','0','18','15','2','16') && 
         myCheckForm.compareCheck('18','2','19') &&
	 myCheckForm.mailaddressCheck('18')){
	return true;
     }
      break;
    case 'pwchange_confirm':
      if(myCheckForm.emptyCheck('1','1','21','20','2','2') &&
         myCheckForm.lengthCheck('21','6','18') &&
         myCheckForm.compareCheck('21','2','17') &&
	 myCheckForm.alphabetCheck('21')){
        return true;
      }
      break;
    case 'pwchange_fromm_confirm':
      if(myCheckForm.emptyCheck('21','20','2','2') &&
         myCheckForm.lengthCheck('21','6','18') &&
         myCheckForm.compareCheck('21','2','17') &&
	 myCheckForm.alphabetCheck('21')){
        return true;
      }
      break;
    case 'pwentry_frommob_confirm':
      if(myCheckForm.emptyCheck('21','20','2','2') &&
         myCheckForm.lengthCheck('21','6','18') &&
         myCheckForm.compareCheck('21','2','17') &&
         myCheckForm.alphabetCheck('21')){
        return true;
      }
      break;
    case 'pwentry_frommob_reentry_confirm':
      if(myCheckForm.emptyCheck('1','1')){
        return true;
      }
      break;
    case 'pwchange_sendmail_confirm':
      if(myCheckForm.emptyCheck('0','0') &&
	 myCheckForm.mailaddressCheck('0')){
        return true;
      }
      break;
    case 'handsetchange_sendmail_confirm':
      if(myCheckForm.emptyCheck('22','0') &&
	 myCheckForm.mmailaddressCheck('22') ){
        return true;
      }
      break;
    case 'chokan':
      if(myCheckForm.emptyCheck('3','3') && myCheckForm.checkboxCheck('6', dow)){
        myRegistData.displayData(url);
      }
      break;
    case 'warn00':
      if(myCheckForm.emptyCheck('4','4') && myCheckForm.diffCheck('5','19','5') &&
         myCheckForm.checkboxCheck('6', dow)){
        myRegistData.displayData(url);
      }
      break;
    case 'quake0':
      if(myCheckForm.emptyCheck('4','4','7','7') &&
        myCheckForm.diffCheck('5','19','5') && myCheckForm.diffCheck('8','5','8') &&
        myCheckForm.diffCheck('9','19','9') && myCheckForm.checkboxCheck('6', dow)){
	myRegistData.displayData(url);
      }
      break;
    case 'typh00':
      myRegistData.displayData(url);
      break;
    case 'rain':
      if(myCheckForm.emptyCheck('10','10')){
        myRegistData.displaySearchResult(url,'10');
      }
      break;
    case 'rainal':
      if(myCheckForm.emptyCheck('14','13') && myCheckForm.checkboxCheck('6', dow)){
         myRegistData.displayData(url);   
      }
      break;
    case 'rainpl':
      if(myCheckForm.emptyCheck('14','13')){
        myRegistData.displayData(url);
      }
      break;
    case 'mywx1':
      if(myCheckForm.emptyCheck('11','10')){
        myRegistData.displaySearchResult(url,'11');
      }
      break;
    case 'mywx2':
      if(myCheckForm.emptyCheck('15','11','12','10')){
        myRegistData.displaySearchResult(url,'12');
      }
      break;
    case 'mywx3':
      if(myCheckForm.emptyCheck('15','11', '20','12', '13','10')){
         myRegistData.displaySearchResult(url,'13');
      }
      break;
    case 'momywx':
      if(myCheckForm.emptyCheck('15','13') && 
         myCheckForm.emptyFlagCheck('16','17','14')){
	 myRegistData.displayData(url);
      }
      break;
  }

  return false;
}

/**
 * 各種定数
 */
FormKeys = new Array(21);
FormKeys[0] = 'mwsid';
FormKeys[1] = 'mwspw';
FormKeys[2] = 'VERIFY';
FormKeys[3] = 'pref';
FormKeys[4] = 'pref1';
FormKeys[5] = 'pref2';
FormKeys[6] = 'dow';
FormKeys[7] = 'rank1';
FormKeys[8] = 'rank2';
FormKeys[9] = 'rank3';
FormKeys[10] = 'point';
FormKeys[11] = 'point1';
FormKeys[12] = 'point2';
FormKeys[13] = 'point3';
FormKeys[14] = 'post__citycd__amds__name';
FormKeys[15] = 'address1_citycd1_amds1_name1';
FormKeys[16] = 'name';
FormKeys[17] = 'name_flag';
FormKeys[18] = 'mwsid_new';
FormKeys[19] = 'pref3';
FormKeys[20] = 'address2_citycd2_amds2_name2';
FormKeys[21] = 'mwspw_new';
FormKeys[22] = 'mmail';

FormMsgs = new Array(19);
FormMsgs[0] = 'メールアドレスを入力してください。';
FormMsgs[1] = 'パスワードを入力してください。';
FormMsgs[2] = '確認用パスワードを入力してください。';
FormMsgs[3] = '地点(県)を選択してください。';
FormMsgs[4] = '一地点目を選択してください。';
FormMsgs[5] = '二地点目を選択してください。';
FormMsgs[6] = '曜日を指定してください。';
FormMsgs[7] = '一地点目の震度を選択してください。';
FormMsgs[8] = '二地点目の震度を選択してください。';
FormMsgs[9] = '三地点目の震度を選択してください。';
FormMsgs[10] = '住所、もしくは郵便番号を入力してください。';
FormMsgs[11] = '一地点目を入力してください。';
FormMsgs[12] = '二地点目を入力してください。';
FormMsgs[13] = '地点を指定してください。';
FormMsgs[14] = '名前/ニックネームを指定してください。';
FormMsgs[15] = '新しいメールアドレスを入力してください。';
FormMsgs[16] = '確認用にもう一度メールアドレスを入力してください。';
FormMsgs[17] = '入力されたパスワードが一致しません。';
FormMsgs[18] = '6文字以上で入力してください。';
FormMsgs[19] = '入力されたメールアドレスが一致しません。';
FormMsgs[20] = '新しいパスワードを入力してください。';

dow = new Array(7);
dow[0] = 'mm_sun';
dow[1] = 'mm_mon';
dow[2] = 'mm_tue';
dow[3] = 'mm_wed';
dow[4] = 'mm_thr';
dow[5] = 'mm_fri';
dow[6] = 'mm_sat';

ajaxMsgs = new Array(5);
ajaxMsgs[0] = '<font color="red">通信に失敗しましたので、もう一度"変更内容の確認をクリックしてください。</font><hr/>';
ajaxMsgs[1] = '<b>Loading...</b>';
ajaxMsgs[2] = '<font color="red">該当する地点が見つかりませんでした。</font>';
ajaxMsgs[3] = '<font color="red">ご迷惑をおかけしますが、<br/>データの処理ができない状態になっております。<br/>お問い合わせ画面より、<br/>症状をお知らせ頂ければ幸いです。</font><hr/>';

TPurl = new Array(27);
TPmsg = new Array(27);
TPurl[0] = '/my/setting/cgi/myweather.cgi';
TPmsg[0] = 'マイウェザー';
TPurl[1] = '/my/setting/cgi/mysetting_mws.cgi';
TPmsg[1] = '登録設定変更';
TPurl[2] = '/my/setting/cgi/mysetting_mws.cgi?menu=id_change';
TPmsg[2] = 'メールアドレスの変更';
TPurl[3] = '/my/setting/cgi/mysetting_mws.cgi?menu=pw_change';
TPmsg[3] = 'パスワードの変更';
TPurl[4] = '/my/setting/cgi/mysetting_mws.cgi?menu=pw_change_sendmail';
TPmsg[4] = 'パスワードの再登録';
TPurl[5] = '/my/setting/cgi/mws_check.cgi?id_flag=1&pw_flag=1';
TPmsg[5] = '登録内容の確認';
TPurl[6] = '/my/setting/cgi/mysetting_mobile.cgi';
TPmsg[6] = '天気Plus設定変更';
TPurl[7] = '/my/setting/cgi/mysetting_mobile.cgi?menu=chokan';
TPmsg[7] = '朝刊メール設定変更';
TPurl[8] = '/my/setting/cgi/mysetting_mobile.cgi?menu=warn00';
TPmsg[8] = '警報メール設定変更';
TPurl[9] = '/my/setting/cgi/mysetting_mobile.cgi?menu=quake0';
TPmsg[9] = '地震情報メール設定変更';
TPurl[10] = '/my/setting/cgi/mysetting_mobile.cgi?menu=typh00';
TPmsg[10] = '台風メール設定変更';
TPurl[11] = '/my/setting/cgi/mysetting_mobile.cgi?menu=rainal';
TPmsg[11] = '雨雲アラーム設定変更';
TPurl[12] = '/my/setting/cgi/mysetting_mobile.cgi?menu=rainpl';
TPmsg[12] = '雨降りアラーム設定変更';
TPurl[13] = '/my/setting/cgi/mysetting_mobile.cgi?menu=momywx';
TPmsg[13] = 'モバイルマイウェザー設定変更';
TPurl[14] = '/my/setting/cgi/mobile_change.cgi?menu=chokan&status=check';
TPmsg[14] = '朝刊メール設定確認';
TPurl[15] = '/my/setting/cgi/mobile_change.cgi?menu=warn00&status=check';
TPmsg[15] = '警報メール設定確認';
TPurl[16] = '/my/setting/cgi/mobile_change.cgi?menu=quake0&status=check';
TPmsg[16] = '地震情報メール設定確認';
TPurl[17] = '/my/setting/cgi/mobile_change.cgi?menu=typh00&status=check';
TPmsg[17] = '台風メール設定確認';
TPurl[18] = '/my/setting/cgi/mobile_change.cgi?menu=rainal&status=check';
TPmsg[18] = '雨雲アラーム設定確認';
TPurl[19] = '/my/setting/cgi/mobile_change.cgi?menu=rainpl&status=check';
TPmsg[19] = '雨降りアラーム設定確認';
TPurl[20] = '/my/setting/cgi/mobile_change.cgi?menu=momywx&status=check';
TPmsg[20] = 'モバイルマイウェザー設定確認';
TPurl[21] = '/my/setting/cgi/mobile_change.cgi?menu=dchokan&status=confirm';
TPmsg[21] = '朝刊メール配信停止';
TPurl[22] = '/my/setting/cgi/mobile_change.cgi?menu=dwarn00&status=confirm';
TPmsg[22] = '警報メール配信停止';
TPurl[23] = '/my/setting/cgi/mobile_change.cgi?menu=dquake0&status=confirm';
TPmsg[23] = '地震情報メール配信停止';
TPurl[24] = '/my/setting/cgi/mobile_change.cgi?menu=dtyph00&status=confirm';
TPmsg[24] = '台風メール配信停止';
TPurl[25] = '/my/setting/cgi/mobile_change.cgi?menu=drainal&status=confirm';
TPmsg[25] = '雨雲アラーム配信停止';
TPurl[26] = '/my/setting/cgi/mobile_change.cgi?menu=drainpl&status=confirm';
TPmsg[26] = '雨降りアラーム配信停止';
TPurl[27] = '/my/setting/cgi/set_mobile_change/cgi?status=confirm';
TPmsg[27] = '設定変更の確定';
TPurl[28] = '/my/setting/cgi/mysetting_mobile.cgi?menu=handset_change_sendmail';
TPmsg[28] = '携帯登録';
//TPurl[] = '';
//TPmsg[] = '';

/**
 * フォームチェック
 */

var checkForm = Class.create();
checkForm.prototype = {

/** 
 * メニューを覚える
 */
  initialize: function(menu) {
    this.menu = menu;
  },
  
/** 
 * フォームの指定項目に空がないかチェック
 * 受け取る項目は 偶数: フォーム名に該当するFormKeysの番号
 * 奇数: この番号-1 のフォーム名が空だった場合のエラーメッセージに該当するFormMsgsの番号
 */
  emptyCheck: function() {

    var elements = new Array();

    for (var i = 0; i < arguments.length; i+=2) {
      var element = arguments[i];
      var element_comment = arguments[i+1];
      if(! $(FormKeys[element])){
        alert(FormMsgs[element_comment]);
        return false;
      }
      if($F(FormKeys[element]) == "") {
        alert(FormMsgs[element_comment]);
        return false;
      }
      elements.push(element);
    }
    switch(this.menu){
      case 'pwchange':
      case 'idchange':
        this.compareCheck(elements[0],elements[1], '17');
	break;
    }
    return 1;
  },

/** 
 * 入力確認時フォームがある時、一つ目と二つ目の内容に差がないかをチェック
 * id1 : 一つ目のフォーム番号 id2: 二つ目のフォーム番号 
 */
  compareCheck: function(id1, id2, msg) {
    if($F(FormKeys[id1]) != $F(FormKeys[id2])){
      alert(FormMsgs[msg]);
      $F(FormKeys[id1]).focus;
      return  false;
    }
    return 1;
  },

  diffCheck: function(id1, id2, msg) {
    if($F(FormKeys[id1]) == "" && $F(FormKeys[id2]) != ""){
      alert(FormMsgs[msg]);
      $F(FormKeys[id1]).focus;
      return  false;
    }
    return 1;
  },

  emptyFlagCheck: function(id1, id2, msg) {
    if($F(FormKeys[id1]) == "" && $F(FormKeys[id2]) == "1"){
      alert(FormMsgs[msg]);
      $F(FormKeys[id1]).focus;
      return  false;
    }
    return 1;
  },

  checkboxCheck: function(){

    var msg = arguments[0];
    var text = new String(arguments[1]);
    var args = text.split(',');

    var flag = 0;
    for(var i=0; i<args.length; i++){

      if($(args[i]).checked){
        flag++;
      }
    }
    if (flag == "0"){
      alert(FormMsgs[msg]);
      return  false;
    }
    return 1;
  },

  lengthCheck: function(id, min, msg) {
    if($F(FormKeys[id]).length < min){
      alert(FormMsgs[msg]);
      $F(FormKeys[id]).focus;
      return false;
    }
    return 1;
  },

  alphabetCheck: function(id) {
    if($F(FormKeys[id]).match( /[^A-Za-z0-9\s.-]+/ )){
      alert('半角英数文字で入力してください。');
      $F(FormKeys[id]).focus;
      return false;
    }
    return 1;
  },

  mailaddressCheck: function(id) {
    if( $F(FormKeys[id]).indexOf('\@',0) == -1 || $F(FormKeys[id]).indexOf('.',0) == -1      || $F(FormKeys[id]).indexOf(".", $F(FormKeys[id]).indexOf("\@")) <= -1 || $F(FormKeys[id]).match(/\!|\#|\$|\%|\^|\&|\*|\(|\)|\[|\]|\{|\}|\:|\;|\'|\"/i)) {
      alert("メールアドレスの形式が間違っています。");
      return false;
    }
    if($F(FormKeys[id]).match(/docomo.ne.jp|vodafone.ne.jp|ezweb.ne.jp|softbank.ne.jp|disney.ne.jp/)){
      alert("携帯のメールアドレスは使えません。");
      return false;
    }
    return 1;
  },

  mmailaddressCheck: function(id) {
    if( $F(FormKeys[id]).indexOf('\@',0) == -1 || $F(FormKeys[id]).indexOf('.',0) == -1      || $F(FormKeys[id]).indexOf(".", $F(FormKeys[id]).indexOf("\@")) <= -1 || $F(FormKeys[id]).match(/\!|\#|\$|\%|\^|\&|\*|\(|\)|\[|\]|\{|\}|\:|\;|\'|\"/i)) {
      alert("メールアドレスの形式が間違っています。");
      return false;
    }
    if(! $F(FormKeys[id]).match(/docomo.ne.jp|vodafone.ne.jp|ezweb.ne.jp|softbank.ne.jp|disney.ne.jp/)){
      alert("携帯電話のメールアドレスを入力して下さい。");
      return false;
    }
    return 1;
  }
}

/**
 * DBにデータを登録して、必要であれば、ページを書き換え
 */ 
var registData = Class.create();
registData.prototype = {
  initialize: function(menu, form) {
    this.menu = menu;
    this.args = 'menu=' + this.menu + '&';
    this.args += Form.serialize($(form));
    this.args += "&send_flag=1";
  },

  passArgs: function(url){
    window.location=url + '?' + this.args;
  },

  displayData: function(url) {
    var menu = this.menu;
    var myAjax = new Ajax.Request(
                                 url,
                                { method: 'get',
                                  parameters: this.args,
				  onFailer: function() {
					    Show("result");
					    $("result").innerHTML = ajaxMsgs[0];
					    },
				  onCreate: function() {
					    Show("result");
					    $("result").innerHTML = ajaxMsgs[1];
					    },
				  onComplete: function(request) {
					    if(request.status != 200 || request.readyState != 4 ){
					      $("result").innerHTML = ajaxMsgs[3];
					      return 1;
					    }

					    if(request.responseText == 'error'){
 					      Show("result");
					      $("result").innerHTML = ajaxMsgs[3];
					    }else{
					      $("content").innerHTML = request.responseText;
					    }
					    }
				}
                                );
  },

  displaySearchResult: function(url, id) {

    var menu = this.menu;

    var category = 3;
    if(isNaN($F(FormKeys[id]))){
      category = 1;
    }
    this.args += "&service="+category;

    var myAjax = new Ajax.Request(
                                 url,
                                { method: 'get',
                                  parameters: this.args,
				  onFailer: function() {
					    Show("result");
					    $("result").innerHTML = ajaxMsgs[0];
					    },
				  onCreate: function() {
					    Show("result");
					    $("result").innerHTML = ajaxMsgs[1];
					    },
				  onComplete: function(request) {
					    var id = 'search';

					    switch(menu){
					      case 'mywx1':
					        id = 'search1';
						break;
					      case 'mywx2':
					        id = 'search2';
						break;
					      case 'mywx3':
					        id = 'search3';
						break;
					      }

					    if(request.status != 200 || request.readyState != 4 ){
 					      Show("result");
					      $("result").innerHTML = ajaxMsgs[3];
					      return 1;
					    }

					    if(request.responseText == 'error'){
 					      Show("result");
					      $("result").innerHTML = ajaxMsgs[2];
					    }else{
					      $(id).innerHTML = request.responseText;
					    }
					    }
				}
				);
  },

  displayDataRedirect: function(url) {

    var menu = this.menu;
    var myAjax = new Ajax.Request(
                                 url,
                                { method: 'get',
                                  parameters: this.args,
				  onFailer: function() {
					    Show("result");
					    $("result").innerHTML = ajaxMsgs[0];
					    },
				  onCreate: function() {
					    Show("result");
					    $("result").innerHTML = ajaxMsgs[1];
					    },
				  onComplete: function(request) {
					    if(request.status != 200 || request.readyState != 4 ){
					      Show("result");
					      $("result").innerHTML = ajaxMsgs[3];
					      return 1;
					    }

					    if(request.responseText == 'error'){
					      $("result").innerHTML = ajaxMsgs[3];
					    }else{
					      document.cookie = 'SSI=;path=/;domain=.weathernews.jp';
					      $("content").innerHTML = request.responseText;
					      setTimeout('top.location.href="./mylogin.cgi";',1000 );
					    }
					    }
				  }
				  );
  }
}

/**
 * スタイルシートを出したり隠したり
 * 設定画面で多用。
 */

function Hide(content){
	 if(navigator.appName.charAt(0) == "M"){
		if(navigator.appVersion.indexOf("MSIE 5") != -1 || navigator.appVersion.indexOf("MSIE 6") != -1){
		       if(document.getElementById){
				document.getElementById(content).style.visibility="hidden";
			}
		}else{
			if(document.all){
				document.all(content).style.visibility="hidden";
			}
		}
	}
	if(navigator.appName.charAt(0) == "N"){
	      if(document.getElementById){
			document.getElementById(content).style.visibility="hidden";
		}
		if(document.layers){
			document.layers[content].visibility="hidden";
		}
	}
}

function Show(content){
	 if(navigator.appName.charAt(0) == "M"){
		if(navigator.appVersion.indexOf("MSIE 5") != -1 || navigator.appVersion.indexOf("MSIE 6") != -1){
		       if(document.getElementById){
				document.getElementById(content).style.visibility="visible";
			}
		}else{
			if(document.all){
				document.all(content).style.visibility="visible";
			}
		}
	}
	if(navigator.appName.charAt(0) == "N"){
	      if(document.getElementById){
			document.getElementById(content).style.visibility="visible";
		}
		if(document.layers){
			document.layers[content].visibility="show";
		}
	}
}

/**
 * コンテンツ毎の県の設定
 *
 * 朝刊用
 */
function changePref_Chokan(n)
{

	if(n==0){
		with(document.forms[0].pref){
			options.length=7;
			options[0].text = '北海道';
			options[0].value = '14';
			options[1].text = '青森';
			options[1].value = '31';
			options[2].text = '岩手';
			options[2].value = '33';
			options[3].text = '秋田';
			options[3].value = '32';
			options[4].text = '宮城';
			options[4].value = '34';
			options[5].text = '山形';
			options[5].value = '35';
			options[6].text = '福島';
			options[6].value = '36';
		}
	}else if(n == 1){
		with(document.forms[0].pref){
			options.length=10;
			options[0].text = '東京';
			options[0].value = '44';
			options[1].text = '神奈川';
			options[1].value = '46';
			options[2].text = '埼玉';
			options[2].value = '43';
			options[3].text = '千葉';
			options[3].value = '45';
			options[4].text = '茨城';
			options[4].value = '40';
			options[5].text = '群馬';
			options[5].value = '42';
			options[6].text = '栃木';
			options[6].value = '41';
			options[7].text = '新潟';
			options[7].value = '54';
			options[8].text = '長野';
			options[8].value = '48';
			options[9].text = '山梨';
			options[9].value = '49';
		}
	}else if(n == 2){
		with(document.forms[0].pref){
			options.length=7;
			options[0].text = '愛知';
			options[0].value = '51';
			options[1].text = '静岡';
			options[1].value = '50';
			options[2].text = '岐阜';
			options[2].value = '52';
			options[3].text = '三重';
			options[3].value = '53';
			options[4].text = '石川';
			options[4].value = '56';
			options[5].text = '富山';
			options[5].value = '55';
			options[6].text = '福井';
			options[6].value = '57';
		}
	}else if(n ==3){
		with(document.forms[0].pref){
			options.length=6;
			options[0].text = '大阪';
			options[0].value = '62';
			options[1].text = '兵庫';
			options[1].value = '63';
			options[2].text = '京都';
			options[2].value = '61';
			options[3].text = '奈良';
			options[3].value = '64';
			options[4].text = '滋賀';
			options[4].value = '60';
			options[5].text = '和歌山';
			options[5].value = '65';
		}
	}else if(n == 4){
		with(document.forms[0].pref){
			options.length=9;
			options[0].text = '広島';
			options[0].value = '67';
			options[1].text = '岡山';
			options[1].value = '66';
			options[2].text = '山口';
			options[2].value = '81';
			options[3].text = '島根';
			options[3].value = '68';
			options[4].text = '鳥取';
			options[4].value = '69';
			options[5].text = '愛媛';
			options[5].value = '73';
			options[6].text = '香川';
			options[6].value = '72';
			options[7].text = '徳島';
			options[7].value = '71';
			options[8].text = '高知';
			options[8].value = '74';
		}
	}else if(n == 5){
	      with(document.forms[0].pref){
			options.length=8;
			options[0].text = '福岡';
			options[0].value = '82';
			options[1].text = '佐賀';
			options[1].value = '85';
			options[2].text = '長崎';
			options[2].value = '84';
			options[3].text = '大分';
			options[3].value = '83';
			options[4].text = '熊本';
			options[4].value = '86';
			options[5].text = '宮崎';
			options[5].value = '87';
			options[6].text = '鹿児島';
			options[6].value = '88';
			options[7].text = '沖縄';
			options[7].value = '91';
		}
	}else{
		with(document.forms[0].pref){
			options.length=1;
			options[0].text = '---';
			options[0].value = '';
		}
	}
	document.forms[0].pref.options[0].selected=true;
}

// 警報用

function changePref_Warn(n, key)
{
	
	if(n==0){
		with(key){
			options.length=14;
			options[0].text = '宗谷';
			options[0].value = '010101';
			options[1].text = '上川';
			options[1].value = '010102';
			options[2].text = '留萌';
			options[2].value = '010103';
			options[3].text = '石狩';
			options[3].value = '010201';
			options[4].text = '空知';
			options[4].value = '010202';
			options[5].text = '後志';
			options[5].value = '010203';
			options[6].text = '網走';
			options[6].value = '010301';
			options[7].text = '根室';
			options[7].value = '010304';
			options[8].text = '釧路';
			options[8].value = '010305';
			options[9].text = '十勝';
			options[9].value = '010306';
			options[10].text = '胆振';
			options[10].value = '010401';
			options[11].text = '日高';
			options[11].value = '010402';
			options[12].text = '渡島';
			options[12].value = '010403';
			options[13].text = '檜山';
			options[13].value = '010404';
		}
	}else if(n == 1){
		with(key){
			options.length=6;
			options[0].text = '青森';
			options[0].value = '0201';
			options[1].text = '岩手';
			options[1].value = '0202';
			options[2].text = '秋田';
			options[2].value = '0204';
			options[3].text = '宮城';
			options[3].value = '0203';
			options[4].text = '山形';
			options[4].value = '0205';
			options[5].text = '福島';
			options[5].value = '0206';
		}
	}else if(n == 2){
		with(key){
			options.length=11;
			options[0].text = '東京';
			options[0].value = '0306';
			options[1].text = '神奈川';
			options[1].value = '0307';
			options[2].text = '埼玉';
			options[2].value = '0304';
			options[3].text = '千葉';
			options[3].value = '0305';
			options[4].text = '茨城';
			options[4].value = '0301';
			options[5].text = '群馬';
			options[5].value = '0303';
			options[6].text = '栃木';
			options[6].value = '0302';
			options[7].text = '新潟';
			options[7].value = '0401';
			options[8].text = '長野';
			options[8].value = '0402';
			options[9].text = '山梨';
			options[9].value = '0403';
			options[10].text = '伊豆諸島';
			options[10].value = '0308';
		}
	}else if(n == 3){
		with(key){
			options.length=7;
			options[0].text = '愛知';
			options[0].value = '0506';
			options[1].text = '静岡';
			options[1].value = '0505';
			options[2].text = '岐阜';
			options[2].value = '0504';
			options[3].text = '三重';
			options[3].value = '0507';
			options[4].text = '石川';
			options[4].value = '0502';
			options[5].text = '富山';
			options[5].value = '0501';
			options[6].text = '福井';
			options[6].value = '0503';
		}
	}else if(n == 4){
		with(key){
			options.length=6;
			options[0].text = '大阪';
			options[0].value = '0603';
			options[1].text = '兵庫';
			options[1].value = '0604';
			options[2].text = '京都';
			options[2].value = '0602';
			options[3].text = '奈良';
			options[3].value = '0605';
			options[4].text = '滋賀';
			options[4].value = '0601';
			options[5].text = '和歌山';
			options[5].value = '0606';
		}
	}else if(n == 5){
		with(key){
			options.length=9;
			options[0].text = '広島';
			options[0].value = '0704';
			options[1].text = '岡山';
			options[1].value = '0703';
			options[2].text = '山口';
			options[2].value = '0705';
			options[3].text = '島根';
			options[3].value = '0702';
			options[4].text = '鳥取';
			options[4].value = '0701';
			options[5].text = '愛媛';
			options[5].value = '0803';
			options[6].text = '香川';
			options[6].value = '0802';
			options[7].text = '徳島';
			options[7].value = '0801';
			options[8].text = '高知';
			options[8].value = '0804';
		}
	}else if(n == 6){
	      with(key){
			options.length=9;
			options[0].text = '福岡';
			options[0].value = '0901';
			options[1].text = '佐賀';
			options[1].value = '0902';
			options[2].text = '長崎';
			options[2].value = '0903';
			options[3].text = '大分';
			options[3].value = '0905';
			options[4].text = '熊本';
			options[4].value = '0904';
			options[5].text = '宮崎';
			options[5].value = '0906';
			options[6].text = '鹿児島';
			options[6].value = '0907';
			options[7].text = '奄美';
			options[7].value = '090704';
			options[8].text = '沖縄';
			options[8].value = '0908';
		}
	}else{
		with(key){
			options.length=1;
			options[0].text = '---';
			options[0].value = '';
		}
	}
	key.options[0].selected=true;
}

// 地震用

function changePref_Quake(n, key)
{

	if(n==0){
		with(key){
			options.length=10;
			options[0].text = '道北';
			options[0].value = '0101';
			options[1].text = '道央';
			options[1].value = '0102';
			options[2].text = '道東';
			options[2].value = '0103';
			options[3].text = '道南';
			options[3].value = '0104';
			options[4].text = '青森';
			options[4].value = '0201';
			options[5].text = '岩手';
			options[5].value = '0202';
			options[6].text = '秋田';
			options[6].value = '0204';
			options[7].text = '宮城';
			options[7].value = '0203';
			options[8].text = '山形';
			options[8].value = '0205';
			options[9].text = '福島';
			options[9].value = '0206';
		}
	}else if(n == 1){
		with(key){
			options.length=11;
			options[0].text = '東京';
			options[0].value = '0306';
			options[1].text = '神奈川';
			options[1].value = '0307';
			options[2].text = '埼玉';
			options[2].value = '0304';
			options[3].text = '千葉';
			options[3].value = '0305';
			options[4].text = '茨城';
			options[4].value = '0301';
			options[5].text = '群馬';
			options[5].value = '0303';
			options[6].text = '栃木';
			options[6].value = '0302';
			options[7].text = '新潟';
			options[7].value = '0401';
			options[8].text = '長野';
			options[8].value = '0402';
			options[9].text = '山梨';
			options[9].value = '0403';
			options[10].text = '伊豆・小笠原諸島';
			options[10].value = '0308';
		}
	}else if(n == 2){
		with(key){
			options.length=7;
			options[0].text = '愛知';
			options[0].value = '0506';
			options[1].text = '静岡';
			options[1].value = '0505';
			options[2].text = '岐阜';
			options[2].value = '0504';
			options[3].text = '三重';
			options[3].value = '0507';
			options[4].text = '石川';
			options[4].value = '0502';
			options[5].text = '富山';
			options[5].value = '0501';
			options[6].text = '福井';
			options[6].value = '0503';
		}
	}else if(n ==3){
		with(key){
			options.length=6;
			options[0].text = '大阪';
			options[0].value = '0603';
			options[1].text = '兵庫';
			options[1].value = '0604';
			options[2].text = '京都';
			options[2].value = '0602';
			options[3].text = '奈良';
			options[3].value = '0605';
			options[4].text = '滋賀';
			options[4].value = '0601';
			options[5].text = '和歌山';
			options[5].value = '0606';
		}
	}else if(n == 4){
		with(key){
			options.length=9;
			options[0].text = '広島';
			options[0].value = '0704';
			options[1].text = '岡山';
			options[1].value = '0703';
			options[2].text = '山口';
			options[2].value = '0705';
			options[3].text = '島根';
			options[3].value = '0702';
			options[4].text = '鳥取';
			options[4].value = '0701';
			options[5].text = '愛媛';
			options[5].value = '0803';
			options[6].text = '香川';
			options[6].value = '0802';
			options[7].text = '徳島';
			options[7].value = '0801';
			options[8].text = '高知';
			options[8].value = '0804';
		}
	}else if(n == 5){
	      with(key){
			options.length=8;
			options[0].text = '福岡';
			options[0].value = '0901';
			options[1].text = '佐賀';
			options[1].value = '0902';
			options[2].text = '長崎';
			options[2].value = '0903';
			options[3].text = '大分';
			options[3].value = '0905';
			options[4].text = '熊本';
			options[4].value = '0904';
			options[5].text = '宮崎';
			options[5].value = '0906';
			options[6].text = '鹿児島';
			options[6].value = '0907';
			options[7].text = '沖縄';
			options[7].value = '0908';
		}
	}else{
		with(key){
			options.length=1;
			options[0].text = '---';
			options[0].value = '';
		}
	}
	key.options[0].selected=true;
}

/**
 * 毎日を選んだときに、全ての曜日にチェックが入るように。
 */
function dowAllSelect() {

  if($("recieve_day").checked){
    for(i=0; i< dow.length; i++){
      if($(dow[i]).checked == "")
        $(dow[i]).checked = 'true';
    }
  }
}

function startViewer() {

     var scrw = screen.width;
     var scrh = screen.height;
     scrh -= 40;

     var attr = "toolbar=0" + ",location=0" + ",directories=0" +  
",status=0"
         + ",menubar=0" + ",scrollbars=0" + ",resizable=1"
         + ",width=" + scrw + ",height=" + scrh
         + ",left=0" + ",top=0" + ",replace=false";
     var viewer = window.open("http://labs.weathernews.jp/anademo/","AnalysisViewer", attr);
     viewer.focus();
}

/* 対応ブラウザか否かをチェック */
function checkSupport(){
    var OS = getOSType();
    var Browser = getBrowserName();
    
    if(OS == "Windows" || OS == "MacOS") return true;
/*    if((OS == "MacOS") && 
	(Browser == "Netscape" || Browser == "Safari" || Browser == "Opera"))
	return true;
*/
    alert("ご利用のブラウザは弊社のサービスサポート対象外のブラウザです。\n有料コンテンツの機能を全てご利用いただけない場合がございますので、ご了承ください。");
    return true;
}

// CookieCheck

function checkCookie(){

//   alert('只今メンテナンス中のため、この操作はご利用いただけません');
//   return false;

   var key = 'cookietest'
   var tmp = key + '=1;';
   document.cookie = tmp;
   var ret = getCookie(key);
   if(ret == 1){
      return checkSupport();
   }
   alert("弊社の有料サービスをご利用いただくためにはCookieへの書き込みが必要です。\nCookieの書き込みを許可していただきますようお願い致します。");

   return false;
}

