

//客户端读取COOKIE时解密 DecodeCookie(加密COOKIE)
function DecodeCookie(str) 
{ 　
	var strArr; 　
	var strRtn=""; 　
	strArr=str.split("~"); 　
	for (var i=strArr.length-1;i>=0;i--) 　
	strRtn+=String.fromCharCode(eval(strArr[i])); 　
	return strRtn; 
} 

//测试客户端是否支持COOKIE
function testCookie(){
	try{
		document.cookie="testcookie=1; ";
		if(document.cookie.indexOf("testcookie")!=-1){
			return true;
		}
	}catch(e){}
	return false;
}



//去掉空格
function trim(obj){
	return obj.replace(/(^\s*)|(\s*$)/g, "");
}

function GetCookieVal(offset)
//获得Cookie解码后的值
{
var endstr = document.cookie.indexOf (";", offset);
if (endstr == -1)
endstr = document.cookie.length;
return unescape(document.cookie.substring(offset, endstr));
}
function SetCookie(name, value)
//设定Cookie值
{
var expdate = new Date();
var argv = SetCookie.arguments;
var argc = SetCookie.arguments.length;
var expires = (argc > 2) ? argv[2] : null;
var path = (argc > 3) ? argv[3] : null;
var domain = (argc > 4) ? argv[4] : null;
var secure = (argc > 5) ? argv[5] : false;
if(expires!=null) expdate.setTime(expdate.getTime() + ( expires * 1000 ));
document.cookie = name + "=" + escape (value) +((expires == null) ? "" : ("; expires="+ expdate.toGMTString()))
+((path == null) ? "" : ("; path=" + path)) +((domain == null) ? "" : ("; domain=" + domain))
+((secure == true) ? "; secure" : "");
}

function DelCookie(name)
//删除Cookie
{
var exp = new Date();
exp.setTime (exp.getTime() - 1);
var cval = GetCookie (name);
document.cookie = name + "=" + cval + "; expires="+ exp.toGMTString();
}

//获得Cookie的原始值
function Get_Cookie(name)
{
  var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
  if(arr != null) return unescape(arr[2]); return null;
}
String.prototype.get = function(name)
{
  var reg = new RegExp("(^|&|\\?)"+ name +"=([^&]*)(&|$)"), r;
  if (r=this.match(reg)) return unescape(r[2]); return null;
}

//top连接
function LoginMenu(URLstr) {
  var mailcount=0
  if (!islogin("gzu521%5Fcampus%5Fstate","UserMail")) {
	    mailcount =0;
	}else{
	    mailcount =islogin("gzu521%5Fcampus%5Fstate","UserMail");
	}
	
	var friendcount=''
  if (!islogin("gzu521%5Fcampus%5Fstate","UserFriend")) {
	    friendcount ='';
	}else{
	    if (islogin("gzu521%5Fcampus%5Fstate","UserFriend")==0){
	        friendcount ='';
	    }else{
	        friendcount ='· <a href="/friend.asp">朋友请求('+islogin("gzu521%5Fcampus%5Fstate","UserFriend")+')</a>';
	    }
	}
	if (!islogin("gzu521%5Fcampus%5Flogin","UserName")) {
    	document.getElementById("LoginMenu").innerHTML='<span class="pl2"><a href="/help.asp">资料分享指南</a> · <a href="/forum.asp">站务中心</a> · 你好，请 <a href="/login.asp?returnurl='+URLstr+'">登录</a> 或 <a href="/reg.asp">注册</a></span>';
	}else{
    	document.getElementById("LoginMenu").innerHTML='<a href="/help.asp">资料分享指南</a> · <a href="/forum.asp">站务中心</a> · '+islogin("gzu521%5Fcampus%5Flogin","UserName")+'的<a href="/user.asp?action=userinfo">设置</a>  · <a href="/mail.asp?action=in">邮箱('+mailcount+')</a> '+friendcount+'  · <a href="/login.asp?action=quit&returnurl='+URLstr+'">退出</a>';
	}
}

//检测用户是否已登录
function islogin(str1,str2) {
try{
	if(document.cookie.indexOf(str2)!=-1){
		//var islogin = DecodeCookie(Get_Cookie(str));
        var islogin = DecodeCookie(Get_Cookie(str1).get(str2));
		if (islogin) {
			return islogin;
		} else {
			return false;
		}
	}else{
			return false;
	}
}catch(e){
  return false;
}
}


//标签取值
function InfoAuthorlist()
{
var musicsingerlisttop = "<select name='selectmenu' style='position:absolute;top:230px;width:355px;height:0px;left:66px;clip:rect(0 380 110 332)' onChange='InfoAuthor.value=this.options[this.selectedIndex].text;document.getElementById(\"Category\").selectedIndex=this.options[this.selectedIndex].value-1'>";
var musicsingerlistbottom ="</select>"
var musicsingerlistHTML
var s
var MusicArray = new Array();
var TempArray = new Array();
var tmpFlag = 0;
try
{	
	if(document.cookie.indexOf("gzu521%5Fmycampus")!=-1){
	    s=Get_Cookie("gzu521%5Fmycampus").split("&");
	}else{
	    s="";
        }
  if (s==""){
      musicsingerlistHTML = "<option value=''></option>"; 
  }else{
      musicsingerlistHTML = ""; 
      for(i=0;i<s.length;i++){
			   var s1=s[i].split("=");
			   //alert(s[i]);
			   for(j=0;j<s1.length;j++){
			      var s2=s1[j].split("|");
			      //alert(s1[j]);
			      for(k=0;k<s2.length;k++){
			        //alert(s2[k]);
			         MusicArray[k] = DecodeCookie(s2[k]);
			      }
			   }
			   //检查是否有重复 tmpFlag=0/1 否/是
			   for(m=0;m<TempArray.length;m++){ 
			   	  if (TempArray[m]==MusicArray[1]){
			   	  	tmpFlag = 1;
			   	  	break;
			   	  }
         }  
         
         if (tmpFlag==0){
         	  TempArray[i] = MusicArray[1];
         	  musicsingerlistHTML += "<option value='"+MusicArray[0]+"'>"+MusicArray[1]+"</option>";
         }			   
			   if (trim(document.getElementById("InfoAuthor").value)==""){
			       document.getElementById("InfoAuthor").value=MusicArray[1];
			       document.getElementById("Category").selectedIndex=MusicArray[0]-1;
			   }
			}
  }
	musicsingerlistHTML = musicsingerlisttop+musicsingerlistHTML+musicsingerlistbottom;
	document.getElementById("selectmenu").innerHTML =  musicsingerlistHTML;

}catch(e){}
}



//复选框的全选，多选，全不选，反选 
function checkAll(str) 
{ 
try{
	if (str=="musicid"){
	     for(k = 1; k < 13; k++){
		      var a = document.getElementsByName("musicid"+k); 
			  var n = a.length; 
			  for (var i=0; i<n; i++) {
			      a[i].checked = window.event.srcElement.checked; 
			  }
		}
	}else{
	      var a = document.getElementsByName(str); 
		  var n = a.length; 
		  for (var i=0; i<n; i++) 
		  a[i].checked = window.event.srcElement.checked; 
	}
}catch(e){}
} 

//20070704
//学习网会员是否登陆
function userSignupCheck(strGoto){
	  var tmpstr;
	  if (islogin("gzu521%5Fcampus%5Flogin","Retain")){
        tmpstr = escape(islogin("gzu521%5Fcampus%5Flogin","UserEmail")) + "strlink" +escape(islogin("gzu521%5Fcampus%5Flogin","PassWord"))+ "strlink1strlink1"
    }else{
        tmpstr = escape(islogin("gzu521%5Fcampus%5Flogin","UserEmail")) + "strlink" +escape(islogin("gzu521%5Fcampus%5Flogin","PassWord"))+ "strlink0strlink1"
    }
    var tmpresult;
    tmpresult=send_request('?t=login&info='+tmpstr+'','',0);
    //alert(tmpresult);
    if(tmpresult==false || tmpresult=="false" || tmpresult=="False"){
        document.getElementById('signup').innerHTML = send_request('?t=registration&info=0','signup',0);
        window.location.hash = "qlogin";
        alert('对不起, 请您先登陆后再发表回应！');
        return false;
    }else{
        return true;
        //document.addform.Comment.focus();
    }
}

//学习网会员登陆
function userLogin(strGoto){
	  var tmpstr;
	  if (document.login_Form.setcookie.checked){
        tmpstr = escape(document.login_Form.username.value) + "strlink" +escape(document.login_Form.password.value)+ "strlink1strlink0"
    }else{
        tmpstr = escape(document.login_Form.username.value) + "strlink" +escape(document.login_Form.password.value)+ "strlink0strlink0"
    }
    var tmpresult;
    tmpresult=send_request('?t=login&info='+tmpstr+'','',0);
    //alert(tmpresult);
    if(tmpresult==false || tmpresult=="false" || tmpresult=="False"){
        alert('对不起, 用户名或密码错误！');
        document.login_Form.Submit.disabled = false;
    }else{
        document.getElementById('signup').innerHTML ="";
        window.location.hash = "comment";
        document.addform.Comment.focus();
    }
}

//修改附件大小
function userModifyFileSize(){
	  var tmpstr;
    tmpstr = escape(document.userinfo.ExpendIntegration.value) + "strlink" + escape(document.userinfo.UploadFileSize.value)
    var tmpresult;
    tmpresult=send_request('?t=modifyfilesize&info='+tmpstr+'','',0);
    if(tmpresult==false || tmpresult=="false" || tmpresult=="False"){
        alert('对不起, 您的操作有误！');
        document.userinfo.Submit.disabled = false;
    }else if(tmpresult=="notenough"){
        alert('您目前可用的积分点数不足'+document.userinfo.ExpendIntegration.value+'点，无法继续升级可上传的文件大小。');
    }else if(tmpresult=="modifyfobidden"){
        alert('网站暂停用户修改上传附件大小功能。');
    }else if(tmpresult=="already"){
        alert('您刚才已经做过一次修改，请5分钟后再来操作，谢谢。');  
    }else if(tmpresult=="needrefresh"){  
    	  alert('请刷新页面后再来操作，谢谢。');       
        SetVal("needrefresh");
    }else{
        alert('操作成功！');
        SetVal(document.userinfo.UploadFileSize.value);
    }
}


//学习网会员回应
function userAddReply(InfoID){
  LoadBar(1,2);
  setTimeout("douserAddReply('"+InfoID+"')",500);
}
function douserAddReply(InfoID){
	  var tmpstype=0;
	  for(var i=0;i<document.addform.stype.length;i++)
		  {
		      if(document.addform.stype[i].checked){
		      	tmpstype=document.addform.stype[i].value;
		      }
		  }

	  var tmpstr;
    tmpstr = escape(document.addform.Comment.value) + "strlink" + escape(tmpstype) + "strlink"  +escape(InfoID) + "strlink"  +escape(document.addform.replycommentid.value)
    var tmpresult;
    tmpresult=send_request('?t=addreply&info='+tmpstr+'','',0);
    if(tmpresult==false || tmpresult=="false" || tmpresult=="False"){
        alert('对不起, 您填写的内容有误！');
        LoadBar(0,2);
        document.addform.Submit.disabled = false;
	      return false
    }else if(tmpresult=="already"){
        alert('您刚才已经回应了评论，请5分钟后再来添加，谢谢。');
    }else if(tmpresult=="commentfobidden"){
        alert('网站暂停发表资料评论功能。');
    }else{
        alert('您的回应已成功发布！');
        document.addform.Comment.value="";
        getComment(escape(InfoID)+'strlink'+escape(document.addform.authorid.value)+'strlink'+escape(document.addform.authorname.value)+'strlink'+escape(document.addform.authoricon.value)+'strlink1');
    }

    LoadBar(0,2);
}


function userDelReply(CommentID){
	  LoadBar(1,2);
	  var tmpstr;
    tmpstr = escape(CommentID)
    var tmpresult;
    tmpresult=send_request('?t=delreply&info='+tmpstr+'','',0);
    if(tmpresult==false || tmpresult=="false" || tmpresult=="False"){
        alert('对不起, 您无权删除！');
    }else{
        alert('您的删除操作成功！');
        getComment(escape(document.addform.mid.value)+'strlink'+escape(document.addform.authorid.value)+'strlink'+escape(document.addform.authorname.value)+'strlink'+escape(document.addform.authoricon.value)+'strlink1');
    }

    LoadBar(0,2);
}

function userCheckReply(CommentID){
	  LoadBar(1,2);
	  var tmpstr;
    tmpstr = escape(CommentID)
    var tmpresult;
    tmpresult=send_request('?t=checkreply&info='+tmpstr+'','',0);
    if(tmpresult==false || tmpresult=="false" || tmpresult=="False"){
        alert('对不起, 您无权审核！');
    }else{
        alert('您的审核操作成功！');
        getComment(escape(document.addform.mid.value)+'strlink'+escape(document.addform.authorid.value)+'strlink'+escape(document.addform.authorname.value)+'strlink'+escape(document.addform.authoricon.value)+'strlink1');
    }

    LoadBar(0,2);
}


function AddCommentReply(CommentID){
	  document.getElementById('replycommentid').value=CommentID;
	  document.getElementById('showreplycontent').innerHTML='回应评论：'+document.getElementById('comment'+CommentID).innerHTML+'<span class="gact" title="取消该回应"><a href="javascript:void(null)" onclick="CancelCommentReply('+CommentID+')">取消该回应</a></span>';
	  document.getElementById('showreplycontent').style.display='';
}

function CancelCommentReply(CommentID){
	  document.getElementById('replycommentid').value=0;
	  document.getElementById('showreplycontent').innerHTML='';
	  document.getElementById('showreplycontent').style.display='';
}


function AddTopicReply(TopicID){
	  var tmpText=document.getElementById('topic'+TopicID).innerHTML;
	  var tmpUsername=document.getElementById('topicusername'+TopicID).innerText;
	  var tmpAddDate=document.getElementById('topicadddate'+TopicID).innerText;
	  tmpText=tmpText.replace(/<DIV.+<\/SPAN><\/DIV>/ig,"");
	  tmpText=tmpText.replace(/<DIV.+<\/DIV>/ig,"");
	  tmpText=tmpText.replace(/<.+>/ig,"");
	  document.getElementById('Comment').value='[quote]'+tmpUsername+'在'+tmpAddDate+'的发言：\r\n'+trim(tmpText)+'[/quote]';
}


//学习网会员计划回应
function userAddPlanReply(PlanID){
  LoadBar(1,2);
  setTimeout("douserAddPlanReply('"+PlanID+"')",500);
}
function douserAddPlanReply(PlanID){
	  var tmpstype=0;
	  for(var i=0;i<document.addform.stype.length;i++)
		  {
		      if(document.addform.stype[i].checked){
		      	tmpstype=document.addform.stype[i].value;
		      }
		  }
	  
	  var tmpstr;
    tmpstr = escape(document.addform.Comment.value) + "strlink" + escape(tmpstype) + "strlink" +escape(PlanID)+ "strlink"  +escape(document.addform.replycommentid.value)
    var tmpresult;
    tmpresult=send_request('?t=addplanreply&info='+tmpstr+'','',0);
    if(tmpresult==false || tmpresult=="false" || tmpresult=="False"){
        alert('对不起, 您填写的内容有误！');
        LoadBar(0,2);
        document.addform.Submit.disabled = false;
	      return false
    }else if(tmpresult=="already"){
        alert('您刚才已经回应了评论，请5分钟后再来添加，谢谢。');
    }else if(tmpresult=="commentfobidden"){
        alert('网站暂停发表资料评论功能。');
    }else{
        alert('您的回应已成功发布！');
        document.addform.Comment.value="";
        getPlanComment(escape(PlanID)+'strlink'+escape(document.addform.authorid.value)+'strlink'+escape(document.addform.authorname.value)+'strlink'+escape(document.addform.authoricon.value)+'strlink1');
    }

    LoadBar(0,2);
}


function userDelPlanReply(CommentID){
	  LoadBar(1,2);
	  var tmpstr;
    tmpstr = escape(CommentID)
    var tmpresult;
    tmpresult=send_request('?t=delplanreply&info='+tmpstr+'','',0);
    if(tmpresult==false || tmpresult=="false" || tmpresult=="False"){
        alert('对不起, 您无权删除！');
    }else{
        alert('您的删除操作成功！');
        getPlanComment(escape(document.addform.mid.value)+'strlink'+escape(document.addform.authorid.value)+'strlink'+escape(document.addform.authorname.value)+'strlink'+escape(document.addform.authoricon.value)+'strlink1');
    }

    LoadBar(0,2);
}

function userCheckPlanReply(CommentID){
	  LoadBar(1,2);
	  var tmpstr;
    tmpstr = escape(CommentID)
    var tmpresult;
    tmpresult=send_request('?t=checkplanreply&info='+tmpstr+'','',0);
    if(tmpresult==false || tmpresult=="false" || tmpresult=="False"){
        alert('对不起, 您无权审核！');
    }else{
        alert('您的审核操作成功！');
        getPlanComment(escape(document.addform.mid.value)+'strlink'+escape(document.addform.authorid.value)+'strlink'+escape(document.addform.authorname.value)+'strlink'+escape(document.addform.authoricon.value)+'strlink1');
    }

    LoadBar(0,2);
}

//显示评论列表
function getComment(tmpstr)
{
    try{
      document.getElementById("comentlist").innerHTML = "正在读取数据...";
      //LoadBar(1,1);
      //setTimeout("doshowComment('"+tmpstr+"')",10);
      send_request('?t=showcomment&info='+tmpstr+'','comentlist',1);
    }catch(e){}	
}

function doshowComment(tmpstr)
{
    try{
        LoadBar(0,1);
        document.getElementById("comentlist").innerHTML = send_request('?t=showcomment&info='+tmpstr+'','',1);
    }catch(e){}
}

//显示计划评论列表
function getPlanComment(tmpstr)
{
    try{
      document.getElementById("comentlist").innerHTML = "正在读取数据...";
      send_request('?t=showplancomment&info='+tmpstr+'','comentlist',1);
    }catch(e){}	
}

//收藏
function addfav(infoid){
    var tmpstr;
    tmpstr = escape(infoid)
    var tmpresult;
    tmpresult=send_request('?t=addfav&info='+tmpstr+'','',0);
    if(tmpresult==false || tmpresult=="false" || tmpresult=="False"){
        alert('对不起, 您无权进行操作！');
    }else if(tmpresult=="self"){
        alert('您不能收藏自己推荐的资料。');
    }else if(tmpresult=="already"){
        alert('已加入您的收藏，请不要重复添加，谢谢。');
    }else{
        alert('成功加入您的收藏！');
        document.getElementById('favoriteshare').style.display='none';
    }
}

//关注计划
function addattention(planid){
	  var tmpresult;
    tmpresult=send_request('?t=addattention&info='+planid+'','',0);
    if(tmpresult=="True"){
        document.getElementById("quickattention").innerHTML = "你开始关注此计划，谢谢。";
    }else{
        alert('你已关注过此计划了。');
    }
}

//取消关注计划
function delattention(planid){
	  var tmpresult;
    tmpresult=send_request('?t=delattention&info='+planid+'','',0);
    if(tmpresult=="True"){
        document.getElementById("quickattention").innerHTML = "你成功取消关注此计划，谢谢。";
    }else{
        alert('您操作太频繁,请5分钟后再试。');
    }
}

//无效报告
function addoverdue(musicid){
	  var tmpresult;
    tmpresult=send_request('?t=addoverdue&info='+musicid+'','',0);
    if(tmpresult=="True"){
        alert('报告成功，谢谢您的参与！');
    }else{
        alert('您已经报告过信息有误，谢谢。');
    }
}

//删除上传附件
function deluploadfile(musicid){
	  var tmpresult;
    tmpresult=send_request('?t=deluploadfile&info='+musicid+'','',0);
    if(tmpresult=="True"){
    	  document.getElementById("delbtn").style.display = 'none';
        document.getElementById("picfile").style.display = '';
        alert('删除附件成功！');
    }else{
        alert('删除附件有误。');
    }
}



//将标签提交到系统列表
function tagToSystem(campustagname,tagid,infocategory){
    var tmpstr;
    tmpstr = escape(campustagname) + "strlink" + escape(tagid) + "strlink" + escape(infocategory);
    var tmpresult;
    tmpresult=send_request('?t=addtagtosystem&info='+tmpstr+'','',0);
    if(tmpresult==false || tmpresult=="false" || tmpresult=="False"){
        alert('对不起, 您无权进行操作！');
    }else if(tmpresult=="already"){
        alert('系统列表已有标签['+campustagname+']，请不要重复添加，谢谢。');
    }else{
        document.getElementById("tagdo"+tagid).style.display = 'none';
        alert('成功加入系统列表！');
    }
}

//将标签删除
function tagToDel(campustagname,tagid,infocategory){
    var tmpstr;
    tmpstr = escape(campustagname) + "strlink" + escape(tagid) + "strlink" + escape(infocategory);
    var tmpresult;
    tmpresult=send_request('?t=deltag&info='+tmpstr+'','',0);
    if(tmpresult==false || tmpresult=="false" || tmpresult=="False"){
        alert('对不起, 您无权进行操作！');
    }else if(tmpresult=="already"){
        alert('系统并无标签['+campustagname+']，请检查你的操作，谢谢。');
    }else{
        document.getElementById("tag"+tagid).style.display = 'none';
        alert('成功删除标签['+campustagname+']！');
    }
}


//检查email
function validateEmail(emailStr){
	//var emailStr = obj.value;
	var failure = 'Invalid email';
	var reg1 = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/; // not valid
	var reg2 = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/; // valid
	if ( !reg1.test( emailStr ) && reg2.test( emailStr ) || emailStr == '' ){
	    //obj.value == emailStr
	    return true;
	}else{	 
	  return false;	
	}
}

//检查username
function validateUsername(usernameStr){
	if (usernameStr=="")  {
		return false;
	}else{
		usernameStr=trim(usernameStr);
	}
	var reg1 = /[- #@$%&*()+=:?<>`~!A-Z]/; // valid
	if ( !reg1.test( usernameStr )){
	    return true;
	}else{	 
	    return false;	
	}
}

// 判断字符串长度，汉字按双字节
function Len(str)
{
    var i,sum;
    sum=0;
    for(i=0;i<str.length;i++)
    {
        if ((str.charCodeAt(i)>=0) && (str.charCodeAt(i)<=255))
            sum=sum+1;
        else
            sum=sum+2;
    }
    return sum;
}

//进度条
function LoadBar(f1,f2)
{
  var x,y,loader;

  if (self.innerHeight)
  {// all except Explorer
    x = self.innerWidth;
    y = self.innerHeight;
  }
  else 
  if (document.documentElement && document.documentElement.clientHeight)
  {// Explorer 6 Strict Mode
   x = document.documentElement.clientWidth;
   //y = document.documentElement.clientHeight;
   y = document.documentElement.clientHeight + document.documentElement.scrollTop
  }
  else
  if (document.body)
  {// other Explorers
   x = document.body.clientWidth;
   //y = document.body.clientHeight;
   y = document.body.clientHeight + document.body.scrollTop;
  }
   if (f2==0){
     el=document.getElementById('Dataloader');
   }else{
     el=document.getElementById('Pageloader');
   }
   //var el=document.getElementById('Dataloader');
	if(null!=el)
	{
		var top = (y/2) - 50;
		var left = (x/2) - 150;
		//var top = y - 35;
		//var left = x - 450;
		//var left = 0;
		//if( left<=0 ) left = 10;
		el.style.visibility = (f1==1)?'visible':'hidden';
		el.style.display = (f1==1)?'block':'none';
		el.style.left = left + "px"
		el.style.top = top + "px";
		el.style.zIndex = 9999999;
	}
}


function showFCK(){
var oFCKeditor = new FCKeditor( 'fbContent' ) ;
//oFCKeditor.BasePath = '/' ;
oFCKeditor.ToolbarSet = 'Basic' ;
oFCKeditor.Width = '100%' ;
oFCKeditor.Height = '400' ;
oFCKeditor.Value = '' ;
//oFCKeditor.Create() ;
oFCKeditor.ReplaceTextarea() ;
}

//vote
var starclick = false;
function showstar(x){
	if(x==0) return;
	  if (starclick == true) { return;}
		for (var i=1; i<x; i++){
			document.getElementById("star"+i).src="/images/icon_star.gif";
		}
		document.getElementById("star"+x).src="/images/icon_star.gif";
} 

function clearstar(){
	if (starclick == true) { return;}
	for (var i=1; i<6; i++){
		document.getElementById("star"+i).src="/images/icon_star_hui.gif";
	}
}

//投票
function addvote(votetype,musicid){
	   var tmpresult;
	   if (!islogin("gzu521%5Fcampus%5Flogin","UserName")) {
		   	try
				{
					switchDisplay('showstar_login', 'showstar');
					return;
				}
				catch (ex)
				{
          tmpresult=send_request('?t=addvote&info='+votetype+'--'+musicid+'','',0);
					if(tmpresult=="True"){
		        document.getElementById("showstar").innerHTML = "你的投票已经提交，谢谢。";
			    }else{
			        alert('您已打过分了。');
			    }
				}   
	   }
        tmpresult=send_request('?t=addvote&info='+votetype+'--'+musicid+'','',0);
		    if(tmpresult=="True"){
		        document.getElementById("showstar").innerHTML = "你的投票已经提交，谢谢。";
		    }else{
		        alert('您已打过分了。');
		    }
}

function js_score_chk(a)
{
	star = '';
	if (a==-1) { a=0; star = '暂无评分';}
	for(i=0;i<a;i++) { star = star + '<img src=/images/icon_star.gif>'; }
	if ($$('js_score')) $$('js_score').innerHTML = star;
}

function switchDisplay(obj1, obj2)
{
	try
	{
		if(document.getElementById(obj1).style.display=='')
		{
			document.getElementById(obj1).style.display='none';
			document.getElementById(obj2).style.display='';
		}
		else
		{
			document.getElementById(obj1).style.display='';
			document.getElementById(obj2).style.display='none';
		}
	}
	catch (ex)
	{
	}
}

//------- qq face  -----------
function bbDisplay() {
 var bbArray = new Array("困惑","生气","思考中","我酷吧","哭泣的脸","咦，好奇怪","努力奋斗","我晕","我稀饭..嘿嘿","大笑","感动中..","睡着了","不告诉你","郁闷","害羞","惊讶","做梦中","你好啊","汗..|","吐舌头","晕","便便..","受.不.了.拉","啊达.啊达达","嘿.嘿.来吧","没天理啊","呜呜..求求你了","倒，谁砸我..","呼.呼..","要死了","我露屁屁.嘿嘿","我的中国心")
 for(var qq=1 ; qq <= 32 ; qq++) {
   document.write('<img src="/images/face/BB' + qq + '.gif" onclick="addface(this,' + qq +')" title="' + bbArray[qq-1] + '" alt="" />') ;
 }
}
function addface(obj,num){
 obj.document.addform.Comment.value += "[BB" + num + "]" ;
}

function bbDisplay1() {
 var bbArray = new Array("困惑","生气","思考中","我酷吧","哭泣的脸","咦，好奇怪","努力奋斗","我晕","我稀饭..嘿嘿","大笑","感动中..","睡着了","不告诉你","郁闷","害羞","惊讶","做梦中","你好啊","汗..|","吐舌头","晕","便便..","受.不.了.拉","啊达.啊达达","嘿.嘿.来吧","没天理啊","呜呜..求求你了","倒，谁砸我..","呼.呼..","要死了","我露屁屁.嘿嘿","我的中国心")
 for(var qq=1 ; qq <= 32 ; qq++) {
   document.write('<img src="/images/face/BB' + qq + '.gif" onclick="addface1(this,' + qq +')" title="' + bbArray[qq-1] + '" alt="" />') ;
 }
}
function addface1(obj,num){
 //eWebEditor1.insertHTML("[BB" + num + "]");

 document.frames("myiframe").EDiaryEditor.iframe.contentWindow.document.body.innerHTML = document.frames("myiframe").EDiaryEditor.iframe.contentWindow.document.body.innerHTML + "[BB" + num + "]"
 document.frames("myiframe").document.getElementById("editor_body_textarea").innerHTML = document.frames("myiframe").document.getElementById("editor_body_textarea").innerHTML + "[BB" + num + "]"

}





function  checkTags(obj){

	var tag = obj.value;
	tag = replaceAll(tag,'，', ',');
  tag = replaceAll(tag,' ', ',');
	if(tag==''){
		//document.getElementById('tagDiv').style.display='';
		//document.getElementById('tagMsg').innerHTML = "请选择或输入标签";
		return true;
	}else{
		var tags = tag.split(',');
		for (var i = 0; i < tags.length ; i++) {
			if (tags[i].replace(/^\s+/,'') == '') {
				tags.splice(i, 1);
				i--;
			}
		}
		
		var v;
		var a = [];
		for(i=0; i<tags.length; i++) {
			v = tags[i];	
			if(!a[v]){
				 a[v] = 0;
			}
			a[v]++;
			if(a[v] > 1) {
				alert("标签["+v+"]有重复:"+a[v]);
				tag = tags.join(',');
				obj.value = tag;
				return false;
		  }
		}


		if (tags.length > 3) {
			//document.getElementById('tagMsg').innerHTML ="标签的数量超过3个了";
			alert("标签的数量超过3个了");
			tag = tags.join(',');
			obj.value = tag;
			return false;
		}

		tag = tags.join(',');
		obj.value = tag;
		return true;
	}
}

function chooseTags(tagName,obj) {
	var tagValue = obj.value;
	tagValue = replaceAll(tagValue,'，', ',');
	tagValue = replaceAll(tagValue,' ', ',');
	var tags = tagValue.split(',');
	var tagArray = new Array();
	tagArray = tags;
	for (var i = 0; i < tagArray.length ; i++) {
		if (tagArray[i].replace(/^\s+/,'') == '') {
			tagArray.splice(i, 1);
			i--;
		}
	}
	if (tagArray.length >= 3) {
		alert("标签的数量已经足够了");
		return;
	}

	tagArray.push(tagName);

	tagValue = tagArray.join(',');
	obj.value = tagValue;
}
function replaceAll(str,oldStr,reStr){ 
	return str.split(oldStr).join(reStr); 
} 