// load cases for list_store

function loadthisstorecases(store_id) {
	
	//cleanup
	
	$('div#container>div#contents>div#case_detail_right>div#case_detail_contents').empty();
	$('div#store_title').css('background','url(../images/store_title'+zeroformat(store_id,2)+'.jpg)');
	
	$.getJSON('../js/famis_case.json', function(cases){
		
		$.each( cases , function ( idx,obj ) {
		
		  if ( obj.store_id == store_id ){
			
			
			//各chipのhtmlを生成
			obj.title = obj.title.replace(/\[br\]/i,'<br />');
			if(obj.space){ obj.space = obj.space + 'm<sup>2</sup>'; }
			
			var caseid = zeroformat(obj.case_id,3);
			var imghtml = '<a href="../case/case_designer' + caseid + '.html"><img class="casechip_ph_l" src="../images/case/caselist_photo_' + caseid + '.jpg" /></a>';
			var ownerdata = obj.case_country + '・' + obj.owner + '<br />' + obj.family + '&nbsp;' + obj.space + '<br />デザイナー：' + obj.d_name+ '<br />ご予算：' + obj.budget + '万円';
			
			var chiplink = imghtml + 
			'<div class="casechip_l_title"><a href="../case/case_designer' + caseid + '.html">' + obj.title + '</a></div>' + 
			'<div class="casechip_l_data">' + ownerdata + '</div><a href="../case/case_designer' + caseid + '.html" class="casechip_button_gotodetail hd">詳細を見る</a>';
			
			$('<div></div>')
			.addClass('casechip_l')
			.addClass('fbox')
			.html(chiplink)
			.prependTo('div#container>div#contents>div#case_detail_right>div#case_detail_contents');
			

			if (obj.title.indexOf('<br \/>') != -1) {
				$('div#container>div#contents>div#case_list>div#case_base>div.casechip_s:first>div.casechip_s_title').addClass('twoline');
			}
		
		  }
		
		} );
	
	});
	
	
}

function zeroformat(num, n){
	// ZeroFormat(1,3) => "001"
	var ret=""+num;
	while(ret.length < n){
		ret = "0" + ret;
	}
return (ret);
}