﻿function ajaxLoginbar(w)
{
	//参数说明:w=-1,0,1分别指"退出","初始化"和"登陆"
	return;
	var uName="";
	var uPass="";
	if(w==null) w=0;
	if(w==1)
	{
		uName=$("#loginBarName").val();
		uPass=$("#loginBarPass").val();
		if(!uName)
		{
			window.location.href=site.Dir + "user/login";
			return;
		}
		if(!uPass)
		{
			window.location.href=site.Dir + "user/login";
			return;
		}
		$("btnLoginbar").attr("disabled","disabled");
	}
	$.ajax({
		type:		"post",
		dataType:	"json",
		data:		"name="+escape(uName)+"&pass="+escape(uPass)+"&state="+w,
		url:		site.Dir + "ajax/user.aspx?oper=ajaxLoginbar&time="+(new Date().getTime()),
		error:		function(XmlHttpRequest,textStatus, errorThrown){if(XmlHttpRequest.responseText!=""){alert(XmlHttpRequest.responseText);}},
		success:	function(d){
			if(d.result!="1" && w==1)
				JumbotCms.Alert(d.returnval,"0");
			else
			{
				if(w==0)
				{
					$("#ajaxLoginbar").setTemplateURL(site.Dir + "templates/_loginbar.htm?time="+(new Date().getTime()), null, {filter_data: true});
					$("#ajaxLoginbar").processTemplate(d);
				}
				else
					window.location.reload();
			}
		}
	});	
}
///////////////////////////////////////////////////////////////////////////
//特约专题
///////////////////////////////////////////////////////////////////////////
function ajaxPluginSpecialList(oDiv, save2file)
{
	if(oDiv==null) oDiv="ajaxPluginSpecialList";
	if(save2file=="js")
		ExecuteJsonData(site.Dir + "_data/json/special.js", site.Dir + "templates/_speciallist.htm", oDiv, site.Dir + "_data/style/p_special.js", "", "js");
	else if(save2file=="html")
		ExecuteJsonData(site.Dir + "_data/json/special.js", site.Dir + "templates/_speciallist.htm", oDiv, site.Dir + "_data/html/p_special.htm", "", "html");
	else
		ExecuteJsonData(site.Dir + "_data/json/special.js", site.Dir + "templates/_speciallist.htm", oDiv);
}
function ajaxGo2View(ccId,id)
{
	$.ajax({
		type:		"post",
		dataType:	"json",
		data:		"contentid="+id+"&channelid="+ccId+"&time="+(new Date().getTime()),
		url:		site.Dir + "ajax/content.aspx?oper=ajaxGo2View",
        	error:		function(XmlHttpRequest,textStatus, errorThrown){if(XmlHttpRequest.responseText!=""){alert(XmlHttpRequest.responseText);}},
		success:	function(d){
			window.open(d.returnval);
		}
	});
}
function ajaxViewCount(cType,id,randomid,needadd)
{
	var addit = needadd == false ? 0 : 1;
	$.ajax({
		type:		"get",
		dataType:	"json",
		data:		"oper=ajaxViewCount&id="+id+"&addit="+addit+"&cType="+cType+"&time="+(new Date().getTime()),
		url:		site.Dir + "ajax/content.aspx",
		error:		function(XmlHttpRequest,textStatus, errorThrown){if(XmlHttpRequest.responseText!=""){alert(XmlHttpRequest.responseText);}},
		success:	function(d){
			$("#ajaxViewCount_"+id+"_"+randomid).text(d.count);
		}
	});
}

function ajaxThreadViewCount(cType,id,randomid,needadd)
{
	var addit = needadd == false ? 0 : 1;
	$.ajax({
		type:		"get",
		dataType:	"json",
		data:		"oper=ajaxThreadViewCount&id="+id+"&addit="+addit+"&cType="+cType+"&time="+(new Date().getTime()),
		url:		site.Dir + "ajax/content.aspx",
		error:		function(XmlHttpRequest,textStatus, errorThrown){if(XmlHttpRequest.responseText!=""){alert(XmlHttpRequest.responseText);}},
		success:	function(d){
			$("#ajaxViewCount_"+id+"_"+randomid).text(d.count);
		}
	});
}



function replaceContentTags(ccid,cType,taglist,bodyid)
{
	try{
		var elms1 = $("#"+bodyid+" a");
		for (i = 0; i < elms1.length; i++){elms1[i].title="";}
		var elms2 = $("#"+bodyid+" img");
		for (i = 0; i < elms2.length; i++){elms2[i].alt="";}
		var returnhtml=$("#"+bodyid).html();
		var tags=taglist.split(',');
		for (i = 0; i < tags.length; i++) {
			if(tags[i].length>1)//只取2个字符以上的
			{
				returnhtml=returnhtml.replace(tags[i],"<a href='"+site.Dir + "extends/search/index.aspx?type="+cType+"&k="+escape(tags[i])+"&t=tag' target='_blank'><font color='blue'>"+tags[i]+"</font></a>");
			}
		}
		$("#"+bodyid).html(returnhtml);
	}
	catch(e){}
}
function addFavorite(ccid,cType,id)
{
	$.ajax({
		type:		"get",
		dataType:	"html",
		data:		"oper=addFavorite&id="+id+"&ccid="+ccid+"&cType="+cType+"&time="+(new Date().getTime()),
		url:		site.Dir + "ajax/content.aspx",
		error:		function(XmlHttpRequest,textStatus, errorThrown){if(XmlHttpRequest.responseText!=""){alert(XmlHttpRequest.responseText);}},
		success:	function(d){
			JumbotCms.Alert(d,"0");
		}
	});
}
var _closeTimer = -1;
function Go2PageForm(url)
{
	var oDialog = new ClassDialog('1', '确认框', 290, 130, 'success', false);
	oDialog.init();
	var sHtml = '<form id="Go2PageForm"><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">\
			<tr><td height="30" align="left"><span id="closetimer"></span></td></tr>\
			<tr><td height="30" align="left">验证：<input name="txtGo2Code" type="text" maxlength="6" id="txtGo2Code" class="ipt" style="width:50px;" /> <img onClick="this.src=\''+ site.Dir + 'plus/getcode2.aspx?n=4&t='+(new Date().getTime())+'\';" src="'+site.Dir+'plus/getcode2.aspx?n=4&t='+(new Date().getTime())+'" align="absmiddle" style="cursor: pointer" alt="暂时不区分大小写&#13;看不清楚？换一张" /></td></tr>\
			<tr><td height="40" align="left"><input type="button" value="确认" onclick="Go2PageCheck(\''+url+'\');" />&nbsp;&nbsp;<input type="button" value="取消" onclick="Go2PageStop();" /></td></tr>\
		</table></form>\
	';
	oDialog.event(sHtml,'');
	Go2PageStart();
}
function Go2PageCheck(url){
	var uCode=$("#txtGo2Code").val();
	if(uCode==""){
		alert('请填写验证码');
		$("#txtGo2Code").focus();
		return;
	}
	window.open(site.Dir + "plus/"+url+"&code="+uCode);
	Go2PageStop();
}
function Go2PageStart(){
	_closeTimer = 20;
	Go2PageAutoClose(_closeTimer, "closetimer");
}
function Go2PageStop(){
	_closeTimer = - 1;
	Go2PageAutoClose(_closeTimer, "closetimer");
}
function Go2PageAutoClose(secs, spanid){
	if(J(spanid) == null)
		return;
	if(secs > 0) 
	{
		_closeTimer = secs - 1;
		$('#'+spanid).html('还有' + _closeTimer + '秒自动关闭');
		window.setTimeout("Go2PageAutoClose(" + _closeTimer + ",'" + spanid + "')", 1000);
	} 
	else if(secs == 0) 
	{
		_closeTimer = -1;
		Go2PageAutoClose(_closeTimer,spanid);
	} 
	else
	{
		new ClassDialog().reset();
	}
}
