
var jsonDirectory   = "_data/json/";
var jsonDataUrl_ary = ["oshirase.json","plan.json","camp.json"];

var decoration_img_deco_ary = {
							"summer":{"c1":["pad_summer_177x243.jpg","pad_summer_177x272.jpg"],"c2":["pad_summer_364x159.jpg"]}
						};

var decoration_img_ary = {
							"summer":["pad_summer_177x243.jpg","pad_summer_177x272.jpg","pad_summer_364x159.jpg"]
						};

var leftpos_ary = [0,187,374];




function successFunc(json,cat){

	var _str = "";

	switch(cat){
		case "oshirase.json":
			// HTML組み立て
			for(var i in json){
				var lnk_s = "";
				var lnk_e = "";
				
				if(json[i].link){
					lnk_s = "<a href='"+ json[i].link +"'>";
					lnk_e = "</a>";
				}
				_str += "<dt>" + json[i].date.split("-").join(".") + "</dt>" + 
						"<dd>" + lnk_s + json[i].honbun + lnk_e + "</dd>";
			}
			// 書き出し。
			$("#oshiraseBox").get(0).innerHTML = _str;
			$("#oshiraseBox").fadeOut(0);
			$("#oshiraseBox").fadeIn("slow");
		break;
		case "plan.json":
			var _obj = document.getElementById("top_box_left");
			// HTML組み立て
			for(var i in json){
				_str += '<div id="l_' + json[i].uid + '" class="top_box_left168">' +
						'<a href="' + json[i].link + '">' + 
						'<div class="top_icon_plan"><img src="images/icon_plan.png" width="34" height="107" alt="宿泊プラン" /></div>' + 
						'<p><img src="_data/img/' + json[i].uid + '.jpg" alt="宿泊プラン" width="168" height="161" /></p>' + 
						'<p class="top_box_captxt">' + json[i].title + '</p>' +
						'<p class="top_box_txt">' + json[i].honbun + '</p></a>' + 
						'</div>';
			}
			$("#top_box_left").get(0).innerHTML = _str;
			$("#top_box_left div").fadeOut(0);
			$("#top_box_left div").fadeIn("slow");
		break;
		case "camp.json":
			var _new_camp = new Array();
			var _etc_camp = new Array();
			var _obj_array = new Array();
			// 配列の分割。
			for(var i in json){
				if(json[i].newflg == "1"){
					_new_camp.push({"src":json[i],"flg":"NEW"});
				}else{
					_etc_camp.push({"src":json[i],"flg":"ETC"});
				}
			}
			// 季節のアイコンをetcにいれて、シャフル。
			// 季節ゲット
			var _month = new Date();
				_month = _month.getMonth() + 1;
			var _sea = "summer";
			/*
			switch(_month){
				case 3:
				case 4:
				case 5:
					_sea = "spring";
				break;
				case 6:
				case 7:
				case 8:
					_sea = "summer";
				break;
				case 9:
				case 10:
				case 11:
					_sea = "autumn";
				break;
				case 12:
				case 1:
				case 2:
					_sea = "winter";
				break;
				default:
					_sea = "summer";
				break;
			}
			*/
			// デコレーションを配列に追加。
			for(var i in decoration_img_ary[_sea]){
				_etc_camp.push({"src":decoration_img_ary[_sea][i],"flg":"DECO"});
			}

			// 最新以外をシャッフル
			_etc_camp = shuffle(_etc_camp);
			// またマージ。
			_obj_array = _new_camp.concat(_etc_camp);

			var _value = [0,0,0];					// line1,line2,line3
			var _ColumnValue;						// 今回のカラム数。
			var _deconum = 1;						// デコレーションした回数。

			// HTML組み立て
			for(var i in _obj_array){

				// サイズ
				if(_obj_array[i].flg == "DECO"){
					_str = rtn_decodiv("c_" + _sea + "_" + i,_obj_array[i].src);
				}else{	// HTML要素------------------------------------------
					var _size = _obj_array[i].src.size.split("x");
					var _icon = (_obj_array[i].flg == "NEW")? '<div class="top_icon_new"><img src="images/icon_new.png" width="34" height="74" alt="NEW" /></div>' : '' ;
					_str =	'<div id="c_' + _obj_array[i].src.uid + '" class="top_box' + _size[0] + '">' +
							'<div class="top_box_main"><a href="' + _obj_array[i].src.link + '">' + 
							_icon + 
							'<p><img src="_data/img/' + _obj_array[i].src.uid + '.jpg" alt="" width="' + _size[0] + '" height="' + _size[1] + '" /></p>' + 
							'<p class="top_box_captxt">' + _obj_array[i].src.title + '</p>' +
							'<p class="top_box_txt">' + _obj_array[i].src.honbun + '</p></a>' + 
							'</div>' + 
							'</div>';
				}

				// 表示
				$("#top_box_center").append(_str);
				// サイズ取得。
				if(_obj_array[i].flg == "DECO"){
					var _o = getObjectPosition($("#c_" + _sea + "_" + i).get(0));
				}else{
					var _o = getObjectPosition($("#c_" + _obj_array[i].src.uid).get(0));
				}

				if(_o.w >= 540){	// 560
					// 3カラム用
					_ColumnValue = 3;
				}else if(_o.w >= 350){	// 370
					// 2カラム用
					_ColumnValue = 2;
				}else{
					// 1カラム用
					_ColumnValue = 1;
				}

				// 一番高さがないところに埋めていく。
				var _h_now = 0;
				if(_ColumnValue == 1){
					for(var j in _value){
						if(_value[_h_now] > _value[j]){
							_h_now = j;
						}
					}
				}else if(_ColumnValue == 2){
					for(var j in _value){
						if(_value[_h_now] > _value[j]){
							_h_now = j;
						}
					}
					if(Number(_h_now) == 2){
						// 次の配置が一番右だったらはみ出るので、移動。
						if( (_value[0] > _value[1]) && (_value[0] > _value[2]) ){
							_h_now = 1;
						}else{
							_h_now = 0;
						}
					}

				}	// _ColumnValue 3 はデフォルト。

				// 自分をおく上に空きがあったら、埋める。
				if( _ColumnValue == 2 ){
					if(_h_now == 1){
						// 
						if((_value[2] - _value[1]) >= 0){
							var _rem = _value[2] - _value[1];
							var _num = 1;
						}else{
							var _rem = _value[1] - _value[2];
							var _num = 2;
						}
						if(_rem >= 200 && _value[1] != 0 ){
							var _deco_src = decoration_img_deco_ary[_sea]["c1"][(_deconum%2)];
							var _deco_str = rtn_decodiv("c_" + _sea + "_d_" + _deconum,_deco_src);
							var _top = (_rem >= Number(_deco_src.split("x")[1].split(".")[0]))? _value[_num] + (_rem-Number(_deco_src.split("x")[1].split(".")[0]))/2 : _value[_num] ;
							$("#top_box_center").append(_deco_str);
							$("#c_" + _sea + "_d_" + _deconum).css({top:_top + "px",left:leftpos_ary[_num] + "px"});
							// 自分を足し多分、高さ加算
							var _deco_tmpnum = Number($("#c_" + _sea + "_d_" + _deconum).css("top").split("px")[0]);
							var _deco_tmphgt = getObjectPosition($("#c_" + _sea + "_d_" + _deconum).get(0));
							_value[_num] = _deco_tmpnum + _deco_tmphgt.h;
							// 出す
							$("#c_" + _sea + "_d_" + _deconum).fadeOut(0);
							$("#c_" + _sea + "_d_" + _deconum).fadeIn(300);
							// 次のために。
							_deconum++;
						}
					}else if(_h_now == 0){
						// 
						if((_value[1] - _value[0]) >= 0){
							var _rem = _value[1] - _value[0];
							var _num = 0;
						}else{
							var _rem = _value[0] - _value[1];
							var _num = 1;
						}
						if(_rem >= 200 && _value[0] != 0 && _value[1] != 0 ){
							var _deco_src = decoration_img_deco_ary[_sea]["c1"][(_deconum%2)];
							var _deco_str = rtn_decodiv("c_" + _sea + "_d_" + _deconum,_deco_src);
							var _top = (_rem >= Number(_deco_src.split("x")[1].split(".")[0]))? _value[_num] + (_rem-Number(_deco_src.split("x")[1].split(".")[0]))/2 : _value[_num] ;
							$("#top_box_center").append(_deco_str);
							$("#c_" + _sea + "_d_" + _deconum).css({top:_top + "px",left:leftpos_ary[_num] + "px"});
							// 自分を足し多分、高さ加算
							var _deco_tmpnum = Number($("#c_" + _sea + "_d_" + _deconum).css("top").split("px")[0]);
							var _deco_tmphgt = getObjectPosition($("#c_" + _sea + "_d_" + _deconum).get(0));
							_value[_num] = _deco_tmpnum + _deco_tmphgt.h;
							// 出す
							$("#c_" + _sea + "_d_" + _deconum).fadeOut(0);
							$("#c_" + _sea + "_d_" + _deconum).fadeIn(300);
							_deconum++;
						}
					}					
				}else if( _ColumnValue == 3 ){	// 3カラム処理

					var _deco_max = 0;
					for(var k in _value){
						if(_value[_deco_max] < _value[k]){
							_deco_max = k;
						}
					}

					if(_deco_max == 0){	// 3カラム処理で、左列が埋まっている場合。
						var _rem1 = _value[0] - _value[1];
						var _rem2 = _value[0] - _value[2];
						if( _rem1 >= 100 && _rem2 >= 100 ){
							if(_rem1 - _rem2 >= 0){
								var _rem = _rem2;
								var _num = 2;
							}else{
								var _rem = _rem1;
								var _num = 1;
							}
							var _deco_src = decoration_img_deco_ary[_sea]["c2"][0];
							var _deco_str = rtn_decodiv("c_" + _sea + "_d_" + _deconum,_deco_src);
							var _top = (_rem >= Number(_deco_src.split("x")[1].split(".")[0]))? _value[_num] + (_rem-Number(_deco_src.split("x")[1].split(".")[0]))/2 : _value[_num] ;
							$("#top_box_center").append(_deco_str);
							$("#c_" + _sea + "_d_" + _deconum).css({top:_top + "px",left:leftpos_ary[1] + "px"});
							// 自分を足し多分、高さ加算
							var _deco_tmpnum = Number($("#c_" + _sea + "_d_" + _deconum).css("top").split("px")[0]);
							var _deco_tmphgt = getObjectPosition($("#c_" + _sea + "_d_" + _deconum).get(0));
							_value[1] = _deco_tmpnum + _deco_tmphgt.h;
							_value[2] = _deco_tmpnum + _deco_tmphgt.h;
							// 出す
							$("#c_" + _sea + "_d_" + _deconum).fadeOut(0);
							$("#c_" + _sea + "_d_" + _deconum).fadeIn(300);
							_deconum++;
						}else if( _rem1 >= 200 || _rem2 >= 200 ){
							if(_rem1 - _rem2 >= 0){
								var _rem = _rem1;
								var _num = 1;
							}else{
								var _rem = _rem2;
								var _num = 2;
							}
							var _deco_src = decoration_img_deco_ary[_sea]["c1"][(_deconum%2)];
							var _deco_str = rtn_decodiv("c_" + _sea + "_d_" + _deconum,_deco_src);
							var _top = (_rem >= Number(_deco_src.split("x")[1].split(".")[0]))? _value[_num] + (_rem-Number(_deco_src.split("x")[1].split(".")[0]))/2 : _value[_num] ;
							$("#top_box_center").append(_deco_str);
							$("#c_" + _sea + "_d_" + _deconum).css({top:_top + "px",left:leftpos_ary[_num] + "px"});
							// 自分を足し多分、高さ加算
							var _deco_tmpnum = Number($("#c_" + _sea + "_d_" + _deconum).css("top").split("px")[0]);
							var _deco_tmphgt = getObjectPosition($("#c_" + _sea + "_d_" + _deconum).get(0));
							_value[_num] = _deco_tmpnum + _deco_tmphgt.h;
							// 出す
							$("#c_" + _sea + "_d_" + _deconum).fadeOut(0);
							$("#c_" + _sea + "_d_" + _deconum).fadeIn(300);
							_deconum++;
						}
					}else if(_deco_max == 2){
						var _rem0 = _value[2] - _value[0];
						var _rem1 = _value[2] - _value[1];
						if( _rem0 >= 100 && _rem1 >= 100 ){
							if(_rem0 - _rem1 >= 0){
								var _rem = _rem1;
								var _num = 1;
							}else{
								var _rem = _rem0;
								var _num = 0;
							}
							var _deco_src = decoration_img_deco_ary[_sea]["c2"][0];
							var _deco_str = rtn_decodiv("c_" + _sea + "_d_" + _deconum,_deco_src);
							var _top = (_rem >= Number(_deco_src.split("x")[1].split(".")[0]))? _value[_num] + (_rem-Number(_deco_src.split("x")[1].split(".")[0]))/2 : _value[_num] ;
							$("#top_box_center").append(_deco_str);
							$("#c_" + _sea + "_d_" + _deconum).css({top:_top + "px",left:leftpos_ary[0] + "px"});
							// 自分を足し多分、高さ加算
							var _deco_tmpnum = Number($("#c_" + _sea + "_d_" + _deconum).css("top").split("px")[0]);
							var _deco_tmphgt = getObjectPosition($("#c_" + _sea + "_d_" + _deconum).get(0));
							_value[0] = _deco_tmpnum + _deco_tmphgt.h;
							_value[1] = _deco_tmpnum + _deco_tmphgt.h;
							// 出す
							$("#c_" + _sea + "_d_" + _deconum).fadeOut(0);
							$("#c_" + _sea + "_d_" + _deconum).fadeIn(300);
							_deconum++;
						}else if( _rem0 >= 200 || _rem1 >= 200 ){
							if(_rem0 - _rem1 >= 0){
								var _rem = _rem0;
								var _num = 0;
							}else{
								var _rem = _rem1;
								var _num = 1;
							}
							var _deco_src = decoration_img_deco_ary[_sea]["c1"][(_deconum%2)];
							var _deco_str = rtn_decodiv("c_" + _sea + "_d_" + _deconum,_deco_src);
							var _top = (_rem >= Number(_deco_src.split("x")[1].split(".")[0]))? _value[_num] + (_rem-Number(_deco_src.split("x")[1].split(".")[0]))/2 : _value[_num] ;
							$("#top_box_center").append(_deco_str);
							$("#c_" + _sea + "_d_" + _deconum).css({top:_top + "px",left:leftpos_ary[_num] + "px"});
							// 自分を足し多分、高さ加算
							var _deco_tmpnum = Number($("#c_" + _sea + "_d_" + _deconum).css("top").split("px")[0]);
							var _deco_tmphgt = getObjectPosition($("#c_" + _sea + "_d_" + _deconum).get(0));
							_value[_num] = _deco_tmpnum + _deco_tmphgt.h;
							// 出す
							$("#c_" + _sea + "_d_" + _deconum).fadeOut(0);
							$("#c_" + _sea + "_d_" + _deconum).fadeIn(300);
							_deconum++;
						}
					}else if(_deco_max == 1){	// 3カラム処理で、真ん中列が埋まっている場合。
						var _deco_ary = [0,2]
						for(var l in _deco_ary){
							var _rem = _value[_deco_max] - _value[_deco_ary[l]];
							var _num = _deco_ary[l];
							if( _rem >= 200 ){
								var _deco_src = decoration_img_deco_ary[_sea]["c1"][(_deconum%2)];
								var _deco_str = rtn_decodiv("c_" + _sea + "_d_" + _deconum,_deco_src);
								var _top = (_rem >= Number(_deco_src.split("x")[1].split(".")[0]))? _value[_num] + (_rem-Number(_deco_src.split("x")[1].split(".")[0]))/2 : _value[_num] ;
								$("#top_box_center").append(_deco_str);
								$("#c_" + _sea + "_d_" + _deconum).css({top:_top + "px",left:leftpos_ary[_num] + "px"});
								// 自分を足し多分、高さ加算
								var _deco_tmpnum = Number($("#c_" + _sea + "_d_" + _deconum).css("top").split("px")[0]);
								var _deco_tmphgt = getObjectPosition($("#c_" + _sea + "_d_" + _deconum).get(0));
								_value[_num] = _deco_tmpnum + _deco_tmphgt.h;
								// 出す
								$("#c_" + _sea + "_d_" + _deconum).fadeOut(0);
								$("#c_" + _sea + "_d_" + _deconum).fadeIn(300);
								_deconum++;
							}
						}
					}
/*
					var _deco_min = 0;
					for(var l in _value){
						if(_value[_deco_min] > _value[l]){
							_deco_min = l;
						}
					}
					alert("0:" + _value[0] + " 1:" + _value[1] + " 2:" + _value[2] + "-------" + "max: " + _deco_max + " min:" + _deco_min);
*/
				}


				// 横の表示位置。
				var _w = leftpos_ary[_h_now];

				// 縦の表示位置
				var _h = 0;
				if( _ColumnValue == 2 ){
					_h = Math.max(_value[_h_now],_value[Number(_h_now)+1]);
				}else if( _ColumnValue == 3 ){
					_h = Math.max(_value[0],_value[1]);
					_h = Math.max(_h,_value[2]);
				}else{
					_h = Math.max(_h,_value[_h_now]);
				}

				// 位置を設定。
				if(_obj_array[i].flg == "DECO"){
					$("#c_" + _sea + "_" + i).css({top:_h + "px",left:_w + "px"});
					$("#c_" + _sea + "_" + i).fadeOut(0);
					$("#c_" + _sea + "_" + i).fadeIn(300);
				}else{
					$("#c_" + _obj_array[i].src.uid).css({top:_h + "px",left:_w + "px"});
					$("#c_" + _obj_array[i].src.uid).fadeOut(0);
					$("#c_" + _obj_array[i].src.uid).fadeIn(300);
				}

				// 次のために高さの値を取得しておく。
				if(_obj_array[i].flg == "DECO"){
					var _tmpnum = Number($("#c_" + _sea + "_" + i).css("top").split("px")[0]);
				}else{
					var _tmpnum = Number($("#c_" + _obj_array[i].src.uid).css("top").split("px")[0]);
				}
				if( _ColumnValue == 2 ){
					_value[_h_now]           = _tmpnum + _o.h;
					_value[Number(_h_now)+1] = _tmpnum + _o.h;
				}else if( _ColumnValue == 3 ){
					_value[0] = _tmpnum + _o.h;
					_value[1] = _tmpnum + _o.h;
					_value[2] = _tmpnum + _o.h;
				}else{
					_value[_h_now] = _tmpnum + _o.h;
				}

			}















			// 最後に全体の高さを枠に設定する。(absoluteなので）
			var _tmp_all_h = Math.max(_value[0],_value[1]);
				_tmp_all_h = Math.max(_tmp_all_h,_value[2]);
			
			$("#top_box_center").css({height:_tmp_all_h + "px"});


		break;
		default:
		break;
	}

}

function rtn_decodiv(id,src){
	var t = src.split("_")[2].split(".")[0].split("x");
	var w = Number(t[0]);
	var h = Number(t[1]);
	var _str =	'<div id="'+id+'" class="top_boxdeco">' + 
				'<p><img src="_data/' + src + '" width="' + w + '" height="' + h + '" /></p>' + 
				'</div>';

	return _str;
}

function getObjectPosition(_obj){
	var targetObj = _obj;
	var objX = 0;
	var objY = 0;
	
	while(targetObj){
		objX += targetObj.offsetLeft;
		objY += targetObj.offsetTop;
		targetObj = targetObj.offsetParent;
	}
	
	if(navigator.userAgent.indexOf('Mac') != -1 && typeof document.body.leftMargin != "undefined"){
		objX += document.body.leftMargin;
		objY += document.body.topMargin;
	}

	// 指定がある場合
	var objW = (_obj.width)? _obj.width : _obj.clientWidth;
	var objH = (_obj.height)? _obj.height : _obj.clientHeight;

	return {x:objX,y:objY,myx:_obj.offsetLeft,myy:_obj.offsetTop,w:objW,h:objH,obj:_obj};
}

function shuffle(list) {
  var i = list.length;
  if(i<=1){return list;}
  while (--i) {
    var j = Math.floor(Math.random() * (i + 1));
    if (i == j) continue;
    var k = list[i];
    list[i] = list[j];
    list[j] = k;
  }
  return list;
}

// キャッシュ対策用
function rndm(){
	var now = new Date();
		now = now.getTime();

	return "?" + now;
}


//=============================================
// SmartRollOver()
//=============================================
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 == 'ov') {
			var src = aImages[i].getAttribute('src');
			var ftype = src.substring(src.lastIndexOf('.'), src.length);
			var hsrc = src.replace(ftype, '_on'+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('_on'+ftype, ftype);
				this.setAttribute('src', sTempSrc);
			}
		}
	}
}

//=============================================
// BlWin2()
//=============================================
function BLinks() {
	if (!document.getElementsByTagName) return;

	var anchors = document.getElementsByTagName("a");

	for (var i=0; i<anchors.length; i++) {
		var anchor = anchors[i];
		if (anchor.getAttribute("href") &&
		anchor.getAttribute("rel") == "bl")
		anchor.target = "_blank";
	}
}

//=============================================
// init()
//=============================================

function init() {
	BLinks();
	initRollovers();


	if(document.getElementById("top_box_center")){
	// JSONデータ読み込み
	$.getJSON(jsonDirectory + jsonDataUrl_ary[0] + rndm(),function(json) {
		successFunc(json,jsonDataUrl_ary[0]);
	});
	$.getJSON(jsonDirectory + jsonDataUrl_ary[1] + rndm(),function(json) {
		successFunc(json,jsonDataUrl_ary[1]);
	});
	$.getJSON(jsonDirectory + jsonDataUrl_ary[2] + rndm(),function(json) {
		successFunc(json,jsonDataUrl_ary[2]);
	});
	}

}


window.onload=init;


//=============================================
// FC追加スクリプト
//=============================================

//=============================================
// ブロック要素の高さを揃える
//=============================================

/*--------------------------------------------------------------------------*
 *  
 *  heightLine JavaScript Library beta4
 *  
 *  MIT-style license. 
 *  
 *  2007 Kazuma Nishihata 
 *  http://www.webcreativepark.net
 *  
 *--------------------------------------------------------------------------*/
new function(){
	
	function heightLine(){
	
		this.className="heightLine";
		this.parentClassName="heightLineParent"
		reg = new RegExp(this.className+"-([a-zA-Z0-9-_]+)", "i");
		objCN =new Array();
		var objAll = document.getElementsByTagName ? document.getElementsByTagName("*") : document.all;
		for(var i = 0; i < objAll.length; i++) {
			var eltClass = objAll[i].className.split(/\s+/);
			for(var j = 0; j < eltClass.length; j++) {
				if(eltClass[j] == this.className) {
					if(!objCN["main CN"]) objCN["main CN"] = new Array();
					objCN["main CN"].push(objAll[i]);
					break;
				}else if(eltClass[j] == this.parentClassName){
					if(!objCN["parent CN"]) objCN["parent CN"] = new Array();
					objCN["parent CN"].push(objAll[i]);
					break;
				}else if(eltClass[j].match(reg)){
					var OCN = eltClass[j].match(reg)
					if(!objCN[OCN]) objCN[OCN]=new Array();
					objCN[OCN].push(objAll[i]);
					break;
				}
			}
		}
		
		//check font size
		var e = document.createElement("div");
		var s = document.createTextNode("S");
		e.appendChild(s);
		e.style.visibility="hidden"
		e.style.position="absolute"
		e.style.top="0"
		document.body.appendChild(e);
		var defHeight = e.offsetHeight;
		
		changeBoxSize = function(){
			for(var key in objCN){
				if (objCN.hasOwnProperty(key)) {
					//parent type
					if(key == "parent CN"){
						for(var i=0 ; i<objCN[key].length ; i++){
							var max_height=0;
							var CCN = objCN[key][i].childNodes;
							for(var j=0 ; j<CCN.length ; j++){
								if(CCN[j] && CCN[j].nodeType == 1){
									CCN[j].style.height="auto";
									max_height = max_height>CCN[j].offsetHeight?max_height:CCN[j].offsetHeight;
								}
							}
							for(var j=0 ; j<CCN.length ; j++){
								if(CCN[j].style){
									var stylea = CCN[j].currentStyle || document.defaultView.getComputedStyle(CCN[j], '');
									var newheight = max_height;
									if(stylea.paddingTop)newheight -= stylea.paddingTop.replace("px","");
									if(stylea.paddingBottom)newheight -= stylea.paddingBottom.replace("px","");
									if(stylea.borderTopWidth && stylea.borderTopWidth != "medium")newheight-= stylea.borderTopWidth.replace("px","");
									if(stylea.borderBottomWidth && stylea.borderBottomWidth != "medium")newheight-= stylea.borderBottomWidth.replace("px","");
									CCN[j].style.height =newheight+"px";
								}
							}
						}
					}else{
						var max_height=0;
						for(var i=0 ; i<objCN[key].length ; i++){
							objCN[key][i].style.height="auto";
							max_height = max_height>objCN[key][i].offsetHeight?max_height:objCN[key][i].offsetHeight;
						}
						for(var i=0 ; i<objCN[key].length ; i++){
							if(objCN[key][i].style){
								var stylea = objCN[key][i].currentStyle || document.defaultView.getComputedStyle(objCN[key][i], '');
									var newheight = max_height;
									if(stylea.paddingTop)newheight-= stylea.paddingTop.replace("px","");
									if(stylea.paddingBottom)newheight-= stylea.paddingBottom.replace("px","");
									if(stylea.borderTopWidth && stylea.borderTopWidth != "medium")newheight-= stylea.borderTopWidth.replace("px","")
									if(stylea.borderBottomWidth && stylea.borderBottomWidth != "medium")newheight-= stylea.borderBottomWidth.replace("px","");
									objCN[key][i].style.height =newheight+"px";
							}
						}
					}
				}
			}
		}
		
		checkBoxSize = function(){
			if(defHeight != e.offsetHeight){
				changeBoxSize();
				defHeight= e.offsetHeight;
			}
		}
		changeBoxSize();
		setInterval(checkBoxSize,1000)
		window.onresize=changeBoxSize;
	}
	
	function addEvent(elm,listener,fn){
		try{
			elm.addEventListener(listener,fn,false);
		}catch(e){
			elm.attachEvent("on"+listener,fn);
		}
	}
	addEvent(window,"load",heightLine);
}

//=============================================
// ウィンドウポップアップ
//=============================================


function openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}


//=============================================
// 印刷ボタン
//=============================================

function PrintPage(){
	if(document.getElementById || document.layers){
		window.print();
	}
}

