﻿var SendChaturl = "/sendChatData.aspx";

function sendComment() {
currentChatText = document.forms['chatForm'].elements['chatbarText'].value;
if (currentChatText != '' & (httpSendChat.readyState == 4 || httpSendChat.readyState == 0)) {
	currentName = document.forms['chatForm'].elements['name'].value;
	//currentName = "沪友";
	//currentID = "1376385";
	currentID = document.forms['chatForm'].elements['id'].value;
	param = 'n='+ currentName+'&c='+ currentChatText+'&id='+ currentID;
	httpSendChat.open("POST", SendChaturl, true);
	httpSendChat.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	httpSendChat.onreadystatechange = handlehHttpSendChat;
	httpSendChat.send(param);
	document.forms['chatForm'].elements['chatbarText'].value = '';
//document.getElementById('chatbarText').focus();
alert("发布成功！感谢您的参与：）");
} else {
	setTimeout('sendComment();',1000);
}
}



function SetUID(id)
{
	var uid = 0;
	uid = id;

	if (uid != 0){
		document.forms['chatForm'].elements['id'].value = uid;
	}
	else{
		document.forms['chatForm'].elements['id'].value = '1376385';
	}
}


function SetUName(name)
{
	var uname = "";
	uname = name;
	currentName = document.forms['chatForm'].elements['name'];
	document.forms['chatForm'].elements['name'].value = uname;

}

function handlehHttpSendChat() {

}

function getHTTPObject() {
	var xmlhttp;
	/*@cc_on
	@if (@_jscript_version >= 5)
		try {
			xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (E) {
				xmlhttp = false;
			}
		}
	@else
	xmlhttp = false;
	@end @*/
	if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
		try {
			xmlhttp = new XMLHttpRequest();
		} catch (e) {
			xmlhttp = false;
		}
	}
	return xmlhttp;
}
var httpSendChat = getHTTPObject();

