// JavaScript Document
$(function(){
	var ids = new Array();
	if($.cookie('estate_id')){
		ids = $.cookie('estate_id').split(",");
	}
	$.each(ids, function() {
		var obj_id = "#est_check_"+this;
		$(obj_id).attr("checked","checked");
	});
	$(".est_check").click(function(){
		var chk_id = this.value;
		if(this.checked){
			ids.push(chk_id);
		}else{
			ids = $.grep(ids, function(n,i){ return n != chk_id; });
		}
		$.cookie('estate_id',ids,{ path:'/' });//書き込み{保存days}
	});
});
function pop_img(id,num){
	w = window.open("pop_img.php?id="+id+"&num="+num, "IMAGE", "width=700,height=500,resizable=yes,scrollbars=yes");
}

function change_view(obj_id){
	var obj = document.getElementById(obj_id);
	if(obj.style.display == 'none'){
		obj.style.display = 'block';
	}else{
		obj.style.display = 'none';
	}
}

function getCnt(pref_id,type,appdend_id){
	var tobj = "#"+appdend_id;
	if($(tobj).css("display") == "none"){
		$(tobj).css("display","block");
		var mess = "データ取得中です。";//$("<img src='./img/load.gif'>");
		$(tobj).append(mess);
		var pdata = 'pref_id='+pref_id+'&type='+type;
		$.ajax({
			url: 'http://zero-town.net/json/get_cnt.php',
			data: pdata,
			cache: false,
			dataType: 'jsonp',
			timeout: 3000,
			error: function(){
				$(tobj).empty();
				var mess = "データが取得できませんでした。";
				$(tobj).append(mess);
			},
			success: function(html){
				$(tobj).empty();
				$(tobj).append(html.mess);
			}
		});
	}else{
		$(tobj).css("display","none");
	}
}
