function show_picture(pictureid) {
	if (!pictureid || pictureid <= 0) {
		alert('无效的图片。');
		return false;
	}
	selected(pictureid);
	if(current_pid==pictureid) return;
	current_pid = pictureid;

	$.get(siteurl+"ajax.php",{action:"showpicture",pictureid:pictureid},function(result){
		if(result == '') {
			alert('图片读取失败，可能网络忙碌，请稍后尝试。');
			return;
		} else if(result.match(/<.+id="browse-picture".*>/)) {
			document.getElementById('pic_right').innerHTML = result;
		} else {
			myDialog('查看图片', result, 300, 300, true);
		}
	});
}

//查找ID在第几个顺序
function ListIndexOf(pictureId) {
	for (var i=0; i<picture_list.length; i++) {
		if(picture_list[i]==pictureId)
			return i;
	}
	return -1;
}

function prev() {
	var i = ListIndexOf(current_pid);
	if (i ==- 1) {
		alert('页面出错，请重新刷新页面。');
	}else if(i == 1){
		alert('已经在最前面啦！');
	}else{
		var pictureid = picture_list[i-1];
		show_picture(pictureid);
	}
}

function next() {
	var i = ListIndexOf(current_pid,picture_list);
	if (i==-1) {
		alert('页面出错，请重新刷新页面。');
	}else if(i == picture_list.length-1){
		alert('已经在最后面啦！');
	}else{
		var pictureid=picture_list[i+1];
		show_picture(pictureid);
	}
}

function selected(pictureId) {
	$("#picture_"+current_pid).attr("className","detail-picture-no");
	$("#picture_"+pictureId).attr("className","detail-picture-yes");
}

function checkpictures(total) {
	if(total <= 0){
		alert('没有可浏览的图片。');
		return false;
	}
}