//フロント共通js
//dovument高速化
/*@cc_on _d=document;eval('var document=_d')@*/

//index areaMapPopUp


//index特集高さ調整
function featImgHeightSet() {
	var heightArray = new Array();
	for (var i = 1; document.getElementById('feat' + String(i)); i++) {
		heightArray.push(document.getElementById('feat' + String(i)).offsetHeight);
	}
	var rowNum = Math.ceil((i - 1) / 5);
	var rowHeightArray = new Array();
	for (var i = 0; i < rowNum; i++) {
		var row1 = i * 5;
		var maxHeight = heightArray[row1];
		for (var i2 = 0; i2 < 5 && heightArray[row1 + i2]; i2++) {
			maxHeight = Math.max(maxHeight, heightArray[row1 + i2]);
		}
		rowHeightArray.push(maxHeight);
	}
	for (var i = 1; document.getElementById('feat' + String(i)); i++) {
		var height = rowHeightArray[Math.ceil((i / 5) - 1)];
		var pad = height - heightArray[i - 1];
		if (pad > 0) {
			pad = Math.ceil(pad / 2);
			document.getElementById('feat' + String(i)).childNodes[0].style.paddingTop    = String(pad) + 'px';
			document.getElementById('feat' + String(i)).childNodes[0].style.paddingBottom = String(pad) + 'px';
			document.getElementById('feat' + String(i)).style.height                      = String(height) + 'px';
		}
	}
}

//お問い合わせ職業選択
function chkWork (id) {
	if (id == 1) {
		document.getElementById('work_kind').disabled = false;
		document.getElementById('work_other').disabled = true;
	} else if (id == 5) {
		document.getElementById('work_kind').disabled = true;
		document.getElementById('work_other').disabled = false;
	} else {
		document.getElementById('work_kind').disabled = true;
		document.getElementById('work_other').disabled = true;
	}
}

//路線選択から駅選択を生成
function stationSelect(selectedId, targetId) {
	var	httpRequest = createHttpRequest();
	try {
		httpRequest.open('POST', '../script/station_select.php', true);
		httpRequest.setRequestHeader("content-type", "application/x-www-form-urlencoded");
		httpRequest.onreadystatechange = function () {
			if (httpRequest.readyState == 4 && httpRequest.status == 200 && httpRequest.responseText) {
				document.getElementById(targetId).innerHTML = httpRequest.responseText;
			}
		}
		httpRequest.send('id=' + selectedId);
	} catch(e) {
		alert("request failed.(" + e + ")");
	}
}

//全チェックOn
function allChkOn () {
	for (var i = 1; document.getElementById('e' + i); i++) {
		document.getElementById('e' + i).checked = true;
	}
	for (var i = 1; document.getElementById('h' + i); i++) {
		document.getElementById('h' + i).checked = true;
	}
}

//全チェックOff
function allChkOff () {
	for (var i = 1; document.getElementById('e' + i); i++) {
		document.getElementById('e' + i).checked = false;
	}
	for (var i = 1; document.getElementById('h' + i); i++) {
		document.getElementById('h' + i).checked = false;
	}
}

//詳細検索
function detailSearch () {
	var eVal = '';
	for (var i = 1; document.getElementById('e' + i); i++) {
		if (document.getElementById('e' + i).checked == true) {
			eVal += document.getElementById('e' + i).value + '-';
		}
	}
	var hVal = '';
	for (var i = 1; document.getElementById('h' + i); i++) {
		if (document.getElementById('h' + i).checked == true) {
			hVal += document.getElementById('h' + i).value + '-';
		}
	}
	document.getElementById('eVal').value = eVal.slice(0, -1);
	document.getElementById('hVal').value = hVal.slice(0, -1);

	document.getElementById('detailSearch').submit();
}

//日本標準座標に変換
function JPoint(a, b, mode) {
	if (mode == 'E') {
		var x = a - b * 0.000046038 - a * 0.000083043 + 0.010040;
		return x;
	} else {
		var y = b - b * 0.00010695 + a * 0.000017464 + 0.0046017;
		return y;
	}
}

//GoogleMapsAPI表示
function initialize(east, north) {
	var latlng = new google.maps.LatLng(JPoint(east, north, 'N'), JPoint(east, north, 'E'));
	var mapOpts = {
		zoom: 17,
		center: latlng,
		mapTypeId: google.maps.MapTypeId.ROADMAP,
		streetViewControl: false
	};
	var mapCanvas = new google.maps.Map(document.getElementById("gMap"), mapOpts);

	var markerOpts = {
		position: latlng,
		map: mapCanvas
	};
	var crossMarker = new google.maps.Marker(markerOpts);

	var panoOpts = {
		position: latlng
	};
	var mapCanvas = new google.maps.StreetViewPanorama(document.getElementById("gSV"), panoOpts);
}

//近い物件表示切替
function rcmWrt(key, page, area, price, hPlan, hPick) {
	var	httpRequest = createHttpRequest();
	try {
		httpRequest.open('POST', '../script/view_recommend.php', true);
		httpRequest.setRequestHeader("content-type", "application/x-www-form-urlencoded");
		httpRequest.onreadystatechange = function () {
			if (httpRequest.readyState == 4 && httpRequest.status == 200 && httpRequest.responseText) {
				document.getElementById('viewRcm').innerHTML = httpRequest.responseText;
			}
		}
		httpRequest.send('key_name=' + key + '&page=' + page + '&area_flag=' + area + '&price_flag=' + price + '&h_plan_flag=' + hPlan + '&hard_pick_flag=' + hPick);
	} catch(e) {
		alert("request failed.(" + e + ")");
	}
}

//サブ画像高さ設定
function subImgHeightSet() {
	var heightArray = new Array();
	for (var i = 1; document.getElementById('subImg' + String(i)); i++) {
		heightArray.push(document.getElementById('subImg' + String(i)).offsetHeight);
	}
	var rowNum = Math.ceil((i - 1) / 3);
	var rowHeightArray = new Array();
	for (var i = 0; i < rowNum; i++) {
		var row1 = i * 3;
		if (heightArray[row1 + 1]) {
			var maxHeight = Math.max(heightArray[row1], heightArray[row1 + 1]);
			if (heightArray[row1 + 2]) {
				maxHeight = Math.max(maxHeight, heightArray[row1 + 2]);
			}
		} else {
			var maxHeight = heightArray[row1];
		}
		rowHeightArray.push(maxHeight);
	}
	for (var i = 1; document.getElementById('subImg' + String(i)); i++) {
		if (heightArray[i - 1] != rowHeightArray[Math.ceil((i / 3) - 1)]) {
			var imgHeight = document.getElementById('subImg' + String(i) + 'Img').offsetHeight;
			if (document.getElementById('subImg' + String(i) + 'Txt')) {
				var txtHeight = document.getElementById('subImg' + String(i) + 'Txt').offsetHeight + 10;
			} else {
				var txtHeight = 0;
			}
			var innerHeight  = imgHeight + txtHeight + 5/*固定値*/;
			var marginHeight = Math.ceil((rowHeightArray[Math.ceil((i / 3) - 1)] - innerHeight) / 2);
			document.getElementById('subImg' + String(i) + 'Img').style.marginTop = String(marginHeight) + 'px';
		}
		document.getElementById('subImg' + String(i)).style.height = String(rowHeightArray[Math.ceil((i / 3) - 1)]) + 'px';
	}
}

//----------------------------------------------ライトボックス----------------------------------------------//
//拡大表示
var BAlpha = 70;
var WAlpha = 30;
var IAlpha = 30;
var inflag7 = false;
var angle = 0;
function photoView(imgPath,width,height,keyName,allNum,thisNum) {
	//グローバル変数へ代入
	window.imgPath = imgPath; //画像パス
	window.width   = width;   //画像横幅
	window.height  = height;  //画像縦幅
	window.keyName     = keyName;     //keyName
	window.allNum  = allNum;  //全画像数
	window.thisNum = thisNum; //この画像の番号

	//グレーアウト処理
	document.getElementById('viewImgBase').className = 'viewImgBase';
	window.bodyWidth = 0;
	window.bodyHeight = 0;
	if (window.innerHeight && window.scrollMaxY) {	
		bodyWidth = window.innerWidth + window.scrollMaxX;
		bodyHeight = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){
		bodyWidth = document.body.scrollWidth;
		bodyHeight = document.body.scrollHeight;
	} else {
		bodyWidth = document.body.offsetWidth;
		bodyHeight = document.body.offsetHeight;
	}
	document.getElementById('viewImgBase').style.width = bodyWidth + 'px';
	document.getElementById('viewImgBase').style.height = bodyHeight + 'px';
	baseAlpha();

	//bodyのサイズより画像サイズが大きければ縮小処理
	if (bodyWidth * 0.8 < width || bodyHeight * 0.8 < height) {
		var reSizePercentW = width / (bodyWidth * 0.8);
		var reSizePercentH = height / (bodyHeight * 0.8);
		if (reSizePercentW > reSizePercentH) {
			window.width = parseInt(bodyWidth * 0.8);
			window.height = parseInt(height / reSizePercentW);
		}
		if (reSizePercentW < reSizePercentH) {
			window.width = parseInt(width / reSizePercentH);
			window.height = parseInt(bodyHeight * 0.8);
		}
		if (reSizePercentW == reSizePercentH) {
			window.width = parseInt(bodyWidth * 0.8);
			window.height = parseInt(bodyHeight * 0.8);
		}
	}
}
function photoView2() {
	//画像白ベース出力
	window.imgMargin = 20;
	window.whiteWidth = width + imgMargin;
	window.whiteHeight = height + imgMargin;
	window.startX = bodyWidth / 2 - imgMargin;
	var startY = 100;

	if (document.all) {
		if (typeof document.body.style.maxHeight != "undefined") {
			// IE 7, mozilla, safari, opera 9
			var scrollPoint = document.documentElement.scrollTop;	
		} else {
			// IE6, older browsers
			var scrollPoint = document.body.scrollTop;
		}
	} else {
		var scrollPoint = window.scrollY;
	}
	startY += scrollPoint;

	document.getElementById('whiteBase').style.left = startX + 'px';
	document.getElementById('whiteBase').style.top = startY + 'px';
	document.getElementById('whiteBase').style.width = imgMargin * 2;
	document.getElementById('whiteBase').style.height = imgMargin * 2;
	whiteAlpha();
}
function photoView3() {
	//白ベースタテ伸ばし
	var WHeight = imgMargin * 2;
	WhiteHeight(WHeight,whiteHeight);
}
function photoView4() {
	//白ベースヨコ伸ばし
	var Wwidth = imgMargin * 2;
	WhiteWidth(Wwidth,whiteWidth);
}
function photoView5() {
	//実寸画像出力
	var leftRightMargin = imgMargin / 2;
	document.getElementById('whiteBase').innerHTML = '<img src="' + imgPath + '" width="' + width + '" height="' + height + '" id="imgLayer">';
	document.getElementById('imgLayer').style.left = leftRightMargin + 'px';
	document.getElementById('imgLayer').style.top = leftRightMargin + 'px';
	imgAlpha();
}
function photoView6() {
	//ボトム伸ばし
	window.lastWhiteHeight = whiteHeight + 30;
	bottomHeight(whiteHeight,lastWhiteHeight);

}
function photoView7() {
	//閉じるボタンとページ移動ボタンとコメント出力
	if (inflag7 == false) {
		var commentStr = getComment(imgPath);
		document.getElementById('whiteBase').innerHTML += '<div id="closeButton" onClick="closeImg();"><span class="close">CLOSE</span><span class="batsu">×</span></div>';
		document.getElementById('whiteBase').innerHTML += '<div id="numViewBox">Image ' + thisNum + ' of ' + allNum + '</div>';
		document.getElementById('whiteBase').innerHTML += '<div id="commentBox">' + commentStr + '</div>';
		if (thisNum != 1) {
			var backTagStr = '<div id="backButtonBase" onMouseOver="document.getElementById(\'backButton\').className=\'roll\';" ';
			backTagStr += 'onMouseOut="document.getElementById(\'backButton\').className=\'\';" onClick="backView(\'' + keyName + '\',' + thisNum + ');"><div id="backButton">BACK</div></div>';
			document.getElementById('whiteBase').innerHTML += backTagStr;
			var backButtonLeft = imgMargin / 2;
			var backButtonTop = imgMargin / 2;
			var halfWidth = width / 2 - 2;
			document.getElementById('backButtonBase').style.left = backButtonLeft + 'px';
			document.getElementById('backButtonBase').style.top = backButtonTop + 'px';
			document.getElementById('backButtonBase').style.width = halfWidth + 'px';
			document.getElementById('backButtonBase').style.height = height + 'px';
			document.getElementById('backButtonBase').style.backgroundImage = 'url(../images/space.gif)';
			document.getElementById('backButtonBase').style.filter = 'alpha(opacity=100)';
			document.getElementById('backButtonBase').style.MozOpacity = 1;
			document.getElementById('backButtonBase').style.opacity = 1;
			document.getElementById('backButton').style.left = '0px';
			document.getElementById('backButton').style.top = '20%';
		}
		if (thisNum != allNum) {
			var nextTagStr = '<div id="nextButtonBase" onMouseOver="document.getElementById(\'nextButton\').className=\'roll\';" ';
			nextTagStr += 'onMouseOut="document.getElementById(\'nextButton\').className=\'\';" onClick="nextView(\'' + keyName + '\',' + thisNum + ');"><div id="nextButton">NEXT</div></div>';
			document.getElementById('whiteBase').innerHTML += nextTagStr;
			var nextButtonLeft = width / 2 + imgMargin / 2 + 2;
			var nextButtonTop = imgMargin / 2;
			var halfWidth = width / 2 - 2;
			var nextButtonNameW = halfWidth - 50;
			document.getElementById('nextButtonBase').style.left = nextButtonLeft + 'px';
			document.getElementById('nextButtonBase').style.top = nextButtonTop + 'px';
			document.getElementById('nextButtonBase').style.width = halfWidth + 'px';
			document.getElementById('nextButtonBase').style.height = height + 'px';
			document.getElementById('nextButtonBase').style.backgroundImage = 'url(../images/space.gif)';
			document.getElementById('nextButtonBase').style.filter = 'alpha(opacity=100)';
			document.getElementById('nextButtonBase').style.MozOpacity = 1;
			document.getElementById('nextButtonBase').style.opacity = 1;
			document.getElementById('nextButton').style.left = nextButtonNameW + 'px';
			document.getElementById('nextButton').style.top = '20%';
		}
		inflag7 = true;
	}
	var buttonLeft = whiteWidth - 90;
	var buttonTop = whiteHeight - 6;
	document.getElementById('closeButton').style.left = buttonLeft + 'px';
	document.getElementById('closeButton').style.top = buttonTop + 'px';
	document.getElementById('closeButton').style.visibility = 'visible';
	var numViewLeft = imgMargin / 2 + 2;
	var numViewTop = whiteHeight + 5;
	document.getElementById('numViewBox').style.left = numViewLeft + 'px';
	document.getElementById('numViewBox').style.top = numViewTop + 'px';
	document.getElementById('numViewBox').style.visibility = 'visible';
	var commentLeft = imgMargin / 2;
	var commentTop = whiteHeight - 6 + 34;
	document.getElementById('commentBox').style.left = commentLeft + 'px';
	document.getElementById('commentBox').style.top = commentTop + 'px';
	window.commentH = document.getElementById('commentBox').offsetHeight + lastWhiteHeight + 5;
	commentHeight(lastWhiteHeight,commentH);
}
function photoView8() {
	//コメント表示
	document.getElementById('commentBox').style.visibility = 'visible';
	if (thisNum != 1) {
		document.getElementById('backButtonBase').style.visibility = 'visible';
	}
	if (thisNum != allNum) {
		document.getElementById('nextButtonBase').style.visibility = 'visible';
	}
	commentShadow();
}

//拡大画像表示用モーション関数群
function baseAlpha() {
	BAlpha = BAlpha + 2;
	if (BAlpha <= 86) {
		document.getElementById('viewImgBase').style.filter = 'alpha(opacity=' + BAlpha + ')';
		document.getElementById('viewImgBase').style.MozOpacity = BAlpha / 100 - 0.1;
		document.getElementById('viewImgBase').style.opacity = BAlpha / 100 - 0.1;
		setTimeout('baseAlpha()', 5);
		BAlpha = BAlpha + 2;
		document.getElementById('viewImgBase').style.filter = 'alpha(opacity=' + BAlpha + ')';
		document.getElementById('viewImgBase').style.MozOpacity = BAlpha / 100 - 0.1;
		document.getElementById('viewImgBase').style.opacity = BAlpha / 100 - 0.1;
		setTimeout('baseAlpha()', 5);
	} else {
		photoView2();
	}
}
function whiteAlpha() {
	WAlpha = WAlpha + 2;
	if (WAlpha < 99) {
		document.getElementById('whiteBase').style.filter = 'alpha(opacity=' + WAlpha + ')';
		document.getElementById('whiteBase').style.MozOpacity = WAlpha / 100 - 0.1;
		document.getElementById('whiteBase').style.opacity = WAlpha / 100 - 0.1;
		setTimeout('whiteAlpha()', 5);
		WAlpha = WAlpha + 2;
		document.getElementById('whiteBase').style.filter = 'alpha(opacity=' + WAlpha + ')';
		document.getElementById('whiteBase').style.MozOpacity = WAlpha / 100 - 0.1;
		document.getElementById('whiteBase').style.opacity = WAlpha / 100 - 0.1;
		setTimeout('whiteAlpha()', 5);
	} else {
		document.getElementById('whiteBase').style.filter = 'alpha(opacity=100)';
		document.getElementById('whiteBase').style.MozOpacity = 1;
		document.getElementById('whiteBase').style.opacity = 1;
		photoView3();
	}
}
function WhiteHeight(px,maxHeight) {
	px = px + 20;
	if (px <= maxHeight) {
		document.getElementById('whiteBase').style.height = px + 'px';
		setTimeout('WhiteHeight(' + px + ',' + maxHeight + ')', 5);
	} else {
		document.getElementById('whiteBase').style.height = maxHeight + 'px';
		photoView4();
	}
}
function WhiteWidth(px,maxWidth) {
	px = px + 20;
	if (px <= maxWidth) {
		var moveToLeft = startX - px / 2;
		document.getElementById('whiteBase').style.width = px + 'px';
		document.getElementById('whiteBase').style.left = moveToLeft + 'px';
		setTimeout('WhiteWidth(' + px + ',' + maxWidth + ')', 5);
	} else {
		var moveToLeft = startX - maxWidth / 2;
		document.getElementById('whiteBase').style.width = maxWidth + 'px';
		document.getElementById('whiteBase').style.left = moveToLeft + 'px';
		photoView5();
	}
}
function imgAlpha() {
	IAlpha = IAlpha + 2;
	if (IAlpha < 99) {
		document.getElementById('imgLayer').style.filter = 'alpha(opacity=' + IAlpha + ')';
		document.getElementById('imgLayer').style.MozOpacity = IAlpha / 100 - 0.1;
		document.getElementById('imgLayer').style.opacity = IAlpha / 100 - 0.1;
		setTimeout('imgAlpha()', 5);
		IAlpha = IAlpha + 2;
		document.getElementById('imgLayer').style.filter = 'alpha(opacity=' + IAlpha + ')';
		document.getElementById('imgLayer').style.MozOpacity = IAlpha / 100 - 0.1;
		document.getElementById('imgLayer').style.opacity = IAlpha / 100 - 0.1;
		setTimeout('imgAlpha()', 5);
	} else {
		document.getElementById('imgLayer').style.filter = 'alpha(opacity=100)';
		document.getElementById('imgLayer').style.MozOpacity = 1;
		document.getElementById('imgLayer').style.opacity = 1;
		photoView6();
	}

}
function bottomHeight(px,maxHeight) {
	px = px + 10;
	if (px <= maxHeight) {
		document.getElementById('whiteBase').style.height = px + 'px';
		setTimeout('bottomHeight(' + px + ',' + maxHeight + ')', 5);
	} else {
		document.getElementById('whiteBase').style.height = maxHeight + 'px';
		photoView7();
	}
}
function commentHeight(px,maxHeight) {
	px = px + 10;
	if (px <= maxHeight) {
		document.getElementById('whiteBase').style.height = px + 'px';
		setTimeout('commentHeight(' + px + ',' + maxHeight + ')', 5);
	} else {
		document.getElementById('whiteBase').style.height = maxHeight + 'px';
		photoView8();
	}
}
function commentShadow() {
	angle = angle + 1;
	if (angle <= 135) {
		document.getElementById('commentBox').style.filter = 'shadow(color=#CCCCDD, direction=' + angle + ')';
		setTimeout('commentShadow()', 20);
	} else {
		document.getElementById('commentBox').style.filter = 'shadow(color=#CCCCDD, direction=135)';
	}
}

//BACK表示
function backView(keyName,thisNum) {
	if (thisNum != 1) {
		document.getElementById('backButtonBase').style.visibility = 'hidden';
	}
	if (thisNum != allNum) {
		document.getElementById('nextButtonBase').style.visibility = 'hidden';
	}
	window.reResultStr = getBackImg(keyName,thisNum);
	document.getElementById('whiteBase').innerHTML = '&nbsp;';
	turnWhiteHeight(commentH,whiteHeight);
}

//NEXT表示
function nextView(keyName,thisNum) {
	if (thisNum != 1) {
		document.getElementById('backButtonBase').style.visibility = 'hidden';
	}
	if (thisNum != allNum) {
		document.getElementById('nextButtonBase').style.visibility = 'hidden';
	}
	window.reResultStr = getNextImg(keyName,thisNum);
	document.getElementById('whiteBase').innerHTML = '&nbsp;';
	turnWhiteHeight(commentH,whiteHeight);
}

//BACK・NEXT共通処理
function reView2() {
	reResultArray = reResultStr.split('<>');
	window.imgPath = reResultArray[0];
	window.width   = parseInt(reResultArray[1]);
	window.height  = parseInt(reResultArray[2]);
	window.thisNum = parseInt(reResultArray[3]);

	//bodyのサイズより画像サイズが大きければ縮小処理
	if (bodyWidth * 0.8 < width || bodyHeight * 0.8 < height) {
		var reSizePercentW = width / (bodyWidth * 0.8);
		var reSizePercentH = height / (bodyHeight * 0.8);
		if (reSizePercentW > reSizePercentH) {
			window.width = parseInt(bodyWidth * 0.8);
			window.height = parseInt(height / reSizePercentW);
		}
		if (reSizePercentW < reSizePercentH) {
			window.width = parseInt(width / reSizePercentH);
			window.height = parseInt(bodyHeight * 0.8);
		}
		if (reSizePercentW == reSizePercentH) {
			window.width = parseInt(bodyWidth * 0.8);
			window.height = parseInt(bodyHeight * 0.8);
		}
	}

	window.oldWhiteWidth = whiteWidth;
	window.oldWhiteHeight = whiteHeight;
	window.whiteWidth = width + imgMargin;
	window.whiteHeight = height + imgMargin;
	reSizeWhiteW(oldWhiteWidth,whiteWidth);
}
function reView3() {
	window.BAlpha = 70;
	window.WAlpha = 30;
	window.IAlpha = 30;
	window.inflag7 = false;
	window.angle = 0;
	reSizeWhiteH(oldWhiteHeight,whiteHeight);
}

//BACK・NEXT表示用モーション関数群
function turnWhiteHeight(px,maxHeight) {
	px = px - 20;
	if (px >= maxHeight) {
		document.getElementById('whiteBase').style.height = px + 'px';
		setTimeout('turnWhiteHeight(' + px + ',' + maxHeight + ')', 5);
	} else {
		document.getElementById('whiteBase').style.height = maxHeight + 'px';
		reView2();
	}
}
function reSizeWhiteW(oldW,newW) {
	if (oldW < newW) {
		oldW = oldW + 20;
		if (oldW <= newW) {
			var moveToLeft = startX - oldW / 2;
			document.getElementById('whiteBase').style.width = oldW + 'px';
			document.getElementById('whiteBase').style.left = moveToLeft + 'px';
			setTimeout('reSizeWhiteW(' + oldW + ',' + newW + ')', 5);
		} else {
			var moveToLeft = startX - newW / 2;
			document.getElementById('whiteBase').style.width = newW + 'px';
			document.getElementById('whiteBase').style.left = moveToLeft + 'px';
			reView3();
		}
	}
	if (oldW > newW) {
		oldW = oldW - 20;
		if (oldW >= newW) {
			var moveToLeft = startX - oldW / 2;
			document.getElementById('whiteBase').style.width = oldW + 'px';
			document.getElementById('whiteBase').style.left = moveToLeft + 'px';
			setTimeout('reSizeWhiteW(' + oldW + ',' + newW + ')', 5);
		} else {
			var moveToLeft = startX - newW / 2;
			document.getElementById('whiteBase').style.width = newW + 'px';
			document.getElementById('whiteBase').style.left = moveToLeft + 'px';
			reView3();
		}
	}
	if (oldW == newW) {
		reView3();
	}
}
function reSizeWhiteH(oldH,newH) {

	if (oldH < newH) {
		oldH = oldH + 20;
		if (oldH <= newH) {
			document.getElementById('whiteBase').style.height = oldH + 'px';
			setTimeout('reSizeWhiteH(' + oldH + ',' + newH + ')', 5);
		} else {
			document.getElementById('whiteBase').style.height = newH + 'px';
			photoView5();
		}
	}
	if (oldH > newH) {
		oldH = oldH - 20;
		if (oldH >= newH) {
			document.getElementById('whiteBase').style.height = oldH + 'px';
			setTimeout('reSizeWhiteH(' + oldH + ',' + newH + ')', 5);
		} else {
			document.getElementById('whiteBase').style.height = newH + 'px';
			photoView5();
		}
	}
	if (oldH == newH) {
		photoView5();
	}
}

//閉じる処理
function closeImg() {
	window.BAlpha = 70;
	window.WAlpha = 30;
	window.IAlpha = 30;
	window.inflag7 = false;
	window.angle = 0;
	if (thisNum != 1) {
		document.getElementById('backButtonBase').style.visibility = 'hidden';
	}
	if (thisNum != allNum) {
		document.getElementById('nextButtonBase').style.visibility = 'hidden';
	}
	document.getElementById('commentBox').style.visibility = 'hidden';
	document.getElementById('numViewBox').style.visibility = 'hidden';
	document.getElementById('closeButton').style.visibility = 'hidden';
	document.getElementById('imgLayer').style.width = '0px';
	document.getElementById('imgLayer').style.height = '0px';
	document.getElementById('imgLayer').style.filter = 'alpha(opacity=0)';
	document.getElementById('imgLayer').style.MozOpacity = 0;
	document.getElementById('imgLayer').style.opacity = 0;
	widthClose(whiteWidth);
}
function closeImg2() {
	heightClose(whiteHeight);
}
function closeImg3() {
	document.getElementById('whiteBase').style.filter = 'alpha(opacity=0)';
	document.getElementById('whiteBase').style.MozOpacity = 0;
	document.getElementById('whiteBase').style.opacity = 0;
	document.getElementById('whiteBase').style.width = '0px';
	document.getElementById('whiteBase').style.height = '0px';
	document.getElementById('whiteBase').innerHTML = '&nbsp;';
	closeAlpha(70);
}
function closeImg4() {
	document.getElementById('viewImgBase').style.filter = 'alpha(opacity=70)';
	document.getElementById('viewImgBase').style.MozOpacity = 0.6;
	document.getElementById('viewImgBase').style.opacity = 0.6;
	document.getElementById('viewImgBase').className = '';
	var objectTag = document.getElementsByTagName('object');
	for (var i = 0; i < objectTag.length; i++) {
		objectTag[i].style.visibility = 'visible';
	}
}

function widthClose(closeWidth) {
	closeWidth = closeWidth - 60;
	if (closeWidth >= imgMargin * 2) {
		var moveToLeft = startX - closeWidth / 2;
		document.getElementById('whiteBase').style.width = closeWidth + 'px';
		document.getElementById('whiteBase').style.left = moveToLeft + 'px';
		setTimeout('widthClose(' + closeWidth + ')', 5);
	} else {
		var moveToLeft = startX - closeWidth / 2;
		document.getElementById('whiteBase').style.width = imgMargin * 2 + 'px';
		document.getElementById('whiteBase').style.left = moveToLeft + 'px';
		closeImg2();
	}
}
function heightClose(closeHeight) {
	closeHeight = closeHeight - 60;
	if (closeHeight >= 0) {
		document.getElementById('whiteBase').style.height = closeHeight + 'px';
		setTimeout('heightClose(' + closeHeight + ')', 5);
	} else {
		document.getElementById('whiteBase').style.height = '0px';
		closeImg3();
	}
}
function closeAlpha(closeAlpha) {
	closeAlpha = closeAlpha - 40;
	if (closeAlpha >= 0) {
		document.getElementById('viewImgBase').style.filter = 'alpha(opacity=' + closeAlpha + ')';
		document.getElementById('viewImgBase').style.MozOpacity = closeAlpha / 100 - 0.1;
		document.getElementById('viewImgBase').style.opacity = closeAlpha / 100 - 0.1;
		setTimeout('closeAlpha(' + closeAlpha + ')', 5);
	} else {
		document.getElementById('viewImgBase').style.filter = 'alpha(opacity=0)';
		document.getElementById('viewImgBase').style.MozOpacity = 0;
		document.getElementById('viewImgBase').style.opacity = 0;
		closeImg4();
	}
}


//非同期通信
function getComment(imagePath) {
	var	httpRequest = createHttpRequest();
	try {
		httpRequest.open('POST', '../script/view_light_box.php', false);
		httpRequest.setRequestHeader("content-type", "application/x-www-form-urlencoded");
		httpRequest.send('mode=getComment&path=' + imagePath);
		return httpRequest.responseText;
	} catch(e) {
		alert("request failed.(" + e + ")");
	}
}
function getBackImg(keyName,thisNum) {
	var	httpRequest = createHttpRequest();
	try {
		httpRequest.open('POST', '../script/view_light_box.php', false);
		httpRequest.setRequestHeader("content-type", "application/x-www-form-urlencoded");
		httpRequest.send('mode=getBackImg&key_name=' + keyName + '&this_num=' + thisNum);
		return httpRequest.responseText;
	} catch(e) {
		alert("request failed.(" + e + ")");
	}
}
function getNextImg(keyName,thisNum) {
	var	httpRequest = createHttpRequest();
	try {
		httpRequest.open('POST', '../script/view_light_box.php', false);
		httpRequest.setRequestHeader("content-type", "application/x-www-form-urlencoded");
		httpRequest.send('mode=getNextImg&key_name=' + keyName + '&this_num=' + thisNum);
		return httpRequest.responseText;
	} catch(e) {
		alert("request failed.(" + e + ")");
	}
}

