﻿var pageType;

onload=function(){
	soBody = document.getElementById('slideObj_body');
	var soBodyH = soBody.scrollHeight;
	var slideObj = document.getElementById('slideObj');
		slideObj.style.top = "-" +soBodyH + "px";
		slideObj.style.visibility = "visible";
	
	// もくじ部分にイベントを追加
	soTitle = document.getElementById('slideObj_title');
	addMenuOpenEvent();
	
	// おとりおきの場合
	if(pageType == "otorioki"){getPrevious();}
	
	// カタログの場合
	if(pageType == "catalogue"){catalogueLoad();}

}

// --------------------　メニュー ---------------------
function openSlideObj() {
	var soBodyH = soBody.scrollHeight;
	var contactTop = Math.round(parseFloat(document.getElementById('slideObj').style.top))
	endPos = -140;
	slideMenuAnim = new YAHOO.util.Anim(
		'slideObj', { top : {from : contactTop ,to: endPos } },0.8,
		YAHOO.util.Easing.backOut
	);
	slideMenuAnim.onComplete.subscribe(function (){addMenuCloseEvent()});   
	slideMenuAnim.animate();
}

				// --------------------　メニュー ---------------------
				function closeSlideObj(event) {
					var clickedTagName;
					event.srcElement?clickedTagName=event.srcElement.nodeName:clickedTagName=event.target.nodeName;
					
					var clickedTagID;
					event.srcElement?clickedTagID=event.srcElement.id:clickedTagID=event.target.id;
					
					
					if(clickedTagID.indexOf('slideObj') != -1){return false;}
					if(clickedTagName == "IMG"){return false;}
					
					if(clickedTagName.match(/TEXTAREA|INPUT|LABEL|FORM|SELECT|OPTION/i)==null){
						addMenuOpenEvent();
						var soBodyH = soBody.scrollHeight;
						var contactTop = Math.round(parseFloat(document.getElementById('slideObj').style.top))
						endPos = soBodyH*-1;
						slideMenuAnim = new YAHOO.util.Anim(
							'slideObj', { top : {from : contactTop ,to: endPos } },0.8,
							YAHOO.util.Easing.backOut
						);
						slideMenuAnim.onComplete.subscribe(function (){removeMenuOpenEvent()});   
						slideMenuAnim.animate();
					}
					
				}
				// --------------------　イベント ---------------------
				function addMenuOpenEvent(){
					window.attachEvent?
						soTitle.attachEvent("onmouseover",openSlideObj):
						soTitle.addEventListener("mouseover",openSlideObj,false);
				}
				function removeMenuOpenEvent(){
					window.attachEvent?
						document.body.detachEvent("onclick",closeSlideObj):
						window.removeEventListener("click",closeSlideObj,false);
				}
				function addMenuCloseEvent(){
					if(window.attachEvent){
						document.body.attachEvent("onclick",closeSlideObj);
			 			soTitle.detachEvent("onmouseover",openSlideObj);
					}else{
					//	soBody.addEventListener("click",function(){alert('TEST');},false);
						window.addEventListener("click",closeSlideObj,false);			// window - click to openSlideObj
						soTitle.removeEventListener("mouseover",openSlideObj,false);		// soTitle - remove
					}
				}




// --------------------　電話番号テキスト表示 ---------------------
function showTextTelNum(obj,bhv){
/*	if(bhv){
		obj.style.filter = "Alpha(opacity=100)";
		obj.style.MozOpacity=1;
		obj.style.opacity=1;
		document.getElementById('telephone_img').src='/catalogue/images/tel_notext.gif';
	}else{
		obj.style.filter = "Alpha(opacity=0)";
		obj.style.MozOpacity=0;
		obj.style.opacity=0;
		document.getElementById('telephone_img').src='/catalogue/images/tel.gif';
	}*/
}

// -------------------- トップページ ---------------------------
// -------------------- お問い合わせオプション表示 -------------
function showOption(obj){
	optObj = document.getElementById('option');
	obj.checked?optObj.style.display="":optObj.style.display="none";

}
// --------------------　選択可能チップ ---------------------
var isShowAddrText = 0;
function showText(obj){
	obj.style.textIndent = "0px";
	obj.style.background = "200px 200px";
	
	
	/*
	if(!isShowAddrText){
		var slctObj = '<div style="position:absolute;background:#fff;padding:3px;border:1px solid #ccc;"><input type="text" onClick="this.select()" onmouseover="this.select()" onFocus="this.select()" value="'+obj.title+'" style="font-size:11px;width:215px;border:none"></div>'
		obj.innerHTML += slctObj;
		isShowAddrText = 1;
	}*/
}

// ---------------------- photo gallery -----------------------
function photoGallery(photoLength){
/* script版、キャッシュ無いと画像サイズ取得できず
	var photos = new Array();


	document.write('<ul class="photogallery">');

	for(var i=0; i<photoLength; i++){

		photos[i] = new Image();
		photos[i].src = 'images/'+i+'.jpg';
		
		var pW = photos[i].width;
		var pH = photos[i].height;

		var pRate = 156/Math.max(pW,pH)
			
		var newW =parseInt(pRate*pW)-2;
		var newH =parseInt(pRate*pH)-2;
		
		document.write('<li><span><img src="'+photos[i].src+'" width="'+newW+'" height="'+newH+'" /></span></li>');
	}

	document.write('</ul>');

*/



	var garellyH = Math.round(photoLength/2)*164;
	document.write('<div style="width:320px;height:'+garellyH+'px;margin:0px auto">');
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="100%" height="100%" id="物件情報フォトビューア" align="middle">\n');
	document.write('<param name="allowScriptAccess" value="sameDomain" />\n');
	document.write('<param name="movie" value="../../../../gallery.swf" />\n');
	document.write('<param name="quality" value="high" />\n');
	document.write('<param name="FlashVars" value="photoLength='+photoLength+'" />\n');

	document.write('<param name="scale" value="noscale" />\n');
	document.write('<param name="bgcolor" value="#ffffff" />\n');
	document.write('<embed src="../../../../gallery.swf" FlashVars="photoLength='+photoLength+'" quality="high" scale="noscale" bgcolor="#ffffff" width="100%" height="100%" name="物件情報フォトビューア" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />\n');
	document.write('</object>\n');
	document.write('</div>');

}


function showOption(obj){
	optObj = document.getElementById('option');
	obj.checked?optObj.style.display="":optObj.style.display="none";
}

function storePhoto(nums){
	document.getElementById('storephoto').src = "images/photo" + nums + ".jpg";
}