
/*------------------------------------------------------------
 * stripedtable.js Version 1.0
 * Author : Kyosuke Nakamura
 * http://kyosuke.jp/
 *------------------------------------------------------------
 * 特定classのtable要素内、tr要素に対して交互にクラスをつけます。
 * className : ロールオーバーを設定するためのクラス名
 * oddlineClassName : 奇数ラインに付くクラス名
 * evanlineClassName : 偶数ラインに付くクラス名
 * 使用方法）http://kyosuke.jp/portfolio/javascript/stripedtable.html
/*------------------------------------------------------------*/
/*------------------------------------------------------------
 * class名を複数指定すると動きません
 * 使いたいページのbodyタグに onload="setStripedTable()" を追加します。
/*------------------------------------------------------------*/
 

conf = {
  className : "stripedtable",
  oddlineClassName : "oddline",
  evenlineClassName : "evenline"
}

function setStripedTable(){
  var tables = getElementsByClassName(conf.className);
  for (var i=0, len=tables.length; i<len; i++){
    var table = tables[i];
    var lines = table.getElementsByTagName("tr");

    for (var j=0, llen=lines.length; j<llen; j++){
      tr = lines[j];
      if(j%2==0) {
        tr.className = conf.oddlineClassName;
      } else {
        tr.className = conf.evenlineClassName;
      }
    }
  }
}

function getElementsByClassName(name){
  var elements = new Array();
  var allElements = document.getElementsByTagName('*');
  for (var i=0, len=allElements.length; i<len; i++){
    if (allElements[i].className == name){
      elements.push(allElements[i]);
    }
  }
  return elements;
} 


//ロールオーバー
/*------------------------------------------------------------
  Standards Compliant Rollover Script
  Author : Daniel Nolan
  http://www.bleedingego.co.uk/webdev.php
 *------------------------------------------------------------
 * マウスオーバー時の画像切り替え
 * ロールオーバーを設定する画像にクラス名「imgover」を指定
 * ロールオーバー時に表示するための画像ファイル名後ろに「_o」をつける
/*------------------------------------------------------------*/


function initRollovers() {
  if (!document.getElementById) return
  
  var aPreLoad = new Array();
  var sTempSrc;
  var aImages = document.getElementsByTagName('img');

  for (var i = 0; i < aImages.length; i++) {    
    if (aImages[i].className == 'imgover') {
      var src = aImages[i].getAttribute('src');
      var ftype = src.substring(src.lastIndexOf('.'), src.length);
      var hsrc = src.replace(ftype, '_o'+ftype);

      aImages[i].setAttribute('hsrc', hsrc);
      
      aPreLoad[i] = new Image();
      aPreLoad[i].src = hsrc;
      
      aImages[i].onmouseover = function() {
        sTempSrc = this.getAttribute('src');
        this.setAttribute('src', this.getAttribute('hsrc'));
      }  
      
      aImages[i].onmouseout = function() {
        if (!sTempSrc) sTempSrc = this.getAttribute('src').replace 
('_o'+ftype, ftype);
        this.setAttribute('src', sTempSrc);
      }
    }
  }
}

window.onload = initRollovers;

// 本文印刷
/*------------------------------------------------------------
 * 本文印刷時のCSS切り替え
 * URL、パス要変更
/*------------------------------------------------------------*/


var path = "http://www.jaf.or.jp/"; //urlを書き換え

//initButton
function initButton() {
  if(navigator.appVersion.indexOf("Mac") > -1 && navigator.appName.charAt(0) == "M"){
    //
    }else{
    document.write('<a href="javascript:void(0)" onclick="replace_css(\'print\',\''+path+'/common/css/print.css\');window.print();changeCSS()">');
    document.write('<img src="'+path+'common/image/btn_print.gif" width="77" height="19" alt="本文印刷" />');
    document.write('</a>');
  }
}

//replace_css
function replace_css(id,url){
if(!document.getElementById) return false;
  var element = document.getElementById(id);
  if(!element || !element.cloneNode) return false;
  var new_node = element.cloneNode(true);
  new_node.href = url;
  element.parentNode.replaceChild(new_node,element);
  return true;
}

//changeCSS
function changeCSS(){
  var cssPath = path + "common/css/screen.css";
  setTimeout("replace_css('print','"+cssPath+"')",5000);
}


// ポップアップ
/*------------------------------------------------------------
 * 月別救援データページで使用するポップアップ
/*------------------------------------------------------------*/
function openWin(URL){
  var wo1;
  wo1=window.open(URL,"newwin","height=480,width=520,toolbar=no,status=no,location=no,scrollbars=no,resizable=no,left=20,top=40");
  wo1.focus();
}
/*------------------------------------------------------------
 * 月別救援データページで使用するポップアップ
/*------------------------------------------------------------*/
function voiceWin(){
  var wo2;
  wo2=window.open("../../rservice/system/voice.htm","voice","height=600,width=490,toolbar=no,status=no,location=no,scrollbars=yes,resizable=no,left=20,top=40");
  wo2.focus();
}
/*------------------------------------------------------------
 * JAFシアターのポップアップ
/*------------------------------------------------------------*/
function movieWin(URL){
  var wo3;
  wo3=window.open(URL,"moviewin","height=510,width=750,toolbar=no,status=no,location=no,scrollbars=no,resizable=yes,left=20,top=40");
  wo3.focus();
}
/*------------------------------------------------------------
 * U-17のポップアップ
/*------------------------------------------------------------*/
function u17Win(URL){
  var wo4;
  wo4=window.open(URL,"u17win","height=742,width=785,toolbar=no,status=no,location=no,scrollbars=no,resizable=yes,left=0,top=0");
  wo4.focus();
}
/*------------------------------------------------------------
 * MS誌のポップアップ
/*------------------------------------------------------------*/
function msWin(URL){
  var wo5;
  wo5=window.open(URL,"mswin","height=785,width=885,toolbar=no,status=no,location=no,scrollbars=no,resizable=yes,left=0,top=0");
  wo5.focus();
}
/*------------------------------------------------------------
 * JAFナビカレンダー
/*------------------------------------------------------------*/

function calendar() {
	//変数宣言
	var dtToday = new Date;
	var strDate;
	//月画像のURLを宣言します。
	var strMonthPicture = new Array(
	    "/common/image/jafnavi/calendar_m_01.gif",
		"/common/image/jafnavi/calendar_m_02.gif",
		"/common/image/jafnavi/calendar_m_03.gif",
		"/common/image/jafnavi/calendar_m_04.gif",
		"/common/image/jafnavi/calendar_m_05.gif",
		"/common/image/jafnavi/calendar_m_06.gif",
		"/common/image/jafnavi/calendar_m_07.gif",
		"/common/image/jafnavi/calendar_m_08.gif",
		"/common/image/jafnavi/calendar_m_09.gif",
		"/common/image/jafnavi/calendar_m_10.gif",
		"/common/image/jafnavi/calendar_m_11.gif",
		"/common/image/jafnavi/calendar_m_12.gif");
	//日付画像のURLを宣言します。
	var strPicture = new Array(
		"/common/image/jafnavi/calendar_d_0.gif",
		"/common/image/jafnavi/calendar_d_1.gif",
		"/common/image/jafnavi/calendar_d_2.gif",
		"/common/image/jafnavi/calendar_d_3.gif",
		"/common/image/jafnavi/calendar_d_4.gif",
		"/common/image/jafnavi/calendar_d_5.gif",
		"/common/image/jafnavi/calendar_d_6.gif",
		"/common/image/jafnavi/calendar_d_7.gif",
		"/common/image/jafnavi/calendar_d_8.gif",
		"/common/image/jafnavi/calendar_d_9.gif");
 
	//年月日を取得
	strDate = dtToday.getDate();
 
	//桁数を整理します
	if (strDate < 10)
	{
		strDate = "0" + strDate;
	}
 
	//数字に画像を当てるための準備です。
	var imgDate;
	imgDate = strDate.toString();
 
	//ここから表示
	document.write('<div id="calendar">');
	document.write('<img src="'+strMonthPicture[dtToday.getMonth()]+'" class="month"><br />');
	document.write('<img src="'+strPicture[imgDate.substring(0,1)]+'">'+'<img src="'+strPicture[imgDate.substring(1,2)]+'"></div>');
}
