var helloText = new Array("","向你打招呼","踩了你一下","电了你一下","捅了你一下","向你飞个吻","捶了你一拳","摸了你一下","给你捏捏脚","狠狠的揪了揪你","对你脑门弹了弹","向你抛媚眼","和你握个手","对你笑一个","和你抱一下","咬了你一口");
var hellText = new Array("","打招呼","踩一下","电一下","捅一下","飞个吻","捶一拳","摸一下","捏捏脚","揪一揪","弹一弹","抛媚眼","握个手","笑一个","抱一下","咬一口");
function showPoke(id){
	document.write(helloText[id]);
}

function sayHello(obj,uid){
	var html = '<div class="dialog-facebox"><div class="dialog-content"><h3>向'+$("#pf-name").text()+'打招呼？他下次登录后将会收到通知。</h3>';
	html += '	<form id="hello-form" method="post" action="'+APP+'/hello/'+uid+'"><div class="dialog-content">';
	html += '	<p class="image">'+$("#pf-picture").find("a").html()+'</p>';
	html += '	<div class="poke">';
	html += '	<h5 class="title">选择动作：</h5>';
	html += '	<ul class="system-action-list">';
	html += '<li><input type="radio" value="1" id="pokedef-1" name="pokedefid" checked="checked" onclick="setPoke(this.value)"/>  ';
	html += ' <img src="'+STATIC+'/images/hello/1.gif"/>'+hellText[1]+'</li>';
	for(var i=2;i<16;i++){
		html += '<li><input type="radio" value="'+i+'" id="pokedef-'+i+'" name="pokedefid" onclick="setPoke(this.value)"/>  ';
		html += ' <img src="'+STATIC+'/images/hello/'+i+'.gif"/>'+hellText[i]+'</li>';
	}
	html += ' 	</ul></div>';
	html += '<div class="poke-action-submit"><input type="hidden" id="pokeid" value="1"/><input type="button" value="确定" class="f-button" onclick="postHello(this)"/><input type="button" value="取消" name="cancel" id="dialog-end" class="f-button f-alt" onclick="$.facebox.close()"/></div>';
	html += '</div></form></div></div>';
	$.facebox(html,"打招呼");
}

function reHello(obj,uid,id){
	var username = $(obj).parent().prev().find("a").text();
	var html = '<div class="dialog-facebox"><div class="dialog-content"><h3>向Ta打招呼？他下次登录后将会收到通知。</h3>';
	html += '	<form id="hello-form" method="post" action="'+APP+'/rehello/'+uid+'"><div class="dialog-content">';
	html += '	<div class="poke">';
	html += '	<h5 class="title">选择动作：</h5>';
	html += '	<ul class="system-action-list">';
	for(var i=1;i<16;i++){
		html += '<li><input type="radio" value="'+i+'" id="pokedef-'+i+'" name="pokedefid" onclick="setPoke(this.value)" ';
		if(i==id){	html += 'checked="checked"/>  ';}
		html += ' <img src="'+STATIC+'/images/hello/'+i+'.gif"/>'+hellText[i]+'</li>';
	}
	html += ' 	</ul></div>';
	html += '<div class="poke-action-submit"><input type="hidden" id="pokeid" value="'+id+'"/><input type="button" value="确定" class="f-button" onclick="postReHello(this,\''+username+'\')"/><input type="button" value="取消" name="cancel" id="dialog-end" class="f-button f-alt" onclick="$.facebox.close()"/></div>';
	html += '</div></form></div></div>';
	$.facebox(html,"回复招呼");
}
function postReHello(obj,username){
	var url = $("#hello-form").attr("action");
	var pokeid = $("#pokeid").val();
	$.get(url,{ajax:1,pokeid:pokeid},
		function(data){
			if("success" == data){		
				var html = '<div class="dialog-facebox"><div class="dialog-content"><h3>你成功向'+username+'<strong>'+hellText[pokeid]+'</strong></h3>';
				html += '<p>他下次登录后将会收到</p><p id="facebox-close"></p></div></div>';
				$.facebox(html,"回复招呼");
				/*$("#facebox-close").hide("3000",function(){
					$.facebox.close();
				}); */
			}else if("repeat" == data){
				var html = '<div class="dialog-facebox"><div class="dialog-content"><h3>你之前已经向'+$("#pf-name").text()+'打过招呼了</h3></div></div>';
				html += '<p id="facebox-close"></p>';
				$.facebox(html,"出错了");
				/*$("#facebox-close").hide("3000",function(){
					$.facebox.close();
				});*/
			}
		}
	);
}
function setPoke(value){
	$("#pokeid").val(value);
}
