/*
===========================================================
フォントサイズ変更スクリプト（タイプC）

Last Updated:08/21/2004
　　　09/21/2001最終更新版より下記のURIのみ変更

insomnia!
http://insomnia.jp/
http://insomnia.jp/workshop/
===========================================================
*/


/*
========== ::: 初期設定 ::: ==========
*/

// 値の単位を設定（必ずダブルクオートかクオートで括る）
var fontSizeUnit = "%";

// 一回の操作で変化させる値を設定（ダブルクオートやクオートで括らない）
var perOrder = 10;

// 初期状態の値を設定（ダブルクオートやクオートで括らない）
var defaultSize = 85;

// クッキーの名前（必ずダブルクオートかクオートで括る）
var ckName = "ootakinen_website";

// クッキーの有効期限（日）（ダブルクオートやクオートで括らない）
var ckDays = 2;

// クッキーのパス（必ずダブルクオートかクオートで括る。指定が不要の場合は"/"にする）
var ckPath = "/"


/*
========== ::: ページ読み込み時の値を設定 ::: ==========
*/

// クッキー読み出し
var fsCK = GetCookie( ckName );

if ( fsCK == null ){
  var currentSize = defaultSize;          //クッキーが無ければ現在の値を初期状態の値に設定
}
else{
  var currentSize = eval( fsCK );          //クッキーがあれば現在の値をクッキーの値に設定
}


/*
========== ::: head内にstyle要素を出力 ::: ==========
*/
currentSize_h2 = currentSize + 30;
currentSize_h3 = currentSize + 20;
currentSize_h4 = currentSize + 10;
currentSize_h5 = currentSize + 10;;
currentSize_t_h3 = currentSize + 10;
currentSize_t_h4 = currentSize + 5;
currentSize_t_li = currentSize + 10;
document.writeln( '<style type="text/css" media="screen,print">' );
document.write( 'body,th,td{font-size:' + currentSize + fontSizeUnit+ '}' );
document.write( 'h2{font-size:' + currentSize_h2 + fontSizeUnit+ '}' );
document.write( 'h3{font-size:' + currentSize_h3 + fontSizeUnit+ '}' );
document.write( 'h4{font-size:' + currentSize_h4 + fontSizeUnit+ '}' );
document.write( 'h5,h6{font-size:' + currentSize_h5 + fontSizeUnit+ '}' );
document.write( '#main h3{font-size:' + currentSize_t_h3 + fontSizeUnit+ '}' );
document.write( '#main h4{font-size:' + currentSize_t_h4 + fontSizeUnit+ '}' );
document.write( '#main li{font-size:' + currentSize_t_li + fontSizeUnit+ '}' );
document.writeln( '</style>' );


/*===================================
  [関数 fsc]
  引数CMDに渡される値に応じて
  変更後の値を算出しクッキーに書き込む。
====================================*/

function fsc( CMD ){

  // 拡大：現時点の値に一回の操作で変化させる値を加えて操作後の値"newSize"に代入
  if ( CMD == "larger" ){
    var newSize = Number( currentSize + perOrder );
    SetCookie( ckName , newSize );          //クッキー書き込み
  }

  // 縮小：現時点の値から一回の操作で変化させる値を引き操作後の値に代入
  // 現時点のサイズの値が一回の操作で変化させる値と同じならそのまま操作後の値に代入
  if ( CMD == "smaller" ){
    if ( currentSize != perOrder ){
      var newSize = Number( currentSize - perOrder );
      SetCookie( ckName , newSize );          //クッキー書き込み
    }
    else{
      var newSize = Number( currentSize );
    }
  }

  // 元に戻す：操作後の値を初期値にする
  if ( CMD == "default" ){
    DeleteCookie( ckName );          //クッキー削除
  }

  // ページの再読み込み
  // 再読み込みをすることで変更後の値を反映したstyle要素が出力される
  location.reload();
}

// _______________________________________ end of function fsc() ___ 


/*===================================
  [関数 SetCookie]
  クッキーに値を書き込む
====================================*/
function SetCookie( name , value ){
  var dobj = new Date();
  dobj.setTime(dobj.getTime() + 24 * 60 * 60 * ckDays * 1000);
  var expiryDate = dobj.toGMTString();
  document.cookie = name + '=' + escape(value) + ';expires=' + expiryDate + ';path=' + ckPath;
}

/*===================================
  [関数 GetCookie]
  クッキーを取得する
====================================*/
function GetCookie (name){
  var arg  = name + "=";
  var alen = arg.length;
  var clen = document.cookie.length;
  var i = 0;
  while (i < clen){
    var j = i + alen;
    if (document.cookie.substring(i, j) == arg)
    return getCookieVal (j);
    i = document.cookie.indexOf(" ", i) + 1;
    if (i == 0) break;
  }
  return null;
}

/*===================================
  [関数 getCookieVal]
  クッキーの値を抽出する
====================================*/
function getCookieVal (offset){
  var endstr = document.cookie.indexOf (";", offset);
  if (endstr == -1)
  endstr = document.cookie.length;
  return unescape(document.cookie.substring(offset,endstr));
}

/*===================================
  [関数 DeleteCookie]
  クッキーを削除する
====================================*/
function DeleteCookie(name){
  if (GetCookie(name)){
    document.cookie = name + '=' +
    '; expires=Thu, 01-Jan-70 00:00:01 GMT;path='+ckPath;
  }
}

//EOF



/*------------------------------プルダウン用*------------------------------*/

function change(myURI){
 if(myURI !="default"){
  window.document.location.href=myURI;
 }
}

/*-------更新オブジェクトの更新画面で削除を押したときの確認チェック*-------*/

function check(){

    if(window.confirm('削除してよろしいですか？')){ // 確認ダイアログを表示
    return true; // 「OK」時は削除を実行
    }

  else{ // 「キャンセル」時の処理

    window.alert('キャンセルされました'); // 警告ダイアログを表示
    return false; // 削除を中止

    }

}

function RandomImageLink(){
	var imglist = [
      [ "img/js_img/js_q_01.jpg", "良質の医療を1", "patient/quality/index.html" ] ,
      [ "img/js_img/js_q_02.jpg", "良質の医療を2", "patient/quality/me.html" ] ,
      [ "img/js_img/js_q_03.jpg", "良質の医療を3", "patient/quality/team.html" ] ,
      [ "img/js_img/js_q_04.jpg", "良質の医療を4", "patient/quality/tendance.html" ] ,
      [ "img/js_img/js_q_05.jpg", "良質の医療を5", "patient/quality/coalition.html" ] //注
   ];
   // どれか１つ選ぶ ………………………《A》
   var selectnum = Math.floor(Math.random() * imglist.length);
   // 画像とリンクを生成 …………………《B》
   var output = 
      '<a href="' + imglist[selectnum][2] + '">' +
      '<img src="' + imglist[selectnum][0] + '"' +
      ' alt="' + imglist[selectnum][1] + '"><br></a>';
   // 生成したHTMLを出力 …………………《C》
   document.write(output);
}

function RandomImageLink2(){
	var imglist = [
      [ "img/js_img/js_l_01.jpg", "パパママスクール", "patient/papamama/index.html" ] ,
      [ "img/js_img/js_l_02.jpg", "糖尿病教室", "patient/diabclass/index.html" ] ,
      [ "img/js_img/js_l_03.jpg", "サマーキャンプ", "patient/camp/index.html" ] ,
      [ "img/js_img/js_l_04.jpg", "栄養相談", "patient/nutrition/index.html" ] ,
      [ "img/js_img/js_l_05.jpg", "人間ドック", "center/medical_check/index.html#h2_dock" ] //注
   ];
   // どれか１つ選ぶ ………………………《A》
   var selectnum = Math.floor(Math.random() * imglist.length);
   // 画像とリンクを生成 …………………《B》
   var output = 
      '<a href="' + imglist[selectnum][2] + '">' +
      '<img src="' + imglist[selectnum][0] + '"' +
      ' alt="' + imglist[selectnum][1] + '"><br></a>';
   // 生成したHTMLを出力 …………………《C》
   document.write(output);
}

//ポップアップウインドウ
function wOpen(url,w_name,w_width,w_height) {
	var features="scrollbars=yes,menubar=yes,toolbar=yes,locationbar=yes,directories=yes,status=yes,resizable=yes";
	features+=", width=" + w_width + ", height=" + w_height;
	window.open(url,w_name,features);
}

//セレクトリンク
function JumpToURL(form,type)
{
  var root_url = 'http://www.okayama-med.jrc.or.jp/';
  if(type == 1){
    var IndexName = form.menu_1.selectedIndex;
    var url= form.menu_1.options[IndexName].value;
  }
  if(type == 2){
    var IndexName = form.menu_2.selectedIndex;
    var url= form.menu_2.options[IndexName].value;
  }
  if(type == 4){
    var IndexName = form.menu_4.selectedIndex;
    var url= form.menu_4.options[IndexName].value;
  }
  if(type == 5){
    var IndexName = form.menu_5.selectedIndex;
    var url= form.menu_5.options[IndexName].value;
  }

  if(type == 3){
    var IndexName = form.menu_3.selectedIndex;
    var url= form.menu_3.options[IndexName].value;
  }
  if (url != "-") location.href = root_url + url;
}

function mailcheck(){
	var arg = "";
	if (document.getElementById('namae').value == ''){
		arg = arg + 'ご氏名を入力して下さい\n';
	}
	if (document.getElementById("email").value == ''){
		arg = arg + 'メールアドレスを入力して下さい\n';
	}else{
		if(!document.mailform.email.value.match(/.+@.+\..+/)){ 
			arg = arg + 'メールアドレスが正しくありません\n';
		}
	}
	if (document.getElementById("msg").value == ''){
		arg = arg + '内容を入力して下さい\n';
	}
	if (arg != ''){
		alert ("*** 入力チェックエラー ***\n\n" + arg);
		return false;
	}
}
function openWin(theURI,takasa) {
	var arg = 'scrollbars=1,' + 'width=810,' + 'height=' + takasa + ',resizable=1,directories=0,toolbar=0,status=1,location=0';
	PopUpWin=window.open(theURI,'theWin',arg);
	PopUpWin.focus();
}