var FEATURED_SPOTS=[{name:'捷運美食',css:'maph_mrt',title:'quick_search_title_mrt',categories:[{name:'淡水線',icon:'/images/v2/map/mrt_r.gif',listicon:'/images/v2/map/mrt_rp.gif',items:[{name:'淡水',address:'捷運淡水站'},{name:'紅樹林',address:'捷運紅樹林站'},{name:'竹圍',address:'捷運竹圍站'},{name:'關渡',address:'捷運關渡站'},{name:'忠義',address:'捷運忠義站'},{name:'復興崗',address:'捷運復興崗站'},{name:'北投',address:'捷運北投站'},{name:'奇岩',address:'捷運奇岩站'},{name:'唭哩岸',address:'捷運唭哩岸站'},{name:'石牌',address:'捷運石牌站'},{name:'明德',address:'捷運明德站'},{name:'芝山',address:'捷運芝山站'},{name:'士林',address:'捷運士林站'},{name:'劍潭',address:'捷運劍潭站'},{name:'圓山',address:'捷運圓山站'},{name:'民權西路',address:'捷運民權西路站'},{name:'雙連',address:'捷運雙連站'},{name:'中山',address:'捷運中山站'},{name:'台北車站',address:'捷運台北車站站'},{name:'台大醫院',address:'捷運台大醫院站'},{name:'小南門',address:'捷運小南門站'},{name:'中正紀念堂',address:'捷運中正紀念堂站'}]},{name:'新店線',icon:'/images/v2/map/mrt_g.gif',listicon:'/images/v2/map/mrt_gp.gif',items:[{name:'古亭',address:'捷運古亭站'},{name:'台電大樓',address:'捷運台電大樓站'},{name:'公館',address:'捷運公館站'},{name:'萬隆',address:'捷運萬隆站'},{name:'景美',address:'捷運景美站'},{name:'大坪林',address:'捷運大坪林站'},{name:'七張',address:'捷運七張站'},{name:'新店市公所',address:'捷運新店市公所站'},{name:'新店',address:'捷運新店站'},{name:'新北投',address:'捷運新北投站'},{name:'小碧潭',address:'捷運小碧潭站'}]},{name:'南勢角線',icon:'/images/v2/map/mrt_y.gif',listicon:'/images/v2/map/mrt_rp.gif',items:[{name:'頂溪',address:'捷運頂溪站'},{name:'永安市場',address:'捷運永安市場站'},{name:'景安',address:'捷運景安站'},{name:'南勢角',address:'捷運南勢角站'}]},{name:'板南線',icon:'/images/v2/map/mrt_b.gif',listicon:'/images/v2/map/mrt_bp.gif',items:[{name:'南港',address:'捷運南港站'},{name:'昆陽',address:'捷運昆陽站'},{name:'後山埤',address:'捷運後山埤站'},{name:'永春',address:'捷運永春站'},{name:'市政府',address:'捷運市政府站'},{name:'國父紀念館',address:'捷運國父紀念館站'},{name:'忠孝敦化',address:'捷運忠孝敦化站'},{name:'忠孝復興',address:'捷運忠孝復興站'},{name:'忠孝新生',address:'捷運忠孝新生站'},{name:'善導寺',address:'捷運善導寺站'},{name:'台北車站',address:'捷運台北車站站'},{name:'西門',address:'捷運西門站'},{name:'龍山寺',address:'捷運龍山寺站'},{name:'江子翠',address:'捷運江子翠站'},{name:'新埔',address:'捷運新埔站'},{name:'板橋',address:'捷運板橋站'},{name:'府中',address:'捷運府中站'},{name:'亞東醫院',address:'捷運亞東醫院站'},{name:'海山',address:'捷運海山站'},{name:'土城',address:'捷運土城站'},{name:'永寧',address:'捷運永寧站'}]},{name:'柵湖線',icon:'/images/v2/map/mrt_br.gif',listicon:'/images/v2/map/mrt_brp.gif',items:[{name:'南港展覽館',address:'捷運南港展覽館站'},{name:'南港軟體園區',address:'捷運南港軟體園區站'},{name:'東湖',address:'捷運東湖站'},{name:'葫洲',address:'捷運葫洲站'},{name:'大湖公園',address:'捷運大湖公園站'},{name:'內湖',address:'捷運內湖站'},{name:'文德',address:'捷運文德站'},{name:'港墘',address:'捷運港墘站'},{name:'西湖',address:'捷運西湖站'},{name:'劍南路',address:'捷運劍南路站'},{name:'大直',address:'捷運大直站'},{name:'松山機場',address:'捷運松山機場站'},{name:'中山國中',address:'捷運中山國中站'},{name:'南京東路',address:'捷運南京東路站'},{name:'大安',address:'捷運大安站'},{name:'科技大樓',address:'捷運科技大樓站'},{name:'六張犁',address:'捷運六張犁站'},{name:'麟光',address:'捷運麟光站'},{name:'辛亥',address:'捷運辛亥站'},{name:'萬芳醫院',address:'捷運萬芳醫院站'},{name:'萬芳社區',address:'捷運萬芳社區站'},{name:'木柵',address:'捷運木柵站'},{name:'動物園',address:'捷運動物園站'}]}]},{name:'校園美食',css:'maph_school',title:'quick_search_title_school',categories:[{name:'國立/市立 > 大學、學院',icon:'/images/v2/map/mrt_g.gif',listicon:'/images/v2/map/mrt_gp.gif',items:[{name:'國立臺灣大學',address:'國立臺灣大學'},{name:'國立政治大學',address:'國立政治大學'},{name:'國立清華大學',lng:120.9904146194458,lat:24.795685681031078},{name:'國立成功大學',address:'國立成功大學'},{name:'國立交通大學',lng:120.98307609558105,lat:24.795773338611355},{name:'國立中興大學',address:'國立中興大學'},{name:'國立中央大學',lng:121.19057178497314,lat:24.96909692127037},{name:'國立中山大學',address:'國立中山大學'},{name:'國立中正大學',address:'國立中正大學'},{name:'國立臺灣海洋大學',lng:121.772565,lat:25.150914},{name:'國立陽明大學',address:'國立陽明大學'},{name:'國立東華大學',address:'國立東華大學'},{name:'國立暨南國際大學',address:'國立暨南國際大學'},{name:'國立臺北大學',address:'國立臺北大學'},{name:'國立高雄大學',address:'國立高雄大學'},{name:'國立嘉義大學',address:'國立嘉義大學'},{name:'國立聯合大學',address:'國立聯合大學'},{name:'國立宜蘭大學',lng:121.748695,lat:24.746076},{name:'國立臺東大學',address:'國立臺東大學'},{name:'國立臺南大學',address:'國立臺南大學'},{name:'國立臺灣藝術大學',address:'國立臺灣藝術大學'},{name:'國立臺北藝術大學',address:'國立臺北藝術大學'},{name:'國立臺南藝術大學',address:'台南縣官田鄉大崎村66號'},{name:'國立體育學院',address:'國立體育學院'},{name:'國立臺灣體育學院',address:'國立臺灣體育學院'},{name:'臺北市立體育學院',address:'臺北市立體育學院'}]},{name:'國立專科學校',icon:'/images/v2/map/mrt_g.gif',listicon:'/images/v2/map/mrt_gp.gif',items:[{name:'國立台南護理專科學校',address:'國立台南護理專科學校'},{name:'國立臺中護理專科學校',lng:120.676121,lat:24.139418},{name:'國立臺東專科學校',lng:121.12452507019043,lat:22.757800474259188}]},{name:'私立 > 科技大學',icon:'/images/v2/map/mrt_g.gif',listicon:'/images/v2/map/mrt_gp.gif',items:[{name:'朝陽科技大學',address:'朝陽科技大學'},{name:'南台科技大學',address:'南台科技大學'},{name:'崑山科技大學',address:'崑山科技大學'},{name:'嘉南藥理科技大學',address:'嘉南藥理科技大學'},{name:'樹德科技大學',lng:120.38232,lat:22.769522},{name:'龍華科技大學',address:'龍華科技大學'},{name:'輔英科技大學',address:'輔英科技大學'},{name:'明新科技大學',address:'明新科技大學'},{name:'清雲科技大學',address:'清雲科技大學'},{name:'正修科技大學',address:'正修科技大學'},{name:'弘光科技大學',address:'弘光科技大學'},{name:'明志科技大學',address:'明志科技大學'},{name:'建國科技大學',address:'建國科技大學'},{name:'萬能科技大學',address:'萬能科技大學'},{name:'嶺東科技大學',address:'嶺東科技大學'},{name:'中國科技大學',address:'中國科技大學'},{name:'中臺科技大學',address:'中臺科技大學'},{name:'大仁科技大學',address:'大仁科技大學'},{name:'聖約翰科技大學',address:'聖約翰科技大學'},{name:'高苑科技大學',address:'高苑科技大學'},{name:'元培科技大學',address:'元培科技大學'},{name:'台南科技大學',address:'台南科技大學'},{name:'遠東科技大學',address:'遠東科技大學'},{name:'德明財經科技大學',address:'德明財經科技大學'},{name:'中華醫事科技大學',address:'中華醫事科技大學'},{name:'東南科技大學',lng:121.604514,lat:25.004266},{name:'景文科技大學',address:'景文科技大學'}]},{name:'私立 > 技術學院',icon:'/images/v2/map/mrt_g.gif',listicon:'/images/v2/map/mrt_gp.gif',items:[{name:'大同技術學院',address:'大同技術學院'},{name:'僑光技術學院',address:'僑光技術學院'},{name:'致理技術學院',address:'致理技術學院'},{name:'醒吾技術學院',address:'醒吾技術學院'},{name:'吳鳳技術學院',address:'吳鳳技術學院'},{name:'修平技術學院',address:'修平技術學院'},{name:'文藻外語學院',address:'文藻外語學院'},{name:'華夏技術學院',address:'華夏技術學院'},{name:'美和技術學院',address:'美和技術學院'},{name:'南榮技術學院',address:'南榮技術學院'},{name:'蘭陽技術學院',address:'蘭陽技術學院'},{name:'東方技術學院',address:'東方技術學院'},{name:'台北海洋技術學院',address:'台北海洋技術學院'},{name:'崇右技術學院',address:'崇右技術學院'},{name:'經國管理暨健康學院',address:'經國管理暨健康學院'},{name:'大華技術學院',address:'大華技術學院'},{name:'永達技術學院',address:'永達技術學院'},{name:'中華技術學院',address:'中華技術學院'},{name:'亞東技術學院',address:'亞東技術學院'},{name:'黎明技術學院',address:'黎明技術學院'},{name:'南亞技術學院',address:'南亞技術學院'},{name:'中州技術學院',address:'中州技術學院'},{name:'北台灣科學技術學院',address:'北台灣科學技術學院'},{name:'南開技術學院',address:'南開技術學院'},{name:'德霖技術學院',address:'德霖技術學院'},{name:'大漢技術學院',address:'大漢技術學院'},{name:'長庚技術學院',lng:121.387355,lat:25.033192},{name:'親民技術學院',lng:120.96994400024414,lat:24.682585116816337},{name:'慈濟技術學院',address:'慈濟技術學院'},{name:'和春技術學院',address:'和春技術學院'},{name:'台灣觀光學院',address:'台灣觀光學院'},{name:'環球技術學院',address:'環球技術學院'},{name:'育達商業技術學院',address:'育達商業技術學院'},{name:'高鳳技術學院',address:'屏東縣長治鄉復興村新興路38號'}]},{name:'國立 > 技術學院',icon:'/images/v2/map/mrt_g.gif',listicon:'/images/v2/map/mrt_gp.gif',items:[{name:'國立台北護理學院',lng:121.52050495147705,lat:25.117912848033207},{name:'國立屏東商業技術學院',address:'國立屏東商業技術學院'},{name:'國立臺中技術學院',address:'國立臺中技術學院'},{name:'國立高雄餐旅學院',lng:120.37254095077515,lat:22.564145296576328},{name:'國立台北商業技術學院',address:'國立台北商業技術學院'},{name:'國立金門技術學院',address:'金門縣金寧鄉大學路1號'},{name:'國立臺灣戲曲學院',lat:24.986838,lng:121.566663}]},{name:'私立專科學校',icon:'/images/v2/map/mrt_g.gif',listicon:'/images/v2/map/mrt_gp.gif',items:[{name:'康寧醫護暨管理專校',lng:121.61011219024658,lat:25.075745621918166},{name:'馬偕醫護管理專校',lng:121.46409273147583,lat:25.122031631580736},{name:'仁德醫護管理專校',address:'仁德醫護管理專校'},{name:'慈惠醫護管理專校',address:'慈惠醫護管理專校'},{name:'樹人醫護管理專校',lng:120.26188373565674,lat:22.882877045677528},{name:'耕莘健康管理專校',lng:121.53578281402588,lat:24.977441607888913},{name:'育英醫護管理專校',address:'育英醫護管理專校'},{name:'敏惠醫護管理專校',lng:120.329993,lat:23.280033},{name:'高美醫護管理專校',lng:120.550973,lat:22.887284},{name:'新生醫護管理專校',address:'桃園縣龍潭鄉中豐路高平段418號'},{name:'聖母醫護管理專校',address:'宜蘭縣三星鄉三星路二段265巷100號'},{name:'崇仁醫護管理專校',address:'嘉義市盧厝里紅毛埤217號'}]},{name:'國立/市立 > 師範大學',icon:'/images/v2/map/mrt_g.gif',listicon:'/images/v2/map/mrt_gp.gif',items:[{name:'國立台灣師範大學',address:'國立台灣師範大學'},{name:'國立高雄師範大學',lng:120.32132148742676,lat:22.6256574411413},{name:'國立彰化師範大學',address:'國立彰化師範大學'},{name:'台北市立教育大學',address:'台北市立教育大學'},{name:'國立台北教育大學',address:'國立台北教育大學'},{name:'國立新竹教育大學',lng:120.96518039703369,lat:24.793046184873752},{name:'國立臺中教育大學',address:'國立臺中教育大學'},{name:'國立屏東教育大學',lng:120.50259590148926,lat:22.668590676099477},{name:'國立花蓮教育大學',lng:121.61871671676636,lat:24.009501617971743}]},{name:'私立 > 大學、學院',icon:'/images/v2/map/mrt_g.gif',listicon:'/images/v2/map/mrt_gp.gif',items:[{name:'東海大學',lng:120.60022830963135,lat:24.181640640122193},{name:'輔仁大學',address:'輔仁大學'},{name:'東吳大學',address:'東吳大學'},{name:'淡江大學',address:'淡江大學'},{name:'中原大學',address:'中原大學'},{name:'逢甲大學',address:'逢甲大學'},{name:'中國文化大學',address:'中國文化大學'},{name:'靜宜大學',address:'靜宜大學'},{name:'世新大學',address:'世新大學'},{name:'銘傳大學',address:'銘傳大學'},{name:'實踐大學',address:'實踐大學'},{name:'義守大學',address:'義守大學'},{name:'長庚大學',address:'長庚大學'},{name:'元智大學',address:'元智大學'},{name:'中華大學',address:'中華大學'},{name:'大葉大學',lng:120.60115098953247,lat:23.999641881182153},{name:'華梵大學',address:'華梵大學'},{name:'真理大學',address:'真理大學'},{name:'高雄醫學大學',address:'高雄醫學大學'},{name:'大同大學',address:'大同大學'},{name:'南華大學',address:'南華大學'},{name:'台北醫學大學',address:'台北醫學大學'},{name:'慈濟大學',address:'慈濟大學'},{name:'玄奘大學',lng:120.94192028045654,lat:24.76886929401311},{name:'中山醫學大學',address:'中山醫學大學'},{name:'長榮大學',address:'長榮大學'},{name:'中國醫藥大學',address:'中國醫藥大學'},{name:'亞洲大學',address:'亞洲大學'},{name:'佛光大學',lng:121.72207832336426,lat:24.81647827077459},{name:'開南大學',address:'開南大學'},{name:'明道大學',address:'彰化縣埤頭鄉文化路369號'},{name:'致遠管理學院',address:'致遠管理學院'},{name:'立德管理學院',address:'立德管理學院'},{name:'興國管理學院',address:'興國管理學院'},{name:'稻江科技暨管理學院',address:'稻江科技暨管理學院'}]},{name:'國立 > 科技大學',icon:'/images/v2/map/mrt_g.gif',listicon:'/images/v2/map/mrt_gp.gif',items:[{name:'國立台北科技大學',address:'台北科技大學'},{name:'國立屏東科技大學',address:'國立屏東科技大學'},{name:'國立台灣科技大學',address:'國立台灣科技大學'},{name:'國立高雄第一科技大學',address:'國立高雄第一科技大學'},{name:'國立雲林科技大學',address:'國立雲林科技大學'},{name:'國立高雄應用科技大學',lng:120.32853126525879,lat:22.6495813054607},{name:'國立虎尾科技大學',address:'國立虎尾科技大學'},{name:'國立澎湖科技大學',address:'國立澎湖科技大學'},{name:'國立勤益科技大學',lng:120.73056221008301,lat:24.144247312175384},{name:'國立高雄海洋科技大學',address:'國立高雄海洋科技大學'}]}]},{name:'高鐵美食',css:'maph_khr',title:'quick_search_title_khr',categories:[{name:'高鐵站',icon:'/images/v2/map/mrt_y.gif',listicon:'/images/v2/map/mrt_yp.gif',items:[{name:'台北站',address:'台北車站'},{name:'板橋站',address:'板橋車站'},{name:'桃園站',address:'高鐵桃園站'},{name:'新竹站',address:'高鐵竹北站'},{name:'台中站',address:'高鐵台中站'},{name:'嘉義站',address:'高鐵嘉義站'},{name:'台南站',address:'高鐵台南站'},{name:'左營站',address:'高鐵左營站'}]}]},{name:'新食代運動',css:'maph_hlt',url:'/action/2009_healthy/'},{name:'地圖定位',css:'maph_set',url:'javascript: void(0)'}];var geoLocator={inited:false,control:null,init:function(){$('.maph_set').click(function(e){e.preventDefault();geoLocator.locate();});},__tryInstallPlugin:function(upgrade){var manualMessage='抱歉，由於您未安裝 Java 程式，所以您必須手動安裝我們的定位程式。',installMessage='現在為您安裝定位模組，安裝過程約為1分鐘,請耐心等候。';if(upgrade)
installMessage='您目前的定位模組為舊版，系統將為您安裝新版本...';if(navigator.javaEnabled()){alert(installMessage);$('#showmehere_install').append('<APPLET CODE="ShowMeHerePlugin.class" archive="http://www.lidido.com.tw/getLocation/ShowMeHere_1.0.0.5.jar"><param name="PluginPath" value="http://www.lidido.com.tw/getLocation/"><param name="SuccessURL" value="http://www.ipeen.com.tw/map/"><param name="FailURL" value="http://www.ipeen.com.tw/map/"></APPLET>');messageLayer.show('#showmehere_install');}else{alert(manualMessage);window.location='http://www.lidido.com.tw/getLocation/setupMSI.php?url='+window.location;}
return false;},__initPluginForGecko:function(){$('body').append('<embed id="ShowMeHere" name="ShowMeHere" type="application/x-showmehere" width=0 height=0 />');navigator.plugins.refresh(false);var mimetype=navigator.mimeTypes["application/x-showmehere"];geoLocator.control=$('#ShowMeHere')[0];if(!mimetype||(mimetype.enabledPlugin&&geoLocator.control.GetPluginVersion()!='1.0.0.5'))
return geoLocator.__tryInstallPlugin(mimetype!=undefined);this.inited=true;return true;},__initPluginForIE:function(){if(!geoLocator.control)
$('body').append('<OBJECT ID="ShowMeHere" CLASSID="CLSID:96D8E229-4D0F-48D2-8C81-F669F213F9DE" CODEBASE="http://www.lidido.com.tw/getLocation/ShowMeHere_1.0.1.4.CAB#version=1,0,1,4"></OBJECT>');geoLocator.control=$('#ShowMeHere')[0];return true;},__initPlugin:function(){if(navigator.platform!='Win32'){alert('抱歉,目前我們僅支援Windows作業系統');return false;}
var initFuncs={'N':this.__initPluginForGecko,'M':this.__initPluginForIE};var browserId=navigator.appName.substr(0,1),initFunc=initFuncs[browserId];if(!initFunc){alert('抱歉，目前我們僅支援 IE 及 Firefox 瀏覽器');return false;}
return initFunc();},locate:function(){if(!this.inited&&!this.__initPlugin())
return;if(typeof(this.control.GetLocation)=='undefined')
return;result=this.control.GetLocation('20091223222201');if(result.substr(0,3)=='Err')
return alert('無法取得您現在的位置！');toolBox.hide();hashManager.update('loc',result);}};(function($){function __checkPromptedEditBox(){if($(this).val()==''||$(this).attr('force')==1)
$(this).hide().data('ph').show();else
$(this).show().data('ph').hide();}
jQuery.fn.getEditBoxPrompt=function(){return this.data('ph').val();};jQuery.fn.changeEditBoxPrompt=function(text){return this.each(function(){$(this).data('ph').val(text);});};jQuery.fn.promptedEditBox=function(text,force){return this.each(function(){var me=$(this),ph=$('<input type="text" />').val(text).data('real',me).addClass(me.attr('class')).css('color','#888888').css('width',me.css('width')).css('height',me.css('height')).focus(function(){$(this).hide();$(this).data('real').show().focus();});$(this).data('ph',ph).attr('force',force?1:0).hide().after(ph).change(__checkPromptedEditBox).blur(__checkPromptedEditBox).change();});};})(jQuery);function isIE6(){return(jQuery.browser.msie&&jQuery.browser.version=='6.0');}
function ShopMarker(s){this.shop=s;this.loc=new GLatLng(s.lat,s.lng);}
(function(){ShopMarker.bgImage=photoServer+'/images/v2/map/map_point_02.png',ShopMarker.shadowImage='http://www.google.com/mapfiles/shadow50.png';ShopMarker.iconOffsets={0:1,6:2,7:3,8:4,9:5,10:6,14:1,21:8,20:9};ShopMarker.prototype=new GOverlay();if(isIE6()){ShopMarker.prototype.__fillDiv=function(d,x,y){var i=document.createElement('div');i.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+ShopMarker.bgImage+"', sizingMethod='crop')";i.style.position='relative';i.style.top=y+'px';i.style.left=x+'px';i.style.width='46px';i.style.height='408px';d.style.overflow='hidden';d.appendChild(i);};ShopMarker.prototype.__createShadowDom=function(){var s=document.createElement('div');s.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+ShopMarker.shadowImage+"', sizingMethod='crop')";return s;};ShopMarker.prototype.__setSpriteOffset=function(offset){this.div.getElementsByTagName('div')[0].style.left=offset+'px';};}else{ShopMarker.prototype.__fillDiv=function(d,x,y){d.style.background="url('"+ShopMarker.bgImage+"') no-repeat "+x+'px '+y+'px';};ShopMarker.prototype.__createShadowDom=function(){var s=document.createElement('img');s.src=ShopMarker.shadowImage;return s;};ShopMarker.prototype.__setSpriteOffset=function(offset){this.div.style.background="url('"+ShopMarker.bgImage+"') no-repeat "+offset+'px '+this.spriteY+'px';};}
ShopMarker.prototype.__createDiv=function(){var s=this.shop,d=document.createElement('div');var x=0,y=ShopMarker.iconOffsets[s.clsid]*-34,zIndex=200;if(s.vip==1){x=-23;zIndex=300;}
d.style.width='23px';d.style.height='34px';d.style.cursor='pointer';d.style.position='absolute';d.style.zIndex=zIndex;this.__fillDiv(d,x,y);d.marker=this;d.setAttribute('title',s.name);GEvent.addDomListener(d,'click',function(){GEvent.trigger(this.marker,'click');});gourmetMap.markerFrag.appendChild(d);this.spriteY=y;return d;}
ShopMarker.prototype.__createShadow=function(){var s=this.__createShadowDom();s.style.width='37px';s.style.height='34px';s.style.position='absolute';s.style.border='0px none';gourmetMap.shadowFrag.appendChild(s);return s;}
ShopMarker.prototype.initialize=function(m){this.map=m;this.div=this.__createDiv();this.shadow=this.__createShadow();}
ShopMarker.prototype.remove=function(){this.div.parentNode.removeChild(this.div);this.shadow.parentNode.removeChild(this.shadow);}
ShopMarker.prototype.copy=function(){return new ShopMarker(this.shop);}
ShopMarker.prototype.redraw=function(force){if(!force)
return;var p=this.map.fromLatLngToDivPixel(this.loc);var y=p.y+'px';var d=this.div,s=this.shadow;d.style.left=p.x+'px';s.style.left=(p.x+2)+'px';d.style.top=s.style.top=y;}
ShopMarker.prototype.select=function(selected){var offset;if(selected==undefined||selected==true){offset=-46;this.oldZIndex=this.div.style.zIndex;this.div.style.zIndex=550;}else{offset=(this.shop.vip?1:0)*-23;this.div.style.zIndex=this.oldZIndex;}
this.__setSpriteOffset(offset);}
ShopMarker.prototype.getZIndex=function(){return this.div.style.zIndex;}
ShopMarker.prototype.getPoint=function(){return this.loc;}})();var hashManager={callback:null,handle:null,last:null,fixed:{},interval:300,start:function(){hashManager.process();this.handle=setInterval('hashManager.process();',this.interval);},stop:function(){clearInterval(this.handle);},parse:function(){var result=[];var hash=decodeURIComponent(window.location.hash.split('#')[1]);if(hash){var params=hash.split('&');for(k in params){var pair=params[k].split('=');result[pair[0]]=pair[1];}}
return result;},get:function(){var result=this.parse(),fixed=this.fixed;if(fixed)
for(k in fixed)
result[k]=fixed[k];return result;},assign:function(param){var result=[];for(k in param)
result.push(k+'='+param[k]);window.location=window.location.pathname+window.location.search+'#'+result.join('&');},update:function(key,value){if(value!=''){var param=this.parse();param[key]=value;this.assign(param);}else
this.remove(key);},remove:function(key){var param=this.parse();delete param[key];this.assign(param);},process:function(){var current=window.location.hash;if(current!=this.last){this.last=current;if(this.callback)
this.callback(this.parse());}}};var gourmetMap={MODE_SEARCH:0,MODE_ROUTE:1,mapDom:null,map:null,manager:null,geocoder:null,directions:null,shopHandler:null,keywordHandler:null,geocodingHandler:null,lastLoc:null,lastZoom:null,optimize:false,addrMarker:null,startMarker:null,endMarker:null,mode:0,showLocMarker:false,lastTempCenter:null,restoreTemp:false,pinText:null,directionsHandler:null,markerFrag:null,shadowFrag:null,map_onClick:null,map_onMoveEnd:null,marker_onClick:null,init:function(dom,defLat,defLng,defZoom){dom=$(dom);var map=new GMap2(dom[0]),dirs=new GDirections(null,null),defLoc=new GLatLng(defLat,defLng);map.setCenter(defLoc,defZoom);map.setUIToDefault();GEvent.addListener(map,'click',this.__map_onClick);GEvent.addListener(map,'moveend',this.__map_onMoveEnd);this.map=map;dirs=new GDirections(null,$('#blackhole')[0]);GEvent.addListener(dirs,'load',this.__directions_onLoad);GEvent.addListener(dirs,'error',this.__directions_onError);this.directions=dirs;this.mapDom=dom;this.geocoder=new GClientGeocoder();this.lastZoom=defZoom;this.lastLoc=defLoc;this.__initAddrMarker(defLoc);this.__initRouteMarkers();return this;},gc:function(){GUnload();},__map_onMoveEnd:function(){if(gourmetMap.restoreTemp){gourmetMap.restoreTemp=false;return;}else if(gourmetMap.lastTempCenter!=null)
return;if(gourmetMap.optimize){var z=gourmetMap.zoom(),last=gourmetMap.lastZoom;gourmetMap.lastZoom=z;if(last<z)
return;if(last==z&&gourmetMap.__isMinorMove())
return;gourmetMap.lastLoc=gourmetMap.center();}
var h=gourmetMap.map_onMoveEnd;if(h&&h.call)
h();},__map_onClick:function(){var h=gourmetMap.map_onClick;if(h&&h.call)
h();},__marker_onClick:function(){var h=gourmetMap.marker_onClick;if(h&&h.call)
h(this);},__pin_onClick:function(){var pinText=gourmetMap.pinText;if(pinText!=null)
gourmetMap.addrMarker.openInfoWindowHtml('<div class="here_point"><div class="here_title">你輸入的地點：</div>'+'<div class="here_add">'+pinText+'</div></div>');},__directions_onLoad:function(){var h=gourmetMap.directionsHandler;gourmetMap.__showDirections();if(h&&h.call){var routes=[],total=gourmetMap.directions.getNumRoutes();for(i=0;i<total;i++)
routes.push(gourmetMap.directions.getRoute(i));h(routes);}},__directions_onError:function(error){alert('無法規劃路線！');},resize:function(height){$(this.mapDom).height(height);this.map.checkResize();},zoom:function(z){if(typeof(z)=='number')
this.map.setZoom(z);else
return this.map.getZoom();return this;},center:function(lat,lng){var c;if(lat instanceof GLatLng)
c=lat;else if(typeof(lat)=='number'&&typeof(lng)=='number')
c=new GLatLng(lat,lng);else
return this.map.getCenter();this.map.panTo(c);return this;},bounds:function(){return this.map.getBounds();},dragging:function(d){if(d)
this.map.enableDragging();else
this.map.disableDragging();return this;},searchMode:function(){if(this.mode!=gourmetMap.MODE_SEARCH){this.mode=gourmetMap.MODE_SEARCH;}
return this;},routeMode:function(){if(this.mode!=gourmetMap.MODE_ROUTE){this.mode=gourmetMap.MODE_ROUTE;this.map.clearOverlays();}
return this;},__geocodingHandler:function(point){var h=gourmetMap.geocodingHandler;if(point)
gourmetMap.pinLocationMarker(point);if(h&&h.call)
h(point);},geocode:function(address,errorProc){this.geocoder.getLatLng(address,gourmetMap.__geocodingHandler);},__showDirections:function(){var polyline=this.directions.getPolyline();this.map.clearOverlays();this.map.addOverlay(polyline);this.startMarker.setLatLng(polyline.getVertex(0));this.map.addOverlay(this.startMarker);this.endMarker.setLatLng(polyline.getVertex(polyline.getVertexCount()-1));this.map.addOverlay(this.endMarker);},getDirections:function(waypoints,options){this.directions.loadFromWaypoints(waypoints,options);},__initAddrMarker:function(loc){var sprite={image:photoServer+'/images/v2/map/map_point.png',left:0,top:408};var icon=new GIcon(G_DEFAULT_ICON);icon.sprite=sprite;icon.iconSize=new GSize(23,34);icon.iconAnchor=new GPoint(5,34);this.addrMarker=new GMarker(loc,{icon:icon,zIndexProcess:function(){return 525;}});GEvent.addListener(this.addrMarker,'click',this.__pin_onClick);},__initRouteMarkers:function(){var spriteImage=photoServer+'/images/v2/map/point_road.png';var defLoc=this.center();var startIcon=new GIcon(G_DEFAULT_ICON),endIcon=new GIcon(G_DEFAULT_ICON);startIcon.sprite={image:spriteImage,left:0,top:0};startIcon.iconSize=new GSize(23,34);startIcon.iconAnchor=new GPoint(5,34);this.startMarker=new GMarker(defLoc,{icon:startIcon});endIcon.sprite={image:spriteImage,left:0,top:34};endIcon.iconSize=new GSize(23,34);endIcon.iconAnchor=new GPoint(5,34);this.endMarker=new GMarker(defLoc,{icon:endIcon});},pinLocationMarker:function(point){if(point!=undefined)
this.addrMarker.setLatLng(point);this.map.addOverlay(this.addrMarker);this.showLocMarker=true;},unpinLocationMarker:function(){this.showLocMarker=false;this.map.removeOverlay(this.addrMarker);},latLngToPoint:function(loc){return this.map.fromLatLngToContainerPixel(loc);},latLngToOrigin:function(loc){var p=this.latLngToPoint(loc),o=this.mapDom.offset();p.x+=o.left;p.y+=o.top;return p;},tempMove:function(x,y){var oc=this.center(),c=this.latLngToPoint(oc);this.lastTempCenter=oc;c.x+=x;c.y+=y;this.center(this.map.fromContainerPixelToLatLng(c));},restoreTempMove:function(){if(this.lastTempCenter!=null){this.center(this.lastTempCenter);this.lastTempCenter=null;this.restoreTemp=true;}},__isMinorMove:function(){var c=this.latLngToPoint(this.center()),l=this.latLngToPoint(this.lastLoc)
return Math.sqrt(Math.pow(c.x-l.x,2)+Math.pow(c.y-l.y,2))<75;},measure:function(a,b){var d=Math.pow(a.lat()-b.lat(),2)+Math.pow(a.lng()-b.lng(),2);return Math.sqrt(d)/0.00000900900901;},addShop:function(shop){this.map.addOverlay(shop.marker);return this;},removeShop:function(shop){this.map.removeOverlay(shop.marker);return this;},clearShops:function(){this.map.clearOverlays();if(this.showLocMarker)
this.pinLocationMarker();return this;},addShops:function(shops){this.markerFrag=document.createDocumentFragment();this.shadowFrag=document.createDocumentFragment();for(k in shops)
this.addShop(shops[k]);this.map.getPane(G_MAP_MARKER_PANE).appendChild(this.markerFrag);this.map.getPane(G_MAP_MARKER_SHADOW_PANE).appendChild(this.shadowFrag);this.markerFrag=null;this.shadowFrag=null;return this;},__internalShopHandler:function(result){if(!result){gourmetMap.clearShops().shopHandler(null);}else{var shops=result.s;for(k in shops){var s=shops[k],marker=new ShopMarker(s);GEvent.addListener(marker,'click',gourmetMap.__marker_onClick);s.marker=marker;}
gourmetMap.clearShops().shopHandler(shops);gourmetMap.keywordHandler(result.k);}
if(gourmetMap.mode==gourmetMap.MODE_ROUTE)
gourmetMap.map.addOverlay(gourmetMap.directions.getPolyline());},getShops:function(param){var p={},b=this.bounds();var ne=b.getNorthEast(),sw=b.getSouthWest();if(param instanceof Array)
for(k in param)
p[k]=param[k];p.ne_lat=ne.lat();p.ne_lng=ne.lng();p.sw_lat=sw.lat();p.sw_lng=sw.lng();$.post('requests/getShops.php',p,this.__internalShopHandler,'json');return this;}};var detailWindow={loading:false,lastShop:null,init:function(){$('#shopDetailWindow .close_btn').click(function(e){e.preventDefault();detailWindow.hide();});$('#shopDetailWindow #collectButton a').click(function(e){e.preventDefault();collectShop($(this).attr('s_id'));});$('#shopDetailWindow #qrcodeButton a').click(function(e){e.preventDefault();window.open('/shop/qrcodeg.php?qrcode='+detailWindow.lastShop.s_id,'shopQRcode','width=395,height=490,scrollbars=yes');});$('#shopDetailWindow #tabCmmt').click(function(e){$('#shopDetailWindow #tabCmmt').attr('class','pfb_tagcmm_select');$('#shopDetailWindow #tabBsCard').attr('class','pfb_tagcollect');$('#shopDetailWindow .pfb_cmmarea').show();$('#shopDetailWindow .pfb_collect').hide();});$('#shopDetailWindow #tabBsCard').click(function(e){$('#shopDetailWindow #tabCmmt').attr('class','pfb_tagcmm');$('#shopDetailWindow #tabBsCard').attr('class','pfb_tagcollect_select');$('#shopDetailWindow .pfb_cmmarea').hide();$('#shopDetailWindow .pfb_collect').show();});$('#shopDetailWindow #collectionNone a').click(function(e){collectShop(detailWindow.lastShop.s_id);});$('#shopDetailWindow #collectionNone a').click(function(e){collectShop(detailWindow.lastShop.s_id);});$('#shopDetailWindow #setStartPoint').click(function(e){directionsList.switchTo().setStart(detailWindow.lastShop);});$('#shopDetailWindow #setEndPoint').click(function(e){directionsList.switchTo().setEnd(detailWindow.lastShop);});},load:function(shop){if(this.loading)
return;if(this.lastShop!=null)
this.lastShop.marker.select(false);shop.marker.select();this.lastShop=shop;$.ajax({type:'POST',url:'requests/getShopSummary.php',data:{s_id:shop.s_id},dataType:'json',success:detailWindow.__fill,complete:function(){detailWindow.loading=false;}});},hide:function(){$('#shopDetailWindow').hide();gourmetMap.restoreTempMove();gourmetMap.dragging(true);},__staticMap:function(shop){var loc=shop.lat+','+shop.lng;return('http://maps.google.com/maps/api/staticmap?center='+
loc+'&zoom=15&size=252x140&key='+googleApiKey+'&sensor=false&markers='+loc);},__fillRep:function(r){var w=$('#shopDetailReputation');var ps=photoServer;if(r==null){w.hide();return;}
w.show();w.find('#shopDetailRepPic').attr('src',ps+'/photo/auction/144x144/'+r.pic);var repUrl='/reputation/exchange_ticket.php?id='+r.id;w.find('#shopDetailRepName').attr('href',repUrl).text(r.name);w.find('#shopDetailRepMore').attr('href',repUrl);w.find('#shopDetailRepType').text(r.lotto>0?'抽獎':'兌換');w.find('#shopDetailRepQuota').text(r.quota);w.find('#shopDetailRepPcash').text(r.pcash);w.find('#shopDetailRepDesc').html(r.desc);if(r.lv!=''){w.find('#shopDetailRepLimit').show();w.find('#shopDetailRepLevel').text(r.lv);w.find('#shopDetailRepTime').text(r.hr);}else
w.find('#shopDetailRepLimit').hide();},__fillAvatar:function(u){return(photoServer+'/photo/usr/'+u.u_id+'/'+u.photo+'_72.jpg');},__fillCmmt:function(s_id,comments,commentsNum){var ps=photoServer;var commentHolders=$('.pfb_cmm_item').hide();if(comments.length>0){$('#commentsHolder').show();$('#commentsNone').hide();for(i in comments){var h=$(commentHolders[i]).show(),c=comments[i];h.find('.pfb_cmm_photo img').attr('src',this.__fillAvatar(c));h.find('.pfb_cmm_photo a').attr('href','/home/'+c.home);h.find('.cmm_user').text(c.name).attr('href','/home/'+c.home);h.find('.shopCmmtLevel').text(c.lv);h.find('.shopCmmtStar').attr('src',ps+'/images/star/icon_star'+c.star+'.png');h.find('.shopCmmtTime').text(c.time);h.find('.shopCmmtContent').text(c.short.substr(0,85));h.find('.pfb_cmm_infocon a.a38').attr('href','/comment/'+c.c_id);}
if(commentsNum>2)
$('#commentsMore').attr('href','/shop/'+s_id+'/').show();else
$('#commentsMore').hide();}else{$('#commentsHolder').hide();$('#commentsNone').show();}},__fillBsCard:function(s_id,bscard,bscardNum){var ps=photoServer;var c=$('.pfb_collect ol').empty();if(bscardNum>0){$('#collectionHolder').show();$('#collectionNone').hide();$('#shopDetailBook').text(bscardNum);for(i in bscard){var b=bscard[i],userUrl='/home/'+b.home+'/';c.append('<li class="collect_item"><div class="collect_pic">'+'<table width="100%" height="72" border="0" cellpadding="0" cellspacing="0">'+'<tr><td align="center" valign="middle">'+'<a target="_blank" href="'+userUrl+'">'+'<img border="0" src="'+this.__fillAvatar(b)+'" alt="'+
b.name+'" title="'+b.name+'" />'+'</a></td></tr></table></div><div class="collect_data">'+'<a class="cmm_user" href="'+userUrl+'">'+b.name+'</a></div>'+'<div class="collect_data">'+b.lv+'</div></li>');}
if(bscardNum>8)
$('#collectionMore').attr('href','/shop/shop_addcardlist.php?id='+s_id).show();else
$('#collectionMore').hide();}else{$('#collectionHolder').hide();$('#collectionNone').show();}},__fill:function(extra){var ps=photoServer;var shop=detailWindow.lastShop,s_id=shop.s_id,shopPath='/shop/'+s_id+'/';var e=extra.s,w=$('#shopDetailWindow');$('#shopDetailWindow #tabCmmt').click();w.find('#shopDetailName').text(shop.name);w.find('#shopDetailStar').css('background-image',"url('"+ps+'/images/star/icon_star'+shop.star+".png')");if(isIE6())
fixPNGforIE(w.find('#shopDetailStar'));var phoneContainer=w.find('#shopDetailPhone');if(shop.tel)
phoneContainer.text(shop.tel).parent().show();else
phoneContainer.parent().hide();w.find('#shopDetailAddress').text(shop.addr);w.find('#shopDetailStaticMap').attr('src',detailWindow.__staticMap(shop));w.find('#shopDetailCmmt').text(shop.cmmt);w.find('#shopDetailBook').text(shop.book);if(shop.vip){w.find('#shopDetailCharacter').attr('href',shopPath+'character/');if(shop.dis)
w.find('#shopDetailCoupon').show().attr('href',shopPath+'coupon/');else
w.find('#shopDetailCoupon').hide();}else
w.find('.pfb_tag_vip').hide();w.find('#shopDetailBook').text(shop.book);if(e.photo=='')
photo='/images/search/piczone140.jpg';else
photo=ps+'/photo/shop'+e.path+'/140x140/'+e.photo;if(e.net>0){var bookingButton=w.find('#bookingButton').show();bookingButton.find('a').attr('href','/eztable/ezt_consent.php?as_id='+s_id);}else
w.find('#bookingButton').hide();w.find('#shopDetailDoor').attr('src',photo);w.find('#shopDetailView').attr('href',shopPath);w.find('#newPostButton a').attr('href','/comment/comment_add.php?id='+s_id+'&sul=%2Fshop%2F'+s_id+'%2F');w.find('#collectButton a').attr('s_id',s_id);var infoHeight=Math.max(extra.c.length*92,Math.ceil(extra.b.length/8)*129)+27;$('.pfb_cmmarea').height(infoHeight);$('.pfb_collect').height(infoHeight-15);detailWindow.__fillCmmt(s_id,extra.c,shop.cmmt);detailWindow.__fillBsCard(s_id,extra.b,extra.bn);detailWindow.__fillRep(extra.r);detailWindow.__show();},__show:function(){var w=$('#shopDetailWindow').css('height','auto');var p=gourmetMap.latLngToOrigin(this.lastShop.marker.getPoint()),maxMargin=$('body').width(),windowHeight=w.height(),halfWidth=w.width()/2,x=p.x-halfWidth,ox=x,y=p.y-w.height()+55,oy=y;gourmetMap.dragging(false);if(x<0)
x=0;else if((p.x+halfWidth)>maxMargin)
x=maxMargin-w.width();if(y<0)
y=0;if(ox!=x||oy!=y)
gourmetMap.tempMove(ox-x,oy-y);$('.pfb_body_bg').height(windowHeight-156);w.css({'left':x+'px','bottom':($(window).height()-y-windowHeight)+'px','height':0}).animate({'height':windowHeight+'px'},'slow');}};var summaryList={orderBy:'star',shops:null,page:0,classIcon:{0:'food',6:'inn',7:'view',8:'sport',9:'indoor',10:'rent'},init:function(){$('.TurnPathStyle').click(function(e){e.preventDefault();summaryList.sort($(this).attr('sortkey'));});$('#prevPage').click(function(e){e.preventDefault();var p=summaryList.page-1;if(p>=0)
summaryList.__populate(p);});$('#nextPage').click(function(e){e.preventDefault();var p=summaryList.page+1,cap=summaryList.__getTotalPages()-1;if(p<=cap)
summaryList.__populate(p);});$('#firstPage').click(function(e){e.preventDefault();summaryList.__populate(0);});$('#lastPage').click(function(e){e.preventDefault();summaryList.__populate(summaryList.__getTotalPages()-1);});$('#tabSummary').click(function(e){e.preventDefault();summaryList.switchTo();});},__collectLink_onClick:function(e){e.preventDefault();collectShop($(this).parents('.mapb_list_itemw,.mapb_list_itemg').attr('s_id'));},__pageLink_onClick:function(e){e.preventDefault();summaryList.__populate($(this).attr('page'));},__createSummary:function(shop){var ps=photoServer,shopUrl='/shop/'+shop.s_id+'/';var source='<div class="mapb_list_itemw" s_id="'+shop.s_id+'">'+'    <div class="mapb_list_itemtitle">'+'        <img src="/images/v2/home/icon_type_s/icon_'+summaryList.classIcon[shop.clsid]+'.gif" border="0" /> '+'        <a class="item_title_a" href="javascript: void(0)">'+
shop.name+'</a>'+'        <span class="mapb_list_itempoint">&nbsp;-&nbsp;<a class="gomap_a" href="javascript: void(0)">顯示地圖位置&gt;</a></span>'+'    </div>';if(shop.dis||shop.rep){source+='<div class="mapb_item_plusstatus">';if(shop.dis)
source+='<a href="'+shopUrl+'coupon" target="_blank"><img src="'+ps+'/images/v2/map/icon_coupon.gif" border="0" /></a>&nbsp;&nbsp;';if(shop.rep)
source+='<a href="/reputation/exchange_ticket.php?id='+shop.rep+'" target="_blank"><img src="'+ps+'/images/v2/map/icon_reputation.gif" border="0" /></a>';source+='</div>';}
source+='    <div class="mapb_list_itemdate">'+'        <img src="'+ps+'/images/v2/map/icon.gif"/>'+'        綜合評鑑：<span class="starContainer"></span>'+'    </div>'+'    <div class="mapb_list_itemdate">'+'        <img src="'+ps+'/images/v2/map/icon.gif"/> 電話：'+shop.tel+'    </div>'+'    <div class="mapb_list_itemdate">'+'        <img src="'+ps+'/images/v2/map/icon.gif"/> 地址：'+shop.addr+'    </div>'+'    <div class="mapb_list_itemcmm">';var info=[];if(shop.cmmt>0)
info.push('<a class="a40" target="_blank" href="'+shopUrl+'cmm">'+shop.cmmt+'篇分享</a>');if(shop.book>0)
info.push('<a class="a40" target="_blank" href="'+shopUrl+'bookmark">'+shop.book+'筆書籤</a>');if(shop.card>0)
info.push('<a class="a40" target="_blank" href="'+shopUrl+'info">'+shop.card+'人收藏</a>');source+=info.join(' | ')+'    </div>'+'    <div class="mapb_list_itemfunction">'+'        <a class="a37" href="/comment/comment_add.php?id='+
shop.s_id+'" target="_blank">發表文章</a> |'+'        <span class="collectLink"></span>'+' |'+'        <a class="a37" target="_blank" href="'+shopUrl+'">詳細商家資訊&gt;&gt;</a>'+'    </div>'+'</div>';var r=$(source);var gomap=r.find('.item_title_a,.gomap_a').each(function(){this.shop=shop;$(this).click(function(e){e.preventDefault();summaryList.highlight(this.shop.s_id,false);detailWindow.load(this.shop);});});r.find('.collectLink').append($('<a class="a37" href="javascript: void(0)">收藏此標的</a>').click(summaryList.__collectLink_onClick));var starImage=$('<span />').css({'background-image':"url('"+ps+'/images/star/icon_star'+shop.star+".png')",'background-repeat':'no-repeat','width':'103px','height':'16px','display':'inline-block'});if(isIE6())
fixPNGforIE(starImage);r.find('.starContainer').append(starImage);return r;},__getTotalPages:function(){return Math.ceil(this.shops.length/10);},__getPageRange:function(){var p=parseInt(this.page),r=[];var total=this.__getTotalPages(),cap=total-1;var min,max;if(total<=7){min=0;max=cap;}else{min=p-3;max=p+3;if(min<0){max-=min;min=0;}else if(max>cap){min-=(max-cap);max=cap;}}
for(i=min;i<=max;i++)
r[i]=i;return r;},__updatePaginator:function(){var c=$('#pageList').empty(),total=this.__getTotalPages();if(total<=1)
$('.mab_list_page').hide();else{$('.mab_list_page').show();for(p in this.__getPageRange()){var d=parseInt(p)+1;c.append('<a href="javascript: void(0)" page="'+p+'">'+d+'</a> ');}
c.find('a').click(this.__pageLink_onClick);if(this.page>0)
$('#prevPage').show();else
$('#prevPage').hide();if(this.page<(total-1))
$('#nextPage').show();else
$('#nextPage').hide();}
this.resize();},__populate:function(p){if(p==undefined||p<0||p>=this.__getTotalPages())
p=0;else if(p==this.page)
return;this.page=p;var start=parseInt(p)*10,displayStart=start+1,end=Math.min(start+10,this.shops.length);var c=$('#shopSummaryContainer');c.empty().scrollTop(0);for(;start<end;start++)
c.append(this.__createSummary(this.shops[start]));this.__updatePaginator();$('#resultPage').text(displayStart+'-'+end);$('#pageList > a').removeClass('page_on_click');$('#pageList > a[page='+p+']').addClass('page_on_click');},__shopComparator:function(a,b){var by=summaryList.orderBy;return b[by]-a[by];},__makeKeyword:function(name,category){return'"<strong>'+name+'</strong>(<span class="keywordNote">'+category+'</span>"';},__makeKeywords:function(items,category){var tags=[];for(k in items)
tags.push('"<strong>'+items[k]+'</strong><span class="keywordNote">('+category+')</span>"');return tags.join('、');},address:function(addr){if(addr==null||addr=='')
$('#addressInfo').hide();else{$('#addressInfo #currentAddress').text(addr);$('#addressInfo').show();}
gourmetMap.pinText=addr;this.resize();return this;},classes:function(classIDs){if(!classIDs)
classIDs=[0];else
classIDs=classIDs.split(',');for(k in classIDs)
classIDs[k]=$('#class_'+classIDs[k]).parent().text();$('#classInfo #classes').empty().append(this.__makeKeywords(classIDs,'分類'));return this;},keyword:function(kw){if(kw==null||kw=='')
$('#keywordInfo').hide();else{kw=kw.split(' ');$('#keywordInfo #keyword').empty().append(this.__makeKeywords(kw,'關鍵字'));$('#keywordInfo').show();}
this.resize();return this;},highlight:function(s_id,scroll){for(i in this.shops)
if(this.shops[i].s_id==s_id)
break;if(i>=this.shops.length)
return;this.__populate(Math.floor(i/10));$('#shopSummaryContainer .mapb_list_itemg').attr('class','mapb_list_itemw');var item=$('#shopSummaryContainer .mapb_list_itemw[s_id='+s_id+']'),offset=0;item.attr('class','mapb_list_itemg');if(scroll){item.prevAll().each(function(){offset+=$(this).height();});$('#shopSummaryContainer').scrollTop(offset);}
return this;},sort:function(by){if(by==this.orderBy)
return;if(by!=undefined)
this.orderBy=by;$('.TurnPathStyle').removeClass('TurnPathStyleSelected');$('.TurnPathStyle + img').hide();$('.TurnPathStyle[sortKey='+this.orderBy+']').addClass('TurnPathStyleSelected').next('img').show();this.shops.sort(this.__shopComparator);this.__populate();},update:function(shopData){delete this.shop;if(shopData==null)
shopData=[];if(shopData.length<=0)
$('#resultPageInfo').hide();else
$('#resultPageInfo').show();$('#resultNum').text(shopData.length);this.shops=shopData;this.sort();return this;},resize:function(){var pageHeight=$('.mab_list_page').is(':visible')?33:0;$('#shopSummaryContainer').height($(window).height()-$('.map_head').height()-
$('#shopSummaryHeader').height()-pageHeight);return this;},switchTo:function(){$('#tabDirections').attr('class','tag_road');$('#tabSummary').attr('class','tag_list_select');directionsList.hide();this.show();return this;},show:function(){$('#map_result').show();return this;},hide:function(){$('#map_result').hide();return this;}};var directionsList={startPoint:null,endPoint:null,init:function(){$('#tabDirections').click(function(e){e.preventDefault();directionsList.switchTo();});$('#directionsStart').click(function(e){e.preventDefault();directionsList.start();});$('#startPoint').change(function(){var v=$(this).val();directionsList.setStart(v==''?null:v);}).promptedEditBox('請輸入起點',true);$('#endPoint').change(function(){var v=$(this).val();directionsList.setEnd(v==''?null:v);}).promptedEditBox('請輸入終點',true);$('#swapLocations').click(function(e){e.preventDefault();directionsList.swapPoints();});gourmetMap.directionsHandler=this.directions_onLoad;$('#method_drive').click(function(){$('#directions_advanced').show('slow');});$('#method_walk').click(function(){$('#directions_advanced').hide('slow');});},__createRouteDiv:function(n,route){var num=parseInt(n)+1;var content='<a href="javascript: void(0)" class="'+((n==0)?'drt_line_sel':'drt_line_un')+'">'+'<table cellpadding="0" cellspacing="0" border="0">'+'<tr><td width="190"><em>路線'+num+'</em></td>'+'<td width="100" align="right">約 '+route.getDuration().html+'</td></tr>'+'<tr><td colspan="2">約 '+route.getDistance().html+'</td></tr></table></a>';return $(content).data('route',route).click(function(e){e.preventDefault();directionsList.loadRoute($(this).data('route'));});},__createStepDiv:function(n,step){var num=parseInt(n)+1;var content='<tr><td width="20" align="right">'+num+'.</td>'+'<td width="200" class="drt_road">'+step.getDescriptionHtml()+'</td>'+'<td width="60" class="drt_km">'+step.getDistance().html+'</td></tr>';return $(content).data('step',step);},directions_onLoad:function(routes){var c=$('#routesContainer').empty().show();$('#titleMethod').text($('.directionsMethod:checked').parent().text());$('#startPointText').text($('#startPoint').getEditBoxPrompt());$('#endPointText, #titleEndText').text($('#endPoint').getEditBoxPrompt());for(k in routes)
c.append(directionsList.__createRouteDiv(k,routes[k]));directionsList.loadRoute(routes[0]).showResult();},loadShopsNearRoute:function(){if(gourmetMap.zoom()<14)
return;var b=gourmetMap.bounds(),p=gourmetMap.directions.getPolyline(),vertexCount=p.getVertexCount(),vertices=[],ne=b.getNorthEast(),sw=b.getSouthWest(),neLat=ne.lat(),neLng=ne.lng(),swLat=sw.lat(),swLng=sw.lng();for(i=0;i<vertexCount;i++){var v=p.getVertex(i),lat=v.lat(),lng=v.lng();if(lat>=swLat&&lng>=swLng&&lat<=neLat&&lng<=neLng)
vertices.push(lat+','+lng);}
var param=[];param['route']=vertices.join('|');gourmetMap.getShops(param);},loadRoute:function(route){var c=$('#stepsContainer').empty().show(),total=route.getNumSteps();this.showResult();for(i=0;i<total;i++)
c.append(this.__createStepDiv(i,route.getStep(i)));this.loadShopsNearRoute();return this.resize();},start:function(){var waypoints=[this.__getPoint(this.startPoint),this.__getPoint(this.endPoint)],options={travelMode:this.method(),avoidHighways:$('#avoidHighway').is(':checked'),getPolyline:true,preserveViewport:false};detailWindow.hide();gourmetMap.routeMode().getDirections(waypoints,options);return this;},setStart:function(p){this.startPoint=this.__setPoint(p,'#startPoint','請輸入起點');},setEnd:function(p){this.endPoint=this.__setPoint(p,'#endPoint','請輸入終點');},__getPointName:function(p){if(p instanceof Object)
return'['+p.name+']';return p;},__getPoint:function(p){if(p instanceof Object)
return new GLatLng(p.lat,p.lng);return p;},__setPoint:function(p,editBox,nullPrompt){var editBox=$(editBox);if(p==null){editBox.changeEditBoxPrompt(nullPrompt);return null;}
if(p instanceof Object)
editBox.val('');editBox.changeEditBoxPrompt(this.__getPointName(p));return p;},swapPoints:function(){var temp=this.startPoint;this.setStart(this.endPoint);this.setEnd(temp);},resize:function(){var elements=['.drt_bottom','.drt_use','.drt_title','.drt_suggest'],height=0;var containerHeight=$(window).height()-$('.map_head').height()-$('#shopSummaryHeader').height();for(k in elements)
height+=$(elements[k]).height();$('#map_direction').height(containerHeight);$('.drt_path').height(containerHeight-height-60);return this;},method:function(how){if(how==null||how==undefined)
return parseInt($('.directionsMethod:checked').val());$('.directionsMethod').removeAttr('checked');$('.directionsMethod[value='+how+']').attr('checked',true);return this;},switchTo:function(){$('#tabDirections').attr('class','tag_road_select');$('#tabSummary').attr('class','tag_list');this.show();summaryList.hide();return this;},showResult:function(){$('#directionsResult').show();return this;},show:function(){$('#map_direction').show();return this;},hide:function(){$('#map_direction').hide();return this;}};var filterQueue={timeout:3000,timeoutID:null,queue_onTimeout:null,paused:false,notify:function(time){if(this.paused)
return;var id=this.timeoutID;if(id!=null)
clearTimeout(id);if(time==undefined)
time=this.timeout;if(time==0)
this.__execute();else
this.timeoutID=setTimeout('filterQueue.__execute();',time);},__execute:function(){var h=filterQueue.queue_onTimeout;if(h&&h.call)
h();filterQueue.timeoutID=null;}};var featuredSpots={current:null,init:function(){var anchor=$('#featuredCategories > div');for(i in FEATURED_SPOTS){var f=FEATURED_SPOTS[i],item=$('<a href="javascript: void(0)"></a>').addClass(f.css).attr('alt',f.name).attr('title',f.name).attr('cat_id',i);if(f.url==undefined){item.click(this.__category_onClick);$('#quick_search_content').append(this.__createPanel(i,f.categories));}else
item.attr('href',f.url).attr('target','_blank');anchor.before(item).before(' ');}
this.switchCategory(0);},__createItem:function(item){var locName,loc;if(item.address!=undefined)
loc=item.address;else
loc=item.lat+','+item.lng;var link=$('<a href="javascript: void(0)" class="quick_srh_a" loc="'+loc+'">'+item.name+'</a>').click(this.__spot_onClick);return $('<li />').append(link);},__createPanel:function(id,categories){var outer=$('<div>').attr('cat_id',id).hide();for(i in categories){var cat=categories[i],spotList='<div class="quick_search_bigitem">'+'<img src="'+photoServer+cat.icon+'" align="absmiddle" />&nbsp;'+'<a class="quick_search_a" href="javascript: void(0)">'+cat.name+'</a>'+'</div><div class="quick_search_itemarea"><ul style="display: none;"></ul></div>';spotList=$(spotList);spotList.find('a').click(function(e){e.preventDefault();$(this).parent().next().find('ul').slideToggle('fast');});var c=spotList.find('ul');for(k in cat.items)
c.append(this.__createItem(cat.items[k]));outer.append(spotList);}
return outer;},__category_onClick:function(e){e.preventDefault();var id=$(this).attr('cat_id');if(!toolBox.submenuShown){$('.quick_search').animate({left:"280px"},350);toolBox.submenuShown=true;}else if(id==featuredSpots.current){$('.quick_search').animate({left:"125px"},350);toolBox.submenuShown=!toolBox.submenuShown;}
featuredSpots.switchCategory(id);if(!toolBox.isVisible())
toolBox.show();},__spot_onClick:function(e){$('.quick_srh_a_selected').attr('class','quick_srh_a');$(this).attr('class','quick_srh_a_selected');hashManager.update('loc',$(this).attr('loc'));},switchCategory:function(id){this.current=id;$('#quick_search_title').attr('class',FEATURED_SPOTS[id].title).attr('cat_id',id);$('#quick_search_content > div').hide();$('#quick_search_content > div[cat_id='+id+']').show();}};var toolBox={__lastLocation:null,__lastZoom:null,submenuShown:false,init:function(){this.updateDraggable();$('#address').promptedEditBox('- 輸入地點，如：台北市中華路 -');$('#keywords').promptedEditBox('- 關鍵字 或 店名 -');$('.srhtool_btn').hide();$('#srh_full').hide();$('#srh_middle').click(function(e){e.preventDefault();$('#srh_middle').hide();$('#srh_full').toggle();$('.search_tool_keywordarea').hide("fast",function(){toolBox.resize();});});$('#srh_full').click(function(e){e.preventDefault();$('#srh_full').hide();$('#srh_middle').toggle();$('.search_tool_keywordarea').show("fast",function(){toolBox.resize();});});$('#side_close').click(function(e){e.preventDefault();$('.quick_search').animate({left:"125px"},350);toolBox.submenuShown=false;});$('#srh_small').click(function(e){e.preventDefault();toolBox.hide();});$('.srhtool_btn').click(function(e){e.preventDefault();toolBox.show();});$('input.class_id').click(function(e){if($('input.class_id:checked').length>0)
toolBox.updateFilter();else{e.preventDefault();alert('至少要選擇一個標的類型！');}});$('input.filter, input.nofilter').click(function(){toolBox.updateFilter();});$('#srh_windows .srh_btn').click(function(e){e.preventDefault();hashManager.update('loc',$('#address').val());hashManager.update('keywords',$('#keywords').val());});$('#srh_windows .clear_btn').click(function(e){e.preventDefault();hashManager.remove('keywords','');$('#keywords').val('').change();});$('#srh_windows #toolBoxForm').submit(function(e){e.preventDefault();$('#srh_windows .srh_btn').click();});$('#starContainer a').click(function(e){var checked=parseInt($(this).attr('checked'));e.preventDefault();$('#starContainer a').attr('checked','0').removeClass('starSelected');if(checked)
$(this).attr('checked','0').prev().attr('checked','1');else
$(this).attr('checked','1');$('#starContainer a[checked=1]').addClass('starSelected').prevAll().addClass('starSelected');toolBox.updateFilter();});},lastZoom:function(z){if(z==undefined)
return this.__lastZoom;this.__lastZoom=z;return this;},lastLocation:function(loc){if(loc==undefined)
return this.__lastLocation;this.__lastLocation=loc;$('#srh_windows #address').val(__parseLatLng(loc)?'':loc).change();return this;},__keyword_onClick:function(e){e.preventDefault();var c=$('#keywords'),text=$(this).text(),keywords=c.val();if(keywords.indexOf(text)<0){if(keywords!='')
keywords+=' ';keywords+=text+' ';}else{keywords+=' ';keywords=keywords.replace(text+' ','');}
keywords=keywords.substr(0,keywords.length-1);c.val(keywords);if(keywords=='')
hashManager.remove('keywords');else
hashManager.update('keywords',keywords);$('#keywords').change();},__fillKeywords:function(container,keywords){var c=$(container).empty();for(id in keywords)
c.append($('<a href="javascript: void(0)" class="map_kw">'+keywords[id]+'</a>').click(toolBox.__keyword_onClick)).append(' ');},updateDraggable:function(){$("#srh_windows").draggable({handle:'.search_tool_title',containment:'window'});return this;},updateFilter:function(){var result=[],classFilter=[],keywords=$('#keywords').val(),addr=$('#address').val();if(s_id!==undefined)
s_id=undefined;if(keywords!='')
result['keywords']=keywords;if(addr!='')
result['loc']=addr;$('input.class_id:checked').each(function(){classFilter.push($(this).val());});result['clsid']=classFilter.join(',');$('input.filter:checked').each(function(){result[$(this).val()]=1;});$('input.nofilter:not(:checked)').each(function(){result['no'+$(this).val()]=1;});result['star']=$('#starContainer a[checked=1]').attr('star');hashManager.assign(result);detailWindow.hide();messageLayer.hide();return this;},updateFilterControl:function(){var param=hashManager.get();var procs={'keywords':function(v){$('#keywords').val(v).change();},'loc':function(v){if(__parseLatLng(v)==false)
$('#address').val(v).change();},'clsid':function(v){var classes=v.split(',');if(v.length<1)
return;$('.class_id').removeAttr('checked');for(k in classes)
$('#class_'+classes[k]).attr('checked',true);}};var defaultProc=function(k){if(/^no/.test(k))
$('.nofilter#filter_'+k.substr(2)).removeAttr('checked');else
$('.filter#filter_'+k).attr('checked',true);};$('.nofilter').attr('checked',true);$('.filter').removeAttr('checked');for(k in param){var val=param[k],proc=procs[k];if(val==undefined)
continue;if(proc==undefined)
defaultProc(k);else
proc(val);}
return this;},setKeywords:function(k){this.__fillKeywords('#keywordArea',k);this.resize();return this;},setOtherInfo:function(i){this.__fillKeywords('#otherInfoArea',i);this.resize();return this;},isVisible:function(){return $('.search_tool').is(':visible');},resize:function(){var bodyHeight=$('.search_tool_body').height();$('.srhbody_bg').height(bodyHeight-8);$('#mrt_quick .quick_search_body').height(bodyHeight-43);return this;},show:function(){$('.search_tool').toggle(300);$('.srhtool_btn').hide();$('#srh_windows').show().animate({left:"550px",top:"80px"},300,'linear',function(){$('.quick_search').toggle();toolBox.resize();});return this;},hide:function(){$('#srh_windows').animate({left:"220px",top:"165px"},200,'linear',function(){$('#srh_windows').hide();$('.srhtool_btn').toggle(50);});$('.search_tool').hide(300);$('.quick_search').hide();return this;}};var weatherWidget={lastLoc:null,__updateWidget:function(result){var icon=result.i.replace('.gif','.png').replace('/ig/images/weather/','');$('#weatherIcon').css({'background-image':"url('"+photoServer+'/images/v2/map/weather/'+icon+"')",'background-repeat':'no-repeat'});if(isIE6())
fixPNGforIE('#weatherIcon');$('#weatherText').text(result.c);$('#weatherTemp').text(result.t);$('#weatherHumidity').text(result.h.substr(4));$('#weatherWidget').show();},update:function(){var c=gourmetMap.center();if(this.lastLoc==null||gourmetMap.measure(this.lastLoc,c)>5000){this.lastLoc=c;$('weatherWidget').hide();$.post('requests/getWeather.php',{lat:c.lat(),lng:c.lng()},this.__updateWidget,'json');}}};var linkWindow={init:function(){$('#printLink').click(function(e){e.preventDefault();window.print();});$('#generateLink').click(function(e){e.preventDefault();linkWindow.update();$('#linkWindow').show();});$('#linkWindow .close_btn').click(function(e){e.preventDefault();$('#linkWindow').hide();});},update:function(){var l=window.location,baseLoc=l.protocol+'//'+l.host+l.port+l.pathname+'#';var c=gourmetMap.center(),z=gourmetMap.zoom();baseLoc+='loc='+c.lat()+','+c.lng();baseLoc+='&z='+z;$('#linkContent').val(baseLoc);}};var loadingLayer={init:function(){$('#loadingLayer').fadeTo('fast',0.5);},resize:function(){var map=$('#map'),offset=map.offset(),flash=$('#flashHolder');$('#loadingLayer').width(map.width()).height(map.height()).css({left:offset.left+'px',top:offset.top+'px'});flash.css({position:'absolute',width:'120px',height:'200px',left:((map.width()-120)/2)+'px',top:((map.height()-200)/2)+'px'});},show:function(){this.resize();$('#loadingLayer').fadeIn('fast');},hide:function(){$('#loadingLayer').fadeOut('fast');}};var messageLayer={lastDialog:null,init:function(){$('#messageLayer').fadeTo('fast',0.5);},resize:function(){var map=$('#map'),offset=map.offset();$('#messageLayer').width(map.width()).height(map.height()).css({left:offset.left+'px',top:offset.top+'px'});if(this.lastDialog!=null)
this.lastDialog.css({'z-index':901,position:'absolute',left:((map.width()-this.lastDialog.width())/2+offset.left)+'px',top:((map.height()-this.lastDialog.height())/2+offset.top)+'px'});},show:function(dialog){this.lastDialog=$(dialog);this.resize();this.lastDialog.fadeIn('fast');$('#messageLayer').fadeIn('fast');},hide:function(){this.lastDialog.fadeOut('fast');$('#messageLayer').fadeOut('fast');this.lastDialog=null;}};var numberFilter={bound:750,max:1000,ignoreBound:false,ignoreMax:false,lastShops:null,init:function(){$('#alertReachBound .mess_ok').click(function(){numberFilter.ignoreBound=true;numberFilter.proceed();messageLayer.hide();});$('#alertReachBound .mess_cel').click(function(){messageLayer.hide();});$('#alertReachMax .mess_btn').click(function(){numberFilter.ignoreMax=true;numberFilter.proceed();messageLayer.hide();});},test:function(shops){var total=shops.length;this.lastShops=shops;if(total>=this.max&&!this.ignoreMax){loadingLayer.hide();messageLayer.show('#alertReachMax');return true;}else if(total>this.bound&&!this.ignoreBound){loadingLayer.hide();messageLayer.show('#alertReachBound');return false;}else
return true;},proceed:function(){gourmetMap.addShops(this.lastShops);loadingLayer.hide();this.lastShops=null;}};var adWindow={count:0,init:function(){if(!hasAd){$('#adWindow').hide();this.update=function(){};}},__update:function(){$('#adWindow').show().load('requests/getAd.php');},update:function(){this.count=(this.count+1)%5;if(this.count==0)
this.__update();}};function __parseLatLng(s){var test=s.split(','),f=/^[0-9]+\.[0-9]+$/;if(test.length==2&&f.test(test[0])&&f.test(test[1]))
return new GLatLng(parseFloat(test[0]),parseFloat(test[1]));return false;}
function collectShop(id){if(loginDialog.loggedIn()){$.post('/cgi/shopcard_add.php',{'id':id},function(result){alert(result.replace('<br />',''));},'text');}else
loginDialog.show();}
function window_onResize(){gourmetMap.resize($(window).height()-$('.map_head').height());summaryList.resize();directionsList.resize();toolBox.updateDraggable();loadingLayer.resize();messageLayer.resize();}
function filterQueue_onTimeout(){var p=hashManager.get(),loc=p.loc,zoom=p.z;if(gourmetMap.mode==gourmetMap.MODE_SEARCH){if(zoom==undefined)
toolBox.lastZoom(null);else if(zoom!=toolBox.lastZoom()){zoom=parseInt(zoom);toolBox.lastZoom(zoom);gourmetMap.zoom(zoom);}
if(s_id!=undefined)
p['s_id']=s_id;else if(loc==undefined){summaryList.address(null);toolBox.lastLocation(null);}else if(loc!=toolBox.lastLocation()){toolBox.lastLocation(loc);var geoLoc=__parseLatLng(loc);if(geoLoc==false){summaryList.address(loc);gourmetMap.geocode(loc);return;}
summaryList.address(null);gourmetMap.pinText=geoLoc.lat()+', '+geoLoc.lng();gourmetMap.center(geoLoc);gourmetMap.pinLocationMarker(geoLoc);}
summaryList.classes(p.clsid).keyword(p.keywords);loadingLayer.show();gourmetMap.getShops(p);}else{loadingLayer.show();directionsList.loadShopsNearRoute();}}
function initComponents(){filterQueue.queue_onTimeout=filterQueue_onTimeout;hashManager.callback=function(){gourmetMap.searchMode();filterQueue.notify(2000);};toolBox.init();featuredSpots.init();detailWindow.init();summaryList.init();directionsList.init();linkWindow.init();loadingLayer.init();messageLayer.init();numberFilter.init();adWindow.init();geoLocator.init();gourmetMap.optimize=true;gourmetMap.geocodingHandler=function(point){if(!point){summaryList.address(null);alert('找不到地址！');}else{filterQueue.paused=true;gourmetMap.center(point).getShops(hashManager.get());filterQueue.paused=false;}};gourmetMap.init('#map',defLat,defLng,defZoom);gourmetMap.shopHandler=function(shops){summaryList.update(shops);adWindow.update();if(numberFilter.test(shops)){numberFilter.proceed();if(first){first=false;toolBox.hide();GEvent.trigger(shops[0].marker,'click');}}};gourmetMap.keywordHandler=function(keywords){if(keywords!=null){toolBox.setKeywords(keywords.t).setOtherInfo(keywords.o);}else
toolBox.setKeywords([]).setOtherInfo([]);};gourmetMap.marker_onClick=function(marker){summaryList.highlight(marker.shop.s_id,true);detailWindow.load(marker.shop);};gourmetMap.map_onMoveEnd=function(){if(s_id===undefined||first)
filterQueue.notify(2000);weatherWidget.update();};gourmetMap.map_onClick=function(){detailWindow.hide();};weatherWidget.update();hashManager.start();}
function fixPNGforIE(dom){var d=$(dom),bg=d.css('background-image');if(/url(.+)/.test(bg)){var sizing;if(d.css('background-repeat')=='no-repeat')
sizing='crop';else
sizing='scale';bg=bg.substr(5,bg.length-7);d.css({'background':'','filter':"progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+bg+"', sizingMethod="+sizing+"')"});}}
function fixAllPNGforIE(){if(isIE6()){var list=['.pfb_bottom','.search_tool_body','.pfb_body_bg','.srhtitle_bg','.search_bottom','.pfb_shopname_bg','.mess_title','.mess_bottom','.weather_data'];for(i in list)
fixPNGforIE(list[i]);}}
function hookEventHandlers(){$(window).resize(window_onResize).unload(gourmetMap.gc);}
$(document).ready(function(){initComponents();window_onResize();hookEventHandlers();toolBox.updateFilterControl();fixAllPNGforIE();filterQueue.notify(0);});