var co_MAX_COUNT = 20;
function co_showPhotoList(latitude, longitude, to) {
	//"popularity:upload_date";
	var order = "popularity";
	// "public:full:user ID number ";
	var set = "public";
	var size = "small";
	var minx,miny,maxx,maxy;
	var epsilon = 0.01;
	minx = sumTude(longitude, epsilon*-1);
	maxx = sumTude(longitude, epsilon*1);
	miny = sumTude(latitude, epsilon*-1);
	maxy = sumTude(latitude, epsilon*1);

	if (to == "") {
		to = 20;
	}

	var json_url = "http://www.panoramio.com/map/get_panoramas.php?order="+order+"&set="+set+"&from=0&to="+to+"&minx="+minx+"&miny="+miny+"&maxx="+maxx+"&maxy="+maxy+"&size="+size+"&callback=?";

	$.getJSON(json_url, function(json, status){
		var obuff = "";
		var cnt = 0;
		var mR10 = "";
		if (json.count > 0) {
			for (i in json.photos) {
				// 4個でDIVを改行
				if (cnt == 4) {
					cnt = 0;
				}

				if (cnt % 4 < 3) {
					// 1段4件の1番右以外の表示
					mR10 = "mR10 ";
				} else {
					mR10 = "";
				}

				obuff += "<li class=\"fl w220 bdLGreen " + mR10 + "fs12 mT10\">";
				obuff += mkDiv(json.photos[i]);
				obuff += "</li>";
				cnt++
			}
			$("#co_photo").html(obuff);
		} else {
			obuff = "<div class=\"co_photo_area\">";
			obuff += "<img src=\"/images/parts/co_no_image_panoramio.jpg\" alt=\"登録されている画像がありません\" />";
			obuff += "</div>";
			$("#co_photo").html(obuff);
		}
		// panoramio thickbox
		tb_init('a.thickbox, area.thickbox, input.thickbox');//pass where to apply thickbox
		imgLoader = new Image();// preload image
		imgLoader.src = tb_pathToImage;
	});
}
//	lstImg["longitude"]
//	lstImg["latitude"]
//	lstImg["width"]
//	lstImg["height"]
//	lstImg["owner_id"]
function mkDiv(lstImg) {
	if (lstImg["photo_title"] === false) lstImg["photo_title"] = "no title";
	var refDIV = "<ul>";
	refDIV += "<li class=\"bgLGreen fgGreen taC p10\">" + lstImg["photo_title"] + "</li>";
	refDIV += "<li class=\"p10\">";
	refDIV += "<div class=\"taC\"><a href=\"http://static.panoramio.com/photos/original/" + lstImg["photo_id"] + ".jpg\" id=\"" + lstImg["photo_id"] + "\" rel=\"plant\"  class=\"thickbox\"><img src=\"" + lstImg["photo_file_url"] + "\" alt=\"" + lstImg["photo_id"] + "\" width=\"150\" height=\"100\" /></a></div>";
	refDIV += "<div class=\"mT5\"><a href=\"" + lstImg["owner_url"] + "\" target=\"_blank\">" + lstImg["owner_name"] + "</a></div>";
	refDIV += "</li></ul>";
	return refDIV;
}
function sumTude(dbl, sam) {
	return (dbl*1 + sam*1);
}

function co_checkShicho(prefCity) {
	return prefCity.replace("支庁", "村");
}


