//编辑照片
function showEditPhoto(photoId,tId)
{
	var editphotocallback = {
            success : function(o) {
				if (!YAHOO.example.container.editphotodialog){
					YAHOO.example.container.editphotodialog = new YAHOO.widget.Panel("editphotodialog", 
									{		  width: "350px", 
											  fixedcenter: true, 
											  close: true, 
											  draggable: true, 
											  zindex:10,
											  modal: true,
											  visible: false 
									} 
							);
					
					YAHOO.example.container.editphotodialog.setHeader("<div class='tl'></div><span>编辑照片信息</span><div class='tr'></div>");
					YAHOO.example.container.editphotodialog.setBody(o.responseText);
					YAHOO.example.container.editphotodialog.render(document.body);
				}
				YAHOO.example.container.editphotodialog.show();

            },
            failure : function(o) {
                my_alert('应该是网络有问题 :( \n 建议你再点击一次试试');
            }
        }
    
        var conn = YAHOO.util.Connect.asyncRequest("GET", "./photo.php?_a=showeditphoto&tid="+tId+"&photoid="+photoId+"&r=" + new Date().getTime(), editphotocallback);
}


function hideeditphotodialog()
{
	YAHOO.example.container.editphotodialog.hide();
}


//提交照片
function doeditphoto(photoid,tid)
{
	if (!$F('photoname'))
		{
			my_alert("照片不能没有名字 :)");
			return false;
		}else
		{
			var url = './photo.php';
			new Ajax.Request(url,
				{
					method: 'get',
					parameters : '_a=doeditphoto&tid=' + encodeURIComponent(tid) + '&photoid=' + encodeURIComponent(photoid) + '&photoalbum=' + encodeURIComponent($F('photoalbum'))+ '&photoname=' + encodeURIComponent($F('photoname')) + '&r=' + new Date().getTime(),
					onComplete:function(ret){
						var res = ret.responseText;
						eval('res = ' + res + ';');
						if (res['status'] == 'succ')	// 检验成功
						{
							 my_alert("修改照片信息成功");
							 hideeditphotodialog();
							window.location.href=window.location.href;
						}
						else
						{
							my_alert("这张照片不是你的或者网络有问题，请重试!");
						}
					}
				}
			);		
		}
}


//删除照片
function delPhoto(photoid,tid)
{
	if (confirm("你确定要删除这张照片吗？ \n\n 删除后将不可恢复"))
	{
		var url = './photo.php';
		new Ajax.Request(url,
			{
				method: 'get',
				parameters : '_a=delphoto&tid=' + encodeURIComponent(tid)  + '&photoid=' + encodeURIComponent(photoid)  + '&r=' + new Date().getTime(),
				onComplete:function(ret){
					var res = ret.responseText;
					eval('res = ' + res + ';');
					if (res['status'] == 'succ')	// 检验成功
					{
						my_alert("删除照片成功");
						window.location.href='./photo.php?_a=morephoto&tid='+encodeURIComponent(tid);
					}
					else
					{
						my_alert("这张照片不是你的或者网络有问题，请重试!");
					}
				}
			}
		);		
	}
}