﻿// ------------------------------------------------------------------------------------------------
//
// daimonji great bon-fire broadcast2006
//
//  2006.8.16  Masaya Miyanami , Fumiko Kurano , Tsurumoto Kenichirou @ softdevice inc.
//
//
//
// ------------------------------------------------------------------------------------------------
//
// 再現ムービー開始時間
var nowhour = 19;
var nowmin = 30;

// デフォルト更新間隔
var myinterval = 6000;

var zoom_timer;
var imagename;

var ramdomvalue;
var url;
var xml;
var data;

var maxwidth = 160;  // 拡大時の画像サイズ(横)
var minwidth = 80;   // 通常時の画像サイズ(横)
var myopacity = 100; // 透明度設定



// 初期実行
function init(){

	// xx秒おきに XML を再読込処理
	myrefleshtimer = setInterval("refreshimages()", myinterval);
}



function refreshimages() {

	// ------------------------------------------
	// 時間帯によって背景切り替え

	if((nowhour > 16) && (nowhour < 19)){
		document.getElementsByTagName('body').item(0).style.backgroundImage = "url(./images/bg0.jpg)";
	}

	if((nowhour >= 19) && (nowhour < 20)){
		document.getElementsByTagName('body').item(0).style.backgroundImage = "url(./images/bg1.jpg)";
	}

	if(nowhour >= 20){
		document.getElementsByTagName('body').item(0).style.backgroundImage = "url(./images/bg.jpg)";
	}

	// 時間桁上がり
	if((nowhour == 18) && (nowmin == 60)){
		nowhour = 19;
		nowmin = 0;
	}
	if((nowhour == 19) && (nowmin == 60)){
		nowhour = 20;
		nowmin = 0;
	}
	if((nowhour == 20) && (nowmin == 60)){
		nowhour = 21;
		nowmin = 0;
	}
	if((nowhour == 21) && (nowmin == 31)){
		nowhour = 19;
		nowmin = 30;
	}

	var mynowhour = nowhour;
	var mynowmin = nowmin;

	// 時間桁揃え
	if(nowhour < 10){mynowhour = "0" + nowhour;}
	if(nowmin < 10){mynowmin = "0" + nowmin;}

	var mytime = mynowhour + ":" + mynowmin + "";
	document.getElementById('now').innerHTML= mytime;

	// ------------------------------------------
	//キャッシュ対策

	ramdomvalue = Math.floor(Math.random()*10000000);
	url = "./xml2/20060816" + mynowhour + mynowmin + ".xml";
	xml = new JKL.ParseXML(url);
	data = xml.parse();

	// ------------------------------------------
	// 右大画像更新

	document.images['mdai1_img'].src = "./camera/d/images/20060816" + mynowhour + mynowmin + ".jpg";
	document.images['mdai1_img'].width = minwidth;

	// ------------------------------------------
	// XML に基づき内容更新

	for(i in data.panels.panel) {

		var tempcode = data.panels.panel[i].code;

		// 画像更新
		var imagename = data.panels.panel[i].code + "_img";
		var imagefile = "./camera/" + data.panels.panel[i].code + "/images/" + data.panels.panel[i].src;

		// 画像が空の場合
		if(data.panels.panel[i].src == "blank.jpg"){
			imagefile = "./images/blank.jpg";
		}

		// メッセージ更新
		var messagename = data.panels.panel[i].code + "_txt";
		var message = data.panels.panel[i].txt;
		if(message == undefined){
			message = "";
		}
		document.getElementById(messagename).innerHTML= message;

		// ユーザ名更新
		var username = data.panels.panel[i].code + "_usr";
		var user = data.panels.panel[i].user + "さん " + data.panels.panel[i].time + "";

		if(document.getElementById(username).innerHTML == user){
			// 通常時の枠線スタイル
			document.getElementById(tempcode).style.borderTop = "#ddd 1px solid";
			document.getElementById(tempcode).style.borderLeft = "#ddd 1px solid";
			document.getElementById(tempcode).style.borderRight = "#555 1px solid";
			document.getElementById(tempcode).style.borderBottom = "#555 1px solid";
		}
		else{
			// 新着の場合、枠線スタイルを変更
			document.getElementById(tempcode).style.borderTop = "#FBBF2F 1px solid";
			document.getElementById(tempcode).style.borderLeft = "#FBBF2F 1px solid";
			document.getElementById(tempcode).style.borderRight = "#FBBF2F 1px solid";
			document.getElementById(tempcode).style.borderBottom = "#FBBF2F 1px solid";
		}

		document.getElementById(username).innerHTML= user;

		document.images[imagename].src = imagefile;
		document.images[imagename].width = minwidth;
	}

	nowmin ++;
}



// カーソルイン時の画像拡大
function zoomInPanel(MyTarget) {

	// ------------------------------------------
	// 表示順序の一時切り替え

	var panelname = MyTarget;
	var imagename = MyTarget + "_img";
	var messagename = MyTarget + "_txt";

	document.getElementById(MyTarget).style.zIndex=document.getElementById(MyTarget).style.zIndex + 100;

	// ------------------------------------------
	// 徐々に画像を大きく

	var zoomin_ref = function() {

		if(document.images[imagename].width < maxwidth){

			// 画像を徐々に大きく
			document.images[imagename].width = document.images[imagename].width + 4;
		}
		if(document.images[imagename].width >= maxwidth){

			// テキストフィールドサイズ可変
			document.getElementById(messagename).style.width = maxwidth;
			document.getElementById(panelname).style.backgroundColor = "#274F62";

			// タイマー解除
			clearInterval(zoom_timer);
		}
	}
	// ------------------------------------------
	// 関数を10msec 毎に実行

	zoom_timer = setInterval(zoomin_ref,10);
}



// カーソルアウト時の画像縮小
function zoomOutPanel(MyTarget) {

	var panelname = MyTarget;
	var imagename = MyTarget + "_img";
	var messagename = MyTarget + "_txt";

	// ------------------------------------------
	// タイマー解除

	clearInterval(zoom_timer);

	// ------------------------------------------
	// 画像重ね順、画像サイズを通常状態に戻す

	var imagename = MyTarget + "_img";
	document.getElementById(MyTarget).style.zIndex=document.getElementById(MyTarget).style.zIndex - 100;
	document.images[imagename].width = minwidth;
	document.getElementById(messagename).style.width = 115;
	document.getElementById(panelname).style.backgroundColor = "transparent";
}



function setRefleshInterval(myvalue) {
	clearInterval(myrefleshtimer);
	myinterval = myvalue;
	myrefleshtimer = setInterval("refreshimages()", myinterval);

	xmlHttp.open('GET', './dmj_ui_logger.php?interval='+myvalue+'', true);
	xmlHttp.send(null);
}



function setRefleshStartTime(myvalue) {

	clearInterval(myrefleshtimer);

	if(myvalue == "1800"){
		nowhour = 18;nowmin = 0;
	}
	if(myvalue == "1830"){
		nowhour = 18;nowmin = 30;
	}
	if(myvalue == "1900"){
		nowhour = 19;nowmin = 0;
	}
	if(myvalue == "1930"){
		nowhour = 19;nowmin = 30;
	}
	if(myvalue == "2000"){
		nowhour = 20;nowmin = 0;
	}
	if(myvalue == "2015"){
		nowhour = 20;nowmin = 15;
	}
	if(myvalue == "2030"){
		nowhour = 20;nowmin = 30;
	}

	refreshimages();
	myrefleshtimer = setInterval("refreshimages()", myinterval);

	xmlHttp.open('GET', './dmj_ui_logger.php?time='+myvalue+'', true);
	xmlHttp.send(null);
}


