<!--
function $ID(s) {
	if (document.getElementById) {
		return eval("document.getElementById(\"" + s + "\")");
	} else {
		return eval("document.all." + s);
	}
}
//##############评分次数显示#################
/*
 *显示评分次数
 */
function display_score_count(count)
{
	if(!count){count=0}
	var width=0;
	if(count>0 && count <=5) width = 9;
	else if(count>5 && count <= 10)  width = 18;
	else if(count>10 && count <= 15) width = 27;
	else if(count>15) width = 36;

	var txt='<img src="http://www.engok.com/images/song/green_bar.gif" width="' + width + 'px" height="3px" onError="this.src=\'images/song/green_bar.gif\'"/>';
	document.write(txt);
}
/*
 *显示评分次数
 */
function display_score_count_orange(count)
{
	if(!count){count=0}
	var width=0;
	if(count>0 && count <=5) width = 9;
	else if(count>5 && count <= 10)  width = 18;
	else if(count>10 && count <= 15) width = 27;
	else if(count>15) width = 36;

	var txt='<img src="http://www.engok.com/images/song/orange_bar.gif" width="' + width + 'px" height="3px" onError="this.src=\'images/song/orange_bar.gif\'" />';
	document.write(txt);
}

//##############评分次数显示-[end]#################


//##############链接速度显示#################
/*
 *链接速度
 */
function display_linkSpeed(count)
{
	if(!count){count=0}
	var width=0;
	if(count>0 && count <=2) width = 10;
	else if(count>2 && count <= 4)  width = 20;
	else if(count>4 && count <= 6) width = 30;
	else if(count>6 && count <= 8) width = 40;
	else if(count>8) width = 50;

	var txt='<img src="../images/song/green_bar.gif" width="' + width + 'px" height="6px" />';
	document.write(txt);
}
//##############链接速度显-[end]示#################
/**
* 复制内容到剪贴板
*/
function copyToClipboard() {
	alert("地址已复制，你可以粘贴到其他网站（BLOG、BBS等）或粘贴到MSN、QQ等聊天窗口发给好友");
	return document.URL;
}
/**
 * 显示用户名
 * @user_id 	用户编号
 * @user_code	用户帐号
 * @length		截取长度
 * @default_user_code	缺省替代用户帐号
 * 示例：<script language="javascript">display_user_code(12,'user_code',8,'default_user_code')</script>
*/
var user_code_number = 0;
function display_user_code(user_id,user_code,length)
{	
	var txt;
	var urlUser ="http://" + window.location.host + "/EnglishIDWeb/userspace/queryUserOpus.action?suserId=" + user_id;
	var display_user_code;
	if(ULength(user_code) > length){
		display_user_code = get_fix_ustring(user_code,length-2) + '…';
	}else{
		display_user_code = user_code;
	}
	
	if(user_id && user_id > 0){
		user_code_number = user_code_number+1;
		txt = "<a class='jTip1' id='user_code_" +user_code_number + "' target='_blank' ";		
		txt += "href='"+urlUser;
		//txt += "&tipuid=" + user_id;
		//txt += "&tipuname=" + escape(user_code);
		txt += "'>";
		txt += display_user_code;
		
		txt += "</a>";		
	}else{
		txt = "<span title='" + user_code + "'>";	
		txt += display_user_code;
		txt += "</span>";	
	}

	
	document.write(txt);
}
/**
 * 显示用户头像
 * @user_id 	用户编号
 * @user_code	用户帐号
 * @user_photo	用户头像地址
 * @width		宽度
 * @height		高度
 * 示例：<script language="javascript">display_user_photo(12,'user_code','user_photo_path',50,50)</script>
*/
var user_photo_number = 0;
function display_user_photo(user_id,user_code,user_photo,width,height)
{	
	var txt="";
	if(user_photo.length==0){
		switch(user_code.charCodeAt(0)%4+1){
			case 1:				
			case 2:					
			case 3:
				user_photo = 'http://www.engok.com/images/user/photo'+(user_code.charCodeAt(0)%4+1)+'.jpg'
				break;
			default:
				user_photo = 'http://www.engok.com/images/user/photo4.jpg'
				break;
		}
	}
	user_photo = encodeURI(user_photo);
	if(user_id>0){
		user_photo_number = user_photo_number +1;
		txt = "<span><a class='jTip' id='user_photo_" +user_photo_number + "' target='_blank' href='http://" + window.location.host + "/EnglishIDWeb/userspace/queryUserOpus.action?suserId=";		
		txt += user_id;
		//txt += "&tipuid=" + user_id;
		//txt += "&tipuname=" + escape(user_code);
		txt += "' rel='"
		txt += user_id + "-" + escape(user_code)
		txt += "'>"
	}
	
	
	txt += "<img src='" + user_photo + "' onerror='this.src=\"/images/user/photo1.jpg\"'";
	if(width && width > 0){ 
		txt += " width='" + width + "px' ";
	}
	if(height && height > 0){
		txt += " height='" + height + "px' "; 
	}	
	txt += " />"
	txt += '<span style="display:none">11111</span>'
	if(user_id>0){
		txt += "</a></span>";		
	}
	document.write(txt);
}
/**
 * 截取固定长度字符串显示
 * @str 		显示字符串
 * @length		显示长度
*/
function display_fix_string(str,length)
{
	var txt;
	var display_str;
	if(ULength(str) > length){
		display_str = get_fix_ustring(str,length-2) + '…';
	}else{
		display_str = str;
	}
	txt = "<span title=\"" + str+ "\">"+display_str+"</span>"
	document.write(txt);
}

/**
 * 截取固定长度字符串(中文字符为2字节)
 * @str 		显示字符串
 * @length		显示长度
*/
function get_fix_ustring(str,length)
{
	var s_return = '';
	var a=0;
	for (i=0; i<str.length && a<length; i++){   
		if (str.charCodeAt(i)>255){
			//按照预期计数增加2
		  	a+=2;
		}else{
			a++;
		}
		s_return = s_return + str.substring(i,i+1);
	}

	return s_return;
}
/**
 * 获取字符串长度(中文字符为2字节)
 * @str 		显示字符串
*/
function ULength(str){
	var a = 0;
	for (i=0;i<str.length;i++){         
		if (str.charCodeAt(i)>255){
			//按照预期计数增加2
		  	a+=2;
		}else{
			a++;
		}
	} 
	return a;
}

//恢复表情符号
function txttoico(sour,cur,rep)
{
	var result = "";
	var arr = sour.match(/\[\:a\d{1,2}\]/g);
	if(arr!=null){
		var i=0;
		while(cur.indexOf(rep)>=0){
			cur=cur.replace(rep,arr[i]);
			i++;
		}
	}
	result=cur;
	return result;
}

//显示最后一条评论
function diaplay_latest_comment(comment_count,comment,length)
{
	var txt;
	var display_comment;
	//定义转移符号
	var rep = "圊";
	//去除评论中的转移符号
	comment = comment.replace(/\圊/g,'');
	//保存最初评论
	var mycom = comment;
	//转换表情以及算长度
	comment = comment.replace(/\[\:a\d{1,2}\]/g,rep);
	if(ULength(comment) > length){
		display_comment = get_fix_ustring(comment,length-2) + '…';
	}else if(comment_count == 0){
		display_comment = '快来发表意见呀！';
	}else{
		display_comment = comment;
	}
	
	display_comment = txttoico(mycom,display_comment,rep);
	
	//替换脸形
	var pos = display_comment.search(/\[\:a\d{1,2}\]/g);
	if(pos>=0){
		var code = new Array()
		var img = new Array()
		for(i=1;i<=20;i++)
		{
			var n = i-1;
			code[n]="[:a"+i+"]";
			img[n] ="<img src='../images/qq/"+i+".gif' />";
		}
		for(i=0;i<code.length;i++)
		{
			var n=i+1;
			var regStr = "\\[\\:a"+n+"\\]"
			var reg = new RegExp(regStr,"g");
			display_comment = display_comment.replace(reg,img[i]);
		}
	}
	display_comment = changeHTML(display_comment);
	comment = comment.replace(/\圊/g,'');
	txt = "<span title='" + comment+ "'>"+display_comment+"</span>"
	document.write(txt);
}

//HTML关键字过滤转换
function changeHTML(xhtml)
{
	xhtml = xhtml.replace(/&amp;(amp;)*ques;/ig, "?");
	xhtml = xhtml.replace(/&amp;(amp;)*shap;/ig, "#");  
	xhtml = xhtml.replace(/&amp;(amp;)*pc;/ig, "%");
	xhtml = xhtml.replace(/&amp;(amp;)*ul;/ig, "_");
	xhtml = xhtml.replace(/&amp;(amp;)*apos;/ig, "'");
	xhtml = xhtml.replace(/&amp;(amp;)*lt;/ig, "<");
	xhtml = xhtml.replace(/&amp;(amp;)*gt;/ig, ">");
	return xhtml;
}



/**
 * 显示图片
 * @img_path 	图片地址
 * @alt			
 * @default_img_path	默认图片地址
 * @width
 * @height
*/
function display_img(img_path,alt,default_img_path,width,height)
{
	var txt;
	var path;
	if(img_path.length==0 && default_img_path){
		path=''
	}
	document.write(txt);
}


//将数字变成时间  
function get_publishtime_from_long(ltime)  
{ 
	try{
	dt=new Date(ltime); 
	var year = dt.getFullYear();
	var month = dt.getMonth()+1;
	var day = dt.getDate();
	var hours = dt.getHours()<10?"0"+dt.getHours():dt.getHours();
	var minutes = dt.getMinutes() < 10?"0"+dt.getMinutes():dt.getMinutes();
	
	document.write(year + "-" + month + "-" + day + " " + hours + ":" + minutes)
	}catch(e){
		//alert(e)
	}	
}

Date.prototype.format = function(format)
{
var o = {
"M+" : this.getMonth()+1, //month
"d+" : this.getDate(),    //day
"h+" : this.getHours(),   //hour
"m+" : this.getMinutes(), //minute
"s+" : this.getSeconds(), //second
"q+" : Math.floor((this.getMonth()+3)/3),  //quarter
"S" : this.getMilliseconds() //millisecond
}
if(/(y+)/.test(format)) format=format.replace(RegExp.$1,
(this.getFullYear()+"").substr(4 - RegExp.$1.length));
for(var k in o)if(new RegExp("("+ k +")").test(format))
format = format.replace(RegExp.$1,
RegExp.$1.length==1 ? o[k] :
("00"+ o[k]).substr((""+ o[k]).length));
return format;
}

//圈子[start]
var join_club_works = function(owner_id){
	document.write('<span id="join_club_works_box"></span>')
	$.ajax({
	   type: "POST",
	   url: "/club/isOwnClub.action",
	   data: "ownerId="+owner_id,
	   dataType: 'json',
	   success: function(jsonObj){
	   		if(jsonObj.msg==1){
				html="<a target='_blank' href='/fansclub/"+owner_id+"'><img src='/images/club/zpbtn.jpg' /></a>"
				$('#join_club_works_box').append(html)
			}		 		
	   },
	   timeout: 2000,
       error: function (xmlHttpRequest, error) {}
	});
}

var embed_club_engok_index = function(){
	document.write('<span id="embed_club_engok_box"></span>')
	$.ajax({
	   type: "POST",
	   url: "/club/recommendClub.action",
	   data: "fromCount=20&displayCount=6",
	   dataType: 'json',
	   success: function(jsonObj){
			fillClubs(jsonObj.clubList) 		 		
	   },
	   timeout: 2000,
       error: function (xmlHttpRequest, error) {
           //fillClubs();
       }
	});

	var fillClubs = function(obj) {
		if(obj.length==0) return;	
		var club_box_index_html='<div id="qztj"><div id="qztj_title"><a href="http://www.engok.com/jsp/club/">更多</a></div><ul id="club_box_index"></ul></div>'
		$("#embed_club_engok_box").append(club_box_index_html)		
		var liHtml = '<li><div class="qztj_img left"><a target="_blank" href="/fansclub/[user_id]"> <img src="[user_photo]" width="50" height="50" /></a></div>'
		liHtml += '<div class="qztj_info left"><strong>[user_name]</strong><br /><small>粉丝：[fans_count]人</small>'
		liHtml += '<a target="_blank" href="/fansclub/[user_id]" class="qztj_btn">我要加入</a></div></li>'
		
		for(var i=0; i<obj.length; i++){
			li = liHtml;
			li = li.replace("[user_id]",obj[i].ownerId)
			li = li.replace("[user_id]",obj[i].ownerId)
			li = li.replace("[user_name]",obj[i].ownerName)
			li = li.replace("[user_photo]",obj[i].ownerPhoto)
			li = li.replace("[fans_count]",obj[i].memberCount)
			$('#club_box_index').append(li)
		}
		return;		
	}
}
//圈子[end]


//-->
