

/////////////////////////////////////////
//店舗情報 非同期検索
/////////////////////////////////////////

var getShopCity=function(num){
	var idVal=document.getElementById("output");
	var idSVal=document.getElementById("shopList");
	var idFt=document.getElementById("footer");
	var msec=(new Date()).getTime();
	var itemName;

	new Ajax.Request("/resources/store/xml/city_per_prefectures.xml",{
		method:"get",
		parameters:"cache="+msec,
		onSuccess:function(httpObj){
			var xmlDoc=httpObj.responseXML;
			var dataTag=xmlDoc.getElementsByTagName("prefecture");
			var df=document.createDocumentFragment();
			var source='';
			var sourceBlock='';

			for(var i=0;i<dataTag.length;i++){
				var attrName=dataTag.item(i).getAttribute("name");
				var attrPid=dataTag.item(i).getAttribute("pid");
				var itemTag=dataTag.item(i).getElementsByTagName("city");
				if(attrPid==num){
					source='<div class="cityArea">\n<p class="title">▼市区郡名で絞り込む</p>\n<ul>\n';
					for(var j=0;j<itemTag.length;j++){
						if(itemTag.item(j)){
							itemName=itemTag.item(j).firstChild.nodeValue;
							liSrc='<li><a href="javascript:void(0);" onclick="getShopItem(\''+num+'\',\''+itemName+'\');">'+itemName+'</a>';
							if(j==(itemTag.length-1)) liSrc+='</li>\n';
							else liSrc+=' | </li>\n';
						}else{
							itemName='';
						}
						source+=liSrc;
					}
					source+='</ul>\n</div>';
					var ulSrc="\n<ul>\n"+source+"</ul>";
					sourceBlock+=ulSrc;
				}
			}
			idVal.innerHTML=sourceBlock;
		}
	});


	new Ajax.Request("/resources/store/xml/prefecture_"+num+".xml",{
		method:"get",
		parameters:"cache="+msec,
		onSuccess:function(httpObj){
			var xmlDoc=httpObj.responseXML;
			var dataTag=xmlDoc.getElementsByTagName("shop");
			var sourceS='';
			var pSource='';

			pSource+='<div class="shopItem">\n';

			for(var i=0;i<dataTag.length;i++){
				sourceS='';
				var shopItemShopId=dataTag.item(i).getElementsByTagName("shop-id").item(0).firstChild.nodeValue;
				var shopItemShopName=dataTag.item(i).getElementsByTagName("shop-name").item(0).firstChild.nodeValue;
				var shopItemCategory=dataTag.item(i).getElementsByTagName("category").item(0).firstChild.nodeValue;
				var shopItemAdd=dataTag.item(i).getElementsByTagName("add").item(0).firstChild.nodeValue;
				var shopItemDeveloper=(dataTag.item(i).getElementsByTagName("developer").item(0).firstChild)?dataTag.item(i).getElementsByTagName("developer").item(0).firstChild.nodeValue:'';
				var shopItemFloor=(dataTag.item(i).getElementsByTagName("floor").item(0).firstChild)?dataTag.item(i).getElementsByTagName("floor").item(0).firstChild.nodeValue:'';
				var shopItemPhoneNum=dataTag.item(i).getElementsByTagName("phone-num").item(0).firstChild.nodeValue;

				sourceS+='<!--item-->\n';
				sourceS+='<div class="item">\n';
				sourceS+='<div class="shopInfo">\n';
				sourceS+='<p class="shopName">'+shopItemShopName;

				if(shopItemCategory=="シネマクラブ") sourceS+='<img src="/resources/store/img/icn_cinemaclub.gif" alt="CINEMA CLUB" width="65" height="12" /></p>\n';
				else if(shopItemCategory=="ハニークラブ") sourceS+='<img src="/resources/store/img/icn_honeyclub.gif" alt="HONEY CLUB" width="65" height="12" /></p>\n';
				else if(shopItemCategory=="クロスオーバー") sourceS+='<img src="/resources/store/img/icn_cross_over.gif" alt="CROSS OVER" width="65" height="12" /></p>\n';
				else if(shopItemCategory=="シェリーコート") sourceS+='<img src="/resources/store/img/icn_shelly_coat.gif" alt="SHELLY COAT" width="65" height="12" /></p>\n';
				else if(shopItemCategory=="Ｈ＆ＳＣ") sourceS+='<img src="/resources/store/img/icn_h_sc.gif" alt="H&amp;SC" width="65" height="12" /></p>\n';
				else if(shopItemCategory=="グラシア") sourceS+='<img src="/resources/store/img/icn_graciea.gif" alt="GLACIEA" width="65" height="12" /></p>\n';
				else if(shopItemCategory=="ＧＬ＆ＨＣ") sourceS+='<img src="/resources/store/img/icn_gl_hc.gif" alt="GL&amp;HC" width="65" height="12" /></p>\n';
				else if(shopItemCategory=="コルザ") sourceS+='<img src="/resources/store/img/icn_colza.gif" alt="COLZA" width="65" height="12" /></p>\n';
				else if(shopItemCategory=="ＪＨ＆ＣＣ") sourceS+='<img src="/resources/store/img/icn_jh_cc.gif" alt="JHJ&amp;CC" width="65" height="12" /></p>\n';
				else if(shopItemCategory=="ハニーハウス") sourceS+='<img src="/resources/store/img/icn_honeyhouse.gif" alt="HONEY HOUSE" width="65" height="12" /></p>\n';
				else if(shopItemCategory=="ANQUIET") sourceS+='<img src="/resources/store/img/icn_anquiet.gif" alt="ANQUIET" width="65" height="12" /></p>\n';
				
				else if(shopItemCategory=="ハニーズ") sourceS+='<img src="/resources/store/img/icn_honeys.gif" alt="HONEYS" width="65" height="12" /></p>\n';
				else sourceS+='</p>\n';

				sourceS+='<p>'+shopItemAdd+'&nbsp;'+shopItemDeveloper+'&nbsp;'+shopItemFloor+'</p>\n';
				sourceS+='<p>'+shopItemPhoneNum+'</p>\n';
				sourceS+='</div>\n';
				sourceS+='<p class="button"><a href="/store/map.html?pref='+num+'&id='+shopItemShopId+'" target="_blank" onclick="return openSubWindow(this.href,this.target,520,600);"><img src="/resources/store/img/btn_map.gif" alt="MAP" width="77" height="27" /></a></p>\n';
				sourceS+='</div><!--/item-->\n';
				pSource+=sourceS;
			}
			pSource+='<div class="shopItem">\n';
			idSVal.innerHTML=pSource;
		}
	});


//	location.href="#divOutput";
//	idFt.style.position="absolute";
//	idFt.style.bottom="0";
};


var getShopItem=function(num,cit){
	var idVal=document.getElementById("output");
	var idSVal=document.getElementById("shopList");
	var idFt=document.getElementById("footer");
	var msec=(new Date()).getTime();
	var itemName;

	new Ajax.Request("/resources/store/xml/prefecture_"+num+".xml",{
		method:"get",
		parameters:"cache="+msec,
		onSuccess:function(httpObj){
			var xmlDoc=httpObj.responseXML;
			var dataTag=xmlDoc.getElementsByTagName("shop");
			var sourceS='';
			var pSource='';

			pSource+='<div class="shopItem">\n';

			for(var i=0;i<dataTag.length;i++){
				sourceS='';
				var attrCity=dataTag.item(i).getAttribute("city");
				if(attrCity==cit){
					var shopItemShopId=dataTag.item(i).getElementsByTagName("shop-id").item(0).firstChild.nodeValue;
					var shopItemShopName=dataTag.item(i).getElementsByTagName("shop-name").item(0).firstChild.nodeValue;
					var shopItemCategory=dataTag.item(i).getElementsByTagName("category").item(0).firstChild.nodeValue;
					var shopItemAdd=dataTag.item(i).getElementsByTagName("add").item(0).firstChild.nodeValue;
					var shopItemDeveloper=(dataTag.item(i).getElementsByTagName("developer").item(0).firstChild)?dataTag.item(i).getElementsByTagName("developer").item(0).firstChild.nodeValue:'';
					var shopItemFloor=(dataTag.item(i).getElementsByTagName("floor").item(0).firstChild)?dataTag.item(i).getElementsByTagName("floor").item(0).firstChild.nodeValue:'';
					var shopItemPhoneNum=dataTag.item(i).getElementsByTagName("phone-num").item(0).firstChild.nodeValue;
					var shopItemMapLat=dataTag.item(i).getElementsByTagName("map-lat").item(0).firstChild.nodeValue;
					var shopItemMapLng=dataTag.item(i).getElementsByTagName("map-lng").item(0).firstChild.nodeValue;

					sourceS+='<!--item-->\n';
					sourceS+='<div class="item">\n';
					sourceS+='<div class="shopInfo">\n';
					sourceS+='<p class="shopName">'+shopItemShopName;

					if(shopItemCategory=="シネマクラブ") sourceS+='<img src="/resources/store/img/icn_cinemaclub.gif" alt="CINEMA CLUB" width="65" height="12" /></p>\n';
					else if(shopItemCategory=="ハニークラブ") sourceS+='<img src="/resources/store/img/icn_honeyclub.gif" alt="HONEY CLUB" width="65" height="12" /></p>\n';
					else if(shopItemCategory=="クロスオーバー") sourceS+='<img src="/resources/store/img/icn_cross_over.gif" alt="CROSS OVER" width="65" height="12" /></p>\n';
					else if(shopItemCategory=="シェリーコート") sourceS+='<img src="/resources/store/img/icn_shelly_coat.gif" alt="SHELLY COAT" width="65" height="12" /></p>\n';
					else if(shopItemCategory=="Ｈ＆ＳＣ") sourceS+='<img src="/resources/store/img/icn_h_sc.gif" alt="H&amp;SC" width="65" height="12" /></p>\n';
					else if(shopItemCategory=="グラシア") sourceS+='<img src="/resources/store/img/icn_graciea.gif" alt="GLACIEA" width="65" height="12" /></p>\n';
					else if(shopItemCategory=="ＧＬ＆ＨＣ") sourceS+='<img src="/resources/store/img/icn_gl_hc.gif" alt="GL&amp;HC" width="65" height="12" /></p>\n';
					else if(shopItemCategory=="コルザ") sourceS+='<img src="/resources/store/img/icn_colza.gif" alt="COLZA" width="65" height="12" /></p>\n';
					else if(shopItemCategory=="ＪＨ＆ＣＣ") sourceS+='<img src="/resources/store/img/icn_jh_cc.gif" alt="JHJ&amp;CC" width="65" height="12" /></p>\n';
					else if(shopItemCategory=="ハニーハウス") sourceS+='<img src="/resources/store/img/icn_honeyhouse.gif" alt="HONEY HOUSE" width="65" height="12" /></p>\n';
					else if(shopItemCategory=="ANQUIET") sourceS+='<img src="/resources/store/img/icn_anquiet.gif" alt="ANQUIET" width="65" height="12" /></p>\n';
					else if(shopItemCategory=="ハニーズ") sourceS+='<img src="/resources/store/img/icn_honeys.gif" alt="HONEYS" width="65" height="12" /></p>\n';
					else sourceS+='</p>\n';

					sourceS+='<p>'+shopItemAdd+'&nbsp;'+shopItemDeveloper+'&nbsp;'+shopItemFloor+'</p>\n';
					sourceS+='<p>'+shopItemPhoneNum+'</p>\n';
					sourceS+='</div>\n';
					sourceS+='<p class="button"><a href="/store/map.html?pref='+num+'&id='+shopItemShopId+'" target="_blank" onclick="return openSubWindow(this.href,this.target,520,600);"><img src="/resources/store/img/btn_map.gif" alt="MAP" width="77" height="27" /></a></p>\n';
					sourceS+='</div><!--/item-->\n';
				}
				pSource+=sourceS;
			}
			pSource+='<div class="shopItem">\n';
			idSVal.innerHTML=pSource;
		}
	});
//	location.href="#divShopList";
//	idFt.style.position="absolute";
//	idFt.style.bottom="0";
};


var mapLoad=function(){
	var loc=window.location.href;
	var num=loc.slice(loc.indexOf("pref")+5,loc.indexOf("&"));
	var id=loc.slice(loc.indexOf("id")+3,loc.length);



	var idSVal=document.getElementById("shopName");
	var msec=(new Date()).getTime();
	var itemName;

	new Ajax.Request("/resources/store/xml/prefecture_"+num+".xml",{
		method:"get",
		parameters:"cache="+msec,
		onSuccess:function(httpObj){
			var xmlDoc=httpObj.responseXML;
			var dataTag=xmlDoc.getElementsByTagName("shop");
			var sourceS='';
			var pSource='';

			for(var i=0;i<dataTag.length;i++){

				var shopItemShopId=dataTag.item(i).getElementsByTagName("shop-id").item(0).firstChild.nodeValue;
				var shopItemShopName=dataTag.item(i).getElementsByTagName("shop-name").item(0).firstChild.nodeValue;
				var shopItemCategory=dataTag.item(i).getElementsByTagName("category").item(0).firstChild.nodeValue;
				var shopItemAdd=dataTag.item(i).getElementsByTagName("add").item(0).firstChild.nodeValue;
				var shopItemDeveloper=(dataTag.item(i).getElementsByTagName("developer").item(0).firstChild)?dataTag.item(i).getElementsByTagName("developer").item(0).firstChild.nodeValue:'';
				var shopItemFloor=(dataTag.item(i).getElementsByTagName("floor").item(0).firstChild)?dataTag.item(i).getElementsByTagName("floor").item(0).firstChild.nodeValue:'';
				var shopItemPhoneNum=dataTag.item(i).getElementsByTagName("phone-num").item(0).firstChild.nodeValue;
				var shopItemMapLat=dataTag.item(i).getElementsByTagName("map-lat").item(0).firstChild.nodeValue;
				var shopItemMapLng=dataTag.item(i).getElementsByTagName("map-lng").item(0).firstChild.nodeValue;

				if(shopItemShopId==id){
					sourceS=shopItemShopName;
					pSource=sourceS;

					var mapMess='<p class="infoName"><strong>'+shopItemShopName+'</strong></p>';
					mapMess+='<p class="subInfo">'+shopItemAdd+'<br />'+shopItemDeveloper+shopItemFloor+'<br />'+shopItemPhoneNum+'</p>';

					var mapLat=shopItemMapLat;
					var mapLng=shopItemMapLng;

				}
			}
			idSVal.innerHTML=pSource;
			mapApi(mapLat,mapLng,mapMess);
		}
	});
};


var mapApi=function(lat,lng,msg){
	var map=new GMap(document.getElementById("shopMap"));
	map.addControl(new GLargeMapControl());
	map.addControl(new GMapTypeControl());
	map.centerAndZoom(new GPoint(lng,lat),2);
	//情報ウィンドウ設定
	var message=msg;
	map.openInfoWindowHtml(map.getCenterLatLng(),message);
	//アイコン表示
	var icon=new GIcon();
	icon.image="/resources/common/img/icn_store_map.png";
	icon.shadow="/resources/common/img/icn_store_map_shadow.png";
	icon.iconSize=new GSize(19,19);
	icon.shadowSize=new GSize(21,21);
	icon.iconAnchor=new GPoint(9,11);
	var marker=new GMarker(map.getCenterLatLng(),icon);
	map.addOverlay(marker);
	//マウスホイールのイベントを追加
	if(navigator.userAgent.match("MSIE")){document.getElementById("shopMap").attachEvent("onmousewheel",mouseWheelZooming);}
	if(navigator.userAgent.match("Gecko")){document.getElementById("shopMap").addEventListener("DOMMouseScroll",mouseWheelZooming,false);}
	if(navigator.userAgent.match("Safari")){document.getElementById("shopMap").onmousewheel=mouseWheelZooming;}
	//マウスホールによるズーム処理
	function mouseWheelZooming(event){
		//マウスホイールの上／下の取得と、スクロールのキャンセル
		if( navigator.userAgent.match("MSIE")){var delta=event.wheelDelta;event.returnValue=false;} //IE
		if( navigator.userAgent.match("Gecko")){var delta=event.detail*-1;event.preventDefault();} //Gecko
		if( navigator.userAgent.match("Safari")){var delta=event.wheelDelta;event.returnValue=false;} //Safari
		//ズーム処理
		map.zoomTo(map.getZoomLevel()+(delta<0?1:-1));
	}
};






