$(document).ready(function(){

	// console.log('tesuto-s');
	// var sesid = window.sessionStorage.getItem(['LOGINID']);
	// console.log(sesid);
	// console.log('tesuto');
	// alert('welcome!'+sesid);

	/* フロア詳細サイド固定 */
	var navF = $('#floorSide');
	if($(navF).length){
		if(typeof navF !== "undefined"){
			offsetF = navF.offset();
			var footsetF = $("#footer").offset().top - $(window).height() + 30;
			var stopF = navF.offset().top;
			$(window).scroll(function () {
				if($(window).scrollTop() > offsetF.top - 60){
					navF.css('top', $(window).scrollTop() - offsetF.top + 160);
					if($(window).scrollTop() > 1800) {
						navF.css('top', (1800 - stopF));
					}
				} else {
					navF.css('top', 0);
				}
			});
		}
	}

	/* 検索ボタン */
	var navS = $('#searchBtnBox');
	if($(navS).length){
		if(typeof navS !== "undefined"){
			var offsetS = $("#footer").offset().top - $(window).height() - 600;	//コンテンツ追加分をプラス
			// 画面がスクロールされたら以下の処理を実行
			$(window).scroll(function () {
				if($(window).scrollTop() < offsetS) {
					$(navS).addClass("posfixed");
				} else {
					$(navS).removeClass("posfixed");
				}
			});
		}
	}

	/* グローバルナビ マウスオーバーイベント */
	$(".gBtn").hover(
		function (){
			var tid = this.id;
			//alert(tid);
			if(tid != ""){
				$("#"+tid+" .nav_gs").show();
			}
		},
		function (){
			var tid = this.id;
			//alert(tid);
			if(tid != ""){
				$("#"+tid+" .nav_gs").hide();
			}
		}
	);

	/* トップページ フリーワード検索 ここから */
	$('#indexSearchBtn').click(function (){
		var words = $('#indexword').val();
		if(words != ""){
			//フリーワード
			var FREEWORD = "/freeword/"+words+"/";
			
			//面積帯
			var archi1 = Number($('#indexarchi1').val());
			var archi2 = Number($('#indexarchi2').val());
			var ARCHI;
			if((archi1 != "")||(archi2 != "")){
				if((archi1)&&(archi2)){
					//両方入力されている場合
					if(archi1 >= archi2){
						$('#wrap_all').before('<div id="errorBG"></div><div id="errorALT"><p class="errorMSG">面積の指定に誤りがあります</p><p class="errorCLOSE">ＯＫ</p></div>');
						return;
					}else{
						ARCHI = archi1+"_"+archi2+"/";
					}
				}else{
					if(archi1){
						ARCHI = archi1+"_0/";
					}
					if(archi2){
						ARCHI = "0_"+archi2+"/";
					}
				}
			}
			
			//坪単価上限
			var rate = Number($('#indexrate').val());
			var RATE;
			if(rate){
				RATE = "0_"+rate+"/";
			}
			
			//URL結合
			//面積帯の入力がなく、坪単価の入力があった場合
			if((!ARCHI)&&(RATE)){
				ARCHI = "0_0/";
			}
			if(ARCHI) FREEWORD += ARCHI;
			if(RATE) FREEWORD += RATE;
			
			//alert(FREEWORD);
			window.location.href = FREEWORD;
			
		}else{
			$('#wrap_all').before('<div id="errorBG"></div><div id="errorALT"><p class="errorMSG">住所、ビル名、駅名等、<br />キーワードを入力してください</p><p class="errorCLOSE">ＯＫ</p></div>');
			return;
		}
	});
	/* トップページ フリーワード検索 ここまで */

	/* ヘッダ フリーワード検索 ここから */
	$('#headerSearchBtn').click(function (){
		var words = $('#headerword').val();
		if(words != ""){
			//フリーワード
			var FREEWORD = "/freeword/"+words+"/";
			
			//alert(FREEWORD);
			window.location.href = FREEWORD;
			
		}else{
			$('#wrap_all').before('<div id="errorBG"></div><div id="errorALT"><p class="errorMSG">住所、ビル名、駅名等、<br />キーワードを入力してください</p><p class="errorCLOSE">ＯＫ</p></div>');
			return;
		}
	});
	/* ヘッダ フリーワード検索 ここまで */

	/* エリア検索ページ ここから */
	/* 都道府県のクリック表示 */
	$('.tdfkchg').on('click', function(){
		var tdfknum = $('.tdfkchg').index(this);
		//alert(tdfknum);
		var tdfksel = $('.tdfkLine');
		for(var c=0;c<tdfksel.length;c++){
			if(c == tdfknum){
				//$(tdfksel[c]).addClass('show');
				$(tdfksel[c]).slideDown('fast');
			}else{
				//$(tdfksel[c]).removeClass('show');
				$(tdfksel[c]).removeClass('show');
				$(tdfksel[c]).slideUp('fast');
			}
		}
		//alert(this.id);
		var tdfkchk11 = "#tdfk11";
		var tdfkchk12 = "#tdfk12";
		var tdfkchk13 = "#tdfk13";
		var tdfkchk14 = "#tdfk14";
		var tbid = this.id.substr(2,2);
		//alert(tbid);
		for(var t=11;t<=14;t++){
			//alert(t);
			if(tbid == t){
				$('#tdfk'+t+' input').prop('disabled',false);
			}else{
				$('#tdfk'+t+' input').prop('disabled',true);
				$('#tdfk'+t+' input').prop('checked',false);
			}
		}
		//都道府県を選択した場合、その都度エリアチェックボックスはリセットするため、
		$('#searchBtnBox p').addClass('show');
		clickTDFKandSearchBtn();
	});

	/* エリアチェック */
	var areaurl = new Array();
	$('.areachk').click(function(){
		var tval = $(this).val();
		var tvalc = tval.length;
		//alert(tvalc);
		//クリックしたチェックボックスのvalueの文字数をカウント
		if(tvalc == 6){
			var tval4 = tval.substr(0,4);
			var CID = '#area'+tval4;
			var cidlist = '#catearea'+tval4;
			if(this.checked){
				//クリックしたことでチェックされた場合、チェックボックスの数とチェックされている数を比較し、同数であれば市区町村チェックを入れる
				var chkc = $(cidlist+' input').length;
				//alert(chkc);
				var chkin = $(cidlist+' input:checked').length;
				//alert(chkin);
				if(chkc == chkin){
					$(CID).prop('checked',true);
				}else{
					$(CID).prop('checked',false);
				}
			}else{
				//チェックを外した場合は、強制的に市区町村のチェックを外す
				$(CID).prop('checked',false);
			}
		}else{
			/* エリア市区町村チェック */
			var acid = '#cate'+this.id;
			//alert(acid);
			if(this.checked){
				//alert('checkしたね');
				$(acid+' input').prop('checked',true);
			} else {
				$(acid+' input').prop('checked',false);
			}
		}
		
		//エリアのチェックがクリックされた場合、その都度エリアが選択されている数をチェック
		//チェックが0の場合は検索ボタンの下にテキストを表示
		//チェックが1以上の場合はテキストを非表示に
		var as = $('[name="areas"]:checked').length;
		var ac = $('[name="areac"]:checked').length;
		//alert(as);
		//alert(ac);
		if((as > 0)||(ac > 0)){
			$('#searchBtnBox p').removeClass('show');
		}else{
			$('#searchBtnBox p').addClass('show');
		}
	});

	/* 駅検索 */
	var stationurl = new Array();
	$('.stationchk').click(function(){

		var stval = $(this).val();	//クリックされたチェックボックスの駅コード
		var chkf = 1;
		//alert($(this).prop('checked'));
		if($(this).prop('checked') == false) chkf = 9;	//チェック外しフラグ
		//同駅は全て一斉処理（チェック・外し）
		//alert(stchkid);
		var stclass = 'st'+stval;
		if(chkf == 9){
			$('.'+stclass).prop('checked',false);
		}else{
			$('.'+stclass).prop('checked',true);
		}
		//alert(chkf);
		var staname = $(this).next('a').text();
		var countw = staname.indexOf('(');
		var sta = staname.substr(0,countw);	//クリックされたチェックボックスの駅名
		//既に選択されているものを取得
		var s_sta = "";
		if($('#stationselect').is(':visible')){
			var ssta = $('#stationselect').text();
			var ssta_ay = ssta.split('／');
			for( var i=0 ; i<ssta_ay.length ; i++ ) {
				if((ssta_ay[i] == sta)&&(chkf == 9)) continue;	//同名駅がある場合はスルー
				if(s_sta != "") s_sta += "／";
				s_sta += ssta_ay[i];
			}
		}
		if(s_sta != ""){
			if(chkf == 1){
				var stations = s_sta+"／"+sta;
			}else{
				var stations = s_sta;
			}
		}else{
			if(chkf == 1){
				var stations = sta;
			}else{
				var stations = "";
			}
		}
		//最終表示
		if(stations != ""){
			$('#stationselect').text(stations);
			$('#notselectstation').removeClass('show').addClass('none');
			$('#stationselect').removeClass('none').addClass('show');
		}else{
			$('#stationselect').text('');
			$('#notselectstation').removeClass('none').addClass('show');
			$('#stationselect').removeClass('show').addClass('none');
		}
		
		//旧タイプここから
		//var tval = $(this).val();
		//var tvalc = tval.length;
		//alert(tvalc);
		//クリックしたチェックボックスのvalueの文字数をカウント
		/*
		if(tvalc == 6){
			var tval4 = tval.substr(0,4);
			var CID = '#area'+tval4;
			var cidlist = '#catearea'+tval4;
			if(this.checked){
				//クリックしたことでチェックされた場合、チェックボックスの数とチェックされている数を比較し、同数であれば市区町村チェックを入れる
				var chkc = $(cidlist+' input').length;
				//alert(chkc);
				var chkin = $(cidlist+' input:checked').length;
				//alert(chkin);
				if(chkc == chkin){
					$(CID).prop('checked',true);
				}else{
					$(CID).prop('checked',false);
				}
			}else{
				//チェックを外した場合は、強制的に市区町村のチェックを外す
				$(CID).prop('checked',false);
			}
		}else{
			// エリア市区町村チェック
			var acid = '#cate'+this.id;
			//alert(acid);
			if(this.checked){
				//alert('checkしたね');
				$(acid+' input').prop('checked',true);
			} else {
				$(acid+' input').prop('checked',false);
			}
		}
		*/

		//var acid = '#cate'+this.id;
		//alert(acid);
		/*
		if(this.checked){
			//alert('checkしたね');
			$(acid+' input').prop('checked',true);
		} else {
			$(acid+' input').prop('checked',false);
		}
		*/
		//旧タイプここまで

		//エリアのチェックがクリックされた場合、その都度エリアが選択されている数をチェック
		//チェックが0の場合は検索ボタンの下にテキストを表示
		//チェックが1以上の場合はテキストを非表示に
		//var as = $('[name="stations"]:checked').length;
		//「チェックをされている数」ではなく、値で「何種類の駅が選択されているか」を判別
		var stay = $('[name="stations"]:checked').map(function(){
			return $(this).val();
			//console.log(value);
		}).get();
		var as = Array.from(new Set(stay)).length;
		//alert(as);
		//alert(ac);
		if((as > 0)){
			$('#searchBtnBox p').removeClass('show');
			if(as >= 20){
				$('input[name="stations"]:not(:checked)').prop('disabled',true);
			}else{
				$('input[name="stations"]').prop('disabled',false);
			}
		}else{
			$('#searchBtnBox p').addClass('show');
		}
		
		//20
		
	});

	//基準階面積選択チェック
	$('#elevator').click(function(){
		if(this.checked){
			$('#hspEv').prop('disabled',false);
		} else {
			$('#hspEv').prop('disabled',true);
		}
	});

	//基準階面積選択チェック
	$('#hspLarge').click(function(){
		if(this.checked){
			$('#hspLarge1').prop('disabled',false);
		} else {
			$('#hspLarge1').prop('disabled',true);
		}
	});

	/* 検索ボタンクリック */
	//一覧ページサイドバーからのフリーワード検索
	//alert(words);
	$('.searchBtnWord').click(function (){
		var words = $('#freeword').val();
		if(words != ""){
			//フリーワード
			var AURL = "/freeword/"+words+"/";
			
			//その他条件がある場合
			var archi1 = Number($('#hscArchi1').val());	//面積下限
			var archi2 = Number($('#hscArchi2').val());	//面積上限
			var archiurl;	//面積追加変数
			//面積選択エラー（下限、上限の矛盾）
			if((archi1)&&(archi2)&&(archi1 >= archi2)){
				$('#wrap_all').before('<div id="errorBG"></div><div id="errorALT"><p class="errorMSG">面積の選択に誤りがあります</p><p class="errorCLOSE">ＯＫ</p></div>');
				return;
				//errflag = 1;
			}else{
				if((archi1)||(archi2)){
					if(!archi1){
						archi1 = "0";
					}
					if(!archi2){
						archi2 = "0";
					}
					archiurl = archi1+"_"+archi2+"/";
				}
			}
			var rate1 = Number($('#hscRate1').val());	//坪単価下限
			var rate2 = Number($('#hscRate2').val());	//坪単価上限
			var rateurl;	//坪単価追加変数
			//坪単価選択エラー（下限、上限の矛盾）
			if((rate1)&&(rate2)&&(rate1 >= rate2)){
				$('#wrap_all').before('<div id="errorBG"></div><div id="errorALT"><p class="errorMSG">坪単価の選択に誤りがあります</p><p class="errorCLOSE">ＯＫ</p></div>');
				return;
				//errflag = 1;
			}else{
				if((rate1)||(rate2)){
					if(!rate1){
						rate1 = "0";
					}
					if(!rate2){
						rate2 = "0";
					}
					rateurl = rate1+"_"+rate2+"/";
					//面積の指定がなかった場合は0_0を指定
					if(!archiurl) archiurl = "0_0/";
				}
			}
			if(archiurl) AURL += archiurl;
			if(rateurl) AURL += rateurl;

			//その他条件
			var otherterm = "";

			//基準階面積
			var tm_hsplarge = $('#hspLarge').prop('checked');
			if(tm_hsplarge == true){
				var val_hsplarge = $('#hspLarge').val();
				var val_hsplarge1 = $('#hspLarge1').val();
				if(otherterm != "") otherterm += "&";
				otherterm += "hspLarge="+val_hsplarge+"&hspLarge1="+val_hsplarge1;
			}
			//要確認を含む
			var tm_notrate = $('#notrate').prop('checked');
			if(tm_notrate == false){
				if(otherterm != "") otherterm += "&";
				otherterm += "notrate=0";
			}
			//竣工年
			var tm_hspyear = $('#hspYear').val();
			if(tm_hspyear){
				if(otherterm != "") otherterm += "&";
				otherterm += "hspYear="+tm_hspyear;
			}
			//トイレ
			var tm_toilet_a = $('#toilet_a').val();
			var tm_toilet_b = $('#toilet_b').val();
			if(tm_toilet_a){
				if(otherterm != "") otherterm += "&";
				otherterm += "toilet_a="+tm_toilet_a;
			}
			if(tm_toilet_b){
				if(otherterm != "") otherterm += "&";
				otherterm += "toilet_b="+tm_toilet_b;
			}
			//20階建て以上
			var tm_hsplarge2 = $('#hspLarge2').prop('checked');
			if(tm_hsplarge2 == true){
				var val_hsplarge2 = $('#hspLarge2').val();
				if(otherterm != "") otherterm += "&";
				otherterm += "hspLarge2="+val_hsplarge2;
			}
			//リニューアル物件
			var tm_renewal = $('#renewal').prop('checked');
			if(tm_renewal == true){
				var val_renewal = $('#renewal').val();
				if(otherterm != "") otherterm += "&";
				otherterm += "renewal="+val_renewal;
			}
			//駐車場付物件
			var tm_parking = $('#parking').prop('checked');
			if(tm_parking == true){
				var val_parking = $('#parking').val();
				if(otherterm != "") otherterm += "&";
				otherterm += "parking="+val_parking;
			}
			//エレベーター有
			var tm_elevator = $('#elevator').prop('checked');
			if(tm_elevator == true){
				var val_elevator = $('#elevator').val();
				var val_hspev = $('#hspEv').val();
				if(otherterm != "") otherterm += "&";
				otherterm += "elevator="+val_elevator+"&hspEv="+val_hspev;
			}
			//一棟貸し物件
			var tm_buildall = $('#build_all').prop('checked');
			if(tm_buildall == true){
				var val_buildall = $('#build_all').val();
				if(otherterm != "") otherterm += "&";
				otherterm += "build_all="+val_buildall;
			}
			//天井高2.7m以上の物件
			var tm_ceiling = $('#ceiling').prop('checked');
			if(tm_ceiling == true){
				var val_ceiling = $('#ceiling').val();
				if(otherterm != "") otherterm += "&";
				otherterm += "ceiling="+val_ceiling;
			}
			//新耐震物件
			var tm_proof1 = $('#proof1').prop('checked');
			if(tm_proof1 == true){
				var val_proof1 = $('#proof1').val();
				if(otherterm != "") otherterm += "&";
				otherterm += "proof1="+val_proof1;
			}
			//新耐震・免震物件のみ
			var tm_proof2 = $('#proof2').prop('checked');
			if(tm_proof2 == true){
				var val_proof2 = $('#proof2').val();
				if(otherterm != "") otherterm += "&";
				otherterm += "proof2="+val_proof2;
			}
			//1F有り物件
			var tm_firstfloor = $('#firstfloor').prop('checked');
			if(tm_firstfloor == true){
				var val_firstfloor = $('#firstfloor').val();
				if(otherterm != "") otherterm += "&";
				otherterm += "firstfloor="+val_firstfloor;
			}
			//店舗・ショールーム（1F有り物件）
			var tm_firstfloor2 = $('#firstfloor2').prop('checked');
			if(tm_firstfloor2 == true){
				var val_firstfloor2 = $('#firstfloor2').val();
				if(otherterm != "") otherterm += "&";
				otherterm += "firstfloor2="+val_firstfloor2;
			}
			//格安オフィス（@10000以下）
			if(document.getElementById("lowprice") != null){
				var val_lowprice = $('#lowprice').val();
				if(otherterm != "") otherterm += "&";
				otherterm += "lowprice="+val_lowprice;
			}
			//空き物件表示
			var tm_nows = $('#nows').prop('checked');
			if(tm_nows == true){
				var val_nows = $('#nows').val();
				if(otherterm != "") otherterm += "&";
				otherterm += "nows="+val_nows;
			}
			
			//その他条件まとめ
			var OTHERS = "";
			if(otherterm != "") OTHERS = "?"+otherterm;

			window.location.href = AURL+OTHERS;

		}else{
			$('#wrap_all').before('<div id="errorBG"></div><div id="errorALT"><p class="errorMSG">検索キーワードの入力、または<br />エリアが選択されていません</p><p class="errorCLOSE">ＯＫ</p></div>');
			return;
		}
	});
	
	var areaurl2 = new Array();		//都道府県コード配列
	var areaurl4 = new Array();		//市区町村コード配列
	var areaurl6 = new Array();		//小エリアコード配列
	var stationurl = new Array();	//駅コード配列
	var errflag = 0;
	$('.searchBtn').click(function (){
		//チェックボックスのチェック
		//市区町村
		$('[name="areac"]:checked').each(function(){
			areaurl4.push($(this).val());
		});
		//小エリア
		$('[name="areas"]:checked').each(function(){
			areaurl6.push($(this).val());
		});
		//駅
		$('[name="stations"]:checked').each(function(){
			stationurl.push($(this).val());
		});
		
		//配列areaurlの空、0、undefindを排除
		var aurl4 = $.grep(areaurl4, function(acodeC){
			//市区町村コード
			return acodeC;
		});
		var aurl6 = $.grep(areaurl6, function(acodeS){
			//小エリアコード
			return acodeS;
		});
		var surl = $.grep(stationurl, function(scode){
			//駅コード
			return scode;
		});

		//重複を削除
		var A4 = aurl4.filter(function (x, i, self) {
			//市区町村コード
			return self.indexOf(x) === i;
		});
		var AURL6 = aurl6.filter(function (x, i, self) {
			//小エリアコード
			return self.indexOf(x) === i;
		});
		var SURL = surl.filter(function (x, i, self) {
			//小エリアコード
			return self.indexOf(x) === i;
		});
		
		//コロンで結合(1回目)
		var acode4 = A4.join(':');
		var ACODE6 = AURL6.join(':');
		var SCODE = SURL.join(':');
		//市区町村が直接選択されている場合は、小エリアの下2桁を99にしたエリアコードを生成
		//alert(A4);
		var AURL99 = new Array();	//99コード配列
		if(acode4 != ""){
			$.each(A4, function(a, v){
				//var code4 = $(this).val();
				AURL99.push(v+'99');
			});
			//alert(AURL4);
		}
		var ACODE99 = AURL99.join(':');
		//alert(ACODE6);
		//alert(ACODE99);
		//エリアが選択されていない場合はアラートを出す
		var fixURL = new Array();	//最終決定6ケタコード配列
		if((acode4 == "")&&(ACODE6 == "")){
			//駅検索の場合
			var linecode = $('#linecode').val();
			var url = window.location.href;
			//alert(url);
			if(SCODE != ""){
				//alert('none4');
				//var linecode = getParam('line');
				//var AURL = "/station/"+linecode+"/"+SCODE;
				var AURL = "/stations/"+SCODE;
			}else{
				var SCODE = $('#sta').val();
				if((SCODE == "")||(SCODE === undefined)){
					var warea = "エリア";
					if(url.match(/station/)){
						//alert(linecode);
						var warea = "駅";
					}
					//alert('none3');
					$('#wrap_all').before('<div id="errorBG"></div><div id="errorALT"><p class="errorMSG">'+warea+'を選択してください</p><p class="errorCLOSE">ＯＫ</p></div>');
					return;
				}else{
					//alert(SCODE);
					var AURL = "/stations/"+SCODE;
				}
			}
			//errflag = 1;
		}else{
			//if(ACODE4 != "") var fff = AURL6.concat(AURL99);
			//alert(fff);
			//alert('AURL6:'+AURL6);
			var a2 = "";
			$.each(AURL6, function(i, val){
				var a6 = val;
				//都道府県コード抽出
				var a2 = a6.substr(0,2);
				areaurl2.push(a2);
				//市区町村コード抽出
				var a4 = a6.substr(0,4);
				//ACODE4の値が存在する場合、A4の配列をループさせ、a4の4桁から始まる値を削除する
				if(acode4 != ""){
					var urlflag = 0;
					$.each(A4, function(a, v){
						if(a4 == v) urlflag = 1;
						//var code4 = $(this).val();
						//AURL99.push(v+'99');
					});
					if(urlflag == 0){
						//市区町村で指定されている場合は、選択されている市区町村の6ケタコードを削除し、後程99コードを追加させる
						//市区町村ではなく、6ケタコードのみの選択であれば決定コードとしてfixURL配列へ追加する
						fixURL.push(val);
					}
				}else{
					fixURL.push(val);
				}
				areaurl4.push(a4);
			});
			//6桁がない小エリアの場合は上のループが行われないため、都道府県コードがないという現象が発生するので、その対策
			if(a2 == ""){
				$.each(A4, function(i, val){
					//都道府県コード抽出
					var a4 = val;
					var a2 = a4.substr(0,2);
					areaurl2.push(a2);
				});
				//alert('no');
			}
			//alert('fixURL:'+fixURL);
			//重複を削除
			var AURL2 = areaurl2.filter(function (x, i, self) {
				return self.indexOf(x) === i;
			});
			//重複を削除した市区町村コード
			var AURL4 = areaurl4.filter(function (x, i, self) {
				return self.indexOf(x) === i;
			});
			//ソート
			AURL4.sort(function(a,b){ return a - b; });
			var FIXCODE = "";
			//alert(fixURL);
			if((fixURL != "")&&(fixURL != "undefined")){
				//重複を削除
				//ソートのための6ケタコード配列（fixURLとAURL99をマージ）
				var fixurl6 = fixURL.concat(AURL99);
				//alert('fixurl6:'+fixurl6);
				//ソート
				fixurl6.sort(function(a,b){ return a - b; });
				var fixURL6 = fixurl6.filter(function (x, i, self) {
					return self.indexOf(x) === i;
				});
				var fixCODE6 = fixURL6.join(':');
				FIXCODE = fixCODE6+"/";
			}
			//alert('fixURL6:'+fixURL6);
			var ACODE2 = AURL2.join(':');
			var ACODE4 = AURL4.join(':');
			/*
			if(ACODE99 != fixCODE6){
				var FIXCODE = fixCODE6+"/";
			}else{
				var FIXCODE = "";
			}
			*/
			
			//遷移先のURLを生成
			var AURL = "/area/P"+ACODE2+"/"+ACODE4+"/"+FIXCODE;
			//alert(AURL);
		}
		
		//その他条件がある場合
		var archi1 = Number($('#hscArchi1').val());	//面積下限
		var archi2 = Number($('#hscArchi2').val());	//面積上限
		var archiurl;	//面積追加変数
		//面積選択エラー（下限、上限の矛盾）
		if((archi1)&&(archi2)&&(archi1 >= archi2)){
			$('#wrap_all').before('<div id="errorBG"></div><div id="errorALT"><p class="errorMSG">面積の選択に誤りがあります</p><p class="errorCLOSE">ＯＫ</p></div>');
			return;
			//errflag = 1;
		}else{
			if((archi1)||(archi2)){
				if(!archi1){
					archi1 = "0";
				}
				if(!archi2){
					archi2 = "0";
				}
				archiurl = archi1+"_"+archi2+"/";
			}
		}
		var rate1 = Number($('#hscRate1').val());	//坪単価下限
		var rate2 = Number($('#hscRate2').val());	//坪単価上限
		var rateurl;	//坪単価追加変数
		//坪単価選択エラー（下限、上限の矛盾）
		if((rate1)&&(rate2)&&(rate1 >= rate2)){
			$('#wrap_all').before('<div id="errorBG"></div><div id="errorALT"><p class="errorMSG">坪単価の選択に誤りがあります</p><p class="errorCLOSE">ＯＫ</p></div>');
			return;
			//errflag = 1;
		}else{
			if((rate1)||(rate2)){
				if(!rate1){
					rate1 = "0";
				}
				if(!rate2){
					rate2 = "0";
				}
				rateurl = rate1+"_"+rate2+"/";
				//面積の指定がなかった場合は0_0を指定
				if(!archiurl) archiurl = "0_0/";
			}
		}
		if(archiurl){
			if(!FIXCODE) AURL += ACODE99+"/";
			AURL += archiurl;
		}
		if(rateurl) AURL += rateurl;

		//その他条件
		var otherterm = "";

		//トップページからのみのカテゴリ
		//指定カテゴリ（8:デザイナーズ/9:レンタルオフィス/10:駅直結/11:BCP/firstfloor2→店舗）
		var tm_cate = $('#cate').val();
		var tm_firstfloor2 = $('#firstfloor2').val();
		//alert(tm_cate);
		if(tm_cate){
			if(otherterm != "") otherterm += "&";
			otherterm += "cate="+tm_cate;
		}
		if(tm_firstfloor2){
			if(otherterm != "") otherterm += "&";
			otherterm += "firstfloor2="+tm_firstfloor2;
		}
		//指定カテゴリ（SOHO）
		var tm_hsptype = $('#hspType').val();
		if(tm_hsptype){
			if(otherterm != "") otherterm += "&";
			otherterm += "hspType=3";
		}
		//基準階面積
		var tm_hsplarge = $('#hspLarge').prop('checked');
		if(tm_hsplarge == true){
			var val_hsplarge = $('#hspLarge').val();
			var val_hsplarge1 = $('#hspLarge1').val();
			if(otherterm != "") otherterm += "&";
			otherterm += "hspLarge="+val_hsplarge+"&hspLarge1="+val_hsplarge1;
		}
		//要確認を含む
		var tm_notrate = $('#notrate').prop('checked');
		if(tm_notrate == false){
			if(otherterm != "") otherterm += "&";
			otherterm += "notrate=0";
		}
		//竣工年
		var tm_hspyear = $('#hspYear').val();
		if(tm_hspyear){
			if(otherterm != "") otherterm += "&";
			otherterm += "hspYear="+tm_hspyear;
		}
		//トイレ
		var tm_toilet_a = $('#toilet_a').val();
		var tm_toilet_b = $('#toilet_b').val();
		if(tm_toilet_a){
			if(otherterm != "") otherterm += "&";
			otherterm += "toilet_a="+tm_toilet_a;
		}
		if(tm_toilet_b){
			if(otherterm != "") otherterm += "&";
			otherterm += "toilet_b="+tm_toilet_b;
		}
		//20階建て以上
		var tm_hsplarge2 = $('#hspLarge2').prop('checked');
		if(tm_hsplarge2 == true){
			var val_hsplarge2 = $('#hspLarge2').val();
			if(otherterm != "") otherterm += "&";
			otherterm += "hspLarge2="+val_hsplarge2;
		}
		//リニューアル物件
		var tm_renewal = $('#renewal').prop('checked');
		if(tm_renewal == true){
			var val_renewal = $('#renewal').val();
			if(otherterm != "") otherterm += "&";
			otherterm += "renewal="+val_renewal;
		}
		//駐車場付物件
		var tm_parking = $('#parking').prop('checked');
		if(tm_parking == true){
			var val_parking = $('#parking').val();
			if(otherterm != "") otherterm += "&";
			otherterm += "parking="+val_parking;
		}
		//エレベーター有
		var tm_elevator = $('#elevator').prop('checked');
		if(tm_elevator == true){
			var val_elevator = $('#elevator').val();
			var val_hspev = $('#hspEv').val();
			if(otherterm != "") otherterm += "&";
			otherterm += "elevator="+val_elevator+"&hspEv="+val_hspev;
		}
		//一棟貸し物件
		var tm_buildall = $('#build_all').prop('checked');
		if(tm_buildall == true){
			var val_buildall = $('#build_all').val();
			if(otherterm != "") otherterm += "&";
			otherterm += "build_all="+val_buildall;
		}
		//天井高2.7m以上の物件
		var tm_ceiling = $('#ceiling').prop('checked');
		if(tm_ceiling == true){
			var val_ceiling = $('#ceiling').val();
			if(otherterm != "") otherterm += "&";
			otherterm += "ceiling="+val_ceiling;
		}
		//新耐震物件
		var tm_proof1 = $('#proof1').prop('checked');
		if(tm_proof1 == true){
			var val_proof1 = $('#proof1').val();
			if(otherterm != "") otherterm += "&";
			otherterm += "proof1="+val_proof1;
		}
		//新耐震・免震物件のみ
		var tm_proof2 = $('#proof2').prop('checked');
		if(tm_proof2 == true){
			var val_proof2 = $('#proof2').val();
			if(otherterm != "") otherterm += "&";
			otherterm += "proof2="+val_proof2;
		}
		//1F有り物件
		var tm_firstfloor = $('#firstfloor').prop('checked');
		if(tm_firstfloor == true){
			var val_firstfloor = $('#firstfloor').val();
			if(otherterm != "") otherterm += "&";
			otherterm += "firstfloor="+val_firstfloor;
		}
		//店舗・ショールーム（1F有り物件）
		var tm_firstfloor22 = $('#firstfloor2').prop('checked');
		if(tm_firstfloor22 == true){
			var val_firstfloor2 = $('#firstfloor2').val();
			if(otherterm != "") otherterm += "&";
			otherterm += "firstfloor2="+val_firstfloor2;
		}
		//格安オフィス（@10000以下）
		if(document.getElementById("lowprice") != null){
			var val_lowprice = $('#lowprice').val();
			if(otherterm != "") otherterm += "&";
			otherterm += "lowprice="+val_lowprice;
		}
		//空き物件表示
		var tm_nows = $('#nows').prop('checked');
		if(tm_nows == true){
			var val_nows = $('#nows').val();
			if(otherterm != "") otherterm += "&";
			otherterm += "nows="+val_nows;
		}
		
		//その他条件まとめ
		var OTHERS = "";
		if(otherterm != "") OTHERS = "?"+otherterm;

		window.location.href = AURL+OTHERS;
	});
	
	/* ソートselect */
	//ソート条件
	$('#sort1').on('change',function(){
		var path = location.pathname;	//ファイルパス
		var param = location.search.replace('?','');	//現URLのパラメータ

		if((param != "")&&(param !== undefined)){
			var param_ay = param.split('&');
			var parameters = "";
			$.each(param_ay,function(i,value){
				if(value.match(/sort1/)) return true;
				if(value.match(/sort2/)) return true;
				if((i == 0)||(parameters == "")){
					parameters += "?"+value;
				}else{
					parameters += "&"+value;
				}
			});
			if((parameters != "")&&(parameters !== undefined)){
				url = path+parameters+"&sort1="+$(this).val();
			}else{
				url = path+"?sort1="+$(this).val();
			}
		}else{
			url = path+"?sort1="+$(this).val();
		}
		window.location.href = url;
	});
	//昇降順
	$('#sort2').on('change',function(){
		var path = location.pathname;	//ファイルパス
		var param = location.search.replace('?','');	//現URLのパラメータ
		
		if((param != "")&&(param !== undefined)){
			var param_ay = param.split('&');
			var parameters = "";
			$.each(param_ay,function(i,value){
				if(value.match(/sort2/)) return true;
				if((i == 0)||(parameters == "")){
					parameters += "?"+value;
				}else{
					parameters += "&"+value;
				}
			});
			if((parameters != "")&&(parameters !== undefined)){
				url = path+parameters+"&sort2="+$(this).val();
			}else{
				url = path+"?sort2="+$(this).val();
			}
		}else{
			url = path+"?sort2="+$(this).val();
		}
		window.location.href = url;
	});

	/* エリア検索ページ ここまで */

	/* エラーアラートcloseボタン */
	$(document).on('click','.errorCLOSE',function(){
		$('#errorBG').remove();
		$('#errorALT').remove();
	});
	$(document).on('click','#errorBG',function(){
		$('#errorBG').remove();
		$('#errorALT').remove();
	});
	
	/* サイドバーエリア検索ボタン */
	$(document).on('click','#sideAreaSearch',function(){
		$('#areasrcBG').css('display','block');
		$('#areasrcBox').css('display','block');
		$('body').addClass('ovfH');
	});
	$(document).on('click','.srcareaCLOSE',function(){
		$('#areasrcBG').css('display','none');
		$('#areasrcBox').css('display','none');
		$('body').removeClass('ovfH');
	});
	$(document).on('click','#areasrcBG',function(){
		$('#areasrcBG').css('display','none');
		$('#areasrcBox').css('display','none');
		$('body').removeClass('ovfH');
	});

	/* ビル詳細ページ マップ切り替え */
	$('#mapBtn').click(function (){
		$('#mapAndStvLine').animate({ left: '0px' }, 100);
		$('#mapBtn').addClass('onMap');
		$('#mapBtn').removeClass('offMap');
		$('#stvBtn').removeClass('onMap');
		$('#stvBtn').addClass('offMap');
	});
	$('#stvBtn').click(function (){
		$('#mapAndStvLine').animate({ left: '-490px' }, 100);
		$('#mapBtn').removeClass('onMap');
		$('#mapBtn').addClass('offMap');
		$('#stvBtn').addClass('onMap');
		$('#stvBtn').removeClass('offMap');
	});
	
	/* フロア情報テーブル 図面マウスオーバー */
	$('.floordrwbox').hover(function(){
		var fid = this.id;
		$("#f"+fid).toggle();
	});

	/* 印刷ボタンクリック */
	$('.btnPrint').click(function(){
		var prid = this.id;
		var PRID = prid.replace('prout','');
		window.open("/printing/"+PRID+"/","","toolbar=no,location=no,status=no,menubar=yes,scrollbars=yes,width=1200,height=830");
	
	});
	/* 印刷プロパティ */
	$('.btnPrintout').click(function(){
		window.print();
	});

	/* お気に入りページ */
	var fvid_ay = new Array();	//お気に入りチェックID配列
	//チェックON/OFF
	$('.favorCheckOn').click(function (){
		//alert('on');
		var items = $('#favoriteHspBox').find('input');
		$(items).prop('checked',true);
	});
	$('.favorCheckOff').click(function (){
		//alert('off');
		var items = $('#favoriteHspBox').find('input');
		$(items).prop('checked',false);
	});
	$('.favorInquiry').click(function (){
		//お気に入りチェックID配列に代入
		$('[class="fvid"]:checked').each(function(){
			fvid_ay.push($(this).val());
		});
		//配列fvid_ayの空、0、undefindを排除
		var fvid_ays = $.grep(fvid_ay, function(fvp){
			//市区町村コード
			return fvp;
		});
		//重複を削除
		var fvid_ayd = fvid_ays.filter(function (x, i, self) {
			//市区町村コード
			return self.indexOf(x) === i;
		});
		var FVID_AY = fvid_ayd.join(':');
		//エラー
		if(!FVID_AY){
			$('#wrap_all').before('<div id="errorBG"></div><div id="errorALT"><p class="errorMSG">問い合わせる物件を選択してください</p><p class="errorCLOSE">ＯＫ</p></div>');
		}else{
			//alert(FVID_AY);
			window.location.href = "/inquiry_f/"+FVID_AY+"/";
		}
	});

	/* お問い合わせ */
	$('#inquiryType1').click(function(){
		if(this.checked){
			$("#inspection").slideDown("fast");
			$("#inspection").find('select').prop('disabled',false);
		}
	});
	$('.inquiryType234').click(function(){
		if(this.checked){
			$("#inspection").slideUp("fast");
			$("#inspection").find('select').prop('disabled',true);
		}
	});

	/*用語集カテゴリクリックオープン*/
	$('.glocatetitle').click(function(){
		var tid = $(this).attr('id');
		var did = tid.replace('gt','gd');
		if($('#'+did).is(':visible')){
			$('#'+did).slideUp('fast');
		}else{
			$('#'+did).slideDown('fast');
			if($('#'+did).hasClass('nonein')){
				$('#'+did).removeClass('nonein');
			}
		}
	});

	//TOP路線・エリア選択window表示
	$('#srcrails').on('click',function(){
		$('.arrows').css('left','235px');
		$('#sBtn01').css('background-color','#337DBE');
		$('#sBtn02').css('background-color','#CACACA');
		$('#sBtn01').removeClass('selrailarea');
		$('#sBtn02').addClass('selrailarea');
	});
	$('#srcareas').on('click',function(){
		$('.arrows').css('left','735px');
		$('#sBtn01').css('background-color','#CACACA');
		$('#sBtn02').css('background-color','#337DBE');
		$('#sBtn01').addClass('selrailarea');
		$('#sBtn02').removeClass('selrailarea');
	});

	$('.stylecomment').hover(function(){
		var sid = $(this).attr('id');
		var styleid = "open"+sid;
		//alert(styleid);
		$('#'+styleid).css('display','block');
	},function(){
		var sid = $(this).attr('id');
		var styleid = "open"+sid;
		//alert(styleid);
		$('#'+styleid).css('display','none');
	});

	$('.navsub').hover(function(){
		var navid = $(this).attr('id');
		var subid = navid.replace('nav','sub');
		$('#'+subid).stop().slideDown('fast');
	
	}, function(){
		$('.sublist').stop().slideUp('fast');
	});

	// 20201013時限バナー非表示（大城指示）
	// //時限式バナー処理
	// var ref = document.referrer;             // リファラ情報を得る
	// var hereHost = window.location.hostname; // 現在ページのホスト(ドメイン)名を得る
	
	// // ホスト名が含まれるか探す正規表現を作る(大文字・小文字を区別しない)
	// var sStr = "^https?://" + hereHost;
	// var rExp = new RegExp( sStr, "i" );

	// // console.log(rExp);
	
	// // リファラ文字列を判別
	// if( ref.length == 0 ) {
	// 	// リファラなしの場合
	// 	setTimeout(function(){
	// 		$('.timerbnr').css('display','block');
	// 		$('.timerbnr').animate({
	// 			left:'0px'
	// 		},300)
	// 	},5000);
	// 	$('.timerbnr .close').on('click',function(){
	// 		$('.timerbnr').css('display','none');
	// 	});
	
	// }else if( ref.match( rExp ) ) {
	// 	// マッチした場合＝アクセス元が自サイト内の場合
	// 	var nurl = location.pathname;
	// 	//比較
	// 	// if(nurl.match(/\/building\//)){
	// 	// 	setTimeout(function(){
	// 	// 		$('.timerbnr').css('display','block');
	// 	// 		$('.timerbnr').animate({
	// 	// 			left:'0px'
	// 	// 		},300)
	// 	// 	},5000);
	// 		$('.timerbnr .close').on('click',function(){
	// 			$('.timerbnr').css('display','none');
	// 		});
	// 	// }

	// }else{
	// 	// マッチしない場合＝アクセス元がサイト外の場合
	// 	setTimeout(function(){
	// 		$('.timerbnr').css('display','block');
	// 		$('.timerbnr').animate({
	// 			left:'0px'
	// 		},300)
	// 	},5000);
	// 	$('.timerbnr .close').on('click',function(){
	// 		$('.timerbnr').css('display','none');
	// 	});
	
	// }
	
	$('#settingButton').on('click',function(){
		$('.search-area-box').slideUp('fast');
		$('#fopArea').removeClass('active');
		$('.cp_sl01_expand').prop('checked',false);
		$('.cp_sl02_expand').prop('checked',false);
	});
		
});

function clickTDFKandSearchBtn(){
	var navS = $('#searchBtnBox');
	if($(navS).length){
		if(typeof navS !== "undefined"){
			// var offsetS = $("#footer").offset().top - $(window).height();
			var offsetS = $("#footer").offset().top - $(window).height() - 600;	//コンテンツ追加分のスペースを追加
			// 画面がスクロールされたら以下の処理を実行
			$(window).scroll(function () {
				if($(window).scrollTop() < offsetS) {
					$(navS).addClass("posfixed");
				} else {
					$(navS).removeClass("posfixed");
				}
			});
		}
	}
}

function GetCookie (name)
{
	var arg  = name + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	while (i < clen)
		{
		var j = i + alen;
		if (document.cookie.substring(i, j) == arg)
		return getCookieVal (j);
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0) break;
		}
	return null;
}

function getCookieVal (offset)
{
var endstr = document.cookie.indexOf (";", offset);
if (endstr == -1)
	endstr = document.cookie.length;
	return unescape(document.cookie.substring(offset,endstr));
}

//お気に入り関数(FOP)
function favoriteAddFop(hid){
	var cid = GetCookie('favoriteFOP');
	if((cid != null)&&(cid != "")&&(cid != "0")){
		cid = cid + "," + hid;
		var QID = cid.replace(/,/g,":");
		qid = QID;
	}else{
		cid = hid;
		qid = hid;
	}
	if((qid != null)&&(qid != "")&&(qid != "0")) qid = qid + "/";

	var id_array = cid.split(',');

	// 重複を削除したリスト
	var pid = id_array.filter(function (x, i, self) {
		return self.indexOf(x) === i;
	});

	var expire_date = new Date();
	// 有効期限を7日にする
	expire_date.setTime(expire_date.getTime() + 7*24*60*60*1000);

	//登録ドメイン
	var domain_add = "www.officetar.jp";

	//Cookie登録
	document.cookie = "favoriteFOP=" + pid + "; domain=" + domain_add + "; path=/furnished; expires=" + expire_date.toGMTString();

	document.getElementById("favorAll" + hid).innerHTML = "<a href=\"javascript:void(0);\" onclick=\"favoriteDeleFop('" + hid + "')\" class=\"btnAlpha favoBtnN active\"><i class=\"fas fa-star\" id=\"favorFOP" + hid + "\"></i></a>";

	//問い合わせにお気に入りを常に表示20160526
	//ヘッダ
	// document.getElementById("btn_contact03").innerHTML = "<a href=\"/inquiry/" + qid + "\"><img class=\"rollover\" src=\"/img/common/img_bnr_mailcontact.gif\" alt=\"メールでのお問い合わせ\" /></a>";
	// //フッタ
	// document.getElementById("btn_contact02").innerHTML = "<a href=\"/inquiry/" + qid + "\"><img class=\"rollover\" src=\"/img/common/img_bnr_mailcontact.gif\" alt=\"メールでのお問い合わせ\" /></a>";

	//お気に入り件数カウント
	var plen = id_array.length;
	document.getElementById("favorFov").innerHTML = plen;
	document.getElementById("favorFov2").innerHTML = plen;
}

//削除関数(FOP)
function favoriteDeleFop(hid){
	var cid = GetCookie('favoriteFOP');
	var id_array = cid.split(',');
	var pid = "";
	var qid = "";
	// 該当IDを削除したリスト
	for(var h in id_array){
		if(id_array[h] != 0){
			if (hid == id_array[h]) continue;
			var cid = id_array[h];
			if((cid != null)&&(cid != "")&&(cid != "0")){
				if(pid != ""){
					pid = pid + "," + cid;
					var QID = pid.replace(/,/g,":");
					qid = QID;
				}else{
					pid = cid;
					qid = pid;
				}
			}
		}
	}
	//alert(qid);
	if((qid != null)&&(qid != "")&&(qid != "0")) qid = qid + "/";

	var expire_date = new Date();
	// 有効期限を7日にする
	expire_date.setTime(expire_date.getTime() + 7*24*60*60*1000);

	//登録ドメイン
	var domain_add = "www.officetar.jp";

	//Cookie登録
	document.cookie = "favoriteFOP=" + pid + "; domain=" + domain_add + "; path=/furnished; expires=" + expire_date.toGMTString();

	document.getElementById("favorAll" + hid).innerHTML = "<a href=\"javascript:void(0);\" onclick=\"favoriteAddFop('" + hid + "')\" class=\"btnAlpha favoBtnN\"><i class=\"fas fa-star\" id=\"favorFOP" + hid + "\"></i></a>";

	// //問い合わせにお気に入りを常に表示20160526
	// //ヘッダ
	// document.getElementById("btn_contact03").innerHTML = "<a href=\"/inquiry/" + qid + "\"><img class=\"rollover\" src=\"/img/common/img_bnr_mailcontact.gif\" alt=\"メールでのお問い合わせ\" /></a>";
	// //フッタ
	// document.getElementById("btn_contact02").innerHTML = "<a href=\"/inquiry/" + qid + "\"><img class=\"rollover\" src=\"/img/common/img_bnr_mailcontact.gif\" alt=\"メールでのお問い合わせ\" /></a>";

	var plen = (id_array.length - 1);
	document.getElementById("favorFov").innerHTML = plen;
	document.getElementById("favorFov2").innerHTML = plen;

}

//削除関数(FOP)
function favoriteDeleFopPage(hid){
	var cid = GetCookie('favoriteFOP');
	var id_array = cid.split(',');
	var pid = "";
	var qid = "";
	// 該当IDを削除したリスト
	for(var h in id_array){
		if(id_array[h] != 0){
			if (hid == id_array[h]) continue;
			var cid = id_array[h];
			if((cid != null)&&(cid != "")&&(cid != "0")){
				if(pid != ""){
					pid = pid + "," + cid;
					var QID = pid.replace(/,/g,":");
					qid = QID;
				}else{
					pid = cid;
					qid = pid;
				}
			}
		}
	}
	//alert(qid);
	if((qid != null)&&(qid != "")&&(qid != "0")) qid = qid + "/";

	var expire_date = new Date();
	// 有効期限を7日にする
	expire_date.setTime(expire_date.getTime() + 7*24*60*60*1000);

	//登録ドメイン
	var domain_add = "www.officetar.jp";

	//Cookie登録
	document.cookie = "favoriteFOP=" + pid + "; domain=" + domain_add + "; path=/furnished; expires=" + expire_date.toGMTString();
	

	var plen = (id_array.length - 1);
	document.getElementById("favorFov").innerHTML = plen;
	document.getElementById("favorFov2").innerHTML = plen;

	location.reload();

}

window.onload = ()=> {
	//お気に入りページ読み込み時判別
	var fopUrl = location.href;
	if (fopUrl.indexOf('furnished') !== -1) {

		var fopAllCookies = document.cookie;
		var fopCookie = fopAllCookies.indexOf("favoriteFOP=");

		if (fopCookie !== -1) {
			//お気に入りのクッキーの配列を作成
			var start = fopCookie + 12;
			var end = fopAllCookies.indexOf(";", start);
			if(end == -1) end = fopAllCookies.length;
			var value = fopAllCookies.substring(start, end);

			//20230316 korenaga バグ修正
			//値が空でsplitを実行すると空の値が一つある配列ができてしまうため、lengthでカウントすると1になってしまい、お気に入りの登録がないのに1とカウントされてしまうバグが発生。
			//→valueが空ではない場合にのみ下を実行することに変更。
			if(value != ""){
				var favoFOPay = value.split(',');
				//idを判別してDOMの編集
				favoFOPay.forEach(function( value ) {
					var favID = "favorAll" + value;
					var favoDev = document.getElementById(favID);
					if (favoDev !== null){
						favoDev.innerHTML = "<a href=\"javascript:void(0);\" onclick=\"favoriteDeleFop('" + value + "')\" class=\"btnAlpha favoBtnN active\"><i class=\"fas fa-star\" id=\"favorFOP" + value + "\"></i></a>";
					}
				});
			}else{
				var favoFOPay = "noarray";
			}

		}

		if(favoFOPay != "noarray"){
			var plen = (favoFOPay.length);
			if(plen >= 1){
				document.getElementById("favoActive").classList.add("active");
			}
			document.getElementById("favorFov").innerHTML = plen;
			document.getElementById("favorFov2").innerHTML = plen;
		}

	}
}

//お気に入り関数(ビル)
function favoriteAdd(hid){
	var cid = GetCookie('favoriteP');
	if((cid != null)&&(cid != "")&&(cid != "0")){
		cid = cid + "," + hid;
		var QID = cid.replace(/,/g,":");
		qid = QID;
	}else{
		cid = hid;
		qid = hid;
	}
	if((qid != null)&&(qid != "")&&(qid != "0")) qid = qid + "/";

	var id_array = cid.split(',');

	// 重複を削除したリスト
	var pid = id_array.filter(function (x, i, self) {
		return self.indexOf(x) === i;
	});

	var expire_date = new Date();
	// 有効期限を7日にする
	expire_date.setTime(expire_date.getTime() + 7*24*60*60*1000);
	
	//登録ドメイン
	var domain_add = "officetar.jp";

	//Cookie登録
	document.cookie = "favoriteP=" + pid + "; domain=" + domain_add + "; path=/; expires=" + expire_date.toGMTString();
	
	document.getElementById("favorAll" + hid).innerHTML = "<a href=\"javascript:void(0);\" onclick=\"favoriteDele('" + hid + "')\" class=\"btnAlpha\"><img src=\"/img/ico_cart_in.png\" alt=\"お気に入りに追加済み\" id=\"favorP" + hid + "\" /></a>";

	//問い合わせにお気に入りを常に表示20160526
	//ヘッダ
	document.getElementById("btn_contact03").innerHTML = "<a href=\"/inquiry/" + qid + "\"><img class=\"rollover\" src=\"/img/common/img_bnr_mailcontact.gif\" alt=\"メールでのお問い合わせ\" /></a>";
	//フッタ
	document.getElementById("btn_contact02").innerHTML = "<a href=\"/inquiry/" + qid + "\"><img class=\"rollover\" src=\"/img/common/img_bnr_mailcontact.gif\" alt=\"メールでのお問い合わせ\" /></a>";

	var plen = id_array.length;
	document.getElementById("favorHsp").innerHTML = plen;
}
//お気に入り関数(フロア)
function favoriteAddC(hid){
	var cid = GetCookie('favoriteC');
	if((cid != null)&&(cid != "")&&(cid != "0")){
		cid = cid + "," + hid;
		var QID = cid.replace(/,/g,":");
		qid = QID;
	}else{
		cid = hid;
		qid = hid;
	}
	if((qid != null)&&(qid != "")&&(qid != "0")) qid = qid + "/";

	var id_array = cid.split(',');

	// 重複を削除したリスト
	var pid = id_array.filter(function (x, i, self) {
		return self.indexOf(x) === i;
	});
	//alert(pid);

	var expire_date = new Date();
	// 有効期限を7日にする
	expire_date.setTime(expire_date.getTime() + 7*24*60*60*1000);
	
	//登録ドメイン
	var domain_add = "officetar.jp";

	//Cookie登録
	document.cookie = "favoriteC=" + pid + "; domain=" + domain_add + "; path=/; expires=" + expire_date.toGMTString();
	
	document.getElementById("favorAll" + hid).innerHTML = "<a href=\"javascript:void(0);\" onclick=\"favoriteDeleC('" + hid + "')\" class=\"btnAlpha\"><img src=\"/img/ico_cart_in.png\" alt=\"お気に入りに追加済み\" id=\"favorC" + hid + "\" /></a>";

	//問い合わせにお気に入りを常に表示20160526
	//ヘッダ
	//document.getElementById("btn_contact03").innerHTML = "<a href=\"/inquiry/" + qid + "\"><img class=\"rollover\" src=\"/img/common/img_bnr_mailcontact.gif\" alt=\"メールでのお問い合わせ\" /></a>";
	$('#navMail').attr('href','/inquiry_f/' + qid);
	//document.getElementById("navMail").innerHTML = "<a href=\"/inquiry_f/" + qid + "\" id=\"navMail\"><span>お問い合わせ</span></a>";
	//フッタ
	document.getElementById("btn_contact02").innerHTML = "<a href=\"/inquiry_f/" + qid + "\"><img class=\"rollover\" src=\"/img/common/img_bnr_mailcontact.gif\" alt=\"メールでのお問い合わせ\" /></a>";

	var plen = id_array.length;
	//alert(plen);
	document.getElementById("favorHsp").innerHTML = plen;
}
//お気に入り関数(フロア・ビルページ新レイアウト)
function favoriteAddBC(hid){
	var cid = GetCookie('favoriteC');
	if((cid != null)&&(cid != "")&&(cid != "0")){
		cid = cid + "," + hid;
		var QID = cid.replace(/,/g,":");
		qid = QID;
	}else{
		cid = hid;
		qid = hid;
	}
	if((qid != null)&&(qid != "")&&(qid != "0")) qid = qid + "/";

	var id_array = cid.split(',');

	// 重複を削除したリスト
	var pid = id_array.filter(function (x, i, self) {
		return self.indexOf(x) === i;
	});
	//alert(pid);

	var expire_date = new Date();
	// 有効期限を7日にする
	expire_date.setTime(expire_date.getTime() + 7*24*60*60*1000);
	
	//登録ドメイン
	var domain_add = "officetar.jp";

	//Cookie登録
	document.cookie = "favoriteC=" + pid + "; domain=" + domain_add + "; path=/; expires=" + expire_date.toGMTString();
	
	document.getElementById("favorAll" + hid).innerHTML = "<a href=\"javascript:void(0);\" onclick=\"favoriteDeleBC('" + hid + "')\" class=\"btnAlpha\"><span style=\"color:#3173B5;text-decoration:underline;position:relative;top:9px;padding-right:5px;\">お気に入りを解除</span><img src=\"/img/ico_cart_in.png\" alt=\"お気に入りを解除\" id=\"favorC" + hid + "\" /></a>";

	//問い合わせにお気に入りを常に表示20160526
	//ヘッダ
	//document.getElementById("btn_contact03").innerHTML = "<a href=\"/inquiry/" + qid + "\"><img class=\"rollover\" src=\"/img/common/img_bnr_mailcontact.gif\" alt=\"メールでのお問い合わせ\" /></a>";
	$('#navMail').attr('href','/inquiry_f/' + qid);
	//フッタ
	document.getElementById("btn_contact02").innerHTML = "<a href=\"/inquiry/" + qid + "\"><img class=\"rollover\" src=\"/img/common/img_bnr_mailcontact.gif\" alt=\"メールでのお問い合わせ\" /></a>";

	var plen = id_array.length;
	//alert(plen);
	document.getElementById("favorHsp").innerHTML = plen;
}
//お気に入り関数スマホver.
function favoriteAddSP(hid){
	var cid = GetCookie('favoriteP');
	if((cid != null)&&(cid != "")&&(cid != "0")){
		cid = cid + "," + hid;
	}else{
		cid = hid;
	}

	var id_array = cid.split(',');

	// 重複を削除したリスト
	var pid = id_array.filter(function (x, i, self) {
		return self.indexOf(x) === i;
	});

	var expire_date = new Date();
	// 有効期限を7日にする
	expire_date.setTime(expire_date.getTime() + 7*24*60*60*1000);
	
	//登録ドメイン
	var domain_add = "officetar.jp";

	//Cookie登録
	document.cookie = "favoriteP=" + pid + "; domain=" + domain_add + "; path=/; expires=" + expire_date.toGMTString();
	
	document.getElementById("favorAll" + hid).innerHTML = "<a href=\"javascript:void(0);\" onclick=\"favoriteDeleSP('" + hid + "')\"><img src=\"/sp/img/common/fv_on.png\" alt=\"お気に入りに追加済み\" id=\"favorP" + hid + "\" /></a>";
	
	var plen = id_array.length;
	document.getElementById("favorHsp").innerHTML = plen;
}
//削除関数(ビル)
function favoriteDele(hid){
	var cid = GetCookie('favoriteP');
	var id_array = cid.split(',');
	var pid = "";
	var qid = "";
	// 該当IDを削除したリスト
	for(var h in id_array){
		if(id_array[h] != 0){
			if (hid == id_array[h]) continue;
			var cid = id_array[h];
			if((cid != null)&&(cid != "")&&(cid != "0")){
				if(pid != ""){
					pid = pid + "," + cid;
					var QID = pid.replace(/,/g,":");
					qid = QID;
				}else{
					pid = cid;
					qid = pid;
				}
			}
		}
	}
	//alert(qid);
	if((qid != null)&&(qid != "")&&(qid != "0")) qid = qid + "/";

	var expire_date = new Date();
	// 有効期限を7日にする
	expire_date.setTime(expire_date.getTime() + 7*24*60*60*1000);
	
	//登録ドメイン
	var domain_add = "officetar.jp";

	//Cookie登録
	document.cookie = "favoriteP=" + pid + "; domain=" + domain_add + "; path=/; expires=" + expire_date.toGMTString();

	document.getElementById("favorAll" + hid).innerHTML = "<a href=\"javascript:void(0);\" onclick=\"favoriteAdd('" + hid + "')\" class=\"btnAlpha\"><img src=\"/img/ico_cart.png\" alt=\"お気に入りに追加\" id=\"favorP" + hid + "\" /></a>";

	//問い合わせにお気に入りを常に表示20160526
	//ヘッダ
	document.getElementById("btn_contact03").innerHTML = "<a href=\"/inquiry/" + qid + "\"><img class=\"rollover\" src=\"/img/common/img_bnr_mailcontact.gif\" alt=\"メールでのお問い合わせ\" /></a>";
	//フッタ
	document.getElementById("btn_contact02").innerHTML = "<a href=\"/inquiry/" + qid + "\"><img class=\"rollover\" src=\"/img/common/img_bnr_mailcontact.gif\" alt=\"メールでのお問い合わせ\" /></a>";

	var plen = (id_array.length - 1);
	document.getElementById("favorHsp").innerHTML = plen;

}
//削除関数(フロア)
function favoriteDeleC(hid){
	var cid = GetCookie('favoriteC');
	var id_array = cid.split(',');
	var pid = "";
	var qid = "";
	// 該当IDを削除したリスト
	for(var h in id_array){
		if(id_array[h] != 0){
			if (hid == id_array[h]) continue;
			var cid = id_array[h];
			if((cid != null)&&(cid != "")&&(cid != "0")){
				if(pid != ""){
					pid = pid + "," + cid;
					var QID = pid.replace(/,/g,":");
					qid = QID;
				}else{
					pid = cid;
					qid = pid;
				}
			}
		}
	}
	//alert(qid);
	if((qid != null)&&(qid != "")&&(qid != "0")) qid = qid + "/";

	var expire_date = new Date();
	// 有効期限を7日にする
	expire_date.setTime(expire_date.getTime() + 7*24*60*60*1000);
	
	//登録ドメイン
	var domain_add = "officetar.jp";

	//Cookie登録
	document.cookie = "favoriteC=" + pid + "; domain=" + domain_add + "; path=/; expires=" + expire_date.toGMTString();

	document.getElementById("favorAll" + hid).innerHTML = "<a href=\"javascript:void(0);\" onclick=\"favoriteAddC('" + hid + "')\" class=\"btnAlpha\"><img src=\"/img/ico_cart.png\" alt=\"お気に入りに追加\" id=\"favorC" + hid + "\" /></a>";

	//問い合わせにお気に入りを常に表示20160526
	//ヘッダ
	//document.getElementById("btn_contact03").innerHTML = "<a href=\"/inquiry/" + qid + "\"><img class=\"rollover\" src=\"/img/common/img_bnr_mailcontact.gif\" alt=\"メールでのお問い合わせ\" /></a>";
	$('#navMail').attr('href','/inquiry_f/' + qid);
	//フッタ
	document.getElementById("btn_contact02").innerHTML = "<a href=\"/inquiry_f/" + qid + "\"><img class=\"rollover\" src=\"/img/common/img_bnr_mailcontact.gif\" alt=\"メールでのお問い合わせ\" /></a>";

	var plen = (id_array.length - 1);
	document.getElementById("favorHsp").innerHTML = plen;

}
//削除関数(フロア・ビルページ新レイアウト)
function favoriteDeleBC(hid){
	var cid = GetCookie('favoriteC');
	var id_array = cid.split(',');
	var pid = "";
	var qid = "";
	// 該当IDを削除したリスト
	for(var h in id_array){
		if(id_array[h] != 0){
			if (hid == id_array[h]) continue;
			var cid = id_array[h];
			if((cid != null)&&(cid != "")&&(cid != "0")){
				if(pid != ""){
					pid = pid + "," + cid;
					var QID = pid.replace(/,/g,":");
					qid = QID;
				}else{
					pid = cid;
					qid = pid;
				}
			}
		}
	}
	//alert(qid);
	if((qid != null)&&(qid != "")&&(qid != "0")) qid = qid + "/";

	var expire_date = new Date();
	// 有効期限を7日にする
	expire_date.setTime(expire_date.getTime() + 7*24*60*60*1000);
	
	//登録ドメイン
	var domain_add = "officetar.jp";

	//Cookie登録
	document.cookie = "favoriteC=" + pid + "; domain=" + domain_add + "; path=/; expires=" + expire_date.toGMTString();

	document.getElementById("favorAll" + hid).innerHTML = "<a href=\"javascript:void(0);\" onclick=\"favoriteAddBC('" + hid + "')\" class=\"btnAlpha\"><span style=\"color:#3173B5;text-decoration:underline;position:relative;top:9px;padding-right:5px;\">お気に入りに追加</span><img src=\"/img/ico_cart.png\" alt=\"お気に入りに追加\" id=\"favorC" + hid + "\" /></a>";

	//問い合わせにお気に入りを常に表示20160526
	//ヘッダ
	//document.getElementById("btn_contact03").innerHTML = "<a href=\"/inquiry/" + qid + "\"><img class=\"rollover\" src=\"/img/common/img_bnr_mailcontact.gif\" alt=\"メールでのお問い合わせ\" /></a>";
	$('#navMail').attr('href','/inquiry_f/' + qid);
	//フッタ
	document.getElementById("btn_contact02").innerHTML = "<a href=\"/inquiry/" + qid + "\"><img class=\"rollover\" src=\"/img/common/img_bnr_mailcontact.gif\" alt=\"メールでのお問い合わせ\" /></a>";

	var plen = (id_array.length - 1);
	document.getElementById("favorHsp").innerHTML = plen;

}
//削除関数スマホver,
function favoriteDeleSP(hid){
	var cid = GetCookie('favoriteP');
	var id_array = cid.split(',');
	var pid = "";
	// 該当IDを削除したリスト
	for(var h in id_array){
		if(id_array[h] != 0){
			if (hid == id_array[h]) continue;
			var cid = id_array[h];
			if((cid != null)&&(cid != "")&&(cid != "0")){
				if(pid != ""){
					pid = pid + "," + cid;
				}else{
					pid = cid;
				}
			}
		}
	}

	var expire_date = new Date();
	// 有効期限を7日にする
	expire_date.setTime(expire_date.getTime() + 7*24*60*60*1000);
	
	//登録ドメイン
	var domain_add = "officetar.jp";

	//Cookie登録
	document.cookie = "favoriteP=" + pid + "; domain=" + domain_add + "; path=/; expires=" + expire_date.toGMTString();

	document.getElementById("favorAll" + hid).innerHTML = "<a href=\"javascript:void(0);\" onclick=\"favoriteAddSP('" + hid + "')\"><img src=\"/sp/img/common/fv_off.png\" alt=\"お気に入りに登録\" id=\"favorP" + hid + "\" /></a>";

	var plen = (id_array.length - 1);
	document.getElementById("favorHsp").innerHTML = plen;

}

function bgchange(ID,FLAG){
	if(FLAG == 1){
		$(function(){
			$('#tr'+ID+' td').each(function(){
				$(this).attr('class','hover');
			});
		});
	}
	else{
		$(function(){
			$('#tr'+ID+' td').each(function(){
				$(this).attr('class','');
			});
		});
	}
}

function togglemenu(){
	$('#wrap-globalmenu').slideToggle('fast');
	$('#globalmenu-conts').slideToggle('fast');
}

function onmousedisp(id){
	$('#'+id).css('display','block');
}
function outmousedisp(id){
	$('#'+id).css('display','none');
}

/*URLパラメータからキーを指定して値取得*/
function getParam(name, url) {
    if (!url) url = window.location.href;
    name = name.replace(/[\[\]]/g, "\\$&");
    var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
        results = regex.exec(url);
    if (!results) return null;
    if (!results[2]) return '';
    return decodeURIComponent(results[2].replace(/\+/g, " "));
}

function acordionBlock(ors,attr){
	alert(attr);
	//ors -> 1:id / 2:class
	//attr -> 属性名
	var attrb = "";
	switch(ors){
		case 1:
			attrb += '#';
			break;
		case 2:
			attrb += '.';
			break;
	}
	attrb += attr;
	alert(attrb);

	// if($(attrb).is(':hidden')){
	// 	//非表示の場合はslideDown
	// }else{

	// }

	$(attrb).slideToggle('fast');
	
}

function testfunction(str){
	alert(str);
}

