﻿var tfengyun = {
	$: function() {
		return document.getElementById(arguments[0]);
	},
	add : function(obj,type,val) { // add Event
		if(obj.attachEvent) {
			obj.attachEvent('on'+type,val);
		}else {
			obj.addEventListener(type,val,false);
		}
	},
	del : function(obj,type,val) {  // del Event
		if(obj.detachEvent) {
			obj.detachEvent('on'+type,val);
		}else {
			obj.removeEventListener(type,val,false);
		}
	},
	addClass : function(obj,value) {
		if(obj.className) {
			var val = obj.className.replace(/^\s|\s$/g,'');
			if(val.indexOf(value) == -1) obj.className=val+' '+value;
		}
		obj.className=value;
	},
	removeClass : function(obj,value) {
		if(obj.className) {
			var val = obj.className.replace(/^\s|\s$/g,'');
			var str = new RegExp(value,'ig');
			if(val.indexOf(value)!==-1) obj.className = val.replace(str,'');
		}
	},
	each : function(arr,fn) {
		for(var i=0,len=arr.length;i<len;i++) {
			if(fn.call(arr[i],arr[i],i)===false) {
				return false;
			};
		} 
	},
	ajax : function(options) {  // ajax
		var o={
			url:'',
			data:'',
			method:'GET',
			type:'xml',
			timeout:15000,
			success:function(){},
			error:function(){},
			complete:function(){}
			};
		for(var attr in options){
			o[attr]=options[attr];
		}
		
		if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera,
									// Safari
			xmlhttp = new XMLHttpRequest();
			if (xmlhttp.overrideMimeType) xmlhttp.overrideMimeType('text/xml');
		}else if (window.ActiveXObject) {// code for IE6, IE5
			try{
				xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
			}catch(e) {
				try{
					xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
				}catch(e) {}
			}
		}

		xmlhttp.open(o.method,o.url+'?'+o.data,true);
		
		var get_data = false;
		setTimeout(function() {
			if(!get_data) {
				xmlhttp.abort();
				o.error(xmlhttp);
			}
		},o.timeout);

		xmlhttp.onreadystatechange=function() {
			o.complete(xmlhttp);
			if (xmlhttp.readyState==4 && xmlhttp.status==200) {
				get_data = true;
				o.type=='xml'?o.success(xmlhttp.responseXML,xmlhttp):o.success(xmlhttp.responseText,xmlhttp);
			}
		}
		xmlhttp.send();
	}
};



/* firefox */
function __firefox(){
    HTMLElement.prototype.__defineGetter__("runtimeStyle", __element_style);
    window.constructor.prototype.__defineGetter__("event", __window_event);
    Event.prototype.__defineGetter__("srcElement", __event_srcElement);
}
function __element_style(){
    return this.style;
}
function __window_event(){
    return __window_event_constructor();
}
function __event_srcElement(){
    return this.target;
}
function __window_event_constructor(){
    if(document.all){
        return window.event;
    }
    var _caller = __window_event_constructor.caller;
    while(_caller!=null){
        var _argument = _caller.arguments[0];
        if(_argument){
            var _temp = _argument.constructor;
            if(_temp.toString().indexOf("Event")!=-1){
                return _argument;
            }
        }
        _caller = _caller.caller;
    }
    return null;
}
var ua = navigator.userAgent.toLowerCase();
if(window.addEventListener && ua.match(/firefox/)){
    __firefox();
   
}
/* end firefox */
// cookie
var CookieHelper = {
 setCookie:function(name, value, expiry, path, domain, secure){
	switch(weiboType()) {
		case 'sina':
			var names = name;
			break;
		case 'qq':
			var names = 'qq'+name;
			break;
		case '163':
			var names = '163'+name;
			break;
		case 'sohu':
			var names = 'sohu'+name;
			break;
	}
    var nameString = names + "=" + value;
    var expiryString = "";
    if (expiry != null) {
        try {
            expiryString = "; expires=" + expiry.toGMTString()
        } 
        catch (e) {
            if (expiry) {
                var lsd = new Date();
                lsd.setTime(lsd.getTime() + expiry * 1000);
                expiryString = "; expires=" + lsd.toGMTString()
            }
        }
    }
    var pathString = (path == null) ? " ;path=/" : " ;path = " + path;
    var domainString = (domain == null) ? "" : " ;domain = " + domain;
    var secureString = (secure) ? ";secure=" : "";
    document.cookie = nameString + expiryString + pathString + domainString + secureString;
},
getCookie : function(name) {
	switch(weiboType()) {
		case 'sina':
			var name = name;
			break;
		case 'qq':
			var name = 'qq'+name;
			break;
		case '163':
			var name = '163'+name;
			break;
		case 'sohu':
			var name = 'sohu'+name;
			break;
	}
	var i, aname, value, ARRcookies = document.cookie.split(";");
	for (i = 0; i < ARRcookies.length; i++) {
		aname = ARRcookies[i].substr(0, ARRcookies[i].indexOf("="));
		value = ARRcookies[i].substr(ARRcookies[i].indexOf("=") + 1);
		aname = aname.replace(/^\s+|\s+$/g, "");
		if (aname == name) {
			return unescape(value);
		}
	}
	
	return '';
}
};

// search input Fn
function searchKeywords(options) {
	this.o={
		obj:'',
		val:'搜索',
		buttonId:'',
		run:function() {},
		error:function() {}
	};
	for(var i in options) {
		this.o[i] = options[i]
	}
	this.obj=typeof this.o.obj=='string'?tfengyun.$(this.o.obj):this.o.obj;
	this._runSearch();
	this._enterSearch();
	if(this.obj.value=='') {
		if(this.o.val) {
			this.obj.value=this.o.val;
		}else {
			return;
		}
	}
	this._registerObjClick();
}

searchKeywords.prototype={
	_registerObjClick:function() {
		var scope_this=this;
		this.obj.onfocus=function() {
			if(scope_this.obj.value==scope_this.o.val) scope_this.obj.value='';  
		}
		this.obj.onblur=function() {
			if(scope_this.obj.value=='') scope_this.obj.value=scope_this.o.val;
		}
	},
	_runSearch:function() {
		var scope_this=this;
		if(this.o.buttonId) {
			this.button = typeof this.o.buttonId=='string'?tfengyun.$(this.o.buttonId):this.o.buttonId;
		}else {
			return;
		}
		this.button.onclick=function() {
			scope_this._runKey();
		}
	},
	_enterSearch:function() {
		var scope_this=this;
		tfengyun.add(this.obj,'keydown',function() {
			if(event.keyCode==13) scope_this._runKey();
		});
	},
	_runKey:function() {
		this.obj.value && this.obj.value!==this.o.val?this.o.run(this.obj.value):this.o.error();
	}
};

function searchSelect() {
	$('#inpTxt').hover(function() {
		$('#inpTxt').css('position','relative');
		$('#keywordsSearch').show();
		//try{tfengyun.del(document.body, 'click', moveWeibo);}catch(err) {}
		//$('#weiboOptions').hide();
	},function() {
		$('#inpTxt').css('position','static');
		$('#keywordsSearch').hide();
	});
}
/*
function moveWeibo() {
	if(tfengyun.$('weiboOptions').style.display=='none') {
		tfengyun.$('weiboOptions').style.display='';
		setTimeout(function() {
			tfengyun.add(document.body, 'click', moveWeibo);
		},200);
	}else {
		tfengyun.$('weiboOptions').style.display='none';
		tfengyun.del(document.body, 'click', moveWeibo);
	}
}
*/

// tab switch
function pubTabSwitch(options) {
	var o={
		objId:'',
		showClass:'',
		hideClass:'',
		nodeClassName:['','',''],
		childNode:'',
		showDiv:false
	};
	for(var i in options) {
		o[i]=options[i];
	}
	var obj=typeof o.objId=='string'?$('#'+o.objId):o.objId;
	obj.find(o.childNode).each(function(i) {
		$(this).mouseover(function() {
			$(this).parent().children().removeClass(o.showClass).addClass(o.hideClass);
			$(this).addClass(o.showClass).removeClass(o.hideClass);
			o.showDiv?hideSelect(false):$('.'+o.nodeClassName[0]).addClass(o.nodeClassName[1]).removeClass(o.nodeClassName[2]);
		}).mouseout(function() {
			$(this).parent().children().removeClass(o.showClass).addClass(o.hideClass);
			o.showDiv?hideSelect(false):$('.'+o.nodeClassName[0]).addClass(o.nodeClassName[2]).removeClass(o.nodeClassName[1]);
		});
	});
}

// hide select
function hideSelect(show) {
	if(!JudgeIe()) return ;
	$('select').each(function() {
		show ? $(this).show() : $(this).hide() ;						  
	});
}

// save user att
function SaveUser(id,sN,lD,des,aR,iR,comment,repost,sC,fC,pR,aF,val,imgurl) {
	this.id = id;
	this.screenName = sN;
	this.locationD = lD;
	this.des = des;
	this.activeRank = aR;
	this.influenceRank = iR;
	this.comment = comment;
	this.repost = repost;
	this.statusesCount = sC;
	this.followersCount = fC;
	this.peopleRank = pR;
	this.activeFans = aF;
	this.val = val;
	this.imgurl = imgurl;
}

// ajax
function timeouthelper(cb,socket){
	var timeoutfunc = function(){
		var sc=arguments.callee.statechange;
		if(sc==true) {			
			return;
		};
		socket.abort();
		cb('timeout');
	};
	timeoutfunc.statechange=false;
	return timeoutfunc;
}

function getData(data,type,timeout,timeoutcb) {
	if(type == 0 || type == 1) {
		loadDiv(true,'正在加载...');
	}
	if(type == 2) {
		tfengyun.$('chartLoading').style.display = '';
		tfengyun.$('chartImg').style.display = 'none';
		tfengyun.$('chartLoading').innerHTML = '<img src="http://image.tfengyun.com/image/p3.gif" align="absmiddle" />&nbsp;&nbsp;正在加载...';
		tfengyun.$('chartImg').innerHTML = '';
	}
	var xmlhttp;
	if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	}else {// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	if(data.indexOf('province_')==-1) {
		switch(weiboType()) {
			case 'sina':
				var dataSite = data;
				break;
			case 'qq':
				var dataSite = data+'&site=qq';
				break;
			case '163':
				var dataSite = data+'&site=163';
				break;
			case 'sohu':
				var dataSite = data+'&site=sohu';
				break;
		}
	}else {
		var dataSite = data;
	}
	xmlhttp.open("GET",dataSite,true);
	var timeoutfunc=timeouthelper(timeoutcb,xmlhttp);
	setTimeout(timeoutfunc,timeout);
	xmlhttp.setRequestHeader('If-Modified-Since', '0');
	xmlhttp.onreadystatechange=function() {
		timeoutfunc.statechange = true;
		 if (xmlhttp.readyState==4 && xmlhttp.status==200) {
			var xml = xmlhttp.responseText;
			switch(type) {
				case 0:
					DealRankingXML(xml);
				break;
				case 1:
					DealUserDetail(xml);
				break;
				case 2:
					DealUserKeyword(xml);
				break;
				case 3:
					DealUserAttention(xml);
				break;
				case 4:
					CityResult(xml);
				break;
				case 5:
					DealUserHot(xml);
				break;
				case 6:
					DealUserF(xml);
				break;
				case 7:
					DealUserF(xml);
				break;
				case 8:
					DealUserOften(xml);
				break;
				case 9:
					DealUserLO(xml)
				break;
			}
		}
	}
	xmlhttp.send();
}

function DealUserLO(str) {
	var sort = GetItemData(str , 'sort'),
		province = GetItemData(str , 'province'),
		activeStr = '',
		influenceStr = '',
		loca = userLocation.split(' ');
	if(loca.length>0) {
		influenceStr += '<a href="rankings.php?province=' + GetItemData(province , 'provinceid') + '&city=" class="blue" target="_blank">' + loca[0] + '</a>排名: <b style="color:#000;font-size:14px;">' + GetItemData(province , 'active_rank') + '</b><br />';
		activeStr += '<a href="rankings.php?province=' + GetItemData(province , 'provinceid') + '&city=" class="blue" target="_blank">' + loca[0] + '</a>排名: <b style="color:#000;font-size:14px;">' + GetItemData(province , 'influence_rank') + '</b><br />';
	}else {
		influenceStr += '没有您所属地域的信息';
		activeStr += '没有您所属地域的信息';
	}
	if(sort) {
		influenceStr += '<a href="rankings.php?sortid=' + sortid + '" target="_blank" class="blue">' + sorttitle + '</a>' + '分类排名: <b style="color:#000;font-size:14px;">' + GetItemData(sort , 'active_rank') + '</b>';
		activeStr += '<a href="rankings.php?sortid=' + sortid + '" target="_blank" class="blue">' + sorttitle + '</a>' + '分类排名: <b style="color:#000;font-size:14px;">' + GetItemData(sort , 'influence_rank') + '</b>';
	}else {
		influenceStr += '分类排名:暂无数据';
		activeStr += '分类排名:暂无数据';
	}
	tfengyun.$('infoActiv').innerHTML = influenceStr;
	tfengyun.$('infoInfluence').innerHTML = activeStr;
}

var itemList = [];
function DealUserOften(str) {
	var itemlist = ExtractStringList(str , 'user'),
		string = '';
	for(var i = 0 ; i < itemlist.length ; i++) {
		switch(weiboType()) {
			case 'sina':
				string += '<li>' +
	        	'<div class="imgPL">' +
	            	'<a href="user.php?f=x&screen_name=' + GetItemData(itemlist[i] , 'id') + '"><img src="http://tp1.sinaimg.cn/' + GetItemData(itemlist[i] , 'id') + '/30/5602405246/1" border="0" /></a>' +
	            '</div>' +
	            '<p><a href="user.php?f=x&screen_name=' + GetItemData(itemlist[i] , 'id') + '" class="blue">' + GetItemData(itemlist[i] , 'name') + '</a><br />所在位置：</p>' +
	        '</li>';
				break;
			case 'qq':
				string += '<li>' +
	        	'<div class="imgPL">' +
	            	'<a href="user.php?f=x&screen_name=' + GetItemData(itemlist[i] , 'id') + '"><img src="' + GetItemData(itemlist[i] , 'profile_image_url') + '/30" border="0" /></a>' +
	            '</div>' +
	            '<p><a href="user.php?f=x&screen_name=' + GetItemData(itemlist[i] , 'id') + '" class="blue">' + GetItemData(itemlist[i] , 'name') + '</a><br />所在位置：</p>' +
	        '</li>';
				break;
			case '163':
				
				break;
			case 'sohu':
				string += '<li>' +
	        	'<div class="imgPL">' +
	            	'<a href="user.php?f=x&screen_name=' + GetItemData(itemlist[i] , 'id') + '"><img src="' + GetItemData(itemlist[i] , 'profile_image_url') + '" border="0" /></a>' +
	            '</div>' +
	            '<p><a href="user.php?f=x&screen_name=' + GetItemData(itemlist[i] , 'id') + '" class="blue">' + GetItemData(itemlist[i] , 'name') + '</a><br />所在位置：</p>' +
	        '</li>';
				break;
		}
	}
	string!=''?tfengyun.$('often').innerHTML = string:tfengyun.$('often').innerHTML = '<li style="text-align:center;color:#646464;line-height:46px;">暂无数据</li>';
}

function DealUserF(str) {
	var itemlist = ExtractStringList(str , 'id');
	if(ExtractStringList(str , 'head')) {
		var head = ExtractStringList(str , 'head');
	}
	var string = '';
	for(var i = 0 ; i < itemlist.length ; i++) {
		switch(weiboType()) {
			case 'sina':
				string += '<li><a href="user.php?screen_name=' + itemlist[i] + '" target="_blank"><img border="0" src="http://tp1.sinaimg.cn/' + itemlist[i] + '/30/5602405246/1" /></a></li>';
				break;
			case 'qq':
				return;
				string += '<li><a href="user.php?screen_name=' + itemlist[i] + '" target="_blank"><img border="0" src="' + head[i] + '/30" width="30" /></a></li>';
				break;
			case '163':
				
				break;
			case 'sohu':
				string += '<li><a href="user.php?screen_name=' + itemlist[i] + '" target="_blank"><img border="0" src="' + head[i] + '" width="30" /></a></li>';
				break;
		}
	}
	Datastatistics(string,itemlist.length);
}





function DealUserDetail(str) {
	if(GetItemData(str , 'id') == '' && userid =='') {
		return;
	}else if(userid == ''){
		errorPoint('您查询的用户不存在，请重新输入',0);
	}
	if(!str) {
		tfengyun.$('updateTime').innerHTML = strftime(last_update_time);
		loadDiv(false);
		return;
	}else {
		tfengyun.$('updateTime').innerHTML = strftime(server_time);
	}
	//setWeiboHome(str,userid,verified);
	switch(weiboType()) {
		case 'sina':
			var imageV = 'http://image.tfengyun.com/image/v.gif';
			break;
		case 'qq':
			var imageV = 'http://image.tfengyun.com/image/g.gif';
			break;
		case '163':
			
			break;
		case 'sohu':
			var imageV = 'http://beta.tfengyun.com/image/s.gif';
			break;
	}
	verified ? tfengyun.$('screen_name').innerHTML = '<a class="blue" href="'+getSite('home')+userid+'" target="_blank">'+GetItemData(str , 'screen_name')+'</a><img src="'+imageV+'" align="absmiddle" />' : tfengyun.$('screen_name').innerHTML = '<a class="blue" href="'+getSite('home')+userid+'" target="_blank">'+GetItemData(str , 'screen_name')+'</a>' ;
	
	tfengyun.$('location').innerHTML = GetItemData(str , 'location');
	tfengyun.$('description').innerHTML = GetItemData(str , 'description');
	tfengyun.$('active_rank').innerHTML = (GetItemData(str , 'active_rank') == '' ? '--' : GetItemData(str , 'active_rank'));
	tfengyun.$('influence_rank').innerHTML = GetItemData(str , 'influence_rank');
	if(tfengyun.$('af')) tfengyun.$('af').innerHTML = GetItemData(str , 'activefans_count');
	tfengyun.$('value').innerHTML = GetItemData(str , 'value');
	tfengyun.$('activefans_count').innerHTML = GetItemData(str , 'score');

	switch(weiboType()) {
		case 'sina':
			tfengyun.$('userHead').src = 'http://tp1.sinaimg.cn/' + GetItemData(str , 'id') + '/50/5602405246/1';
			break;
		case 'qq':
			other_head?tfengyun.$('userHead').src = other_head + '/50':tfengyun.$('userHead').src = 'http://mat1.gtimg.com/www/mb/images/head_50.jpg';
			break;
		case '163':
			
			break;
		case 'sohu':
			tfengyun.$('userHead').src = other_head;
			break;
	}
	tfengyun.$('aver_status_count').innerHTML = GetItemData(str , 'aver_status_count');
	tfengyun.$('week_status_count').innerHTML = GetItemData(str , 'week_status_count');
	tfengyun.$('original_status_count').innerHTML = GetItemData(str , 'original_status_count');
	tfengyun.$('attention_ratio').innerHTML = GetItemData(str , 'attention_ratio');
	tfengyun.$('people_rank').innerHTML = GetItemData(str , 'people_rank');
	tfengyun.$('comments').innerHTML = GetItemData(str , 'comments');
	tfengyun.$('repost').innerHTML = GetItemData(str , 'repost');
	tfengyun.$('userrank').innerHTML = GetItemData(str , 'userrank');
	tfengyun.$('userrank1').innerHTML = parseInt(GetItemData(str , 'userrank')) + 1;
	tfengyun.$('statuses_count').innerHTML = GetItemData(str , 'statuses_count');
	tfengyun.$('friends_count').innerHTML = GetItemData(str , 'friends_count');
	tfengyun.$('followers_count').innerHTML = GetItemData(str , 'followers_count');
	tfengyun.$('interaction_ratio').innerHTML = GetItemData(str , 'interaction_ratio');
	tfengyun.$('activefans_ratio').innerHTML = GetItemData(str , 'activefans_ratio');
	if(userid == my_userid) {
		tfengyun.$('myInfluenceRank').innerHTML = GetItemData(str , 'influence_rank');
		tfengyun.$('myActiveRank').innerHTML = GetItemData(str , 'active_rank');
		tfengyun.$('myValue').innerHTML = GetItemData(str , 'value');
		tfengyun.$('myRank').innerHTML = GetItemData(str , 'userrank');
	}
	if(GetItemData(str , 'sorttitle') !== '') {
		tfengyun.$('sorttitle').style.display = '';
		tfengyun.$('sorttitle').innerHTML = '所属分类：<a href="rankings.php?sortid=' + GetItemData(str , 'sortid') + '" class="blue" target="_blank">' + GetItemData(str , 'sorttitle') + '</a>';
	}
	switch(weiboType()) {
		case 'sina':
			tfengyun.$('share').innerHTML = '@' + GetItemData(str , 'screen_name') + ' 的微博注册' + GetItemData(str , 'created_time') + '天,原创率' + GetItemData(str , 'original_status_count') + '%,活跃度排名' + (GetItemData(str , 'active_rank') == '' ? '--' : GetItemData(str , 'active_rank')) + '位,影响力排名' + GetItemData(str , 'influence_rank') + '位,PR值' + GetItemData(str , 'people_rank') + ',微博价值' + GetItemData(str , 'value');
			tfengyun.$('shareLink').href = "javascript:void((function(s,d,e,r,l,p,t,z,c){var%20f='http://v.t.sina.com.cn/share/share.php?appkey=878922546',u=z||d.location,p=['&url=',e(u),'&title=',e(t||d.title),'&source=',e(r),'&sourceUrl=',e(l),'&content=',c||'gb2312','&pic=',e(p||'')].join('');function%20a(){if(!window.open([f,p].join(''),'mb',['toolbar=0,status=0,resizable=1,width=440,height=430,left=',(s.width-440)/2,',top=',(s.height-430)/2].join('')))u.href=[f,p].join('');};if(/Firefox/.test(navigator.userAgent))setTimeout(a,0);else%20a();})(screen,document,encodeURIComponent,'','','','@" + GetItemData(str , 'screen_name') + " 的原创率" + GetItemData(str , 'original_status_count') + "%,活跃度排名" + (GetItemData(str , 'active_rank') == '' ? '--' : GetItemData(str , 'active_rank')) + "位,影响力排名" + GetItemData(str , 'influence_rank') + "位,PR值" + GetItemData(str , 'people_rank') + ",微博价值" + GetItemData(str , 'value') + "  (来自#微博风云#) 详情请点击：','http://www.tfengyun.com/user.php?screen_name=" + userid + "',''));";
			break;
		case 'qq':
			tfengyun.$('share').innerHTML = '@' + GetItemData(str , 'screen_name') + ' 的原创率' + GetItemData(str , 'original_status_count') + '%,活跃度排名' + (GetItemData(str , 'active_rank') == '' ? '--' : GetItemData(str , 'active_rank')) + '位,影响力排名' + GetItemData(str , 'influence_rank') + '位,PR值' + GetItemData(str , 'people_rank') + ',微博价值' + GetItemData(str , 'value');
			tfengyun.$('qqTxt').innerHTML = '<a href="javascript:void(0)" class="blue" onclick="postToWb({t:\''+'@' + GetItemData(str , 'id') + ' 的活跃度排名' + (GetItemData(str , 'active_rank') == '' ? '--' : GetItemData(str , 'active_rank')) + '位,影响力排名' + GetItemData(str , 'influence_rank') + '位,PR值' + GetItemData(str , 'people_rank') + ',微博价值' + GetItemData(str , 'value') + '  (来自 #微博风云#) 详情请点击：'+'\'});return false;"><img src="http://image.tfengyun.com/image/ttIcon.gif" align="absmiddle" border="0" /> 分享到腾讯微博</a>&nbsp;&nbsp;';

			break;
		case '163':
			
			break;
		case 'sohu':
			tfengyun.$('share').innerHTML = '@' + GetItemData(str , 'screen_name') + ' 的微博注册' + GetItemData(str , 'regtime') + '天,原创率' + GetItemData(str , 'original_status_count') + '%,活跃度排名' + (GetItemData(str , 'active_rank') == '' ? '--' : GetItemData(str , 'active_rank')) + '位,影响力排名' + GetItemData(str , 'influence_rank') + '位,PR值' + GetItemData(str , 'people_rank') + ',微博价值' + GetItemData(str , 'value');
			tfengyun.$('shareLink').href = "javascript:void((function(s,d,e,r,l,p,t,z,c){var f='http://t.sohu.com/third/post.jsp?',u=z||d.location,p=['&appkey=','3OqK8Ug5fifBfttTJT4e','&url=',e(u),'&title=',e(t||d.title),'&content=',c||'gb2312','&pic=',e(p||'')].join('');function%20a(){if(!window.open([f,p].join(''),'mb',['toolbar=0,status=0,resizable=1,width=660,height=470,left=',(s.width-660)/2,',top=',(s.height-470)/2].join('')))u.href=[f,p].join('');};if(/Firefox/.test(navigator.userAgent))setTimeout(a,0);else%20a();})(screen,document,encodeURIComponent,'','','','@" + GetItemData(str , 'screen_name') + " 的原创率" + GetItemData(str , 'original_status_count') + "%,活跃度排名" + (GetItemData(str , 'active_rank') == '' ? '--' : GetItemData(str , 'active_rank')) + "位,影响力排名" + GetItemData(str , 'influence_rank') + "位,PR值" + GetItemData(str , 'people_rank') + ",微博价值" + GetItemData(str , 'value') + "  (来自#微博风云#) 详情请点击：','http://www.tfengyun.com/user.php?screen_name=" + userid + "','utf-8'));";
			break;
	}
	tfengyun.$('updateTime').innerHTML = strftime(server_time);// //////////////////////////////////////
	loadDiv(false);
	var shareStr = '<textarea name="" readonly="readonly" wrap="physical" style="width:97%;border:1px solid #dedede;height:70px;">' + tfengyun.$('share').innerHTML + '</textarea>';
	setTimeout(function() {if(repost_to_weibo) errorPoint(shareStr,2)},2000);
}

function userSearch(name) {
	window.open('user.php?f=c&screen_name=' + encodeURIComponent(name));
}

function saveImg(img,img1,img2) {
	this.img = img;
	this.img1 = img1;
	this.img2 = img2;
}

var saveVar = [];
function DealUserHot(str) {
	var itemlist = ExtractStringList(str , 'status');
	var string = '';
	var base = 0;
	for(var i = 0 ; i < itemlist.length; i++) {
		var created_at = GetItemData(itemlist[i] , 'created_at');
		var text = GetItemData(itemlist[i] , 'text');
		var source = GetItemData(itemlist[i] , 'source');
		var screen_name = GetItemData(itemlist[i] , 'screen_name');
		var rt = GetItemData(itemlist[i] , 'rt');
		var comments = GetItemData(itemlist[i] , 'comments');
		var texted = text.replace(/\s*@([A-Za-z0-9_\u4e00-\u9fa5]*)\s?/gi,"<span style='color:#4f8cc9;cursor:pointer;' onclick=userSearch('$1')>@$1</span>");
		if(GetItemData(itemlist[i] , 'retweeted_status')) {
			var retweeted = GetItemData(itemlist[i] , 'retweeted_status');
			var name = ExtractStringList(retweeted , 'user');
			if(GetItemData(itemlist[i] , 'thumbnail_pic')) {
				saveVar[base] = new saveImg(GetItemData(itemlist[i] , 'thumbnail_pic'),GetItemData(itemlist[i] , 'bmiddle_pic'),GetItemData(itemlist[i] , 'original_pic'));
				string += '<div class="weibo">' +
								'<div class="weiboTxt">' + texted + '</div>' +
								'<div class="weiboRt">' +
									'<p>' + '<a class="blue" target="_blank" href="user.php?f=s&screen_name=' + ExtractStringList(name , 'id') + '">@' + ExtractStringList(name , 'screen_name') + '</a>：' + ExtractStringList(retweeted , 'text') + '</p>' +
									'<div class="weiboImg">' +
										'<img type="s" src="' + saveVar[base].img + '" />' +
									'</div>' +
									'<div><div class="rtfrom"></div></div>' +
								'</div>' +
								'<div class="weiboint">' + '<span style="float:right;">评论(' + comments + ')' + '&nbsp;' + '转发(' + rt + ')' + '</span>' + source + '&nbsp;' +strftime(created_at) + '</div>' +
							'</div>';
				base++;
			}else {
				string += '<div class="weibo">' +
								'<div class="weiboTxt">' + texted + '</div>' +
								'<div class="weiboRt">' +
									'<p>' + '<a class="blue" target="_blank" href="user.php?f=s&screen_name=' + ExtractStringList(name , 'id') + '">@' + ExtractStringList(name , 'screen_name') + '</a>：' + ExtractStringList(retweeted , 'text') + '</p>' +
									'<div><div class="rtfrom"></div></div>' +
								'</div>' +
								'<div class="weiboint">' + '<span style="float:right;">评论(' + comments + ')' + '&nbsp;' + '转发(' + rt + ')' + '</span>' + source + '&nbsp;' +strftime(created_at) + '</div>' +
							'</div>';
			}
		}else {
			if(GetItemData(itemlist[i] , 'thumbnail_pic')) {
			saveVar[base] = new saveImg(GetItemData(itemlist[i] , 'thumbnail_pic'),GetItemData(itemlist[i] , 'bmiddle_pic'),GetItemData(itemlist[i] , 'original_pic'));
			string += '<div class="weibo">' +
							'<div class="weiboTxt">' + texted + '</div>' +
							'<div class="weiboImg"><img type="s" src="' + saveVar[base].img + '" /></div>' +
							'<div class="weiboint">' + '<span style="float:right;">评论(' + comments + ')' + '&nbsp;' + '转发(' + rt + ')' + '</span>' + source + '&nbsp;' +strftime(created_at) + '</div>' +
						'</div>';
			base++;
			}else {
					string += '<div class="weibo">' +
							'<div class="weiboTxt">' + texted + '</div>' +
							'<div class="weiboint">' + '<span style="float:right;">评论(' + comments + ')' + '&nbsp;' + '转发(' + rt + ')' + '</span>' + source + '&nbsp;' +strftime(created_at) + '</div>' +
						'</div>';
			}
		}
		
	}
	Datastatistics(string);
}

function DealUserAttention(str) {
	var itemlist = ExtractStringList(str , 'text');
	var string = '' , stringA = '';
	for(var i = 0 ; i < itemlist.length ; i++) {
		if(i < 15) {
			string += itemlist[i] + '　';
			stringA += '#' + itemlist[i] + '#　';
		}
	}
	if(string !== '') {

		switch(weiboType()) {
			case 'sina':
				tfengyun.$('attention').innerHTML = string + ' <a class="blue" href="" style="font-size:12px;" id="statusesId"><img src="http://image.tfengyun.com/image/sinaIcon1.gif" border="0" align="absmiddle" title="分享到微博" /></a>';
				tfengyun.$('statusesId').href = "javascript:void((function(s,d,e,r,l,p,t,z,c){var%20f='http://v.t.sina.com.cn/share/share.php?appkey=878922546',u=z||d.location,p=['&url=',e(u),'&title=',e(t||d.title),'&source=',e(r),'&sourceUrl=',e(l),'&content=',c||'gb2312','&pic=',e(p||'')].join('');function%20a(){if(!window.open([f,p].join(''),'mb',['toolbar=0,status=0,resizable=1,width=440,height=430,left=',(s.width-440)/2,',top=',(s.height-430)/2].join('')))u.href=[f,p].join('');};if(/Firefox/.test(navigator.userAgent))setTimeout(a,0);else%20a();})(screen,document,encodeURIComponent,'','','','@" + screen_name + ' 正在关注：' + stringA + " (来自#微博风云#) 详情请点击：','http://www.tfengyun.com/user.php?screen_name="+userid+"',''));";
				break;
			case 'qq':
				tfengyun.$('attention').innerHTML = string + '<a href="javascript:void(0)" style="font-size:12px;" class="blue" onclick="postToWb({t:\'@'+ userid + ' 正在关注：' + stringA + '  (来自 #微博风云#) 详情请点击：'+'\'});return false;"><img src="http://image.tfengyun.com/image/ttIcon.gif" border="0" align="absmiddle" title="分享到微博" /></a>&nbsp;&nbsp;';
				break;
			case '163':
				
				break;
			case 'sohu':
				tfengyun.$('attention').innerHTML = string + ' <a class="blue" href="" style="font-size:12px;" id="statusesId"><img src="http://beta.tfengyun.com/image/16icon.gif" border="0" align="absmiddle" title="分享到搜狐微博" /></a>';
				tfengyun.$('statusesId').href = "javascript:void((function(s,d,e,r,l,p,t,z,c){var f='http://t.sohu.com/third/post.jsp?',u=z||d.location,p=['&appkey=','3OqK8Ug5fifBfttTJT4e','&url=',e(u),'&title=',e(t||d.title),'&content=',c||'gb2312','&pic=',e(p||'')].join('');function%20a(){if(!window.open([f,p].join(''),'mb',['toolbar=0,status=0,resizable=1,width=660,height=470,left=',(s.width-660)/2,',top=',(s.height-470)/2].join('')))u.href=[f,p].join('');};if(/Firefox/.test(navigator.userAgent))setTimeout(a,0);else%20a();})(screen,document,encodeURIComponent,'','','','@" + screen_name + ' 正在关注：' + stringA + " (来自#微博风云#) 详情请点击：','http://sohu.tfengyun.com/user.php?screen_name="+userid+"','utf-8'));";
				break;
		}
	}else {
		tfengyun.$('attention').innerHTML = '暂无数据';
	}
}

function DealUserKeyword(str) {
	var itemlist = ExtractStringList(str , 'keyword1');
	var itemlist1 = ExtractStringList(str , 'keyword2');
	var string = [[''],['']];
	var stringRe = [[''],['']];
	for(var i = 0 ; i < itemlist.length ; i++) {
		var len = ExtractStringList(itemlist[i] , 'text');
		for(var loop = 0 ; loop < len.length ; loop++) {
			string[0] += len[loop] + '　';
			stringRe[0] += '#' + len[loop] + '#　';
		}
	}
	for(var i = 0 ; i < itemlist1.length ; i++) {
		var len = ExtractStringList(itemlist1[i] , 'text');
		for(var loop = 0 ; loop < len.length ; loop++) {
			string[1] += len[loop] + '　';
			stringRe[1] += '#' + len[loop] + '#　';
		}
	}
	Datastatistics(string,stringRe);
}

function GetUserDetail(userId , last_update_time , server_time , limit) {
	if(!compareTime(last_update_time , server_time)) return;
	if(userId) {
		var url = 'api.php?type=user_detail&refresh=1&userid=' + userId;
		getData(url , 1 , 15000 , function() {
			// errorPoint('加载超时',1);
			loadDiv(false);
		});
	}
}

//
function DealRankingXML(str)
{
	var itemlist = ExtractStringList(str, "item");
	var obj = tfengyun.$('rankForwardBg');
	var stra = GetItemData(str, 'title') + '分类按' + rankTitle(parseInt(GetItemData(str, 'orderby'))) + '排名前10名是:';
	var straqq = stra;
	for (var i=0; i<itemlist.length; i++)
	{
		var subitem = itemlist[i];
		itemList[i] = new SaveUser(GetItemData(subitem, 'id'),GetItemData(subitem, 'screen_name'),GetItemData(subitem, 'location'),GetItemData(subitem, 'description'),GetItemData(subitem, 'active_ranking'),GetItemData(subitem, 'influence_ranking'),GetItemData(subitem, 'comment'),GetItemData(subitem, 'repost'),GetItemData(subitem, 'statuses_count'),GetItemData(subitem, 'followers_count'),GetItemData(subitem, 'people_rank'),GetItemData(subitem, 'score'),GetItemData(subitem, 'value'),GetItemData(subitem, 'profile_image_url'));
		if(i<10 && obj) {

				i!==9 ? straqq += ' @' + GetItemData(subitem, 'id') + ' ,' : straqq += ' @' + GetItemData(subitem, 'id');	
				

				i!==9 ? stra += ' @' + GetItemData(subitem, 'screen_name') + ' ,' : stra += ' @' + GetItemData(subitem, 'screen_name');

		}
	}
	if(obj) {

		switch(weiboType()) {
			case 'sina':
				tfengyun.$('rankForwardBg').innerHTML = '<p>' + stra + '</p><span><a href="" id="sentA"><img src="http://image.tfengyun.com/image/sinaIcon1.gif" align="absmiddle" border="0" /> 分享到新浪微博</a></span>';
				tfengyun.$('sentA').href = "javascript:void((function(s,d,e,r,l,p,t,z,c){var%20f='http://v.t.sina.com.cn/share/share.php?appkey=878922546',u=z||d.location,p=['&url=',e(u),'&title=',e(t||d.title),'&source=',e(r),'&sourceUrl=',e(l),'&content=',c||'gb2312','&pic=',e(p||'')].join('');function%20a(){if(!window.open([f,p].join(''),'mb',['toolbar=0,status=0,resizable=1,width=440,height=430,left=',(s.width-440)/2,',top=',(s.height-430)/2].join('')))u.href=[f,p].join('');};if(/Firefox/.test(navigator.userAgent))setTimeout(a,0);else%20a();})(screen,document,encodeURIComponent,'','','','"+stra+" (来自#微博风云#) 详情请点击：','http://www.tfengyun.com/rankings.php?sortid="+sor+"&orderby="+parseInt(GetItemData(str, 'orderby'))+"',''));";
				break;
			case 'qq':
				tfengyun.$('rankForwardBg').innerHTML='<p>' + stra + '</p><span><a href="javascript:void(0)" class="blue" onclick="postToWb({t:\''+straqq+ '  (来自 #微博风云#) 详情请点击：'+'\'});return false;"><img src="http://image.tfengyun.com/image/ttIcon.gif" align="absmiddle" border="0" /> 分享到腾讯微博</a></span>';
				break;
			case '163':
				
				break;
			case 'sohu':
				tfengyun.$('rankForwardBg').innerHTML='<p>' + stra + '</p><span><a id="sentA" href=""><img src="http://beta.tfengyun.com/image/16icon.gif" align="absmiddle" border="0" /> 分享到搜狐微博</a></span>';
				tfengyun.$('sentA').href = "javascript:void((function(s,d,e,r,l,p,t,z,c){var f='http://t.sohu.com/third/post.jsp?',u=z||d.location,p=['&appkey=','3OqK8Ug5fifBfttTJT4e','&url=',e(u),'&title=',e(t||d.title),'&content=',c||'gb2312','&pic=',e(p||'')].join('');function%20a(){if(!window.open([f,p].join(''),'mb',['toolbar=0,status=0,resizable=1,width=660,height=470,left=',(s.width-660)/2,',top=',(s.height-470)/2].join('')))u.href=[f,p].join('');};if(/Firefox/.test(navigator.userAgent))setTimeout(a,0);else%20a();})(screen,document,encodeURIComponent,'','','','"+stra+" (来自#微博风云#) 详情请点击：','http://sohu.tfengyun.com/rankings.php?sortid="+sor+"&orderby="+parseInt(GetItemData(str, 'orderby'))+"','utf-8'));";
				break;
		}
	}
	if(tfengyun.$('listTitle')) tfengyun.$('listTitle').innerHTML = GetItemData(str, 'title');
	writeCount(itemlist.length);
	loadDiv(false);
}

function GetItemData(data, item)
{
	data = "data" + data;
	var SItem = "<" + item + ">";
	var EItem = "</" + item + ">";
	var StrLen = SItem.length;
	var Begin = 0;

	if((Begin =  data.indexOf(SItem, Begin))){
		var End = data.indexOf(EItem, Begin + StrLen);
		if(End - Begin > StrLen){
			var ItemText = data.substring(Begin + StrLen,End);
			return ItemText;
		}
	}
	return "";
}

function ExtractStringList(data, item)
{
    data = "data" + data;
	if (data.length == 0)
		return;

	var itemlist = [];
	var strStart = "<" + item + ">";
	var strEnd = "</" + item + ">";

	var Start = 1;
	var End   = 1;

	while ((Start = data.indexOf(strStart, Start)) > 0) {
		var End = data.indexOf(strEnd, Start+1);
		if (End > Start) {
			var LineData = data.substring(Start + strStart.length, End);
			itemlist.push(LineData);
		
			// 载入完成
			Start = End;
		} else break;
	}

	return itemlist;
}


//
function writeCount(num) {
	var str = '' , numBase = 0;
	for(var i = 0 ; i < num ; i++) {
		numBase++;
		var user_location='';
		itemList[i].locationD==''||itemList[i].locationD=='未知'?user_location='':user_location='[' + itemList[i].locationD + ']';

		switch(weiboType()) {
			case 'sina':
				var head = '<div class="rankhead"><a href="user.php?screen_name=' + itemList[i].id + '" class="blue" target="_blank"><img src="http://tp1.sinaimg.cn/' + itemList[i].id + '/30/5602405246/1" border="0" /></a></div>';
				break;
			case 'qq':
				var head = '<div class="rankhead"><a href="user.php?screen_name=' + itemList[i].id + '" class="blue" target="_blank"><img src="' + itemList[i].imgurl + '/30" border="0" width="30" /></a></div>';
				break;
			case '163':
				
				break;
			case 'sohu':
				var head = '<div class="rankhead"><a href="user.php?screen_name=' + itemList[i].id + '" class="blue" target="_blank"><img src="' + itemList[i].imgurl + '" border="0" width="30" /></a></div>';
				break;
		}
		str += '<li class="hideList">' +
                	'<div class="user">' +
                    	'<div class="rankNum"><span>' + numBase + '</span></div>' + head +
                        '<div class="rankDes"><a href="user.php?screen_name=' + itemList[i].id + '" class="blue" target="_blank">' + itemList[i].screenName + '</a>' + user_location + '<p>' + itemList[i].des + '<p></div>' +
                    '</div>' +
                    '<div class="hy">' + itemList[i].activeRank + '</div>' +
                    '<div class="yx">' + itemList[i].influenceRank + '</div>' +
                    '<div class="zh">' + itemList[i].val + '元</div>' +
                    '<div class="pl">' + Remainder(itemList[i].comment,1) + '-' + Remainder(itemList[i].repost,1) + '</div>' +
                    '<div class="num">' + itemList[i].statusesCount + '-' + itemList[i].followersCount + '</div>' +
                    '<div class="hf">' + (itemList[i].activeFans == '' ? '--' : itemList[i].activeFans) + '</div>' +
                    '<div class="jz">' +
                    	'<dl>' +
                        	'<dt>' + itemList[i].peopleRank + '</dt>' +
                        '</dl>' +
                    '</div>' +
                '</li>';
	}
	tfengyun.$('rankTable').innerHTML = str;
	pubTabSwitch({  // 类别分类 标签切换
		objId:'rank',
		showClass:'showList',
		hideClass:'hideList',
		childNode:'li',
		showDiv:true
	});
}

// get float
function Remainder(number , base) {
	return parseFloat(number/base);
}

//
var listBase = 1 , ob = 0 , sor = '' , prov = '' , ct = '' , cn = 0;
function rank(sortId,count,orderby,province,city) {
	sor = sortId;
	prov = province;
	ct = city;
	ob = orderby;
	cn = count;
	
	getData('ranking.php?xml=1&sortid=' + sortId + '&count=' + cn + '&orderby=' + moveList(ob,true) + '&province=' + prov + '&city=' + ct,0,15000,function() {
		errorPoint('加载超时',1);
		loadDiv(false);
	});
	$('#rankClick').find('span').each(function(i) {
		if(ob == i) $(this).addClass('titleShow');
		$(this).click(function(e) {
			if(i !== 0) {
				$(this).parent().parent().children().children().removeClass('titleShow');
				$(this).addClass('titleShow');
				ob = i;
				moveList(ob);
			}
		});
	});
}

function moveList(num , tf) {
	var b = cn*listBase;
	orderByVar = num;
	switch(num) {
				case 1:
					if(tf) return 2;
					getRankings(sor,b,2,prov,ct);  //
				break;
				case 2:
					if(tf) return 1;
					getRankings(sor,b,1,prov,ct);
				break;
				case 3:
					if(tf) return 8;
					getRankings(sor,b,8,prov,ct);
				break;
				case 4:
					if(tf) return 4;
					getRankings(sor,b,4,prov,ct);
				break;
				case 5:
					if(tf) return 3;
					getRankings(sor,b,3,prov,ct);
				break;
				case 6:
					if(tf) return 6;
					getRankings(sor,b,6,prov,ct);
				break;
				case 7:
					if(tf) return 5;
					getRankings(sor,b,5,prov,ct);
				break;
				case 8:
					if(tf) return 9;
					getRankings(sor,b,9,prov,ct);
				break;
				case 9:
					if(tf) return 7;
					getRankings(sor,b,7,prov,ct);
				break;
			}
}

function rankTitle(num) {
	switch(num) {
				case 1:
					return '影响力';
				break;
				case 2:
					return '活跃度';
				break;
				case 3:
					return '转发数';
				break;
				case 4:
					return '评论数';
				break;
				case 5:
					return '粉丝数';
				break;
				case 6:
					return '微博数';
				break;
				case 7:
					return 'PR值';
				break;
				case 8:
					return '微博价值';
				break;
				case 9:
					return '活跃粉丝';
				break;
			}
}

function moveClick() {
	listBase++;
	moveList(ob);
}

function getRankings(sortId,count,orderBy,province,city) {
	var url = 'ranking.php?xml=1&sortid=' + sortId + '&count=' + count + '&orderby=' + orderBy + '&province=' + province + '&city=' + city;
	getData(url , 0 , 15000 , function() {
		errorPoint('加载超时',1);
		loadDiv(false);
	});
}

// [screen_name,location,id]
function writeHistoryCookie(cookies,limit) {
	
	// view self return
	try {if(my_userid == userid) {
		showHistory(limit);
		return;
	}}catch(err) {}
	if(!cookies||!cookies[2]){
		showHistory(limit);
		return;
	}
	
	// read all history
	var hist = [];
	
	for(var i=0;i<limit;i++){
		if(!CookieHelper.getCookie('id'+i))break;
		var t_id=CookieHelper.getCookie('id'+i);
		// no this group
		cookies[2]=cookies[2].replace(/^\s*|\s*$/g,'');
		if(cookies[2]==t_id)continue;
		
		var temp=[];
		temp.push(unescape(CookieHelper.getCookie('screen_name'+i)));
		temp.push(unescape(CookieHelper.getCookie('location'+i)));
		temp.push(t_id);
		temp.push(unescape(CookieHelper.getCookie('profile_image_url'+i)));
		hist.push(temp);
	}
	// limit
	hist=hist.slice(0,limit-2);
	// put to first
	hist.unshift(cookies);
	// writhe all
	for(var i=0;i<hist.length;i++){
		CookieHelper.setCookie('screen_name'+i,escape(hist[i][0]),3600 * 24 * 365 * 10,'/','tfengyun.com');
		CookieHelper.setCookie('location'+i,escape(hist[i][1]),3600 * 24 * 365 * 10,'/','tfengyun.com');
		CookieHelper.setCookie('id'+i,escape(hist[i][2]),3600 * 24 * 365 * 10,'/','tfengyun.com');
		CookieHelper.setCookie('profile_image_url'+i,escape(hist[i][3]),3600 * 24 * 365 * 10,'/','tfengyun.com');
	}
	// screen_nmae
	showHistory(limit);
}
function showHistory(limit) {
	var str='',strSearch='';
	for(var i=0;i<limit;i++){
		if(!CookieHelper.getCookie('id'+i))break;
		switch(weiboType()) {
			case 'sina':
				var headUrl = 'http://tp1.sinaimg.cn/' + CookieHelper.getCookie('id'+i) + '/30/5602405246/1';
				break;
			case 'qq':
				var headUrl = CookieHelper.getCookie('profile_image_url'+i) + '/30';
				break;
			case '163':
				
				break;
			case 'sohu':
				var headUrl = CookieHelper.getCookie('profile_image_url'+i);
				break;
		}
		headUrl?headUrl:headUrl='http://mat1.gtimg.com/www/mb/images/head_30.jpg';
		str += '<li>' +
                	'<div class="imgPL">' +
                    	'<a href="user.php?f=c&screen_name=' + CookieHelper.getCookie('id'+i) + '" class="blue"><img src="'+headUrl+'" border="0" width="30" /></a>' +
                    '</div>' +
                    '<p><a href="user.php?f=c&screen_name=' + CookieHelper.getCookie('id'+i) + '" class="blue">' + unescape(CookieHelper.getCookie('screen_name'+i)) + '</a><br />位置：' + unescape(CookieHelper.getCookie('location'+i)) + '</p>' +
                '</li>';
		strSearch += '<a href="user.php?f=c&screen_name=' + CookieHelper.getCookie('id'+i) + '" class="blue"><img src="'+headUrl+'" style="float:left;margin-right:5px;padding:1px;border:1px solid #eee;width:30px;" /></a>'+' ';

	}
	if(str == '') {
		tfengyun.$('keywordsSearch').innerHTML = '无查询记录';
		if(tfengyun.$('history')) tfengyun.$('history').innerHTML = '<li style="line-height:50px; text-align:center;">无历史记录</li>';
	//	if(tfengyun.$('clearJl')&&gethost().indexOf('qq.')==-1) {
				//tfengyun.$('clearJl').style.display = 'none';
				//ontlet(2);
		//}
	}else{
		if(tfengyun.$('history')) tfengyun.$('history').innerHTML = str;
		tfengyun.$('keywordsSearch').innerHTML = '<span style="padding:0 0 3px 0; width:100%; display:block;">最近查询记录:</span>'+strSearch;
	}
}

// 加入收藏
function addfavorite() {
	if (document.all) {
		window.external.addFavorite(window.location,'微博风云');
	}else if (window.sidebar) {
		window.sidebar.addPanel('微博风云', window.location, "");
	}
} 

// load Div
function loadDiv(tf,val) {
	if(tf) {
		if(document.getElementById('loading')) document.body.removeChild(document.getElementById('loading'));
		var getWidth = document.body.clientWidth;
		var divWidth = 200;
		var leftVal = parseInt(getWidth/2) - parseInt(divWidth/2);
		var objDiv = document.createElement("div");
		with(objDiv.style) {
			width = divWidth + 'px';
			borderWidth = '1px';
			borderColor = '#febf6e';
			borderStyle = 'solid';
			backgroundColor = '#fff7b5';
			height = '26px';
			JudgeIe() ? position = 'absolute' : position = 'fixed';
			top = '0px';
			zIndex = '99999';
			left = leftVal + 'px';
			fontSize = '12px';
			lineHeight = '26px';
			textAlign = 'center';
		}
		objDiv.setAttribute("id","loading");
		objDiv.innerHTML = val;
		document.body.appendChild(objDiv);
		if(JudgeIe()) {
			if($('#loading')) objDiv.style.top = get_scrollTop_of_body() + 'px';
			$(window).scroll(function() {
				if($('#loading')) objDiv.style.top = get_scrollTop_of_body() + 'px';
			});
			
		}
	}else {
		if(document.getElementById('loading')) document.body.removeChild(document.getElementById('loading'));
	}
}

// get time
function compareTime(val , server) {
	if((server - val*1000) > (3600 * 24 * 1000)) return true;
}

// show Time
function strftime(timestamp) {
	if(typeof timestamp == 'string') {
		return timestamp;
	}
	var now = timestamp.toString().length < 13 ? new Date(timestamp * 1000) : new Date(timestamp);
	var myYears = (now.getYear() < 1900) ? (1900+now.getYear()) : now.getYear();
	return myYears + '.' + ((now.getMonth() + 1) < 10 ? "0" + (now.getMonth() + 1) : (now.getMonth() + 1)) + '.' + (now.getDate() < 10 ? "0" + now.getDate() : now.getDate()) + ' ' + (now.getHours() < 10 ? "0" + now.getHours() : now.getHours()) + ':' + (now.getMinutes() < 10 ? "0" + now.getMinutes() : now.getMinutes());
}


//
function errorPoint(val,type) {
	if(JudgeIe()) {
		if(type!==2) alert(val);
		return;
	}
	if(document.getElementById('fra')) return;
	$(document.createElement("div"))
	.attr('id','fra')
  .css({
   position : "absolute",
   "z-index" : 999999999999999999,
   left : "0px",
   top : 0,
   zoom : 1,
   width : $(document).width(),
   height : $(document).height(),
   "overflow":"hidden"
  }).appendTo($(document.body))
  .append("<div  id='_alpha' style='position:absolute;z-index:999999999999999999;width:100%;height:100%;left:0;top:0;opacity:0.3;filter:Alpha(opacity=30);background:#000'></div><div id='_iframe' style='position:absolute;z-index:999999999999999999;'></div>");
  $("#_iframe").append('<div style="background:#f00;" >' +
							'<div class="Twin" style=" width:300px;" id="dw"></div>' +
								'<div class="TwinCou" style=" width:288px;" id="dw1">' +
								'</div>' +
							'</div>');
  switch(type) {
		case 0:
			switch(weiboType()) {
				case 'sina':
					$('#dw1').css('height','388px');
					$('#dw').css('height','400px');
					$('#dw1').html('<div style="border:1px solid #dddddd; position:absolute; z-index:3; padding:0 4px; background:#fefefe; cursor:pointer; top:5px; right:5px;color:#646464; font-size:12px;" onclick="userVs(true);">X</div>' +
							'<dl id="title" style="font-size:14px;"></dl>' +
									'<dl>' +
										'<dt><input type="text" id="inpuN" style="width:180px" /></dt>' +
										'<dd><img src="http://image.tfengyun.com/image/ok.gif" onclick="clickUser();" /></dd>' +
									'</dl>' +
									'<dl style="margin-top:5px; text-align:left; text-indent:20px;">这里输入您想查询人的昵称 例如“姚晨”<br /></dl>' +
									'<dl style="margin-top:5px; text-align:left; text-indent:20px;"><b>您是否对他们感兴趣？</b></dl>' +
									'<ul id="headtr" style="padding-left:12px;">' +
										'<li style="width:38px; height:45px;"><a href="user.php?type=mypage"><img src="http://tp1.sinaimg.cn/' + my_userid + '/30/5602405246/1" style="padding:1px; border:1px solid #e5e5e5;" title="我自己" /></a></li>' +
										'<li style="width:38px; height:47px;"><a href="user.php?screen_name=%E5%A7%9A%E6%99%A8"><img src="http://tp1.sinaimg.cn/1266321801/30/5602405246/1" style="padding:1px; border:1px solid #e5e5e5;" title="姚晨" /></a></li>' +
										'<li style="width:38px; height:47px;"><a href="user.php?screen_name=%E6%9D%A8%E5%B9%82"><img src="http://tp1.sinaimg.cn/1195242865/30/5602405246/1" style="padding:1px; border:1px solid #e5e5e5;" title="杨幂" /></a></li>' +
										'<li style="width:38px; height:47px;"><a href="user.php?screen_name=%E6%9D%8E%E5%BC%80%E5%A4%8D"><img src="http://tp1.sinaimg.cn/1197161814/30/5602405246/1" style="padding:1px; border:1px solid #e5e5e5;" title="李开复" /></a></li>' +
										'<li style="width:38px; height:45px;"><a href="user.php?screen_name=%E9%BB%84%E5%81%A5%E7%BF%94"><img src="http://tp1.sinaimg.cn/1362607654/30/5602405246/1" style="padding:1px; border:1px solid #e5e5e5;" title="黄健翔" /></a></li>' +
									'</ul>' +
									'<dl style="width:250px; padding-left:20px; line-height:20px; text-align:left;"><b>微博风云建议您：</b><br />1. 如果该微博的微博数或者粉丝数为0，暂不能参加评级.<br />2. 请确认 <a class="blue" href="http://t.sina.com.cn/n/' + getSearchCookie() + '" target="_blank">http://t.sina.com.cn/n/' + getSearchCookie() + '</a> 这个微博是否存在.<br />3. 请注意昵称是否是繁体字！建议直接复制您微博首页上的昵称.</dl>');
					break;
				case 'qq':
					$('#dw1').css('height','438px');
					$('#dw').css('height','450px');
					$('#dw1').html('<div style="border:1px solid #dddddd; position:absolute; z-index:3; padding:0 4px 0 4px; background:#fefefe; cursor:pointer; top:5px; right:5px;color:#646464; font-size:12px;" onclick="userVs(true);">X</div>' +
							'<dl id="title" style="font-size:14px;"></dl>' +
									'<dl>' +
										'<dt><input type="text" id="inpuN" style="width:180px" /></dt>' +
										'<dd><img src="http://image.tfengyun.com/image/ok.gif" onclick="clickUser();" /></dd>' +
									'</dl>' +
									'<dl style="margin-top:5px; text-align:left; text-indent:20px;">这里输入查询人的ID<br /></dl>' +
									'<dl style="margin-top:5px; text-align:left; text-indent:20px;"><b>您是否对他们感兴趣？</b></dl>' +
									'<ul id="headtr" style="padding-left:12px;">' +
										'<li style="width:38px; height:45px;"><a href="user.php?screen_name=zhangjunyivip"><img src="http://t1.qlogo.cn/mbloghead/fbf2301965a8ff1b725e/30" style="padding:1px; border:1px solid #e5e5e5;" title="张俊以" /></a></li>' +
										'<li style="width:38px; height:47px;"><a href="user.php?screen_name=jeasonleslie"><img src="http://t1.qlogo.cn/mbloghead/a6aebca855acd7052580/30" style="padding:1px; border:1px solid #e5e5e5;" title="周振霆" /></a></li>' +
										'<li style="width:38px; height:47px;"><a href="user.php?screen_name=fangsanjun2011"><img src="http://t3.qlogo.cn/mbloghead/690767c83df3918734b4/30" style="padding:1px; border:1px solid #e5e5e5;" title="方三俊" /></a></li>' +
										'<li style="width:38px; height:47px;"><a href="user.php?screen_name=xyyuan521"><img src="http://t3.qlogo.cn/mbloghead/141c699c76bc96ca6afa/30" style="padding:1px; border:1px solid #e5e5e5;" title="夏元元" /></a></li>' +
										'<li style="width:38px; height:45px;"><a href="user.php?screen_name=lizihan_22731001"><img src="http://t3.qlogo.cn/mbloghead/606f6f2a1234bbe4f57a/30" style="padding:1px; border:1px solid #e5e5e5;" title="李川" /></a></li>' +
									'</ul>' +
									'<dl style="width:250px; padding-left:20px; line-height:20px; text-align:left;"><b>微博风云建议您：</b><br />1. 要输入被查询人的ID 而不是用户昵称  例:<br />(1)进入何炅微博主页 如图 粘贴红色框内的ID.<br />(2)进入微博风云在搜索框输入刚刚粘贴的ID.<br /><img src="http://beta.tfengyun.com/image/qqt.gif" /><br />2. 如果该微博的微博数或者粉丝数为0，暂不能参加评级.<br />3. 请确认<a class="blue" href="http://t.qq.com/' + getSearchCookie() + '" target="_blank">http://t.qq.com/' + getSearchCookie() + '</a> 这个微博是否存在.</dl>');
					break;
				case '163':
					
					break;
				case 'sohu':
					$('#dw1').css('height','388px');
					$('#dw').css('height','400px');
					$('#dw1').html('<div style="border:1px solid #dddddd; position:absolute; z-index:3; padding:0 4px; background:#fefefe; cursor:pointer; top:5px; right:5px;color:#646464; font-size:12px;" onclick="userVs(true);">X</div>' +
							'<dl id="title" style="font-size:14px;"></dl>' +
									'<dl>' +
										'<dt><input type="text" id="inpuN" style="width:180px" /></dt>' +
										'<dd><img src="http://image.tfengyun.com/image/ok.gif" onclick="clickUser();" /></dd>' +
									'</dl>' +
									'<dl style="margin-top:5px; text-align:left; text-indent:20px;">这里输入您想查询人的昵称 例如“崔永元”<br /></dl>' +
									'<dl style="margin-top:5px; text-align:left; text-indent:20px;"><b>您是否对他们感兴趣？</b></dl>' +
									'<ul id="headtr" style="padding-left:12px;">' +
										'<li style="width:38px; height:45px;"><a href="user.php?screen_name=999703"><img src="http://s5.cr.itc.cn/mblog/icon/1d/bc/12898048215245.jpg" width="30" style="padding:1px; border:1px solid #e5e5e5;" title="刘烨" /></a></li>' +
										'<li style="width:38px; height:47px;"><a href="user.php?screen_name=4362874"><img src="http://s5.cr.itc.cn/mblog/icon/25/40/12753576269313.jpg" width="30" style="padding:1px; border:1px solid #e5e5e5;" title="崔永元" /></a></li>' +
										'<li style="width:38px; height:47px;"><a href="user.php?screen_name=999419"><img src="http://s5.cr.itc.cn/mblog/icon/b7/4d/12985737674369.JPG" width="30" style="padding:1px; border:1px solid #e5e5e5;" title="刘亦菲" /></a></li>' +
										'<li style="width:38px; height:47px;"><a href="user.php?screen_name=17997113"><img src="http://s5.cr.itc.cn/mblog/icon/46/9f/4042803588769063.jpg" width="30" style="padding:1px; border:1px solid #e5e5e5;" title="袁国宝" /></a></li>' +
										'<li style="width:38px; height:45px;"><a href="user.php?screen_name=555469"><img src="http://s5.cr.itc.cn/mblog/icon/ac/24/12718307268278.png" width="30" style="padding:1px; border:1px solid #e5e5e5;" title="草根屁民" /></a></li>' +
									'</ul>' +
									'<dl style="width:250px; padding-left:20px; line-height:20px; text-align:left;"><b>微博风云建议您：</b><br />1. 如果该微博的微博数或者粉丝数为0，暂不能参加评级.<br />2. 请确认 <a class="blue" href="http://t.sohu.com/u/' + getSearchCookie() + '" target="_blank">http://t.sohu.com/u/' + getSearchCookie() + '</a> 这个微博是否存在.<br />3. 请注意昵称是否是繁体字！建议直接复制您微博首页上的昵称.</dl>');
					break;
			}
			break;
		case 1:
			$('#dw1').html('<dl id="title" style="font-size:14px;"></dl>' +
							'<ul>' +
								'<li style="width:77px; margin-left:100px;"><img src="http://image.tfengyun.com/image/ok.gif" onclick="userVs()" /></li>' +
							'</ul>');
			$('#dw1').css('height','88px');
			$('#dw').css('height','100px');
		break;
		case 2:
			$('#dw1').html('<dl id="title" style="text-align:left; font-size:12px; width:97%; padding-left:6px;"></dl>' +				
								'<dl style="padding-left:3px; margin:0px;">' +
										'<dt style="padding:1px 0 0 0;"><input id="check" type="checkbox" style="text-indent:0px;" checked="" /></dt>' +
										'<dd>将查询结果分享到我的新浪微博</dd>' +
								'</dl>' +
							'<ul>' +
								'<li style="width:77px; margin-left:100px;" id="queryloading"><img src="http://image.tfengyun.com/image/ok.gif" onclick="query()" /></li>' +
							'</ul>');
			$('#dw1').css('height','158px');
			$('#dw').css('height','170px');
		break;
		case 3:
			$('#dw1').html('<dl id="title" style="font-size:14px;"></dl>' +
							'<ul>' +
								'<li style="width:77px; margin-left:100px;"><img src="http://image.tfengyun.com/image/ok.gif" onclick="userVs()" /></li>' +
							'</ul>');
			$('#dw1').css('height','88px');
			$('#dw').css('height','100px');
		break;
	}
	if(tfengyun.$('title')) tfengyun.$('title').innerHTML = val;
	var getWidth = document.body.clientWidth;
	var getHeight = document.body.clientHeight;
	var divWidth = $('#dw').width();
	var divHeight = $('#dw1').height();
	var leftVal = parseInt(getWidth/2) - parseInt(divWidth/2);
	var topVal = 60;
	with(tfengyun.$('dw').style) {
		top = topVal + 'px';
		left = leftVal + 'px';
		position = "fixed";
		zIndex = 99999999999999;
	}
	with(tfengyun.$('dw1').style) {
		top = topVal + 'px';
		left = leftVal + 'px';
		position = "fixed";
		zIndex = 99999999999999;
	}
}

function checkTF(ev) {
	var obj = typeof ev == 'object' ? ev : tfengyun.$(ev);
	if(obj.checked) {
		return true;	
	}else {
		return false;
	};
}

// 分享查询结果
function query() {
	if(checkTF('check')) {
		tfengyun.$('queryloading').innerHTML = '正在分享...';
		tfengyun.ajax({
			 url:'api.php',
			 data:'type=sharemyinfo&userid=' + my_userid ,
			 method:'POST',
			 success:function(response,xhr){
				if(response) document.body.removeChild(document.getElementById('fra'));
			 },
			 error:function(){
				alert('超时');
			 }
		});
	}else {
		document.body.removeChild(document.getElementById('fra'));
	}
}

function userVs(tf) {
	document.body.removeChild(document.getElementById('fra'));
	if(tf) {
		tfengyun.$('pageCount').style.cssText = 'font-size:12px; text-align:center; color:#646464; line-height:35px;';
		tfengyun.$('pageCount').innerHTML = '此用户不存在或暂未被收录 <a href="/" class="blue">点击这里返回首页</a> 或 重新查询';
	}
}

function setSearchCookie(val) {
	CookieHelper.setCookie('searchName',escape(val),3600 * 24 * 1,'/','tfengyun.com');
}

function getSearchCookie() {
	return unescape(CookieHelper.getCookie('searchName'));	
}



function showlocation()
{
    var province = tfengyun.$("province").value;
    var city = tfengyun.$("city").value;
	city=='不限' ? city = '' : city;
    setp2(province,city);
}


var aprovince = "";
var acity = "";
var aindex = "";
var acount = "20";
function setp2(p1, p2)
{
    aprovince = p1;
    acity = p2;
    aindex = "";
    acount = "20";
    window.open("rankings.php?province="+aprovince+"&city="+acity);
}

function city()
{
    var province = tfengyun.$("province").value;
   
    if (province == "") {
        var selLen=tfengyun.$("city").options.length;
           for(var i=0;i<selLen;i++)
           {
               tfengyun.$("city").options.remove(0);
           }
        tfengyun.$("city").options[0]=new Option("不限","");
        return;
    }
	var qurl = "location/province_" + province + ".txt";
	getData(qurl , 4 , 15000 , function() {
		errorPoint('加载超时',1);
		loadDiv(false);
	});
}

function CityResult(str)
{
	var selLen=tfengyun.$("city").options.length;
	
	for(var i=0;i<selLen;i++)
	{
	   tfengyun.$("city").options.remove(0);
	}
	tfengyun.$("city").options[0]=new Option("不限","");
	var itemlist = str.split(";");

	for(var i=0;i<itemlist.length-1;i++)
	{
	   var item = itemlist[i].split(","); 
	   tfengyun.$("city").options[i+1]=new Option(item[1],item[0]);
	}
}

// load Div
// 意见反馈
function Feedback() {
	if(JudgeIe()) return;
	var objDiv = document.createElement("div");
	with(objDiv.style) {
		width = 360 + 'px';
		height = '216px';
		JudgeIe() ? position = 'absolute' : position = 'fixed';
		top = '150px';
		zIndex = '999999';
		right = '-333px';
		fontSize = '12px';
		lineHeight = '16px';
	}
	objDiv.setAttribute("id","feedback");
	document.body.appendChild(objDiv);
	if(JudgeIe()) {
			if($('#feedback')) objDiv.style.top = get_scrollTop_of_body() + 150 + 'px';
			$(window).scroll(function() {
				$('#feedback').css('display','none');
				setTimeout(function() {
						$('#feedback').css('display','');
						$('#feedback').css('top',get_scrollTop_of_body() + 150 + 'px');
				},500);
			});
			
		}
	objDiv.innerHTML = '<div id="feelTitle">发<br />送<br />意<br />见<br />反<br />馈<br /><span id="gt">&lt;&lt;</span></div>' +
										'<div id="feelCou">' +
											'<p>您对微博风云有任何意见和建议都可以在这里告诉我们,我们会认真听取</p>' +
											'<div id="feednc">' +
											'<input id="ncId" align="absmiddle" value="输入您的昵称" style=" background:none; border:1px solid #dedede; width:300px; height:15px; line-height:15px;" type="text" />' +
											'</div>' +
											'<textarea id="feedbackTxt" style="margin-top:5px;"></textarea><input type="button" onclick="subFeedback()"  /><span id="feedtx" style="line-height:18px; padding-left:8px; color:#c00;"></span>' +
										'</div>';
	tfengyun.$('ncId').onfocus = function() {
		if(tfengyun.$('ncId').value == '输入您的昵称') tfengyun.$('ncId').value = '';
	}
	tfengyun.$('ncId').onblur = function() {
		if(tfengyun.$('ncId').value == '') tfengyun.$('ncId').value = '输入您的昵称';
	}
	animeFback(objDiv);
}

// anime feedback
var userNameFeed = '';
var swit = false;
function animeFback(obj) {
	var ev = typeof obj=='object' ? obj : tfengyun.$(obj);
	userNameFeed = CookieHelper.getCookie('my_userid');
	if(CookieHelper.getCookie('my_screen_name') !== '') tfengyun.$('ncId').value = CookieHelper.getCookie('my_screen_name');
	tfengyun.$('feelTitle').onclick = function() {
		swit ? swit = false : swit = true;
		tfengyun.$('feedbackTxt').value = '';
		anime(ev,swit);
	}
}

function anime(obj,tf) {
	var base = parseInt(obj.style.right);
	tfengyun.$('feedtx').innerHTML = '';
	if(tf) {
		base = base + 111;
		obj.style.right = base + 'px';
		tfengyun.$('feedbackTxt').focus();
		tfengyun.$('gt').innerHTML = '&gt;&gt;';
		if(base >= 0) return;
	}else {
		base = base - 111;
		obj.style.right = base + 'px';
		tfengyun.$('feedbackTxt').blur();
		tfengyun.$('gt').innerHTML = '&lt;&lt;';
		if(base <= -333) return;	
	}
	setTimeout(function() {anime(obj,tf);},10);
}

function subFeedback() {
	userNameFeed = tfengyun.$('ncId').value;
	var txt = tfengyun.$('feedbackTxt').value;
	if(txt == '') {
		tfengyun.$('feedtx').innerHTML = '意见不能为空';
		return;
	}
	if(userNameFeed == '' || userNameFeed == '输入您的昵称') {
		tfengyun.$('feedtx').innerHTML = '昵称不能为空';
		return;
	}
	tfengyun.ajax({
		 url:'api.php',
		 data:'type=feedback&id=' + userNameFeed + '&text=' + txt ,
		 method:'POST',
		 success:function(response,xhr){
			tfengyun.$('feedtx').innerHTML = '提交成功,感谢您的意见';
		 	setTimeout(function() {
				swit ? swit = false : swit = true;
				anime(tfengyun.$('feedback'),swit);
			},2500);
		 },
		 error:function(){
			alert('超时');
		 }
	});
	
}

function JudgeIe() {
	var isie6 = navigator.userAgent.search(/msie 6.0/gi) != -1;
	return isie6;
}

// 查看自己的排名
function viewRanking() {
	var val = CookieHelper.getCookie('tipTfengyun');
	val !== '' ? tfengyun.$('tip').style.display = 'none' :	tfengyun.$('tip').style.display = '';
	tfengyun.$('closeTip').onclick = function() {
		CookieHelper.setCookie('tipTfengyun','1',3600 * 24 * 2,'/','tfengyun.com');
		tfengyun.$('tip').style.display = 'none';
	}
}

function Datastatistics(attr , num) {
	$('.TBNavi2').find('span').each(function(i) {
		if($(this).hasClass('TBshow')) {
			var titles = $(this).text();
			switch(titles) {
				case '关键词':
					tfengyun.$('chartImg').innerHTML = '<span style="font-size:12px;color:#646464;">按出现次数统计的关键词:</span><br />' + attr[0] + '<br /><br /><span style="font-size:12px;color:#646464;">按近期热点统计的关键词:</span><br />' + attr[1];
					// tfengyun.$('chatLink').style.display = '';
					$('#imgToWeibo').css('display','');
					$('#imatoweibotext').html("@"+screen_name+" 的微博近期出现最多的关键词：" + num[1]);

					switch(weiboType()) {
						case 'sina':
							$('#imgtoweiboA').html("<a class='blue' id='shareImg' href=''><img src='http://image.tfengyun.com/image/sinaIcon1.gif' border='0' align='absmiddle' /> 分享到新浪微博</a>");
							tfengyun.$('shareImg').href = "javascript:void((function(s,d,e,r,l,p,t,z,c){var%20f='http://v.t.sina.com.cn/share/share.php?appkey=878922546',u=z||d.location,p=['&url=',e(u),'&title=',e(t||d.title),'&source=',e(r),'&sourceUrl=',e(l),'&content=',c||'gb2312','&pic=',e(p||'')].join('');function%20a(){if(!window.open([f,p].join(''),'mb',['toolbar=0,status=0,resizable=1,width=440,height=430,left=',(s.width-440)/2,',top=',(s.height-430)/2].join('')))u.href=[f,p].join('');};if(/Firefox/.test(navigator.userAgent))setTimeout(a,0);else%20a();})(screen,document,encodeURIComponent,'','','','@" + screen_name + " 的微博近期出现最多的关键词：" + num[1] + " (来自#微博风云#) 详情请点击：','http://www.tfengyun.com/user.php?screen_name="+userid+"',''));";
							break;
						case 'qq':
							$('#imgtoweiboA').html('<a href="javascript:void(0)" class="blue" onclick="postToWb({t:\'@'+userid+'  的微博近期出现最多的关键词：'+num[1]+'  (来自 #微博风云#) 详情请点击：'+'\'});return false;"><img src="http://image.tfengyun.com/image/ttIcon.gif" align="absmiddle" border="0" /> 分享到腾讯微博</a>');
							break;
						case '163':
							
							break;
						case 'sohu':
							$('#imgtoweiboA').html("<a class='blue' id='shareImg' href=''><img src='http://beta.tfengyun.com/image/16icon.gif' border='0' align='absmiddle' /> 分享到搜狐微博</a>");
							tfengyun.$('shareImg').href = "javascript:void((function(s,d,e,r,l,p,t,z,c){var f='http://t.sohu.com/third/post.jsp?',u=z||d.location,p=['&appkey=','3OqK8Ug5fifBfttTJT4e','&url=',e(u),'&title=',e(t||d.title),'&content=',c||'gb2312','&pic=',e(p||'')].join('');function%20a(){if(!window.open([f,p].join(''),'mb',['toolbar=0,status=0,resizable=1,width=660,height=470,left=',(s.width-660)/2,',top=',(s.height-470)/2].join('')))u.href=[f,p].join('');};if(/Firefox/.test(navigator.userAgent))setTimeout(a,0);else%20a();})(screen,document,encodeURIComponent,'','','','@" + screen_name + " 的微博近期出现最多的关键词：" + num[1] + " (来自#微博风云#) 详情请点击：','http://www.tfengyun.com/user.php?screen_name="+userid+"','utf-8'));";
							break;
					}
					tfengyun.$('chartLoading').style.display = 'none';
					tfengyun.$('chartImg').style.display = '';
				break;
				case '近期热门微博':
					tfengyun.$('chartImg').style.position = 'static';
					tfengyun.$('chartImg').innerHTML = attr;
					tfengyun.$('chartLoading').style.display = 'none';
					tfengyun.$('chartImg').style.display = '';
					tfengyun.$('chatLink').style.display = 'none';
					imgClick();
				break;
				case '共同关注':
					tfengyun.$('chartImg').innerHTML = '<div class="weibo" style="border:none;"><div class="weiboint"><b>' + my_screen_name + '</b> 与 <b>' + screen_name + '</b> 共同关注' + num + '人</div><ul>' + attr + '</ul></div>';
					tfengyun.$('chartLoading').style.display = 'none';
					tfengyun.$('chartImg').style.display = '';
					tfengyun.$('chatLink').style.display = 'none';
				break;
				case '互相关注':
					tfengyun.$('chartImg').innerHTML = '<div class="weibo" style="border:none;"><div class="weiboint">与 <b>' + screen_name + '</b> 互相关注共' + num + '人</div><ul>' + attr + '</ul></div>';
					tfengyun.$('chartLoading').style.display = 'none';
					tfengyun.$('chartImg').style.display = '';
					tfengyun.$('chatLink').style.display = 'none';
				break;
				default:
					return;
				break;
			}
		}
	});
}

function imgClick() {
	$('#chartImg').find('.weiboImg').find('img').each(function(i) {
		$(this).click(function() {
			var status =  $(this).attr('type');
			status == 's' ? ($(this).attr('src',saveVar[i].img1).attr('type','b').css('cursor','url(http://image.tfengyun.com/image/mouse2.cur),-moz-zoom-out')) : ($(this).attr('src',saveVar[i].img).attr('type','s').css('cursor','url(http://image.tfengyun.com/image/mouse1.cur),-moz-zoom-out'));
		});
	});
}

var baseVs = 0;
function get_scrollTop_of_body(){ 
	var scrollTop; 
	if(typeof window.pageYOffset != 'undefined'){ 
		scrollTop = window.pageYOffset; 
	} else if(typeof document.compatMode != 'undefined' && document.compatMode != 'BackCompat'){ 
		scrollTop = document.documentElement.scrollTop; 
	} else if(typeof document.body != 'undefined'){ 
		scrollTop = document.body.scrollTop;  
	}else if (typeof document.compatMode != 'undefined' && document.compatMode != 'BackCompat') { 
		scrollTop = document.documentElement.scrollTop; 
	} 
	 return scrollTop; 
	 
}

function topHeader() {
	var objDiv = document.createElement("div");
	tfengyun.$('glo').appendChild(objDiv);
	
	if(JudgeIe()) {
		objDiv.innerHTML = '<div id="top"></div>';
		tfengyun.$('top').style.cssText = 'width:46px; height:18px; position:absolute; cursor:pointer; display:none; background:url(http://image.tfengyun.com/image/top.gif); right:-50px;';
		$(window).scroll(function() {
			$('#top').css('display','none');
			setTimeout(function() {
				if(get_scrollTop_of_body() !==0) {
					$('#top').css('display','');
					$('#top').css('top',get_scrollTop_of_body() + 440 + 'px');
				}
			},500);
		});
		if(get_scrollTop_of_body() !==0 ) {
			tfengyun.$('top').style.display = '';
			tfengyun.$('top').style.top = get_scrollTop_of_body() + 440 + 'px';
		}
	}else {
		objDiv.setAttribute("id","top");
		objDiv.style.cssText = 'width:46px; height:18px; position:fixed; cursor:pointer; display:none; background:url(http://image.tfengyun.com/image/top.gif); bottom:50px;';
		var webWidth = $(document.body).width();
		if((webWidth - 970) > 50) {
			// objDiv.style.left = (webWidth - 970)/2 - 51;
			$(objDiv).css('right',(webWidth - 970)/2 - 51);
		}else {
			tfengyun.$('top').style.display = 'none';
			return;
		}
		$(window).scroll(function() {
			setTimeout(function() {
				get_scrollTop_of_body() !==0 ? $('#top').css('display','') : $('#top').css('display','none');
			},500);
		});
		if(get_scrollTop_of_body() !==0 ) {
			tfengyun.$('top').style.display = '';
		}
	}
	
	tfengyun.$('top').onclick = function() {
		$(window).scrollTop(0);
	}
}

function closePrompt() {
	tfengyun.$('closePrompt').style.display = 'none';
	CookieHelper.setCookie('closePrompt', 'none' , 3600 * 24 * 365 * 10, "/", 'tfengyun.com');
}


//function gethost() {
//	return window.location.host;
//}

function weiboType() {
	var weiboUrl = window.location.host;
	if(weiboUrl.search('www.tfengyun')!=-1) {
		return 'sina';
	}else if(weiboUrl.search('beta.tfengyun')!=-1) {
		return 'sina';
	}else if(weiboUrl.search('qq.tfengyun')!=-1) {
		return 'qq';
	}else if(weiboUrl.search('163.tfengyun')!=-1) {
		return '163';
	}else if(weiboUrl.search('sohu.tfengyun')!=-1) {
		return 'sohu';
	}
}

function getSite(type) {
	switch(type) {
		case 'home':

			switch(weiboType()) {
				case 'sina':
					return 'http://weibo.com/'
					break;
				case 'qq':
					return 'http://t.qq.com/';
					break;
				case '163':
					
					break;
				case 'sohu':
					return 'http://t.sohu.com/u/';
					break;
			}
			break;
		case 'replaceHtml':
			$('.host').each(function() {
				var url = $(this).attr('href');

				switch(weiboType()) {
					case 'sina':
						return;
						break;
					case 'qq':
						var newUrl = url.replace(/weibo.com/gi,'t.qq.com');
						break;
					case '163':
						
						break;
					case 'sohu':
						var newUrl = url.replace(/weibo.com/gi,'t.sohu.com/u/');
						break;
				}
			});
			break;
		case 'head':
			switch(weiboType()) {
				case 'sina':
					return;
					break;
				case 'qq':
					
					break;
				case '163':
					
					break;
				case 'sohu':
					
					break;
			}
			break;
	}
}

function postToWb(options){
	var o={
		url:document.location,
		assname:'',
		appkey:"87b81f05ec054149a9e233b13f39fc3b",
		pic:'',
		t:'' //请在这里添加你自定义的分享内容
	};
	for(var i in options) {
		o[i]=options[i];
	}
	var _url = encodeURIComponent(o.url);
	var _assname = encodeURI(o.assname);//你注册的帐号，不是昵称
	var _appkey = encodeURI(o.appkey);//你从腾讯获得的appkey
	var _pic = encodeURIComponent(o.pic);//（例如：var _pic='图片url1|图片url2|图片url3....）

	var _t=o.t;
	 _t =  encodeURIComponent(_t);//请在这里添加你自定义的分享内容


	var _u = 'http://share.v.t.qq.com/index.php?c=share&a=index&url='+_url+'&appkey='+_appkey+'&pic='+_pic+'&assname='+_assname+'&title='+_t;

	window.open( _u,'', 'width=700, height=680, top=0, left=0, toolbar=no, menubar=no, scrollbars=no, location=yes, resizable=no, status=no' );
}

function searchUserName(key) {
	tfengyun.ajax({
		 url:'api.php',
		 data:'type=search_user&keyword=' + key,
		 method:'POST',
		 success:function(response,xhr){
			alert(response);
			
		 },
		 error:function(){
			alert('超时');
		 }
	});
}
