
jQuery.th={};jQuery.th.browser={ie6flg:null,isIE6:function(){if(this.ie6flg!=null){return this.ie6flg}
return this.ie6flg=navigator.userAgent.match(/.*MSIE\s*6\.[0-9].*/)?true:false;},ie7flg:null,isIE7:function(){if(this.ie7flg!=null){return this.ie7flg}
return this.ie7flg=navigator.userAgent.match(/.*MSIE\s*7\.[0-9].*/)?true:false;}}
jQuery.th.constants={domain:'search.town-room.com',inquiryLimit:60,favoriteLimit:60,detailLimit:60}
jQuery.th.path={checkRedOnChkS:'/images/ico_check01_on.gif',checkOffChkS:'/images/ico_check01_off.gif',checkOffOverChkS:'/images/ico_check01_o.gif',checkRedOnChkM:'/images/ico_check02_on.gif',checkOffOverChkM:'/images/ico_check02_off_o.gif',checkOffOutChkM:'/images/ico_check02_off.gif',checkRedOnChkPref:'/images/ico_check03_on.gif',checkOffChkPref:'/images/ico_check03_off.gif',checkRedOnChkMDetail:'/images/ico_check04_on.gif',checkOffOverChkMDetail:'/images/ico_check04_off_o.gif',checkOffOutChkMDetail:'/images/ico_check04_off.gif',checkRedOnChkRail:'/images/ico_check05_on.gif',checkOffChkRail:'/images/ico_check05_off.gif',checkRedOnRadio:'/images/ico_radio_on.gif',checkRedOffRadio:'/images/ico_radio_off.gif',addFavoriteOverBtnResult:'/images/btn_result_fav02_o.gif',addFavoriteOutBtnResult:'/images/btn_result_fav02.gif',addFavoriteOffBtnResult:'/images/btn_result_fav02_off.gif',addFavoriteOffBtnDetail:'/images/btn_detail_fav_off.gif',addFavoriteOverBtnDetail:'/images/btn_detail_fav_o.gif',addFavoriteOutBtnDetail:'/images/btn_detail_fav.gif',addFavoriteOffBtnDetail:'/images/btn_detail_fav_off.gif',loadSearch:'/images/txt_load.gif',loadRead:'/images/txt_load02.gif',noImg:'/images/img_result_noimage.gif',kodawariPopup:'/search/kodawariPopup',searchConditionSet:'/cookie/searchConditionSet',searchConditionGet:'/cookie/searchConditionGet',googleMapError:'/article/mapErrorMail',favorite:'/favorite',inquiryRent:'https://'+$.th.constants.domain+'/inquiry/rent',kantanInquiryRent:'https://'+$.th.constants.domain+'/inquiry/rent/simpleConfirm',articleHeader:'/article/',cookieFavoriteRentSetHeader:'/cookie/favoriteRentSet/',cookieFavoriteRentdeleteHeader:'/cookie/favoriteRentDelete/'}
jQuery.th.common={goSearchResult:function(formSelector){$.th.search(formSelector,'/search/searchResult');},goAddress:function(formSelector){$.th.search(formSelector,'/search/addressPref');},backAddress:function(formSelector){$.th.search(formSelector,'/search/addressPref','post',true);},goAddressCity:function(formSelector){$.th.search(formSelector,'/search/addressCity');},goCityExecute:function(formSelector){$.th.search(formSelector,'/search/cityExecute');},goRoute:function(formSelector){$.th.search(formSelector,'/search/routePref');},backRoute:function(formSelector){$.th.search(formSelector,'/search/routePref','post',true);},goRouteRail:function(formSelector){$.th.search(formSelector,'/search/routeRail');},backRouteRail:function(formSelector){$.th.search(formSelector,'/search/routeRail','post',true);},goRailExecute:function(formSelector){$.th.search(formSelector,'/search/railExecute');},goRouteStat:function(formSelector){$.th.search(formSelector,'/search/routeStation');},goStatExecute:function(formSelector){$.th.search(formSelector,'/search/statExecute');},goUniv:function(formSelector){$.th.search(formSelector,'/search/univPref');},backUniv:function(formSelector){$.th.search(formSelector,'/search/univPref','post',true);},goUnivUniv:function(formSelector){$.th.search(formSelector,'/search/univUniv');},goUnivExecute:function(formSelector){$.th.search(formSelector,'/search/univExecute');}}
jQuery.th.firstLoad=function(imgArray){var imgMax=imgArray.length;var images=new Array(imgMax);for(var i=0;i<imgMax;i++){images[i]=new Image();images[i].src=imgArray[i];}};jQuery.th.submitForm=function(formSelector,url,type){$(formSelector).attr('method',type||'post').attr('action',url).submit();};jQuery.th.search=function(formSelector,url,type,back){this.xhr=$.th.cancelRequest(this.xhr);this.xhr=$.ajax({type:type||'POST',dataType:"json",url:url,data:$(formSelector).serialize(),success:function(response){if(response){if(response.status!='SUCCESS'){$.th.message.show('confirm',response.message);}else{if(back){window.location.href=response.url+"?isBack=true";}else{window.location.href=response.url;}}}else{$.th.message.show('confirm','検索に失敗しました。');}},error:function(request){$.th.message.show('confirm','エラーが発生しました。');}});};jQuery.th.getCount=function(target,param){if(!target||!param){return;}
this.xhr=$.th.cancelRequest(this.xhr);this.xhr=$.ajax({type:'POST',url:$('/searchCount').val(),data:param,success:function(response){$(target).each(function(){$(this).html($(this).find('span.txt')).prepend(response);});},error:function(){$.th.message.show('confirm','件数の取得に失敗しました。');}});};jQuery.th.img={swapRedRdio:function(img,name){$.th.img.swapImageOnOff(img,name,$.th.path.checkRedOnRadio,$.th.path.checkRedOffRadio);},swapRedChkS:function(img,name){$.th.img.swapImageOnOff(img,name,$.th.path.checkRedOnChkS,$.th.path.checkOffChkS);},swapRedChkM:function(img,name){$.th.img.swapImageOnOff(img,name,$.th.path.checkRedOnChkM,$.th.path.checkOffOverChkM);},swapRedChkMMouse:function(img,name,mouse){$.th.img.swapImageOnOffMouse(img,name,mouse,$.th.path.checkRedOnChkM,$.th.path.checkRedOnChkM,$.th.path.checkOffOverChkM,$.th.path.checkOffOutChkM);},swapRedChkRail:function(img,name){$.th.img.swapImageOnOff(img,name,$.th.path.checkRedOnChkRail,$.th.path.checkOffChkRail);},swapRedChkPref:function(img,name){$.th.img.swapImageOnOff(img,name,$.th.path.checkRedOnChkPref,$.th.path.checkOffChkPref);},swapFavMouseResult:function(img,mouse){$.th.img.swapImageMouse(img,mouse,$.th.path.addFavoriteOverBtnResult,$.th.path.addFavoriteOutBtnResult);},swapFavMouseDetail:function(img,mouse){$.th.img.swapImageMouse(img,mouse,$.th.path.addFavoriteOverBtnDetail,$.th.path.addFavoriteOutBtnDetail);},swapImageOnOff:function(img,name,onPath,offPath){if(name=='on'){img.attr('src',onPath);}else{img.attr('src',offPath);}},swapImageMouse:function(img,mouse,overPath,outPath){if(mouse=='over'){img.attr('src',overPath);}else if(mouse=='out'){img.attr('src',outPath);}},swapImageOnOffMouse:function(img,name,mouse,onOverPath,onOutPath,offOverPath,offOutPath){if(name=='on'){if(mouse=='over'){img.attr('src',onOverPath);}else if(mouse=='out'){img.attr('src',onOutPath);}}else{if(mouse=='over'){img.attr('src',offOverPath);}else if(mouse=='out'){img.attr('src',offOutPath);}}}}
jQuery.th.favorite={conf:{xhr:null},add:function(btn,offImg){var clazz=$(btn).attr('class');if(clazz=='on'){$.th.favorite.conf.xhr=$.th.cancelRequest($.th.favorite.conf.xhr);var id=$(btn).attr('id').replace('favorite_','');$.th.favorite.conf.xhr=$.ajax({url:$.th.path.cookieFavoriteRentSetHeader+id,success:function(response){$.th.message.show('confirm',response);$.th.favorite.changeImg(id,offImg);},error:function(){$.th.message.show('confirm','エラーが発生しました。');}});}},addAll:function(formId,offImg){var tmp=jQuery.th.elemVal(formId+' :hidden');if(tmp.length<=0){$.th.message.show('confirm','物件が選択されていません。');return false;}
if(tmp.length>0){$.th.favorite.conf.xhr=$.th.cancelRequest($.th.favorite.conf.xhr);$.th.favorite.conf.xhr=$.ajax({url:$.th.path.cookieFavoriteRentSetHeader+tmp.join(','),success:function(response){$.th.message.show('confirm',response);$.each(tmp,function(){$.th.favorite.changeImg(this,offImg)});},error:function(){$.th.message.show('confirm','エラーが発生しました。');}});}},swapImageOverResult:function(obj){var clazz=$(obj).attr('class');if(clazz=='on'){$.th.img.swapFavMouseResult($(obj).find('img'),'over');}},swapImageOutResult:function(obj){var clazz=$(obj).attr('class');if(clazz=='on'){$.th.img.swapFavMouseResult($(obj).find('img'),'out');}},swapImageOverDetail:function(obj){var clazz=$(obj).attr('class');if(clazz=='on'){$.th.img.swapFavMouseDetail($(obj).find('img'),'over');}},swapImageOutDetail:function(obj){var clazz=$(obj).attr('class');if(clazz=='on'){$.th.img.swapFavMouseDetail($(obj).find('img'),'out');}},changeImg:function(id,offImg){$('#favorite_'+id).css('cursor','auto').attr('class','off');$('#favorite_'+id+' img').attr('src',offImg);},go:function(){var url=$.th.shopInfo.getUrl($.th.path.favorite,true);window.location.href=url;}}
jQuery.th.detail={goSingle:function(bkCd){var url=$.th.shopInfo.getUrl($.th.path.articleHeader+bkCd,true);window.location.href=url;},go:function(formId,limit){var tmp=jQuery.th.elemVal(formId+' :hidden');$.th.detail.move(limit,tmp);},go2:function(selector,limit){var tmp=jQuery.th.elemVal(selector+' :checked');$.th.detail.move(limit,tmp);},move:function(limit,tmp){if(tmp.length>limit){$.th.message.show('confirm',$.th.message.error.maxnum('物件',limit+1));return false;}else if(tmp.length<=0){$.th.message.show('confirm','物件が選択されていません。');return false;}
var url=$.th.shopInfo.getUrl($.th.path.articleHeader+tmp.join(','),true);window.location.href=url;}}
jQuery.th.inquiry={go:function(formId,limit){var tmp=jQuery.th.elemVal(formId+' :hidden');$.th.inquiry.move(formId,limit,tmp);},go2:function(selector,formId,limit){var tmp=jQuery.th.elemVal(selector+' :checked');$.th.inquiry.move(formId,limit,tmp);},move:function(formId,limit,tmp){if(tmp.length>limit){$.th.message.show('confirm',$.th.message.error.maxnum('物件',limit+1));return false;}else if(tmp.length<=0){$.th.message.show('confirm','物件が選択されていません。');return false;}
$.th.submitForm(formId,$.th.shopInfo.getUrl($.th.path.inquiryRent,true));}}
jQuery.th.articleCheck={click:function(id,form,onImg,offImg){if($(id).hasClass('on')){$(id).attr('class','off');$.th.img.swapImageOnOff($(id).find('img'),'off',onImg,offImg);form.removeVal('article',$(id).attr('id'));}else{$(id).attr('class','on');$.th.img.swapImageOnOff($(id).find('img'),'on',onImg,offImg);form.addVal('article',$(id).attr('id'),'article');}},mouseover:function(id,onImg,offOverImg,offOutImg){if($(id).hasClass('on')){$.th.img.swapImageOnOffMouse($(id).find('img'),'on','over',onImg,onImg,offOverImg,offOutImg);}else{$.th.img.swapImageOnOffMouse($(id).find('img'),'off','over',onImg,onImg,offOverImg,offOutImg);}},mouseout:function(id,onImg,offOverImg,offOutImg){if($(id).hasClass('on')){$.th.img.swapImageOnOffMouse($(id).find('img'),'on','out',onImg,onImg,offOverImg,offOutImg);}else{$.th.img.swapImageOnOffMouse($(id).find('img'),'off','out',onImg,onImg,offOverImg,offOutImg);}},allCheck:function(target,form){var checked=false;$(target).each(function(){if($(this).hasClass('off')){checked=true;return false;}});var hiddenList="";if(checked){form.removeClazz('.article');$(target).removeClass('off').addClass('on').find('img[name = off]').hide().end().find('img[name = on]').show();$(target).each(function(){hiddenList+='<input type="hidden" name="article" value="'+$(this).attr('id')+'" class="article" />';})
form.form.append(hiddenList);}else{$(target).removeClass('on').addClass('off').find('img[name = on]').hide().end().find('img[name = off]').show();$(target).each(function(){})
form.removeClazz('.article');}},imgClick:function(id,form){if($(id).hasClass('on')){$(id).attr('class','off').find('img[name = on]').hide().end().find('img[name = off]').show();form.removeVal('article',$(id).attr('id'));}else{$(id).attr('class','on').find('img[name = off]').hide().end().find('img[name = on]').show();form.addVal('article',$(id).attr('id'),'article');}}}
jQuery.th.searchSavedCondition=function(){var conf={xhr:null};conf.xhr=$.th.cancelRequest(conf.xhr);conf.xhr=$.ajax({type:'GET',url:$.th.shopInfo.getUrl($.th.path.searchConditionGet,true),success:function(response){if(response&&response.length>0){window.location.href=response;}else{$.th.message.show('confirm','検索条件が保存されていません。');}},error:function(response,error,con){if(response.status!=0){$.th.message.show('confirm','エラーが発生しました。');}}});return false;};jQuery.th.lazyLoad={load:function(selector,options){var conf={noImg:$.th.path.noImg,timeout:30};$.extend(conf,options);conf.images=$(selector);conf.loadCnt=0;conf.images.each(function(){$.data(this,'lazyload',{top:$.cumulativeOffset(this).top,isSet:false});});$.th.lazyLoad.draw(conf);$(window).bind('scroll.lazyLoad',function(){$.th.lazyLoad.draw(conf);})},draw:function(conf){var win=$(window);var top=win.scrollTop();var range={top:top,bottom:top+win.height()};conf.images.each(function(idx,image){var pos=null;if($(image).data('lazyload')){pos=$(image).data('lazyload').top;}
if(range.top<pos&&pos<=range.bottom){var imgContainer=$(image);if(imgContainer.data('lazyload').isSet){return;}
var img=new Image();var path=(imgContainer.attr('name'))?imgContainer.attr('name'):conf.noImg;img.onload=$.scope(self,function(){$.th.lazyLoad.resize(img,imgContainer);});img.onerror=$.scope(self,function(){imgContainer.attr({'src':conf.noImg});if(imgContainer.data('timer')){clearTimeout(imgContainer.data('timer'));}});img.src=path;var timer=setTimeout(function(){if(img.src!=imgContainer.attr('src')){imgContainer.attr({'src':conf.noImg});}},conf.timeout*1000);imgContainer.data('timer',timer);conf.loadCnt++;imgContainer.data('lazyload',{isSet:true});}});if(conf.loadCnt>=conf.images.length){$(window).unbind('scroll.lazyLoad');}},destroy:function(){$(window).unbind('scroll.lazyLoad');},resize:function(img,imgContainer){var maxImageSize=Math.max(imgContainer.attr('width'),imgContainer.attr('height'));var imageWidth;var imageHeight;var imegeW=img.width;var imegeH=img.height;var maxSize=Math.max(imegeW,imegeH);if(maxSize){imageWidth=imegeW*maxImageSize/maxSize;imageHeight=imegeH*maxImageSize/maxSize;}else{imageWidth=maxImageSize;imageHeight=maxImageSize;}
var marginTop=(maxImageSize-imageHeight)/2;imgContainer.attr({'src':img.src,'width':imageWidth,'height':imageHeight}).css('margin-top',marginTop);if(imgContainer.data('timer')){clearTimeout(imgContainer.data('timer'));}}};jQuery.th.unescape=function(str){str=str.replace(/&amp;/g,"&");str=str.replace(/&quot;/g,"\"");str=str.replace(/&#034;/g,"\"");str=str.replace(/&#039;/g,"'");str=str.replace(/&lt;/g,"<");str=str.replace(/&gt;/g,">");return str;}
jQuery.th.message={conf:{target:'#miniPop',isIE6:null},show:function(type,message){$.th.popupResize.bind(this.conf.target);var pop=$(this.conf.target);if(pop.data('visible')){this.hide();}
if(type=='load'){pop.find('p.close a, p.btn a').hide().end().find('p.txt').html(message||'<p class="load"><img height="23" width="74" alt="検索中" src="'+$.th.path.loadSearch+'" /></p>');}else if(type=='reading'){pop.find('p.close a, p.btn a').hide().end().find('p.txt').html(message||'<p class="load02"><img height="23" width="125" alt="読み込み中" src="'+$.th.path.loadRead+'" /></p>');}else if(type=='notice'){pop.find('p.close a, p.btn a').hide().end().find('p.txt').html(message||'');}else if(type=='confirm'){pop.find('p.close a, p.btn a').click($.scope(this,function(){this.hide();return false;})).show().end().find('p.txt').html(message||'');}
if(this.conf.isIE6==null){this.conf.isIE6=$.th.browser.isIE6();}
if(this.conf.isIE6){$('select').css('visibility','hidden');}
pop.setCenterPos().data('visible',true).show();},hide:function(){$.th.popupResize.unbind();if(!$.th.overlay.is()&&this.conf.isIE6){$('select').not('.dummy').css('visibility','visible');}
$(this.conf.target).data('visible',false).hide();},write:function(html){$(this.conf.target).find('p.txt').html(html);},is:function(){return($(this.conf.target).data('visible'));},error:{limitCheck:function(){return'選択できる'+arguments[0]+'は最大'+arguments[1]+'個までです。';},maxnum:function(){return arguments[0]+'が'+arguments[1]+'箇所以上選択されています。';},required:function(){return arguments[0]+'は必須です。';},noResultList:function(){return'申し訳ございません。<br />ご指定の検索条件に該当する物件はありません。';}}};jQuery.th.overlay={conf:{target:'#overlay',timer:null},show:function(){var overlay=$(this.conf.target);if(!overlay.data('visible')){this.overlayPoint();}
$(window).bind('resize.overlay',function(){$.th.overlay.overlayPoint();return false;});},overlayPoint:function(){var overlay=$(this.conf.target);if($.th.browser.isIE6()){var doc=$(document.body);$('select').css('visibility','hidden');overlay.css({backgroundColor:'#000',position:'absolute',width:doc.width(),height:doc.height(),top:'0px',left:'0px',opacity:'0.5',filter:'alpha(opacity=50)'}).data('visible',true).show();}else if($.th.browser.isIE7()){var doc=$(document.body);overlay.css({backgroundColor:'#000',position:'absolute',width:doc.width(),height:doc.height(),top:'0px',left:'0px',opacity:'0.5',filter:'alpha(opacity=50)'}).data('visible',true).show();}else{overlay.css({backgroundColor:'#000',position:'fixed',width:'100%',height:'100%',top:'0px',left:'0px',opacity:'0.5',filter:'alpha(opacity=50)'}).data('visible',true).show();}},hide:function(){if($.th.browser.isIE6()){$('select').not('.dummy').css('visibility','visible');}
$(window).unbind('resize.overlay');$(this.conf.target).data('visible',false).hide();},is:function(){return($(this.conf.target).data('visible'));}};jQuery.th.form=function(formId){this.form=$(formId);this.get=function(){return $(this.form).serialize();};this.getVal=function(name){return $(this.form).find('[name='+name+']');};this.setVal=function(name,values){this.remove(name);$(this.form).append(values);};this.changeVal=function(name,value){$(this.form).find(':hidden[name='+name+']').val(value);};this.addVal=function(name,val,clazz){if($(this.form).find(':hidden[name='+name+'][value='+val+']').length>0){return;}
(clazz)?$(this.form).append('<input type="hidden" name="'+name+'" value="'+val+'" class="'+clazz+'" />'):$(this.form).append('<input type="hidden" name="'+name+'" value="'+val+'" />');};this.removeVal=function(name,val){$(this.form).find(':hidden[name='+name+'][value='+val+']').remove();};this.removeClazz=function(clazz){$(this.form).find(clazz).remove();};this.remove=function(name){$(this.form).find(':hidden[name='+name+']').remove();};this.size=function(name){return $(this.form).find('[name='+name+']').length;};}
jQuery.th.shopInfo={getUrl:function(path,isHf){if(isHf){return $.th.shopInfo.makeUrl(path,$('#shopInfoShopValue').val(),$('#shopInfoHf').val());}else{return $.th.shopInfo.makeUrl(path,null,null);}},makeUrl:function(path,shopValue,hf){var url=path;if(shopValue||hf){url+="?";}
if(shopValue){url+="shop="+shopValue;}
if(hf){if(shopValue){url+="&"}
url+="hf="+hf;}
return url;}};jQuery.th.popupResize={bind:function popResize(targetId){var target=$(targetId);$(window).bind('resize.popupResize',function(){target.setCenterPos();return false;});},unbind:function(){$(window).unbind('resize.popupResize');}};jQuery.th.popupScroll={conf:{timer:null},bind:function popScroll(targetId){var target=$(targetId);$(window).bind('scroll.popupScroll',function(){if($.th.popupScroll.conf.timer){clearTimeout($.th.popupScroll.conf.timer);$.th.popupScroll.conf.timer=null;}
$.th.popupScroll.conf.timer=setTimeout(function(){target.nextPos=target.setCenterPosSet();target.animate(target.nextPos)},100);return false;})},unbind:function(){$(window).unbind('scroll.popupScroll');}};jQuery.cumulativeOffset=function(element){var valueT=0,valueL=0;do{valueT+=element.offsetTop||0;valueL+=element.offsetLeft||0;element=element.offsetParent;}while(element);return{'top':valueT,'left':valueL};};jQuery.scope=function(target,func){return function(){return func.apply(target,arguments);}};jQuery.th.cancelRequest=function(xhr){try{if(xhr&&xhr.abort){xhr.abort();}}catch(error){}
finally{return xhr=null;}};jQuery.th.elemVal=function(selector){var elem=$(selector);var rtn=[];elem.each(function(){var val=$(this).val();if(val)rtn.push(val);});return rtn||[];};jQuery.fn.extend({setCenterPos:function(){var target=$(this);var win=$(window);return target.css({left:(win.width()-target.width())/2+win.scrollLeft(),top:(win.height()-target.height())/2+win.scrollTop()})},setCenterPosSet:function(){var target=$(this);var win=$(window);return{left:(win.width()-target.width())/2+win.scrollLeft(),top:(win.height()-target.height())/2+win.scrollTop()}}});jQuery.th.tooltip=function(thumbnails,tooltip,callback){callback=callback||function(){return{top:-(20+$(tooltip).height()),left:-(20+$(tooltip).width())};};var timer=null;thumbnails=$(thumbnails).mouseover(show).mouseout(hide);tooltip=$(tooltip).mouseover(clearTimer).mouseout(hide);function show(event){clearTimer();var margin=callback.apply(this);var offset=$(event.target).offset();offset.top+=margin.top;offset.left+=margin.left;tooltip.css({top:offset.top+'px',left:offset.left+'px',display:'block'});return false;}
function hide(event){clearTimer();timer=setTimeout(function(){tooltip.hide();},500);return false;}
function clearTimer(){if(timer)clearTimeout(timer);}};$(function(){});