function $(o) {if(document.getElementById&&document.getElementById(o)){return document.getElementById(o);}else if (document.all&&document.all(o)){return document.all(o);}else if (document.layers&&document.layers[o]){return document.layers[o];}else{return false;}} 
function inittab(o){
	var lis=$(o).getElementsByTagName('li');
	for(var i=0;i<lis.length;i++){
		lis[i].onmouseover=function(){
			var u = this.parentNode; var s = u.getElementsByTagName('li');
			var a = u.act; a = a ? a : s[0];
			a.className = '';this.className = 'act';u.act = this;
			var c = u.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div');
			for(var k=0;k<s.length;k++){c[k].style.display= s[k]==this ? '' : 'none';}
		}
	}
}

function setsize(n, o){
	$('articlecontent').className = 'content f' + n;
	var a = o.parentNode.getElementsByTagName('a');
	for(var i=0;i<a.length;i++) a[i].className = '';
	o.className = 'act';
}

function initso(flag){
	var f = $('searchform');
	var i = f.keyword;
	var t = '2011 搜索引擎市场';
	i.value=i.value==''?t:i.value;
	var tab = $('sotype');
	var lis=tab.getElementsByTagName('em');
	var type = f.typeid;
	tab.onli = lis[0];
	for(var k=0;k<lis.length;k++){
		lis[k].index = k;
		lis[k].onclick = function(){
			tab.onli.className = tab.onli.className.replace(new RegExp('( ?|^)act\\b'),'');
			tab.onli = this;
			type.value = this.index+1;
			this.className = 'act';
			if(flag && i.value!=''){f.submit();}
		}
	}
	//f.onsubmit=function(){if(f.keyword.value == t){f.keyword.value = '';}}
	i.onfocus=function(){this.value=this.value==t?'':this.value;}
	//i.onblur=function(){this.value=this.value==''?t:this.value;}
}

var isGecko=(navigator.userAgent.indexOf("Gecko")>-1)&&(navigator.userAgent.indexOf("KHTML")==-1);
var isIE=navigator.userAgent.indexOf("MSIE")!=-1&&!window.opera;
window.ican={
	bgc:'#3366CC',
	txtc:'#FFFFFF',
	su:function(d){
		if(this.S.isclose)return ;
		if(typeof(d)=="object"&&d.s&&typeof(d.s)!="undefined"&&typeof (d.s[0])!="undefined"&&d.s.length>0){this.d=d;this.sc()}else{this.cs();this.d={}}
	},
	init:function(){
		this.k=$('keyword');
		//this.k.parentNode.style.position='relative';
		this.S=$('sug');
		var tthis=this;
		with(this.S.style){
			border='1px solid #000';
			background='#FFFFFF';
			margin='27px 0px 0px 76px';
			display="none";
			position="absolute";
			fontFamily='Arial, Helvetica, sans-serif';
			fontSize='12px'
			//left='0px'
			width=(isIE?tthis.k.offsetWidth:tthis.k.offsetWidth-1)+"px";
			//top=(isGecko?tthis.k.offsetHeight-1:tthis.k.offsetHeight)+"px";
		}
		this.k.onkeydown=function(e){tthis.kd(e)}
		this.k.onkeyup=function(e){tthis.get()}
		this.k.setAttribute("autocomplete","off");
	},
	
	get:function(){
		if(this.k.value==''||(this.CS&&(this.CS.kw==this.k.value||this.CS.ckw==this.k.value)))return ;
		if(this.CS){document.body.removeChild(this.CS)}this.CS=this.C('script');
		this.CS.src='http://www.icandata.com/su?wd='+this.k.value+"&t="+(new Date()).getTime();
		document.body.appendChild(this.CS);
	},
	set:function(){alert(this.d)},
	
	//输入框键按下动作
	kd:function(e){
		e=e||window.event;
		var cli;
		if((e.keyCode==38||e.keyCode==40)&&this.S.style.display!='none'){
			var lis=this.S.getElementsByTagName('li');
			var l=lis.length;
			var c=-1;
			for(var i=0;i<l;i++){if(lis[i]==lis[i].parentNode.ison){c=i;break}}
			var cli;
			if(e.keyCode==38){if(c==0){this.k.value=this.CS.kw;c=-1}else{if(c==-1){c=l}cli=lis[--c]}}
			else{if(c==l-1){this.k.value=this.CS.kw;c=-1}else{cli=lis[++c]}}
			for(var i=0;i<l;i++){this.lio(lis[i],false);}
			if(lis[0].parentNode.ison){this.lio(lis[0].parentNode.ison, false)}
			if(c>=0){this.lio(lis[c],true);this.CS.ckw=this.k.value=lis[c].innerHTML}
		}
	},
	
	//提示内容包含容器
	sc:function(){
		this.CS.kw=this.k.value;
		var ul=this.C('ul');
		with(ul){id='sugul';style.margin='0';style.padding='0';style.listStyle='none';style.cursor="default"}
		var li;
		var tthis=this;

		for(var i=0;i<this.d.s.length;i++){
			li=this.C('li');
			li.innerHTML=this.d.s[i];
			with(li.style){height='20px';lineHeight='20px';paddingLeft='4px';textAlign='left';overflow='hidden'}
			li.onmouseover=function(){tthis.lio(this,true)}
			li.onmouseout=function(){tthis.lio(this,false)}
			li.onclick=function(){tthis.k.value=this.innerHTML;tthis.k.form.submit();tthis.cs();}
			ul.appendChild(li);
		}
		this.S.innerHTML='';
		this.S.appendChild(ul);
		var csdiv=this.C('div');
		with(csdiv.style){lineHeight='20px';paddingRight='4px';textAlign='right'}
		csdiv.innerHTML='<a href="javascript:window.ican.csu();">关闭</a>';
		this.S.appendChild(csdiv);
		this.S.style.display='';		
	},
	cs:function(){this.S.style.display='none'},
	csu:function(){this.S.isclose=true;this.cs()},
	C:function(e){return document.createElement(e)},
	lio:function(o,f){if(o.parentNode.ison){with(o.parentNode.ison.style){background=color=''}o.parentNode.ison=false;}o.parentNode.ison=f?o:f;with(o.style){background=f?this.bgc:'';color=f?this.txtc:''}}
};
function getIEVer(){var a = 0;var b = navigator.userAgent;if(b.indexOf("MSIE")>-1){var c=b.split(";")[1];c=c.replace("MSIE","");a=parseFloat(c)}return a}
function initGotoTop(){
  var div = document.createElement('a');
  div.style.cssText = 'position:fixed;display:block;width:19px;height:61px;outline:none;background:url(/theme/gototop.gif) no-repeat 0 0';
  document.body.appendChild(div);
  div.href="#pagetop";
  div.target="_self";
  var a  = document.createElement('a');
   a.id = a.name = 'pagetop';
  document.body.insertBefore(a, document.body.firstChild);
  var isIE=!-[1,];
  if(isIE && getIEVer() == 6){
    div.style.position = 'absolute';
    div.style.left = '960px';
    window.onscroll = function(){
        div.style.top = (document.documentElement.scrollTop + document.documentElement.clientHeight - 171) + 'px';
    }
  }else{
    var x = div.offsetLeft;
    var p = div;
    while(p.offsetParent){
      p = p.offsetParent;
      x += p.offsetLeft;
    }
    div.style.left = (x + 960) + 'px';
    div.style.top = document.documentElement.clientHeight - 169 + 'px';
  }
}

document.onkeydown=function(e){if(isGecko){e=e||window.event;if(e.ctrlKey){if(e.keyCode==61||e.keyCode==107||e.keyCode==109||e.keyCode==96||e.keyCode==48){}}}};

document.onmousedown=function(e){e=e||window.event;var el=e.target||e.srcElement;if(el==window.ican.k){return }while(el=el.parentNode){if(el==window.ican.S||el==window.ican.k){return }}setTimeout("window.ican.cs()",200)};

function getContentInfo(id){
	ajax.request('get', '/action/content.php', {success:function(response){
		var v = ajax.jsondecode(response.responseText);
		setInnerHtml('content_click', v['click'] ? v['click'] : 0);
		setInnerHtml('content_op_support', v['digg'] ? v['digg'] : 0);
		setInnerHtml('content_op_oppose', v['trample'] ? v['trample'] : 0);
		setInnerHtml('comment_count_0', v['comment'] ? v['comment'] : 0);
		setInnerHtml('comment_count_1', v['comment'] ? v['comment'] : 0);
		setInnerHtml('comment_count_2', v['comment'] ? v['comment'] : 0);
		setInnerHtml('comment_count_3', v['comment'] ? v['comment'] : 0);
	}},{contentid:id});
}

function setInnerHtml(element, value){
	if(typeof element !== 'object'){element = $(element);}
	if(element){element.innerHTML = value;}
}

/*
EXCMS (C) 2007-2009 Sinoican Inc.
$Id: ajax.js 18 2009-10-27 10:42:02Z zhanghaisong $
*/
ajax = {
	isIE : window.navigator.userAgent.toLowerCase().indexOf("msie") >= 1,
	request : function(method, uri, cb, data, options) {
		if(options){
			var hs = options.headers;
			if(hs){
				for(var h in hs){
					if(hs.hasOwnProperty(h)){
						this.initHeader(h, hs[h], false);
					}
				}
			}
		}
		if(typeof data == "object"){data = this.urlEncode(data);}
		method = method.toUpperCase();
		if(method == 'GET' && data){
			uri += (uri.indexOf('?') != -1 ? '&' : '?') + data + '&excmstime=' + (new Date().getTime());
		}
		return this.asyncRequest(method, uri, cb, data);
	},
	
	serializeForm : function(form) {
          if(typeof form == 'string') {
              form = (document.getElementById(form) || document.forms[form]);
          }

          var el, name, val, disabled, data = '', hasSubmit = false;
          for (var i = 0; i < form.elements.length; i++) {
              el = form.elements[i];
              disabled = form.elements[i].disabled;
              name = form.elements[i].name;
              val = form.elements[i].value;

              if (!disabled && name){
                  switch (el.type)
                          {
                      case 'select-one':
                      case 'select-multiple':
                          for (var j = 0; j < el.options.length; j++) {
                              if (el.options[j].selected) {
                                  if (this.isIE) {
                                      data += encodeURIComponent(name) + '=' + encodeURIComponent(el.options[j].attributes['value'].specified ? el.options[j].value : el.options[j].text) + '&';
                                  }
                                  else {
                                      data += encodeURIComponent(name) + '=' + encodeURIComponent(el.options[j].hasAttribute('value') ? el.options[j].value : el.options[j].text) + '&';
                                  }
                              }
                          }
                          break;
                      case 'radio':
                      case 'checkbox':
                          if (el.checked) {
                              data += encodeURIComponent(name) + '=' + encodeURIComponent(val) + '&';
                          }
                          break;
                      case 'file':

                      case undefined:

                      case 'reset':

                      case 'button':

                          break;
                      case 'submit':
                          if(hasSubmit == false) {
                              data += encodeURIComponent(name) + '=' + encodeURIComponent(val) + '&';
                              hasSubmit = true;
                          }
                          break;
                      default:
                          data += encodeURIComponent(name) + '=' + encodeURIComponent(val) + '&';
                          break;
                  }
              }
          }
          data = data.substr(0, data.length - 1);
          return data;
      },
	
	asyncRequest:function(method, uri, callback, postData)
	{
		var o = this.getConnectionObject();

		if (!o) {
			return null;
		}
		else {
			o.conn.open(method, uri, true);

			if (this.useDefaultXhrHeader) {
				if (!this.defaultHeaders['X-Requested-With']) {
					this.initHeader('X-Requested-With', this.defaultXhrHeader, true);
				}
			}

			if(postData && this.useDefaultHeader && (!this.hasHeaders || !this.headers['Content-Type'])){
				this.initHeader('Content-Type', this.defaultPostHeader);
			}

			 if (this.hasDefaultHeaders || this.hasHeaders) {
				this.setHeader(o);
			}

			this.handleReadyState(o, callback);
			o.conn.send(postData || null);

			return o;
		}
	},


	headers:{},
	hasHeaders:false,
	useDefaultHeader:true,
	defaultPostHeader:'application/x-www-form-urlencoded; charset=UTF-8',
	useDefaultXhrHeader:true,
	defaultXhrHeader:'XMLHttpRequest',
	hasDefaultHeaders:true,
	defaultHeaders:{},
	poll:{},
	timeout:{},
	pollInterval:50,
	transactionId:0,
	setProgId:function(id)
	{
		this.activeX.unshift(id);
	},

	setDefaultPostHeader:function(b)
	{
		this.useDefaultHeader = b;
	},

	setDefaultXhrHeader:function(b)
	{
		this.useDefaultXhrHeader = b;
	},

	setPollingInterval:function(i)
	{
		if (typeof i == 'number' && isFinite(i)) {
			this.pollInterval = i;
		}
	},

	createXhrObject:function(transactionId)
	{
		var obj,http;
		try
		{

			http = new XMLHttpRequest();

			obj = { conn:http, tId:transactionId };
		}
		catch(e)
		{
			for (var i = 0; i < this.activeX.length; ++i) {
				try
				{

					http = new ActiveXObject(this.activeX[i]);

					obj = { conn:http, tId:transactionId };
					break;
				}
				catch(e) {
				}
			}
		}
		finally
		{
			return obj;
		}
	},

	getConnectionObject:function()
	{
		var o;
		var tId = this.transactionId;

		try
		{
			o = this.createXhrObject(tId);
			if (o) {
				this.transactionId++;
			}
		}
		catch(e) {
		}
		finally
		{
			return o;
		}
	},



	handleReadyState:function(o, callback)
	{
		var oConn = this;

		if (callback && callback.timeout) {
			this.timeout[o.tId] = window.setTimeout(function() {
				oConn.abort(o, callback, true);
			}, callback.timeout);
		}

		this.poll[o.tId] = window.setInterval(
				function() {
					if (o.conn && o.conn.readyState == 4) {
						window.clearInterval(oConn.poll[o.tId]);
						delete oConn.poll[o.tId];

						if (callback && callback.timeout) {
							window.clearTimeout(oConn.timeout[o.tId]);
							delete oConn.timeout[o.tId];
						}

						oConn.handleTransactionResponse(o, callback);
					}
				}
				, this.pollInterval);
	},

	handleTransactionResponse:function(o, callback, isAbort)
	{

		if (!callback) {
			this.releaseObject(o);
			return;
		}

		var httpStatus, responseObject;

		try
		{
			if (o.conn.status !== undefined && o.conn.status != 0) {
				httpStatus = o.conn.status;
			}
			else {
				httpStatus = 13030;
			}
		}
		catch(e) {
			httpStatus = 13030;
		}

		if (httpStatus >= 200 && httpStatus < 300) {
			responseObject = this.createResponseObject(o, callback.argument);
			if (callback.success) {
				if (!callback.scope) {
					callback.success(responseObject);
				}
				else {
					callback.success.apply(callback.scope, [responseObject]);
				}
			}
		}
		else {
			switch (httpStatus) {

				case 12002:
				case 12029:
				case 12030:
				case 12031:
				case 12152:
				case 13030:
					responseObject = this.createExceptionObject(o.tId, callback.argument, (isAbort ? isAbort : false));
					if (callback.failure) {
						if (!callback.scope) {
							callback.failure(responseObject);
						}
						else {
							callback.failure.apply(callback.scope, [responseObject]);
						}
					}
					break;
				default:
					responseObject = this.createResponseObject(o, callback.argument);
					if (callback.failure) {
						if (!callback.scope) {
							callback.failure(responseObject);
						}
						else {
							callback.failure.apply(callback.scope, [responseObject]);
						}
					}
			}
		}

		this.releaseObject(o);
		responseObject = null;
	},

	createResponseObject:function(o, callbackArg)
	{
		var obj = {};
		var headerObj = {};

		try
		{
			var headerStr = o.conn.getAllResponseHeaders();
			var header = headerStr.split('\n');
			for (var i = 0; i < header.length; i++) {
				var delimitPos = header[i].indexOf(':');
				if (delimitPos != -1) {
					headerObj[header[i].substring(0, delimitPos)] = header[i].substring(delimitPos + 2);
				}
			}
		}
		catch(e) {
		}

		obj.tId = o.tId;
		obj.status = o.conn.status;
		obj.statusText = o.conn.statusText;
		obj.getResponseHeader = headerObj;
		obj.getAllResponseHeaders = headerStr;
		obj.responseText = o.conn.responseText;
		obj.responseXML = o.conn.responseXML;

		if (typeof callbackArg !== undefined) {
			obj.argument = callbackArg;
		}

		return obj;
	},

	createExceptionObject:function(tId, callbackArg, isAbort)
	{
		var COMM_CODE = 0;
		var COMM_ERROR = 'communication failure';
		var ABORT_CODE = -1;
		var ABORT_ERROR = 'transaction aborted';

		var obj = {};

		obj.tId = tId;
		if (isAbort) {
			obj.status = ABORT_CODE;
			obj.statusText = ABORT_ERROR;
		}
		else {
			obj.status = COMM_CODE;
			obj.statusText = COMM_ERROR;
		}

		if (callbackArg) {
			obj.argument = callbackArg;
		}

		return obj;
	},

	initHeader:function(label, value, isDefault)
	{
		var headerObj = (isDefault) ? this.defaultHeaders : this.headers;

		if (headerObj[label] === undefined) {
			headerObj[label] = value;
		}
		else {


			headerObj[label] = value + "," + headerObj[label];
		}

		if (isDefault) {
			this.hasDefaultHeaders = true;
		}
		else {
			this.hasHeaders = true;
		}
	},


	setHeader:function(o)
	{
		if (this.hasDefaultHeaders) {
			for (var prop in this.defaultHeaders) {
				if (this.defaultHeaders.hasOwnProperty(prop)) {
					o.conn.setRequestHeader(prop, this.defaultHeaders[prop]);
				}
			}
		}

		if (this.hasHeaders) {
			for (var prop in this.headers) {
				if (this.headers.hasOwnProperty(prop)) {
					o.conn.setRequestHeader(prop, this.headers[prop]);
				}
			}
			this.headers = {};
			this.hasHeaders = false;
		}
	},

	resetDefaultHeaders:function() {
		delete this.defaultHeaders;
		this.defaultHeaders = {};
		this.hasDefaultHeaders = false;
	},

	abort:function(o, callback, isTimeout)
	{
		if (this.isCallInProgress(o)) {
			o.conn.abort();
			window.clearInterval(this.poll[o.tId]);
			delete this.poll[o.tId];
			if (isTimeout) {
				delete this.timeout[o.tId];
			}

			this.handleTransactionResponse(o, callback, true);

			return true;
		}
		else {
			return false;
		}
	},


	isCallInProgress:function(o)
	{
		if (o.conn) {
			return o.conn.readyState != 4 && o.conn.readyState != 0;
		}
		else {

			return false;
		}
	},


	releaseObject:function(o)
	{
		o.conn = null;
		o = null;
	},

	activeX:[
	'MSXML2.XMLHTTP.3.0',
	'MSXML2.XMLHTTP',
	'Microsoft.XMLHTTP'
	],
	
	urlEncode : function(o){
		if(!o){
			return "";
		}
		var buf = [];
		for(var key in o){
			var ov = o[key], k = encodeURIComponent(key);
			var type = typeof ov;
			if(type == 'undefined'){
				buf.push(k, "=&");
			}else if(type != "function" && type != "object"){
				buf.push(k, "=", encodeURIComponent(ov), "&");
			}else if(this.isArray(ov)){
				if (ov.length) {
					for(var i = 0, len = ov.length; i < len; i++) {
						buf.push(k, "=", encodeURIComponent(ov[i] === undefined ? '' : ov[i]), "&");
					}
				} else {
					buf.push(k, "=&");
				}
			}
		}
		buf.pop();
		return buf.join("");
	},
	
	isArray : function(v){
		return v && typeof v.length == 'number' && typeof v.splice == 'function';
	},
	
	jsondecode : function(json){
		try{return eval("("+json+")")}catch(e){return {}}
	},

	
	update : function(element, method, uri, data){
		var tthis = this;
		this.request(method, uri, {success:function(response){
			if(typeof element !== 'object'){
				element = tthis.getDom(element);
			}
			if(element){
				element.innerHTML = response.responseText;
			}
		}}, data);
	},
	
	getDom:function(o){if(document.getElementById&&document.getElementById(o)){return document.getElementById(o)}else if(document.all&&document.all(o)){return document.all(o)}else if(document.layers&&document.layers[o]){return document.layers[o]}else{return false}}
};


function couplet(){ 
	if(arguments.length>=1) this.objID = document.getElementById(arguments[0]); 
	if(arguments.length>=2) this.divTop = arguments[1]; 
	if(arguments.length>=3) this.divPlane = arguments[2]; 
	if(arguments.length>=4) this.scrollDelay = arguments[4]; 
	if(arguments.length>=5) this.waitTime = arguments[5]; 
	if(!this.objID){ 
		this.objID = null; return; 
	}else{ 
		this.objID.style.position="absolute"; 
		this.objID.style.display="block"; 
		this.objID.style.zIndex=9999; 
	} 
	if("" == this.objID.style.top){ 
		if(isNaN(this.divTop)){ 
			return; 
		}else{ 
			this.objID.style.top = this.divTop+"px"; 
		} 
	} 
	if("" == this.objID.style.left && "" == this.objID.style.right){ 
		if(isNaN(this.divPlane)){ 
			return; 
		} 
		if(this.divPlane>0) this.objID.style.left = this.divPlane+"px"; 
		if(this.divPlane<0){
			var x = Math.abs(this.divPlane) - Math.floor((document.documentElement.clientWidth - document.body.clientWidth) / 2);
			this.objID.style.right = x+"px"; 
		}
	} 
	if(this.scrollDelay<15 || isNaN(this.scrollDelay)) this.scrollDelay = 15; 
	if(this.waitTime<500 || isNaN(this.waitTime)) this.waitTime = 500; 
	if(arguments.length>=1) this.start(); 
} 
couplet.prototype.start = function(){ 
	if(null == this.objID) return; 
	var objCouplet = this; 
	timer = this.scrollDelay; 
	objCouplet.lastScrollY = 0; 
	objCouplet.timerID = null; 
	objCouplet.startID = function(){ 
		if("block" == objCouplet.objID.style.display){ 
			objCouplet.run(); 
		}else{ 
			clearInterval(objCouplet.timerID); 
		} 
	} 
	objCouplet.Begin = function(){ 
		objCouplet.timerID = setInterval(objCouplet.startID,timer); 
	} 
	setTimeout(objCouplet.Begin,this.waitTime); 
} 
couplet.prototype.run = function(){ 
	if(document.documentElement && document.documentElement.scrollTop){ 
		uu_scrY = parseFloat(document.documentElement.scrollTop); 
	}else if(document.body){ 
		uu_scrY = parseFloat(document.body.scrollTop); 
	} 
	uu_divX = parseFloat(this.objID.style.top.replace("px","")); 
	uu_curTop = .1 * (uu_scrY - this.lastScrollY); 
	uu_curTop = uu_curTop>0?Math.ceil(uu_curTop):Math.floor(uu_curTop); 
	this.objID.style.top = parseFloat(uu_divX + uu_curTop) + "px"; 
	this.lastScrollY += uu_curTop; 
}

function initQQonline(){
	var div = document.createElement('div');
	document.body.appendChild(div);
	div.id = 'qqonline';
	div.innerHTML = '<a target="_blank" href="http://wpa.qq.com/msgrd?v=3&uin=631869414&site=qq&menu=yes"><img border="0" src="http://wpa.qq.com/pa?p=2:631869414:1" alt="艾凯数据研究中心杨老师" title="艾凯数据研究中心杨老师"></a><a target="_blank" href="http://wpa.qq.com/msgrd?v=3&uin=761575339&site=qq&menu=yes"><img border="0" src="http://wpa.qq.com/pa?p=2:761575339:1" alt="艾凯数据研究中心林老师" title="艾凯数据研究中心林老师"></a><a target="_blank" href="http://wpa.qq.com/msgrd?v=3&uin=1004649607&site=qq&menu=yes"><img border="0" src="http://wpa.qq.com/pa?p=2:1004649607:1" alt="艾凯数据研究中心胡老师" title="艾凯数据研究中心胡老师"></a> <a target="_blank" href="http://wpa.qq.com/msgrd?v=3&uin=1037266413&site=qq&menu=yes"><img border="0" src="http://wpa.qq.com/pa?p=2:1037266413:1" alt="艾凯数据研究中心罗老师" title="艾凯数据研究中心罗老师"></a>';
	new couplet("qqonline",150,-8); 
}

window.onload=function(){initQQonline();initGotoTop();}
