is_dong_click=0;
is_danzi_click=0;
is_subway_click=0;
$(document).ready(function(){
	auto=0;
	
		//키워드
	$(function() {
		$( "#keyword" ).autocomplete({
			autoFocus: true,
			delay:30,
			source: function( request, response ) {
				$.ajax( {
					url: "/address/get_address_json",
					dataType: "json",
					data: {
					term: request.term
				},
				success: function( data ) {
						response( data );
					}
				} );
			},focus: function(event,ui) {
				//event.preventDefault();
				return false;
			},
			select: function( event, ui ) {
				if($("#keyword").val()){
					$("#keyword").val( ui.item.title );
				}
				if(ui.item.id){
					if(ui.item.type=='address' || ui.item.type=='address_gugun'){
						//자동완성으로 group by 된 동의 첫번째 동 값이 넘어오면 동을 구값으로 바꿔서 검색한다
						if(ui.item.type=='address_gugun'){
							$('#address_id').val('gugun'+ui.item.gugun_id);
						} else {
															$('#address_id').val(ui.item.id);
													}
						$('#sido_id').val('');
						$('#gugun_id').val('');
						$('#dong_id').val('');
					} else {
						$('#subway_id').val(ui.item.id);
					}


					$('#lat').val(ui.item.lat);
					$('#lng').val(ui.item.lng);
					auto=1;
					
					lat=ui.item.lat
					lng=ui.item.lng;
					setCookie('lat',lat,7);
					setCookie('lng',lng,7);
					
										setCookie('level',6,7);
															$('#form_search').submit();
					return false;
				} 
			}, close:function(){
								//$('#address_id').val(0);
				//$('#subway_id').val(0);
								
			}, open:function(event, ui){
				
			}, change: function (event, ui) {
				
			}
		}).autocomplete( "instance" )._renderItem = function( ul, item ) {
			return $( "<li>" )
			.append( item.title )
			.appendTo( ul );
		};
	});
	

	$(function(){
		$('#form_search').ajaxForm({
			beforeSerialize: function(){
												 

							},
			beforeSubmit: function(){ 
				keyword=$('#keyword').val();
				if(keyword){
					var isFiveDigits = /^\d{5}$/.test(keyword);
					if($.isNumeric(keyword) && isFiveDigits){
												$.post('/item/item_chk',{id:keyword},function(data){
							if(data){
																	location.href='/item/view/'+keyword;
																
								return false;
							} else {
								alert('해당 번호의 매물이 없습니다.');
								return false;
							}
						})
						return false;
											} 
				} else {
										$('#address_id').val('');
					$('#subway_id').val('');
										$('#lat').val('');
					$('#lng').val('');
				}
			}, success: function(search_position){
				

				$('#map_list_panel').scrollTop(0);
				if(search_position=='main'){
											location.href='/search';
									} else if(search_position=='map'){
					get_position();
									} else if(search_position=='grid'){
					get_grid();
				} else if(search_position=='admin_item'){
					if($('#item_admin_type').val()){
													location.href='/admin_item/item/1?item_admin_type='+$('#item_admin_type').val();
												
					} else {
													location.href='/admin_item/item/1';
												
					}
				}
			}
		});
	});


	//정렬
	$('.btn_align').click(function(){
		align=$(this).data('type');
		if($(this).data('type')=='price_low' ){
			align='price_high';
			$(this).data('type','price_high');
			$(this).children('.indicator_price').html('↑');
		} else if($(this).data('type')=='price_high') {
			align='price_low';
			$(this).data('type','price_low');
			$(this).children('.indicator_price').html('↓');
		}
		if($(this).data('type')=='area_low' ){
			align='area_high';
			$(this).data('type','area_high');
			$(this).children('.indicator_area').html('↑');
		} else if($(this).data('type')=='area_high') {
			align='area_low';
			$(this).data('type','area_low');
			$(this).children('.indicator_area').html('↓');
		}

		if($(this).data('type')=='current_low' ){
			align='current_high';
			$(this).data('type','current_high');
			//$(this).children('.indicator_current').html('↑');
		} else if($(this).data('type')=='current_high') {
			align='current_low';
			$(this).data('type','current_low');
			//$(this).children('.indicator_current').html('↓');
		}
		
		if($(this).data('type')=='jegebal_type_low' ){
			align='jegebal_type_high';
			$(this).data('type','jegebal_type_high');
			$(this).children('.indicator_area').html('↑');
		} else if($(this).data('type')=='jegebal_type_high') {
			align='jegebal_type_low';
			$(this).data('type','jegebal_type_low');
			$(this).children('.indicator_area').html('↓');
		}
		if($(this).data('type')=='jegebal_gamjung_low' ){
			align='jegebal_gamjung_high';
			$(this).data('type','jegebal_gamjung_high');
			$(this).children('.indicator_area').html('↑');
		} else if($(this).data('type')=='jegebal_gamjung_high') {
			align='jegebal_gamjung_low';
			$(this).data('type','jegebal_gamjung_low');
			$(this).children('.indicator_area').html('↓');
		}

		if($(this).data('type')=='jegebal_premium_low' ){
			align='jegebal_premium_high';
			$(this).data('type','jegebal_premium_high');
			$(this).children('.indicator_area').html('↑');
		} else if($(this).data('type')=='jegebal_premium_high') {
			align='jegebal_premium_low';
			$(this).data('type','jegebal_premium_low');
			$(this).children('.indicator_area').html('↓');
		}
		if($(this).data('type')=='jegebal_insu_low' ){
			align='jegebal_insu_high';
			$(this).data('type','jegebal_insu_high');
			$(this).children('.indicator_area').html('↑');
		} else if($(this).data('type')=='jegebal_insu_high') {
			align='jegebal_insu_low';
			$(this).data('type','jegebal_insu_low');
			$(this).children('.indicator_area').html('↓');
		}

		$('input[name="align"]').val(align);
		$('#form_search').submit();
		$('html').scrollTop(0);
	})
	//매물종류
		$('#category').on('change',function(){
		$('#form_search').submit();
	})
					
	//테마
		$('#theme').on('change',function(){
		$('#form_search').submit();
	})
	
	//테마서브
		$('#theme_sub').on('change',function(){
		$('#form_search').submit();
	})
	
	//테마서브
		$('#theme_sub2').on('change',function(){
		$('#form_search').submit();
	})
	
	//지역바로가기
				
	//지하철호선
		$('#subway_line').on('change',function(){
		$('#form_search').submit();
	})
	
	//추가선택항목
		$('#optional_select').on('change',function(){
		
		$('#form_search').submit();
	})
	
	//방, 화장실, 층
		$('#room').on('change',function(){
		
		$('#form_search').submit();
	})
	$('#floor').on('change',function(){
		
		$('#form_search').submit();
	})
	$('#label').on('change',function(){
		$('#form_search').submit();
	})
	$('#elev').on('change',function(){
		$('#form_search').submit();
	})
	$('#land_use').on('change',function(){
		$('#form_search').submit();
	})
	$('#land_aim').on('change',function(){
		$('#form_search').submit();
	})
	$('#build_use').on('change',function(){
		$('#form_search').submit();
	})
	$('#bath').on('change',function(){
		
		$('#form_search').submit();
	})
	$('#search_image_item').on('change',function(){
		
		$('#form_search').submit();
	})
	
	
	//검색항목 셋팅
	function price_search_set(type){
		$('.price_search').hide();
		if(type=='inst'){
			$('.price_search_'+'real').show();
		}
		if(type=='month_rent'){
			$('.price_search_'+'month_deposit').show();
			$('.price_search_'+'premium').show();
		}
		if(type=='sagul'){
			$('.price_search_'+'sagul_deposit').show();
		}
		$('.price_search_'+type).show();
		
					}

	price_search_set('');

	//거래유형
	$('.types').click(function(){
		if($(this).hasClass('active')){
			$(this).removeClass('active');
			types=0;
			$('.types').removeClass('active');
			$('#type').val('none');
		} else {
			$('.types').removeClass('active');
			types=$(this).data('type');
			$(this).addClass('active');	
			$('#type').val(types);
		}
		
		if(types){
			price_search_set(types);
			$('#trigger_type').selectpicker('val','btn_type_'+types);
		} else {
			$('#trigger_type').selectpicker('val','');
			$('.price_search').hide();
					}
					$('#form_search').submit();
				$('html').scrollTop(0);
	})
	//거래유형
	$('#type').on('change',function(){
		price_search_set($(this).val());
					$('#form_search').submit();
			})

	//드랍다운 토글 유지
	$('.price_drop_box, .area_drop_box').on({
		"click":function(e){
			e.stopPropagation();
		}
	});	

	//금액검색창
			$('.price_start').click(function(){
			$('#price_'+$(this).data('type')+'_start').val($(this).data('val'));
			$('.start_'+$(this).data('type')).html($(this).html());
			$('.price_start.li_'+$(this).data('type')).removeClass('active');
			$(this).addClass('active');
						$('#form_search').submit();
					})
		$('.price_end').click(function(){
			$('#price_'+$(this).data('type')+'_end').val($(this).data('val'));
			$('.end_'+$(this).data('type')).html($(this).html());
			$('.price_end.li_'+$(this).data('type')).removeClass('active');
			$(this).addClass('active');
						$('#form_search').submit();
					})
		$('.price_search_box').on('keyup',function(){
			$('.'+$(this).data('type')).html($(this).val()+$(this).data('unit'));
						$('#form_search').submit();
					})
	
	//면적검색창
		$('.area_start').click(function(){
		$('#'+$(this).data('type')+'_start').val($(this).data('val'));
		$('.start_'+$(this).data('type')).html($(this).html());
		$('.area_start.li_'+$(this).data('type')).removeClass('active');
		$(this).addClass('active');
				$('#form_search').submit();
			})
	$('.area_end').click(function(){
		$('#'+$(this).data('type')+'_end').val($(this).data('val'));
		$('.end_'+$(this).data('type')).html($(this).html());
		$('.area_end.li_'+$(this).data('type')).removeClass('active');
		$(this).addClass('active');
				$('#form_search').submit();
			})
	$('.area_search_box').on('keyup',function(){
		$('.'+$(this).data('type')).html($(this).val()+$(this).data('unit'));
				$('#form_search').submit();
			})
	
	//모바일검색
	$('.mobile_search_btn').click(function(){
		if($(this).hasClass('active')){
			
			$('#grid_list').show();
			$('html').css('position','relative');

			$('.search_console').hide();
			$(this).removeClass('active');
		} else {
			
			$('#grid_list').hide();
			$('html').css('position','fixed');

			$('.search_console').show();
			$(this).addClass('active');
		}
	})

	//멀티셀렉트
	setTimeout(function(){
		$('#category').each(function(){
			$('#category').selectpicker({
			  noneResultsText : '매칭된 단어가 없습니다.',
			  noneSelectedText: '매물 종류',
				countSelectedText: function (numSelected, numTotal) {
					return "매물 종류 <div class='badge'>{0}</div>";
				},
			});
		})
	})
	
	$('#category_main').selectpicker({
	  noneSelectedText: '매물 종류',
		countSelectedText: function (numSelected, numTotal) {
			return "매물 종류 <div class='badge'>{0}</div>";
		},
	});
	$('#theme_main').selectpicker({
	  noneSelectedText: '테마',
		countSelectedText: function (numSelected, numTotal) {
			return "테마 <div class='badge'>{0}</div>";
		},
	});

	$('#categories').each(function(){
		$('#categories').selectpicker({
		  noneSelectedText: '카테고리',
			countSelectedText: function (numSelected, numTotal) {
				return "카테고리 <div class='badge'>{0}</div>";
			},
		});
	})
	$('#theme').each(function(){
		$('#theme').selectpicker({
		  noneSelectedText: '테마',
			countSelectedText: function (numSelected, numTotal) {
				return "테마 <div class='badge'>{0}</div>";
			},
		});
	})
	$('#theme_sub').each(function(){
		$('#theme_sub').selectpicker({
		  noneSelectedText: '테마서브',
			countSelectedText: function (numSelected, numTotal) {
				return "테마서브 <div class='badge'>{0}</div>";
			},
		});
	})
	$('#theme_sub2').each(function(){
		$('#theme_sub2').selectpicker({
		  noneSelectedText: '테마서브',
			countSelectedText: function (numSelected, numTotal) {
				return "테마서브 <div class='badge'>{0}</div>";
			},
		});
	})
	$('#room').each(function(){
		$('#room').selectpicker({
		  noneSelectedText: '방',
			countSelectedText: function (numSelected, numTotal) {
				return "방 <div class='badge'>{0}</div>";
			},
		});
	})
	$('#floor').each(function(){
		$('#floor').selectpicker({
		  noneSelectedText: '층수',
			countSelectedText: function (numSelected, numTotal) {
				return "층수 <div class='badge'>{0}</div>";
			},
		});
	})
	$('#label').each(function(){
		$('#label').selectpicker({
		  noneSelectedText: '라벨',
			countSelectedText: function (numSelected, numTotal) {
				return "라벨 <div class='badge'>{0}</div>";
			},
		});
	})
	$('#elev').each(function(){
		$('#elev').selectpicker({
		  noneSelectedText: '엘리베이터',
			countSelectedText: function (numSelected, numTotal) {
				return "엘리베이터 <div class='badge'>{0}</div>";
			},
		});
	})
	$('#land_use').each(function(){
		$('#land_use').selectpicker({
		  noneSelectedText: '용도지역',
			countSelectedText: function (numSelected, numTotal) {
				return "용도지역 <div class='badge'>{0}</div>";
			},
		});
	})
	$('#land_aim').each(function(){
		$('#land_aim').selectpicker({
		  noneSelectedText: '지목',
			countSelectedText: function (numSelected, numTotal) {
				return "지목 <div class='badge'>{0}</div>";
			},
		});
	})
	$('#build_use').each(function(){
		$('#build_use').selectpicker({
		  noneSelectedText: '건축물용도',
			countSelectedText: function (numSelected, numTotal) {
				return "건축물용도 <div class='badge'>{0}</div>";
			},
		});
	})
	$('#bath').each(function(){
		$('#bath').selectpicker({
		  noneSelectedText: '화장실',
			countSelectedText: function (numSelected, numTotal) {
				return "화장실 <div class='badge'>{0}</div>";
			},
		});
	})
	$('#search_image_item').each(function(){
		$('#bath').selectpicker({
		  noneSelectedText: '사진유무',
			countSelectedText: function (numSelected, numTotal) {
				return "사진유무 <div class='badge'>{0}</div>";
			},
		});
	})
	
	$('#location_id').each(function(){
		$('#location_id').selectpicker({
		  noneSelectedText: '위치',
			countSelectedText: function (numSelected, numTotal) {
				return "위치 <div class='badge'>{0}</div>";
			},
		});
	})
	$('#type').each(function(){
		$('#type').selectpicker({
		  noneSelectedText: '거래 유형',
			countSelectedText: function (numSelected, numTotal) {
				return "거래 유형 <div class='badge'>{0}</div>";
			},
		});
	})
	$('#subway_line').each(function(){
		$('#subway_line').selectpicker({
		  noneSelectedText: '호선 검색',
			countSelectedText: function (numSelected, numTotal) {
				return "호선 검색 <div class='badge'>{0}</div>";
			},
		});
	})

	$('#optional_select').each(function(){
		$('#optional_select').selectpicker({
		  noneSelectedText: '추가입력항목',
			countSelectedText: function (numSelected, numTotal) {
				return "추가입력항목 <div class='badge'>{0}</div>";
			},
		});
	})
  

	//2차매물종류 
	setTimeout(function(){
		$('.category_main').click(function(){
							if($(this).parent().hasClass('selected')){
					$('#category option[data-parent_id="'+$(this).data('tokens').replace(/\[.*?\]/g, '')+'"]').prop('selected',''); 
					$('.category_sub_'+$(this).data('tokens').replace(/\[.*?\]/g, '')).parent().removeClass('selected');

					if($('.banner_category[data-category_id='+$(this).data('tokens').replace(/\[.*?\]/g, '')+']').hasClass('active')){
						$('.banner_category[data-category_id='+$(this).data('tokens').replace(/\[.*?\]/g, '')+']').removeClass('active');
					} else {
						$('.banner_category[data-category_id='+$(this).data('tokens').replace(/\[.*?\]/g, '')+']').addClass('active');
					}

				} else {
					if($('.banner_category[data-category_id='+$(this).data('tokens').replace(/\[.*?\]/g, '')+']').hasClass('active')){
						$('.banner_category[data-category_id='+$(this).data('tokens').replace(/\[.*?\]/g, '')+']').removeClass('active');
					} else {
						$('.banner_category[data-category_id='+$(this).data('tokens').replace(/\[.*?\]/g, '')+']').addClass('active');
					}

					$('#category option[data-parent_id="'+$(this).data('tokens').replace(/\[.*?\]/g, '')+'"]').prop('selected','selected'); 
					$('.category_sub_'+$(this).data('tokens').replace(/\[.*?\]/g, '')).parent().addClass('selected');	
				}
					})
		$('.c_sub').click(function(){
			if($('.category_main_'+$(this).data('tokens').replace(/\[.*?\]/g, '').replace('s_','')).parent().hasClass('selected')){ //부모가 선택되어있으면
				$('#category option[data-tokens="'+$(this).data('tokens').replace(/\[.*?\]/g, '').replace('s_','')+'"]').prop('selected',''); 
				$('.category_main_'+$(this).data('tokens').replace(/\[.*?\]/g, '').replace('s_','')).prop('selected','').parent().removeClass('selected');	
			} 
		})

		$('.theme_main').click(function(){
			if($(this).parent().hasClass('selected')){
				if($('.banner_theme[data-theme_id='+$(this).data('tokens')+']').hasClass('active')){
					$('.banner_theme[data-theme_id='+$(this).data('tokens')+']').removeClass('active');	
				} else {
					$('.banner_theme[data-theme_id='+$(this).data('tokens')+']').addClass('active');	
				}
			} else {
				if($('.banner_theme[data-theme_id='+$(this).data('tokens')+']').hasClass('active')){
					$('.banner_theme[data-theme_id='+$(this).data('tokens')+']').removeClass('active');	
				} else {
					$('.banner_theme[data-theme_id='+$(this).data('tokens')+']').addClass('active');	
				}
			}
		})
		$('.theme_main_sub').click(function(){
			if($(this).parent().hasClass('selected')){
				if($('.banner_theme_sub[data-theme_sub_id='+$(this).data('tokens')+']').hasClass('active')){
					$('.banner_theme_sub[data-theme_sub_id='+$(this).data('tokens')+']').removeClass('active');	
				} else {
					$('.banner_theme_sub[data-theme_sub_id='+$(this).data('tokens')+']').addClass('active');	
				}
			} else {
				if($('.banner_theme_sub[data-theme_sub_id='+$(this).data('tokens')+']').hasClass('active')){
					$('.banner_theme_sub[data-theme_sub_id='+$(this).data('tokens')+']').removeClass('active');	
				} else {
					$('.banner_theme_sub[data-theme_sub_id='+$(this).data('tokens')+']').addClass('active');	
				}
			}
		})
		$('.theme_main_sub2').click(function(){
			if($(this).parent().hasClass('selected')){
				if($('.banner_theme_sub2[data-theme_sub2_id='+$(this).data('tokens')+']').hasClass('active')){
					$('.banner_theme_sub2[data-theme_sub2_id='+$(this).data('tokens')+']').removeClass('active');	
				} else {
					$('.banner_theme_sub2[data-theme_sub2_id='+$(this).data('tokens')+']').addClass('active');	
				}
			} else {
				if($('.banner_theme_sub2[data-theme_sub2_id='+$(this).data('tokens')+']').hasClass('active')){
					$('.banner_theme_sub2[data-theme_sub2_id='+$(this).data('tokens')+']').removeClass('active');	
				} else {
					$('.banner_theme_sub2[data-theme_sub2_id='+$(this).data('tokens')+']').addClass('active');	
				}
			}
		})
	})
	

	//슬라이더
	$('.range').each(function(){
		if($(this).data('type')=='month_deposit'){
			step=1000;
		} else if($(this).data('type')=='month_rent'){
			step=50;
		} else if($(this).data('type')=='inst'){
			step=1;
		} else if($(this).data('type')=='real'){
			step=100;
		} else if($(this).data('type')=='sell'){
			step=1;
		} else if($(this).data('type')=='full_rent'){
			step=1000;
		} else {
			step=10;
		}
		if($(this).data('end')){
			end_val=$(this).data('end');
		} else {
			end_val=$(this).data('val');
		}
		$( '.range_'+$(this).data('type') ).slider({
			range: true,
			min: 0,
			max: $(this).data('val'),
			step:step,
			values: [ $(this).data('start'), end_val ],
			slide: function( event, ui ) {
				$( "#price_"+$(this).data('type')+"_start").val(ui.values[0]);
				$( "#price_"+$(this).data('type')+"_end").val(ui.values[1]);
				$( "#"+$(this).data('type')+"_start").val(ui.values[0]);
				$( "#"+$(this).data('type')+"_end").val(ui.values[1]);
				$( ".start_"+$(this).data('type')).html(ui.values[0]+$(this).data('unit'));
				$( ".end_"+$(this).data('type')).html(ui.values[1]+$(this).data('unit'));
			},
			stop:function(){
				$('#form_search').submit();
			}
		});
	})

	//매물종류 트리거
	$(function(){
		trigger_category=[];
		$('.trigger_category.active').each(function(){
			trigger_category.push($(this).data('id'));
		})
		$('.trigger_category').click(function(){
			if($(this).hasClass('active')){
				$(this).removeClass('active');
				//trigger_category.pop($(this).data('id'));
			} else {
				$(this).addClass('active');
				//trigger_category.push($(this).data('id'));
			}
			trigger_category=[];
			$('.trigger_category.active').each(function(){
				trigger_category.push($(this).data('id'));
			})
			
			$('#category').val(trigger_category);
			
			$('#form_search').submit();
		})
	})

	
	//테마 트리거
	$(function(){
		trigger_theme=[];
		$('.trigger_theme.active').each(function(){
			trigger_theme.push($(this).data('id'));
		})
		$('.trigger_theme').click(function(){
			if($(this).hasClass('active')){
				$(this).removeClass('active');
				//trigger_theme.pop($(this).data('id'));
			} else {
				$(this).addClass('active');
				//trigger_theme.push($(this).data('id'));
			}
			trigger_theme=[];
			$('.trigger_theme.active').each(function(){
				trigger_theme.push($(this).data('id'));
			})
			$('#theme').val(trigger_theme);
			$('#form_search').submit();
		})
	})
	//테마 트리거
	$(function(){
		trigger_theme_sub=[];
		$('.trigger_theme_sub.active').each(function(){
			trigger_theme_sub.push($(this).data('id'));
		})
		$('.trigger_theme_sub').click(function(){
			if($(this).hasClass('active')){
				$(this).removeClass('active');
				//trigger_theme_sub.pop($(this).data('id'));
			} else {
				$(this).addClass('active');
				//trigger_theme_sub.push($(this).data('id'));
			}
			trigger_theme_sub=[];
			$('.trigger_theme_sub.active').each(function(){
				trigger_theme_sub.push($(this).data('id'));
			})
			$('#theme_sub').val(trigger_theme_sub);
			
			$('#form_search').submit();
		})
	})
	//테마 트리거
	$(function(){
		trigger_theme_sub2=[];
		$('.trigger_theme_sub2.active').each(function(){
			trigger_theme_sub2.push($(this).data('id'));
		})
		$('.trigger_theme_sub2').click(function(){
			if($(this).hasClass('active')){
				$(this).removeClass('active');
				//trigger_theme_sub2.pop($(this).data('id'));
			} else {
				$(this).addClass('active');
				//trigger_theme_sub2.push($(this).data('id'));
			}
			trigger_theme_sub2=[];
			$('.trigger_theme_sub2.active').each(function(){
				trigger_theme_sub2.push($(this).data('id'));
			})
			$('#theme_sub2').val(trigger_theme_sub2);
			
			$('#form_search').submit();
		})
	})

	

})

function search_reset(){
	$('.banner_category').removeClass('active');
	$('.banner_theme').removeClass('active');
	$('.banner_theme_sub').removeClass('active');
	$('.banner_theme_sub2').removeClass('active');
	
	$('.types.active').click();
	$('#keyword').val('');
	$('#category').val('');
	$('#category').selectpicker('refresh');
	
	
	$('#theme').val('');
	$('#theme').selectpicker('refresh');
	$('#theme_sub').val('');
	$('#theme_sub').selectpicker('refresh');
	$('#theme_sub2').val('');
	$('#theme_sub2').selectpicker('refresh');

	$('.theme_main').removeClass('active');

	$('#room').val('');
	$('#room').selectpicker('refresh');
	$('#floor').val('');
	$('#floor').selectpicker('refresh');
	$('#label').val('');
	$('#label').selectpicker('refresh');
	$('#elev').val('');
	$('#elev').selectpicker('refresh');
	$('#land_use').val('');
	$('#land_use').selectpicker('refresh');
	$('#land_aim').val('');
	$('#land_aim').selectpicker('refresh');
	$('#build_use').val('');
	$('#build_use').selectpicker('refresh');
	$('#bath').val('');
	$('#bath').selectpicker('refresh');
	$('#search_image_item').val('');
	$('#search_image_item').selectpicker('refresh');
	$('#location_id').val('');
	$('#location_id').selectpicker('refresh');
	$('#type').val('');
	$('#type').selectpicker('refresh');
	$('.price_search_box').val('');
	$('.price_search').hide();
	$('.area_search_box').val('');
	$('#sido_id').val('');
	$('#subway_line').val('');
	$('#subway_line').selectpicker('refresh');
	$('#is_random_marker').val('');
	$('#is_random_marker').selectpicker('refresh');
	$('#optional_select').val('');
	$('#optional_select').selectpicker('refresh');
	$('#gugun_id').val('');
	$('#dong_id').val('');
	$('#member_id').val('');
	$('#member_id').selectpicker('refresh');
	$('#owner_id').val('');
	$('#owner_id').selectpicker('refresh');
	$('#biz_id').val('');
	$('#biz_id').selectpicker('refresh');
	$('#is_finish').val('');
	$('#is_finish').selectpicker('refresh');
	$('#is_public').val('');
	$('#is_public').selectpicker('refresh');
	$('#expire_date').val('');
	$('#expire_date').selectpicker('refresh');
	$('#build_date').val('');
	$('#build_date').selectpicker('refresh');
	$('#expire_date').val('');
	$('#expire_date').selectpicker('refresh');
	$('#build_check').val('');
	$('#build_check').selectpicker('refresh');
	$('#build_confirm').val('');
	$('#build_confirm').selectpicker('refresh');
	//$('#jegebal').val('');
	//$('#jegebal').selectpicker('refresh');
	$('#search_danzi').val('');
	$('#search_danzi').selectpicker('refresh');
	$('.val_zone_start').html('0');
	$('.start_area_law, .start_area_real').html('0py');
	
	$('.val_zone_end').html('무제한');
	$('#map_item').hide();
	is_dong_click=0;
	is_subway_click=0;
	is_danzi_click=0;

	
		
	$('#form_search').submit();
}

function mobile_search(type){
	if(type==1){
		$('#form_search').submit();
		
		/*if( !$('#address_id').val() && !$('#subway_id').val() && $('#keyword').val() ){
			location.href='/search/direct/grid/?keyword='+$('#keyword').val();
		}*/
	} else {
			}
	$('#grid_list').show();
	$('html').css('position','relative');
	$('.mobile_search_btn').removeClass('active');
}


$(document).ready(function(){
		$('#dong_id').html('<option value="">읍/면/동</option>');
	$('#sido_id').on('change',function(){
		$.post('/address/get_gugun',{sido_id:$('#sido_id').val()},function(data){
			$('#gugun_id').html(data);
		})
		if(!$(this).val()){
			$('#dong_id').html('<option value="">읍/면/동</option>');
		}
			})

	$('#gugun_id').on('change',function(){
		$.post('/address/get_dong',{gugun_id:$('#gugun_id').val()},function(data){
			$('#dong_id').html(data);
		})
	})

									})



$(function(){
	$('.drop_box').click(function(e){
		e.stopPropagation(); 
		if($(this).next('.drop_box_content').hasClass('hide')){
			$('.open').click();
			$(this).next('.drop_box_content').removeClass('hide');
		} else {
			$(this).next('.drop_box_content').addClass('hide');
		}
	})
	$(document).click(function(e) {
		if (!$(e.target).closest('.drop_box').length) {
			$('.drop_box_content').addClass('hide');
		}
	});
	$('.dropdown-toggle').click(function(e) {
		$('.drop_box_content').addClass('hide');
	})
})
				