<?
$SES_MEMBER_ID          = $this->session->userdata('C_Member_Id');
?>
<link rel="stylesheet" type="text/css" href="/css/web/imgcss.css"/>


	<div class="contents">
		<div class="s_wrap">
			<div id="search" style="border-bottom:0 !important; padding-bottom:0px !important">
				<div class="search_images">
					<div class="search_cate" style="margin:0 0 0 20px">
						이미지  <span class="search_num"><?=number_format($total_count)?>건</span>
					</div>
					<section class="image-grid"></section>
				</div>
			</div>
		</div>
	</div>



<script>
<? if($total_count <= $limit) {?>
	var more_yn = 'N';
<?} else {?>
	var more_yn = 'Y';
<?}?>
$(document).ready(function () {
  $(document).scroll(function() {
    var maxHeight = $(document).height();
    var currentScroll = $(window).scrollTop() + $(window).height();
    if (maxHeight <= currentScroll + 100) {
        if(more_yn=='Y') {
            get_img_list();
        }
    }
  })
});


var img_list_page = 1;
function get_img_list() {
	var form_data = {
		"page"              : img_list_page,
		"search_keyword"    : "<?=$search_keyword?>"
	};
	$.ajax({
		url: '/web/search/image_list_more',
		async: false,
		type: 'POST',
		dataType: 'HTML',
		data: form_data,
		success: function (rtnHtml) {
			var arrHtml = rtnHtml.split("|||||");
			if(arrHtml[0].trim()=='0000') {
				more_yn = arrHtml[2];
				if (arrHtml[1] != "") {
					$('.image-grid').append(arrHtml[1]);
					img_list_page++;
				}
			}
		},
		error: function (rtnHtml) {
			alert('데이터 로드에 실패했습니다.');
			return false;
		}
	});

}

get_img_list();

$(document).ready(function(){

	$('.smalls').click(function(){
	  var tmp = $(this).parent()
		  if (tmp.attr('class') == 'imms') {
			  $('.imms').removeClass('act');
			  tmp.addClass('act');
		  }else{
			  tmp.removeClass('act');
		  }
	});
	$('.omm_a2').click(function(){
	  var tmp = $(this).parent().parent()
		  if (tmp.attr('class') == 'omgg_ul1') {
			  tmp.addClass('act');
		  }else{
			  tmp.removeClass('act');
		  }
	});
	$('.omm_c').click(function(){
	  	$('.omgg_ul1').removeClass('act');
	});
	
	
	$('.ommbtn').click(function() {
	  var tmp1 = $(this).parent().parent()
	  if ($tmp1.hasClass('is-collapsed')) {
		$('html, body').animate({ scrollTop : $(this).offset().top}, 300);
		//return true;
	  } else {
		$tmp1.removeClass('is-expanded').addClass('is-collapsed');
	  }
	});
	
	
});

var $cell = $('.image__cell');
function thumb_img_click(t){
	var $thisCell = $(t).closest('.image__cell');
  	if ($thisCell.hasClass('is-collapsed')) {
    	$cell.not($thisCell).removeClass('is-expanded').addClass('is-collapsed');
    	$thisCell.removeClass('is-collapsed').addClass('is-expanded');
		$('html, body').animate({ scrollTop : $(t).offset().top}, 300);
  	} else {
    	$thisCell.removeClass('is-expanded').addClass('is-collapsed');
	}
}

function img_view_change(num){
	var $thisCell = $("#img_item"+num).closest('.image__cell');
  	if ($thisCell.hasClass('is-collapsed')) {
    	$cell.not($thisCell).removeClass('is-expanded').addClass('is-collapsed');
    	$thisCell.removeClass('is-collapsed').addClass('is-expanded');
		$('html, body').animate({ scrollTop : $(t).offset().top}, 300);
  	} else {
    	$thisCell.removeClass('is-expanded').addClass('is-collapsed');
	}
}

function img_view_close(t){
	var $thisCell = $(t).closest('.image__cell');
  	$thisCell.removeClass('is-expanded').addClass('is-collapsed');
}
</script>