$(document).ready(function(){
	//変数
	var bt = {
		h : null,
		m : null,
		imgpath : "tokeisrc2/",
		xmlpath : "tokeisrc2/xml/",
		item_f : new Array
	};

	//時間取得
	function btGettime(){
		var c = new Date();
		var nh = c.getHours();
		var nm = c.getMinutes();
		if (nh != bt.h || nm != bt.m){
			bt.h = nh;
			bt.m = nm;
			btChange();
		}
	};
	
	//時間→ファイル名
	function btGettimestr(b, a){
		return (b < 10 ? "0" + b : "" + b) + (a < 10 ? "0" + a : "" + a);
	};
	

	//画像・プロフィール入れ替え
	function btChange(){
		$("#btInner").fadeOut(500,function(){
			btDataset();
			$("#btPh img").attr("src",bt.imgpath+btGettimestr(bt.h,bt.m)+".jpg").load(function() {
				$("#btInner").fadeIn(500);
			});
		});
	}

$(function(){
     $("#btPh img").hover(function(){
        $(this).attr('src', $(this).attr('src').replace('.jpg', '_on.jpg'));
          }, function(){
             if (!$(this).hasClass('currentPage')) {
             $(this).attr('src', $(this).attr('src').replace('_on.jpg', '.jpg'));
        }
   });
});
 





	//xml読み込み
	function btDataset(){
		$.ajax({
			url: bt.xmlpath+btGettimestr(bt.h,bt.m)+'.xml',
			type: 'GET',
			dataType: 'xml',
			timeout: 60000,
			error: function(){
				//alert("データの読み込みに失敗しました");
			},
			success: function(xml){
				$(xml).find('row').each(function(){
					var btItem_name = $(this).find("name").text();
					$("#btNmae").html(btItem_name);
					for(var i =1; i<=2; i++){
						bt.item_f[i] = $(this).find("f"+i).text();
						//alert(bt.item_f[i] );
						$("#f"+i).html(bt.item_f[i]);
					}
				});
			}
		});
	}
	
	//スタート
	btGettime();
	setInterval(function(){
		btGettime();
	},1000);
});

