/* --------------------------------------------------------------------------
JavaScript 共通用
汎用的に使えるものはみんなここに入れておいてください。
どこかのページでしか使えないものなどは、それ専用でファイルを作成して使用して
ください。

１．ポップアップウインドウ
-------------------------------------------------------------------------- */

/* ポップアップウインドウ */
function popup (url,wi,he){
	urlPage = url + ".html";
	paramPage = "width="+wi+",height="+he+",scrollbars=yes";
	window.open(urlPage,"",paramPage);
}
/* ポップアップウインドウ②(stadium/jikken.htmlのみで使用中) */
function popup02 (url,wi,he,op){
	urlPage = url + ".html#" + op;
	paramPage = "width="+wi+",height="+he+",scrollbars=yes";
	window.open(urlPage,"",paramPage);
}

/* スワップイメージ(/stadium/jishin.htmlのみで使用・・・よって内容は固定(非汎用性)です) */
/* イメージのプリロード */
new Image().src = "image/jishin/10_image_1_1_anm.gif";
new Image().src = "image/jishin/10_image_1_2_anm.gif";

/* イメージの切り替え */
function jishin_swap(switchs){
	if(switchs == "on"){
		left_img = "image/jishin/10_image_1_1_anm.gif";
		right_img = "image/jishin/10_image_1_2_anm.gif";
	} else {
		left_img = "image/jishin/10_image_1_1.gif";
		right_img = "image/jishin/10_image_1_2.gif";
	}
	document.images["j_img_1"].src = left_img;
	document.images["j_img_2"].src = right_img;
}

/* イメージの切り替え(barriefree.htmlで使用) */
// 変数の定義
var ids = "";  // id名
var go_x = 0;  // X軸の移動先
var now_x = 0; // 現在のX軸の値
var timer;     // settimeoutのタイマー

function timecount(){
	
	// 移動する値の計算
	dx = (go_x - now_x)/2;
	// 移動する
	document.getElementById(ids).style.left=dx+now_x;
	// 処理終了の判断
	if(Math.abs(dx)<1){
			document.getElementById(ids).style.left = go_x;
			clearTimeout(timer);
	} else {
			now_x = now_x + dx;
			timer = setTimeout("timecount()",100);
	}
}
function moveimg(ch,ci){
	// タイマーをクリア
	if(timer){
		clearTimeout(timer);
	}
	//this.gg=ch;
	// IDをセット
	ids = ch;
	// leftの値を取り出す
	dx1=document.getElementById(ch).style.left;
	// 変数から｢px｣を取り除く
	dx1=dx1.replace(/(\d+)px/,"$1");
	// 座標を数値に変換
	dx1=parseInt(dx1);
	// 現在の座標位置のセット
	now_x = dx1;
	// ずらす値をセット
	go_x = ci;
	// セットする関数の実行
	timecount();
}
/* ハウススタジアム 台風体験でのみ使用 */
function taifuu_img(){
	document.getElementById('house_in').style.display = "block";
}

/* --- 展示場で使用：開始 --- */
/* --- 2008/01/25以降使用せず --- 
var nowID = "sub00"; // 現在開いているID(始めは宮城県のみ)
// パラメータ：id名
function menuDisp(ids){
	// 現在のIDと同じ場合は処理しない
	if(nowID != ids) {
		// 現在開いている(block)IDを閉じる
		document.getElementById(nowID).style.display = "none";
		// 引き続きパラメータのIDを開く
		document.getElementById(ids).style.display = "block";
		// ID名を保存する
		nowID = ids;
	}
}*/
// クッキーを書き出す(ここでは削除用。本当の書き出し用は、linkChg.jsにて)
function writeCookie(value,hours) {
  var expire = "";
  var namePut = "iframeSrc";
  if(hours != null) {
    expire = new Date((new Date()).getTime() + hours * 3600000);
    expire = "; expires=" + expire.toGMTString();
  }
	// ドメイン内で使用できるようにパスはセットしておく
  document.cookie = namePut + "=" + escape(value) +"; path=/; "+ expire;
}

// クッキーを読み込む
function readCookie() {
  var name = "iframeSrc";
  var cookieValue = "";
  var search = name + "=";
  if(document.cookie.length > 0) { 
    offset = document.cookie.indexOf(search);
    if (offset != -1) { 
      offset += search.length;
      end = document.cookie.indexOf(";", offset);
      if (end == -1) end = document.cookie.length;
      cookieValue = unescape(document.cookie.substring(offset, end))
    }
  }
	// クッキーを読み込めたら処理する
  if(cookieValue){
		if(cookieValue == "syk"){
			// Cookieが読み込めたら、iframeのsrcをセットする
			document.frames["r_frame"].location.href = "http://www.sumori.jp/exhibition/listinfo2.php";
		} else {
			// Cookieが読み込めたら、iframeのsrcをセットする
			document.frames["r_frame"].location.href = "http://www.sumori.jp/exhibition/exbinfo.php?hyou=" + cookieValue;
		}
		// Cookieを消去する
		writeCookie("", -1);
	}
}
/* --- 展示場で使用：終了 --- */

/* --- 全国ビルダー会で使用：開始 --- */
var nowID = "";
function menuDisp(ids){
	// 現在のIDと同じ場合は処理しない
	if(nowID != ids) {
		// 現在開いている(block)IDを閉じる
		if(nowID){
			document.getElementById(nowID).style.display = "none";
		}
		// 引き続きパラメータのIDを開く
		document.getElementById(ids).style.display = "block";
		// ID名を保存する
		nowID = ids;
	}
}
/* --- 全国ビルダー会で使用：終了 --- */

/* --- 展示場の案内で使用：開始 --- */
/*var idName = "";
var idNames = "";
var timer2 = "";
function popDisp(idName){
	clearTimeout(timer2);
	if(idNames && idNames != idName){
		document.getElementById(idNames).style.display = "none";
		idNames = "";
	}
	// ポップアップメニューの表示
	document.getElementById(idName).style.display = "block";
}
function popEras(idName) {
	// ポップアップの非表示
	document.getElementById(idName).style.display = "none";
}
function popErasTime(idName) {
	idNames = idName;
	timer2 = setTimeout("popEras(idNames)",250);
}*/
/* --- 展示場の案内で使用：終了 --- */
