// JavaScript Document

//图片评价
function rateIt(op,pid,aid){
	if (pid == ""){
		alert("参数错误!");
	}
	$.get("viewimg_ajax.php?ac=rate&op="+op+"&pid="+pid+"&aid="+aid,function(r){
		if (r == "success"){
			NextImg(pid,aid,op);
		}
	})
}
//$("#photoBox"); $("#VoteButton")
function NextImg(pid,aid,op){
	if (pid == ""){
		alert("参数错误!");
	}
	ShowRate(pid,op);
	$.get("viewimg_ajax.php?ac=getimg&pid="+pid+"&aid="+aid,function(r){
		r = r.split("||||");
		if (r[0] == "LastOne"){
			alert("这是最后一张!");
			$("#VoteButton").html(r[1]);
		}
		else {
			$("#photoBox").html(r[0]);
			$("#VoteButton").html(r[1]);
		}
	});
}
//$("#RateBox");
function ShowRate(pid,op){
	//alert("viewimg_ajax.php?ac=getrate&pid="+pid+"&op="+op);
	$.get("viewimg_ajax.php?ac=getrate&pid="+pid+"&op="+op,function(r){
		$("#RateBox").css("display",'block');
		$("#RateBox").html(r);
	})
}


//Index_ajax
function rateIt2(op,pid,aid,n,al,ratetype,eventid){
	if (pid == ""){
		alert("参数错误!");
	}
//	alert("viewimg_ajax.php?ac=rate&op="+op+"&pid="+pid+"&aid="+aid+"&n="+n+"&ratetype="+ratetype);
	$.get("viewimg_ajax.php?ac=rate&op="+op+"&pid="+pid+"&aid="+aid+"&n="+n+"&ratetype="+ratetype+"&eid="+eventid,function(r){
		if (r == "success"){
			NextImg2(pid,aid,op,n,al,ratetype,eventid);
		}
		else
			alert(r);
	})
}
function NextImg2(pid,aid,op,n,al,ratetype,eventid){
	if (pid == ""){
		alert("参数错误!");
	}
	ShowRate2(pid,op,ratetype,eventid);
	//alert("viewimg_ajax.php?ac=getimg2&pid="+pid+"&aid="+aid+"&n="+n+"&al="+al);
	$.get("viewimg_ajax.php?ac=getimg2&pid="+pid+"&aid="+aid+"&n="+n+"&al="+al+"&ratetype="+ratetype+"&eid="+eventid,function(r){
		r = r.split("||||");
		if (r[0] == "LastOne"){
			$("#VoteButton").html(r[1]);
			$("#VoteButton").html("这是最后一张!看看<a href='albums.php?do=album&view=all'>大家的相册</a>吧");
			
		}
		else {
			$("#photoBox").html(r[0]);
			$("#VoteButton").html(r[1]);
			$("#NextImgBox").html(r[2]);
			$("#AlbumsName").html(r[3]);
			$("#PostBy").html(r[4]);
		}
	});
}
function ShowRate2(pid,op,ratetype,eventid){
	//alert("viewimg_ajax.php?ac=getrate&pid="+pid+"&op="+op);
	$.get("viewimg_ajax.php?ac=getrate&pid="+pid+"&op="+op+"&ratetype="+ratetype+"&eid="+eventid,function(r){
		$("#RateBox").css("display",'block');
		$("#Button_tip_1").css("display",'none');
		$("#RateBox").html(r);
	})
}
