
function call_remote(action, url, funPointer) {
	var xmlObj = null;
	if (window.XMLHttpRequest) {
		xmlObj = new XMLHttpRequest();
	}
	else if (window.ActiveXObject) {
		xmlObj = new ActiveXObject("Microsoft.XMLHTTP");
	}
	else {
		return;
	}
	if (funPointer != null) {
		xmlObj.onreadystatechange = function ()
								{
									if (xmlObj.readyState == 4 && xmlObj.status == 200)
										funPointer(xmlObj.responseText);
								}
	}
	xmlObj.open(action, url, true);
	xmlObj.setRequestHeader("context-type","text/xml;charset=GB2312");
	xmlObj.send(null);
}

// 输出文章浏览次数
function outputHits(response) {
	document.getElementById("spanhits").innerHTML = response;
	return ;
}   
//输出加入人数
function outputjoin(response) {
	document.getElementById("spanhits").innerHTML = response;
	return ;
}

// 处理文章浏览次数
function hitsCount(section, artid) {

	//var url = "/"+section+"/room.aspx?artcleid="+artid;
	//var url1="/"+ section +"/hotel_pic.aspx?artcleid="+artid;
	var url2="/"+ section +"/Specials.aspx";
	//var url3="/"+ section +"/search.aspx";
	if (arguments.length > 2) {
		call_remote("GET", url1, null);
	}
	else {
		//call_remote("GET",url1,piclist);
		//call_remote("GET",url,room);
		call_remote("GET",url2,Specials);
		//call_remote("GET",url3,search);
	}
	return;
}

function piclist(response) {

	document.getElementById("piclist").innerHTML = response;

	//alert(response);
	return ;
}

function search(response) {

	document.getElementById("search").innerHTML = response;
	//alert(response);
	return ;
}

function room(response) {

	document.getElementById("room").innerHTML = response;

	//alert(response);
	return ;
}
function Specials(response) {

	document.getElementById("Specials").innerHTML = response;

	//alert(response);
	return ;
}
//输出加入信息
function outputjoininfo(response) {
	document.getElementById("joininfo").innerHTML = response;
	return ;
}



function voteCount(section,columnid, artid,typeid) {

	var url = "/"+section+"/count.aspx?id="+artid;
	if (arguments.length > 2) {
		call_remote("GET", url, null);
	}
	else {
		call_remote("GET", url, outputHits);
	}
	return;
}

function expertHeat(section, designerid) {
	var url = "/"+section+"/count.aspx?designerid="+designerid;
	call_remote("GET", url, outputHits);
	return;
}

// 自动显示发表人为匿
function anonym(txt_name) {
	var obj = document.getElementById("chkAnonym");
	if (obj.checked == true)
		document.getElementById(txt_name).value = "匿名";
	else
		document.getElementById(txt_name).value = "";
	return;
}

// 发送文章评论
function commentSend(section) {
   
	var artId	= document.frmComment.hdnArticleId.value;
	var speaker	= document.frmComment.txtSpeaker.value;
	var comment = document.frmComment.txtComment.value;
//    var htmlpath= document.frmComment.htmlpath.value;
//    var template= document.frmComment.template.value;
    
	if (speaker.length == 0 || comment.length == 0) {
		alert("发表人或评论不能为空。");
		return false;
	}
	
	if (speaker.length > 20)
		speaker = speaker.substr(0, 20);
	if (comment.length > 1000)
		comment = comment.substr(0, 990)+"...";
	var url = "/"+ section +"/comment.aspx?artId="+ artId +"&speaker="+ speaker +"&comment="+ comment;
	call_remote("GET", url, reactionToComment);

	return;
}

function reactionToComment(response) {

	document.getElementById("spanpic").innerHTML = response;
	//alert(response);
	return ;
}

function faqSendQuiz(section) {
	var sender	= document.frmQuiz.txtSender.value;
	var title	= document.frmQuiz.txtFAQTitle.value;
	var content	= document.frmQuiz.txtFAQContent.value;
	
	if (sender == "" || title == "") {
		alert("发表人或我要提出的问题不能为空。");
		return false;
	}
	
	if (content == "")
		document.getElementById("txtFAQContent").value = title;
	if (section == "") {
		document.frmQuiz.submit();
	}
	else {
		var url = "/"+ section +"/faq.aspx";
		call_remote("POST", url, reactionToQuiz);
	}
	return ;
}

function reactionToQuiz(response) {
	document.frmQuiz.reset();
	alert(response);
	return;
}

function faqSendAnswer(section) {
	var sender	= document.frmAnswer.txtSender.value;
	var title	= document.frmAnswer.txtFAQTitle.value;
	var content	= document.frmAnswer.txtFAQContent.value;
	
	if (sender == "" || title == "" || content == "") {
		alert("回答者，标题或回答内容信息不能为空。");
		return false;
	}

	if (section == "") {
		document.frmAnswer.submit();
	}
	else {
		var url = "/"+ section +"/faq.aspx";
		call_remote("POST", url, reactionToQuiz);
	}
	return;
}

function getChildNodes(section, parentId) {
	if (parentId == "") {
		alert("请选择一级类别。");
		return false;
	}
	var url = "/"+ section +"/node.aspx?pid="+ parentId;
	call_remote("GET", url, setChildNodes);
	return;
}

function setChildNodes(response) {
	var selobj = document.getElementById("cId");
	selobj.options.length = 0;
	var arrsel = response.split("|");
	if (arrsel.length > 1) {
		selobj.options.add(new Option("请选择二级类别...", ""));
		for (var i = 0; i < arrsel.length; i += 2) {
			selobj.options.add(new Option(arrsel[i+1], arrsel[i]));
		}		
	}
	else {
		selobj.options.add(new Option("其下暂无二级类别", ""));		
	}

	selobj.options[0].selected = true;
	return;
}

// 发送供求信息留言
function replySend(section) {
	//alert("hello");
	//return;
	var msgId	= document.getElementById("hdnMessageId").value;
	var name	= document.getElementById("txtSpeaker").value;
	var topic	= document.getElementById("txtTopic").value;	
	var comment = document.getElementById("txtComment").value;

	if (name.length == 0 || topic.length == 0) {
		alert("发布者，留言主题。");
		return false;
	}
	if (comment.length == 0) {
		comment = topic;
	}
	
	if (name.length > 20)
		name = name.substr(0, 20);
	if (topic.length > 100)
		topic = topic.substr(0, 100);
	if (comment.length > 800)
		comment = comment.substr(0, 800)+"...";
	var url = "/"+ section +"/comment.aspx?msgId="+ msgId +"&name="+ name +"&topic="+ topic +"&comment="+ comment;
	call_remote("GET", url, reactionToComment);

	return;
}

function Cbg(obj, objColor)
{
obj.style.backgroundColor=objColor;
}

 function hrefs()
 {
 	var href=location.href;
	//alert("sdfsdfsdf");
	href=href.replace("fjtct.now.cn:7751/","");
	location.href=href;
 }

