if (typeof(PeriodicalExecuter.prototype.resume) == 'undefined') {
	PeriodicalExecuter.prototype.resume = function(){
		if(!this.timer)
			this.registerCallback();
	};
}
function replyckform() {
	if ( $('replyform') ){
		if($F('reply_content')=="") {
			alert("必须要有内容!");
			$('reply_content').focus();
			return false;
		}
		if($F('replyimagecode')=="" || $F('replyimagecode')=="点击显示") {
			alert("验证码必须要填写!");
			$('replyimagecode').focus();
			return false;
		}
		return true;
	}
}

function fastreplyforreply(fastreplyid)
{
	if( fastreplyid ){
		
		var objDialog = $("showfastreplyreply");
		if (!objDialog) objDialog = document.createElement("div");
		objDialog.id = "showfastreplyreply";
		objDialog.innerHTML = '<div style="border:1px #ddd dashed;margin:10px;padding:5px 10px;width:90%;"><div style=\"float:right;\"><a href=\"javascript:void(0);\" onclick=\"closefastreplyreply('+fastreplyid+');\" style=\"color:red;\"><img style=\"border: 0pt none ; width: 16px; height: 16px;\" src=\"/images/admin/icons/delete.gif\"/></a></div><span id=fastreplything'+fastreplyid+'>回复内容</span><br\/><textarea id=fastreplycontent'+fastreplyid+' rows=3 cols=50><\/textarea><br\/><input type=text id=fastreplyimagecode'+fastreplyid+' size=8  value=\'验证码\' style=\'vertical-align:middle;color:#999;\' onfocus=\'if(\$(\"validate_code'+fastreplyid+'\").src.substr(\$(\"validate_code'+fastreplyid+'\").src.length-3,3)==\"gif\"){ \$(\"validate_code'+fastreplyid+'\").src=\"/validatecode/display/\"+(new Date()).getTime();this.value=\"\"; }\'><a  onclick=\'\$(\"validate_code'+fastreplyid+'\").src=\"/validatecode/display/\"+(new Date()).getTime();\'><img src=\'/images/dot_clear.gif\' id=\'validate_code'+fastreplyid+'\' style=\'vertical-align:middle;border:0;\'></a><input type=\"button\" onclick=\'fastreplysubmit('+fastreplyid+');\' size=\"20\" value=\"发表\"></div>';
		
		$('replycontent_reply_input_'+fastreplyid).appendChild(objDialog);
		$('replycontent_reply_input_'+fastreplyid).style.display="block";
		$('fastreplycontent'+fastreplyid).focus();
	}
}

function closefastreplyreply(fastreplyid)
{
	$('replycontent_reply_input_'+fastreplyid).innerHTML='';
}

function fastreplysubmit(fastreplyid)
{
	$('fastreplyreplytodoid').innerHTML=fastreplyid;
	if( $F('fastreplyimagecode'+fastreplyid).replace(/\s/g,"")=="" || $F('fastreplyimagecode'+fastreplyid)=="验证码" )
	{	
		$('fastreplything'+fastreplyid).innerHTML="请输入验证码";
		Field.focus('fastreplyimagecode'+fastreplyid);
	}
	else if( $F('fastreplycontent'+fastreplyid)=="" || $F('fastreplycontent'+fastreplyid).replace(/\s/g,"").replace("　","").replace("\n","").replace("\n\r","").length<1 )
	{
		$('fastreplything'+fastreplyid).innerHTML="请输入完整";
		Field.focus('fastreplycontent'+fastreplyid);
	}
	else
	{		
		$('fastreplything'+fastreplyid).innerHTML="开始提交...";
		var pars = 'imagecode='+$F('fastreplyimagecode'+fastreplyid)+'&reply_content='+$F('fastreplycontent'+fastreplyid);
		
		 var url = "/operate/replyreply/type/ajax/id/"+fastreplyid;
			var myAjax = new Ajax.Request ( 
				url, 
				{
					method: 'post', 
					evalScripts:true,
					parameters: pars,
					onComplete: getReplyreplyResponse
				}
			);
	}
}

function showdelreplyreply(rid,stype)
{
	if(stype=='on')
	{
		$('replyreplytitle'+rid).style.backgroundColor = '#cccccc';
		$('delreplyreply'+rid).style.display = 'block';
	}
	else if(stype=='off')
	{
		$('replyreplytitle'+rid).style.backgroundColor = '';
		$('delreplyreply'+rid).style.display = 'none';
	}
	else if(stype=='del')
	{
		if( confirm('确认删除?') )
		{
			 var url = "/operate/replyreply/type/del/id/"+rid;
				var myAjax = new Ajax.Request ( 
					url, 
					{
						method: 'get', 
						evalScripts:true,
						onComplete: getReplyreplyDelResponse
					}
				);
		}
	}
}

function getReplyreplyDelResponse(originalRequest)
{
	var returnword = originalRequest.responseText;
	var targetid;
	if( returnword.substring(0, 2) ==="1_" )
	{
		targetid = returnword.substring(2);
		if( $('replyreply'+targetid) )
		{
			$('replyreply'+targetid).style.display='none';
		}
	}
	else
	{
		var getmsg=returnword.replace("<script>","").replace("<\/script>","");
		eval(getmsg);
	}
}
function getReplyreplyResponse(originalRequest)
{
	var fastreplyid = $('fastreplyreplytodoid').innerHTML;
	var returnword = originalRequest.responseText;
	if( returnword.substring(0, 2) ==="1_" )
	{
		var objDialog = document.createElement("div");
		//objDialog.id = "getfastreplyajaxback"+fastreplyid;
		objDialog.innerHTML = returnword.substring(2);
		
		$("replycontent_reply_list_"+fastreplyid).appendChild(objDialog);
		closefastreplyreply(fastreplyid);
	}
	else
	{
		var getmsg=originalRequest.responseText.replace("<script>","").replace("<\/script>","");
		eval(getmsg);
	}
}


function newtime(postunixtimestamp)
{
	//var jstimestamp = myDate((postunixtimestamp*1000));
	var now = new Date();
	var jsnowtimestamp = now.getTime();
	
	newtimeserver(postunixtimestamp,Math.floor(jsnowtimestamp/1000));
	
//	var vtime=	jsnowtimestamp-postunixtimestamp*1000;
//	
//	if( vtime>0 && vtime<30*24*3600*1000 )
//	{
//		var tonowtime = tonow(vtime);
//		document.writeln(tonowtime); 
//	}
//	else if( vtime<0 )
//	{
//		document.writeln("0分钟前"); 
//	}
//	else
//	{
//		var jstimestamp = myDate((postunixtimestamp*1000));
//		document.writeln(jstimestamp); 
//	}
}
function newtime(postunixtimestamp,servertime)
{
	newtimeserver(postunixtimestamp,servertime);
}

function newtimeserver(postunixtimestamp,servertime)
{
	var jsnowtimestamp = servertime;
	var vtime=	jsnowtimestamp-postunixtimestamp;
	if( vtime>0 && vtime<30*24*3600 )
	{
		var tonowtime = tonow(vtime*1000);
		document.writeln(tonowtime); 
	}
	else if( vtime<0 )
	{
		document.writeln("0分钟前"); 
	}
	else
	{
		var jstimestamp = myDate((postunixtimestamp*1000));
		document.writeln(jstimestamp); 
	}
}

function replayNewTime(postunixtimestamp,servertime)
{
	var jsnowtimestamp = servertime;
	var vtime=	jsnowtimestamp-postunixtimestamp;
	if( vtime>0 && vtime<30*24*3600 )
	{
		var tonowtime = tonow(vtime*1000);
		return tonowtime; 
	}
	else if( vtime<0 )
	{
		return "0分钟前"; 
	}
	else
	{
		var jstimestamp = myDate((postunixtimestamp*1000));
		return jstimestamp; 
	}
}


function tonow(vtime)
{
	var days=Math.floor( vtime/(24*3600*1000) )
	var hours=Math.floor( ( vtime-days*24*3600*1000) /(3600*1000) )
	var minutes=Math.floor( ( vtime-days*24*3600*1000-hours*3600*1000 ) /(60*1000) )
	return (days?days+"天":"")+(hours?hours+"小时":"")+minutes+"分钟前";
}

function myDate(timestamp) {
	d = new Date(timestamp);
	//var jstimestamp = (d.getFullYear())+"-"+(d.getMonth()+1)+"-"+(d.getDate())+" "+(d.getHours())+":"+(d.getMinutes())+":"+(d.getSeconds());
	var jstimestamp = (d.getFullYear())+"-"+(d.getMonth()+1)+"-"+(d.getDate());
	return jstimestamp;
}

//评星星
function star_fchange(objname,fsetid,starnum){
	eval('$(\''+objname+'_star_vname\').innerHTML=fsetid');
	star_rchange(objname,-fsetid,starnum);
}
function star_dchange(objname,fsetid,starnum){
	eval('$(\''+objname+'_star_vname_nownum\').value=fsetid');
	eval('$(\''+objname+'_star_vname\').innerHTML=$(\''+objname+'_star_vname_nownum\').value');
	star_rchange(objname,fsetid,starnum);
}

function star_rchange(objname,fsetid,starnum){
	if(fsetid==-1001){
		eval('fsetid=Number($(\''+objname+'_star_vname_nownum\').value)');
	}
	scolor='#F98C02';
	if( $(objname+'_star_vname') )
	{
		if(fsetid<0){fsetid=-fsetid;scolor='#ff4400';}
		eval('$(\''+objname+'_star_vname\').innerHTML=fsetid');
		for(jjj=1;jjj<=starnum;jjj++){if(jjj>fsetid)
		{eval('$(\''+objname+'_star_num_'+jjj+'\').style.color="#cccccc"');}
		else{eval('$(\''+objname+'_star_num_'+jjj+'\').style.color="'+scolor+'"');}}
	}
	if(starnum==5 && $(objname+'_desp') )
	{
		switch (fsetid)
		{
			case 1:
			eval('$(\''+objname+'_desp\').innerHTML="很差"');
			break;
			case 2:
			eval('$(\''+objname+'_desp\').innerHTML="较差"');
			break;
			case 3:
			eval('$(\''+objname+'_desp\').innerHTML="一般"');
			break;
			case 4:
			eval('$(\''+objname+'_desp\').innerHTML="较好"');
			break;
			case 5:
			eval('$(\''+objname+'_desp\').innerHTML="极好"');
			break;
			default:
			eval('$(\''+objname+'_desp\').innerHTML="--"');
			break;
		}
	}
}

//更改 img obj 对象宽度
function picmaxwidth(obj,width,onclickthis)
{
	if (!obj) return ;
	if (!width) {
		width = obj.clientWidth * 0.9;
	}
	var s_height = obj.height;
	var s_width = obj.width;
	if( obj.width > width )
	{
		obj.style.width = width + "px";
		if(onclickthis)
		{
			obj.style.height = width/s_width*s_height + "px";
			obj.onclick = function() {window.open(this.src)};
			obj.style.cursor = "pointer";
			obj.alt = "点击查看原始尺寸";
		}
	}
}


function selectautoselect(selectid,value)
{
	var selectobject=$(selectid);
	for(var i=0;i<selectobject.options.length;i++)
	if(selectobject.options[i].value==value)
	selectobject.options[i].selected=true;
}




//ie 6 PNG
function correctPNG() // correctly handle PNG transparency in Win IE 5.5 & 6.
{
	var arVersion = navigator.appVersion.split("MSIE")
	var version = parseFloat(arVersion[1])
	if ((version >= 5.5) && (version < 7) && (document.body.filters))
	{
		for(var j=0; j<document.images.length; j++)
		{
			var img = document.images[j]
			var imgName = img.src.toUpperCase()
			if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
			{
				var imgID = (img.id) ? "id='" + img.id + "' " : ""
				var imgClass = (img.className) ? "class='" + img.className + "' " : ""
				var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
				var imgStyle = "display:inline-block;" + img.style.cssText
				if (img.align == "left") imgStyle = "float:left;" + imgStyle
				if (img.align == "right") imgStyle = "float:right;" + imgStyle
				if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
				var strNewHTML = "<span " + imgID + imgClass + imgTitle
				+ " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
				+ "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
				+ "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>"
				img.outerHTML = strNewHTML
				j = j-1
			}
		}
	}
}

function definesitereport( ctype,id)
{
	lightboxcommand='Site Report';
	ScreenConvert();
	DialogShowCenter(200,55);

	if( ctype=="bewwwnote" || ctype=="ghreply" )
	{
		var url = "/operate/report/type/"+ctype+"/id/"+id+"/?"+(new Date()).getTime();;
		var myajax = new Ajax.Updater(
		{success: 'Space-DialogCover-Content'},
		url,
		{
			asynchronous:true,
			method: 'get',
			evalscripts:true,
			onSuccess :reportend()
		}
		);
	}
	else
	{
		$('Space-DialogCover-Content').innerHTML = "未设置相应处理流程<br/>请使用其它方式联系我们!";
	}
}

function reportend()
{
	DialogShowResize(280,250);
}

function sitealertshort(innerhtml)
{
	sitealert(innerhtml,1600,200,100);
}
function sitealert(innerhtml,autodistime,width,height)
{
	lightboxcommand='Site Alert';
	if( ! $('Space-DialogCover-Content') )
	{
		ScreenConvert();
		DialogShowCenter(width,height);
		$('Space-DialogCover-Content').innerHTML = innerhtml;
	}
	else
	{
		$('Space-DialogCover-Content').innerHTML = innerhtml;
	}	
	if (autodistime > 0) {
			setTimeout("DialogCloseCenter()",autodistime);
	}
}

/**
/    09/11/23  新增功能，将回复改成ajax形式
*/
var clockSubmit = false;
function firstreplysubmit(fastreplyid)
{
	
	//判断ajax锁定
	if(clockSubmit) return false;
	
	//取值
	var cid = $F('first_cid');
	var id = $F('first_id');
	var p = $F('first_p');
	var reply_content = $F('first_reply_content');
	var imagecode = $F('first_replyimagecode');

	//校验
	if( reply_content=="" || reply_content.replace(/\s/g,"").replace("　","").replace("\n","").replace("\n\r","").length<1)
	{
		alert('请输入留言内容!');
		Field.focus('first_reply_content');
	}
	else if( imagecode.replace(/\s/g,"")=="" || imagecode=="点击显示" )
	{
		alert('请输入验证码!');
		Field.focus('first_replyimagecode');
	}
	else
	{
		var pars = 'cid='+cid+'&id='+id+'&p='+p+'&reply_content='+reply_content+'&imagecode='+imagecode;
		var url = "/operate/replynew/type/ajax/id/"+fastreplyid;
		clockSubmit = true; //锁定AJAX操作
		var myAjax = new Ajax.Request ( 
					url, 
					{
						method: 'post',
						evalScripts:true,
						parameters: pars,
						onComplete: getReplynewResponse
					}
				);
	}
	$('first_reply_content').value = "";
	$('first_replyimagecode').value = "点击显示";
	$('validate_code').src = "/images/dot_clear.gif";
}

function getReplynewResponse(originalRequest)
{
	var getmsg=originalRequest.responseText.replace("<script>","").replace("<\/script>","");
	eval(getmsg);
	//alert(getmsg);
}

function addNewreplyDiv(replyid,strhtml,type)
{
	if(replyid=='' || type =='')
	{
		alert('错误，未指定回复日志或回复类型!');
		return false;
	}
	//alert(type);
	var nodeName = '';
	switch(type)
	{
		case 'article':
			nodeName = 'usercontent_content_reply';
			break;
		case 'photo':
			nodeName = 'usercontent_content_reply';
			break;
		case 'video':
			nodeName = 'usercontent_content_reply';
			break;
		case 'vote':
			nodeName = 'usercontent_content_reply';
			break;
		case 'user':
			nodeName = 'user-reply';
			break;
		case 'song':
			nodeName = 'song-reply';
			break;
		case 'live':
			nodeName = 'singripreplytag';
			break;
		default:
			alert('无正确返回类型!');
			return false;
	}
	
	//创建新div
	var newDiv = document.createElement('div');
	newDiv.id = 'replysshow'+replyid;
	newDiv.className = 'form_table';
	newDiv.innerHTML = strhtml;
	
	//插入处理
	var replyNode = $('form_relpy_input').nextSibling;
	if(replyNode == null){
		$(nodeName).insertBefore(newDiv);
	} else {
		$(nodeName).insertBefore(newDiv,replyNode);
	}
	
	//刷新验证码
//	$('validate_code').src='/validatecode/display/'+(new Date()).getTime();
//	$('first_replyimagecode').value='';
	
	//解锁
	clockSubmit = false;
}

/**
*  09/11/25  新增功能，将分页改成ajax形式
*/
function getPageList(page)
{
	clockSubmit = true; //锁定AJAX操作
	var myAjax = new Ajax.Request ( 
				page, 
				{
					method: 'GET',
					evalScripts: true,
					onComplete: showPageList
				}
			);
}

function showPageList(originalRequest)
{
	var strHTML = originalRequest.responseText.split('&page&');
	$(strHTML[1]).innerHTML = strHTML[0];
	eval(strHTML[2]);
	if(strHTML.length == 5){
		$("pagination").innerHTML = eval(strHTML[3]);
	}
	//alert(strHTML[1]);
	clockSubmit = false;
}

function showFirstPage($pagetool)
{
	if($pagetool)
	{
		document.write($pagetool);
		//alert($pagetool);
	}
}

/**
*  09/12/02  物品赠送
*/
function getGiftList(url)
{
	clockSubmit = true; //锁定AJAX操作
	var myAjax = new Ajax.Request ( 
				url, 
				{
					method: 'GET',
					evalScripts:false,
					onComplete: showGift
				}
			);
}

function getGiftListOn(url)
{
  //DialogCloseCenter();
  getGiftList(url);
}

function showGift(originalRequest)
{
	var str = originalRequest.responseText.split('&page&');
	eval('var data='+str);
	if(!$('Space-DialogCover-Content')){
    	sitealert(data['html'], 0, 520, 460);
	} else {
    	$('Space-DialogCover-Content').innerHTML = data['html'];
	}
	if(data['page']!= ''){
		$("gift_page_list").innerHTML = eval(data['page']);
	}
	clockSubmit = false;
}

//收藏歌曲部分
function favorites(id,type)
{
	if( type=='' )
	{
		sitealert('参数丢失...',1000,230,80);
		return false;
	}
	//sitealert('<br />正在获取内容...',0,230,80);
	url='/operate/favorites/id/'+id+'/type/'+type+'/?'+((new Date()).getTime());
	addToMusicPlayer(id, 2);
	return false;
	var myAjax = new Ajax.Request ( 
				url, 
				{
					method: 'GET',
					evalScripts:false,
					onComplete: favoritesMsg
				}
			);
}

function favoritesMsg(originalRequest){
	sitealert(originalRequest.responseText , 1000, 230, 80);
}


//送礼物
/**
 * giftid 礼品id
 * getuid 收礼人id
 * iswish 是不是愿望(bool)
 */
function sendGiftMsg(giftid, getuid, wishid)
{
	//验证下
	getuid = !getuid ? $('friendid').value : getuid;
	getuid = parseInt(getuid);
	if(!getuid){
		sitealert('<br />请在上方选择赠送人~...', 1500, 260, 80);
		return false;
	}
	
	sitealert('<br />读取中...', 0, 400, 200);
	var url = '/index/gift/~sendgiftmsg/giftid/'+giftid+'/userid/'+getuid+'/wishid/'+wishid;
	var myAjax = new Ajax.Request (
				url, 
				{
					method: 'GET',
					evalScripts:false,
					onComplete: function(msg)
						{
							sitealert(msg.responseText, 0, 400, 200);
						}
				}
			);
}

//撤销愿望
function removeWish(id)
{
	var html = '<form method="post" action="/group/sendGift/method/removewish">';
	html += '<input type="hidden" name="giftradio" value="'+id+'" /><br />确定要撤销此愿望么?';
	html += '<br /><input type="submit" value="确认" class="clickbutton" />';
	html += '</form>';
	sitealert(html, 0, 260, 90);
}