<!--
//xmlhttp和xmldom对象
var M1979XHTTP = null;
var m1979XDOM = null;
var M1979Container = null;
var M1979ShowError = false;
var M1979ShowWait = false;
var M1979ErrCon = "";
var M1979ErrDisplay = "下载数据失败";
var M1979WaitDisplay = "正在下载数据...";

//获取指定ID的元素

function $DE(id) {
	return document.getElementById(id);
}

//gcontainer 是保存下载完成的内容的容器
//mShowError 是否提示错误信息
//M1979ShowWait 是否提示等待信息
//mErrCon 服务器返回什么字符串视为错误
//mErrDisplay 发生错误时显示的信息
//mWaitDisplay 等待时提示信息
//默认调用 M1979Ajax('divid',false,false,'','','')

function M1979Ajax(gcontainer,mShowError,mShowWait,mErrCon,mErrDisplay,mWaitDisplay)
{

	M1979Container = gcontainer;
	M1979ShowError = mShowError;
	M1979ShowWait = mShowWait;
	if(mErrCon!="") M1979ErrCon = mErrCon;
	if(mErrDisplay!="") M1979ErrDisplay = mErrDisplay;
	if(mErrDisplay=="x") M1979ErrDisplay = "";
	if(mWaitDisplay!="") M1979WaitDisplay = mWaitDisplay;


	//post或get发送数据的键值对
	this.keys = Array();
	this.values = Array();
	this.keyCount = -1;
	this.sendlang = 'gb2312';

	//请求头类型
	this.rtype = 'text';

	//初始化xmlhttp
	//IE6、IE5
	if(window.ActiveXObject) {
		try { M1979XHTTP = new ActiveXObject("Msxml2.XMLHTTP");} catch (e) { }
		
		if (M1979XHTTP == null){		
			try { M1979XHTTP = new ActiveXObject("Microsoft.XMLHTTP");} catch (e) { }
		}
	} else {
		M1979XHTTP = new XMLHttpRequest();
	}

	//增加一个POST或GET键值对
	this.AddKeyN = function(skey,svalue) {
		if(this.sendlang=='utf-8') this.AddKeyUtf8(skey, svalue);
		else this.AddKey(skey, svalue);
	};
	
	this.AddKey = function(skey,svalue) {
		this.keyCount++;
		this.keys[this.keyCount] = skey;
		svalue = svalue+'';
		if(svalue != '') svalue = svalue.replace(/\+/g,'$#$');
		this.values[this.keyCount] = escape(svalue);
	};

	//增加一个POST或GET键值对
	this.AddKeyUtf8 = function(skey,svalue) {
		this.keyCount++;
		this.keys[this.keyCount] = skey;
		svalue = svalue+'';
		if(svalue != '') svalue = svalue.replace(/\+/g,'$#$');
		this.values[this.keyCount] = encodeURI(svalue);
	};

	//增加一个Http请求头键值对
	this.AddHead = function(skey,svalue) {
		this.rkeyCount++;
		this.rkeys[this.rkeyCount] = skey;
		this.rvalues[this.rkeyCount] = svalue;
	};

	//清除当前对象的哈希表参数
	this.ClearSet = function() {
		this.keyCount = -1;
		this.keys = Array();
		this.values = Array();
		this.rkeyCount = -1;
		this.rkeys = Array();
		this.rvalues = Array();
	};


	M1979XHTTP.onreadystatechange = function() {
		//在IE6中不管阻断或异步模式都会执行这个事件的
		if(M1979XHTTP.readyState == 4){
			if(M1979XHTTP.status == 200)
			{
				if(M1979XHTTP.responseText!=M1979ErrCon) {
					M1979Container.innerHTML = M1979XHTTP.responseText;
				}
				else {
					if(M1979ShowError) M1979Container.innerHTML = M1979ErrDisplay;
				}
				M1979XHTTP = null;
			}
			else { if(M1979ShowError) M1979Container.innerHTML = M1979ErrDisplay; }
		}
		else { if(M1979ShowWait) M1979Container.innerHTML = M1979WaitDisplay; }
	};

	//检测阻断模式的状态
	this.BarrageStat = function() {
		if(M1979XHTTP==null) return;
		if(typeof(M1979XHTTP.status)!=undefined && M1979XHTTP.status == 200)
		{
			if(M1979XHTTP.responseText!=M1979ErrCon) {
				M1979Container.innerHTML = M1979XHTTP.responseText;
			}
			else {
				if(M1979ShowError) M1979Container.innerHTML = M1979ErrDisplay;
			}
		}
	};

	//发送http请求头
	this.SendHead = function()
	{
		//发送用户自行设定的请求头
		if(this.rkeyCount!=-1)
		{ 
			for(var i = 0;i<=this.rkeyCount;i++)
			{
				M1979XHTTP.setRequestHeader(this.rkeys[i],this.rvalues[i]);
			}
		}
		　if(this.rtype=='binary'){
		　M1979XHTTP.setRequestHeader("Content-Type","multipart/form-data");
	}else{
		M1979XHTTP.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	}
};

//用Post方式发送数据
this.SendPost = function(purl) {
	var pdata = "";
	var i=0;
	this.state = 0;
	M1979XHTTP.open("POST", purl, true);
	this.SendHead();
	//post数据
	if(this.keyCount!=-1)
	{
		for(;i<=this.keyCount;i++)
		{
			if(pdata=="") pdata = this.keys[i]+'='+this.values[i];
			else pdata += "&"+this.keys[i]+'='+this.values[i];
		}
	}
	M1979XHTTP.send(pdata);
};

//用GET方式发送数据
this.SendGet = function(purl) {
	var gkey = "";
	var i=0;
	this.state = 0;
	//get参数
	if(this.keyCount!=-1)
	{ 
		for(;i<=this.keyCount;i++)
		{
			if(gkey=="") gkey = this.keys[i]+'='+this.values[i];
			else gkey += "&"+this.keys[i]+'='+this.values[i];
		}
		if(purl.indexOf('?')==-1) purl = purl + '?' + gkey;
		else  purl = purl + '&' + gkey;
	}
	M1979XHTTP.open("GET", purl, true);
	this.SendHead();
	M1979XHTTP.send(null);
};

//用GET方式发送数据，阻塞模式
this.SendGet2 = function(purl) {
	var gkey = "";
	var i=0;
	this.state = 0;
	//get参数
	if(this.keyCount!=-1)
	{ 
		for(;i<=this.keyCount;i++)
		{
			if(gkey=="") gkey = this.keys[i]+'='+this.values[i];
			else gkey += "&"+this.keys[i]+'='+this.values[i];
		}
		if(purl.indexOf('?')==-1) purl = purl + '?' + gkey;
		else  purl = purl + '&' + gkey;
	}
	M1979XHTTP.open("GET", purl, false);
	this.SendHead();
	M1979XHTTP.send(null);
	//firefox中直接检测XHTTP状态
	this.BarrageStat();
};

//用Post方式发送数据
this.SendPost2 = function(purl) {
	var pdata = "";
	var i=0;
	this.state = 0;
	M1979XHTTP.open("POST", purl, false);
	this.SendHead();
	//post数据
	if(this.keyCount!=-1)
	{
		for(;i<=this.keyCount;i++)
		{
			if(pdata=="") pdata = this.keys[i]+'='+this.values[i];
			else pdata += "&"+this.keys[i]+'='+this.values[i];
		}
	}
	M1979XHTTP.send(pdata);
	//firefox中直接检测XHTTP状态
	this.BarrageStat();
};


} // End Class M1979Ajax

//初始化xmldom
function InitXDom() {
	if(m1979XDOM!=null) return;
	var obj = null;
	// Gecko、Mozilla、Firefox
	if (typeof(DOMParser) != "undefined") { 
		var parser = new DOMParser();
		obj = parser.parseFromString(xmlText, "text/xml");
	}
	// IE
	else { 
		try { obj = new ActiveXObject("MSXML2.DOMDocument");} catch (e) { }
		if (obj == null) try { obj = new ActiveXObject("Microsoft.XMLDOM"); } catch (e) { }
	}
	m1979XDOM = obj;
};



//读写cookie函数
function GetCookie(c_name)
{
	if (document.cookie.length > 0)
	{
		c_start = document.cookie.indexOf(c_name + "=")
		if (c_start != -1)
		{
			c_start = c_start + c_name.length + 1;
			c_end   = document.cookie.indexOf(";",c_start);
			if (c_end == -1)
			{
				c_end = document.cookie.length;
			}
			return unescape(document.cookie.substring(c_start,c_end));
		}
	}
	return null
}
//在js里面设置 cookie
function SetCookie(c_name,value,expiredays)
{
	var exdate = new Date();
	exdate.setDate(exdate.getDate() + expiredays);
	document.cookie = c_name + "=" +escape(value) + ((expiredays == null) ? "" : ";expires=" + exdate.toGMTString()); //使设置的有效时间正确。增加toGMTString()
}

//===============================
//自动增加收藏和分享数
//参数：aid=文档id，typecs=upstow（增加收藏），upshare（更新分享），remark，stow，share（单个显示收藏，评论和分享），all（输出所以统计信息）
function upstowshare(aid,typecs)
{
var taget_obj = document.getElementById('isfav');
	myajax = new DedeAjax(taget_obj,false,false,'','','');
	myajax.SendGet2("/plus/count.php?typecs="+typecs+"&aid="+aid);
	DedeXHTTP = null;
}


//===============================
//提取顶踩数
//参数：showid=标签id，aid=文档id
function getDigg(showid,ftype,aid)
{
	var taget_obj = document.getElementById(showid);
	myajax = new M1979Ajax(taget_obj,false,false,'','','');
	myajax.SendGet2("/plus/digg_ajax.php?formurl=caicai&action="+ftype+"&id="+aid);
	DedeXHTTP = null;
}


//======================================
//顶踩通用ajax函数，只显示数字
// 参数：showid=标签id，ftype=good,bad(顶和踩)，aid=文档id
function postDigg(showid,ftype,aid)
{
	var taget_obj = document.getElementById(showid);
	var saveid = GetCookie('diggid');
	var info="";
	if(ftype=="bad"){
			info="您已经踩过该帖，请不要重复踩帖 ！";
		}
	if(ftype=="good"){
			info="您已经顶过该帖，请不要重复顶帖 ！";
		}
	if(ftype=="fan" || ftype=="zheng"){
			info="您已经投过票了！";
		}
	if(saveid != null)
	{
		var saveids = saveid.split(',');
		var hasid = false;
		saveid = '';
		j = 1;
		for(i=saveids.length-1;i>=0;i--)
		{
			if(saveids[i]==aid && hasid) continue;
			else {
				if(saveids[i]==aid && !hasid) hasid = true;
				saveid += (saveid=='' ? saveids[i] : ','+saveids[i]);
				j++;
				if(j==20 && hasid) break;
				if(j==19 && !hasid) break;
			}
		}
		if(hasid) { alert(info); return; }
		else saveid += ','+aid;
		SetCookie('diggid',saveid,1);
	}
	else
	{
		SetCookie('diggid',aid,1);
	}
	myajax = new M1979Ajax(taget_obj,false,false,'','','');
	var url = "/plus/digg_ajax.php?formurl=caicai&action="+ftype+"&id="+aid;
	myajax.SendGet2(url);
	M1979XHTTP = null;
}

//FLASH播放器 复制,,,
	function copyToClipboard(theField,isalert) {
	var copytoclip=1;
	var tempval=document.getElementById("plink"+theField.toString());		
	if (navigator.appVersion.match(/\bMSIE\b/)){
		tempval.select();		
		if (copytoclip==1){
			therange=tempval.createTextRange();
			therange.execCommand("Copy");
			if(isalert!=false)alert("复制成功。现在您可以粘贴（Ctrl+v）到Blog 或BBS中了。");
		}
		return;
	}else{
		alert("您使用的浏览器不支持此复制功能，请使用Ctrl+C或鼠标右键。");
		tempval.select();		
	}
	}

-->

