//触发服务器事件
function AjaxServer()
{

}

//创建XMLhttp对象
AjaxServer.CreateHttpObj=function(){
	var objhttp;
	try
	{
		//IE浏览器
		try
		{
			objhttp = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e)
		{
			objhttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	catch(e)
	{
		//不是IE浏览器
		try
		{
			objhttp = new XMLHttpRequest();
		}
		catch(e)
		{
			objhttp = null;
		}
	}
	return objhttp
}


//获取新闻点击量
AjaxServer.getHits = function(id,pathstr)
{
	var xmlhttp = AjaxServer.CreateHttpObj();
	if(xmlhttp)
	{
		xmlhttp.open("GET", pathstr +"www/js/server.asp?flag=hits&ID="+ id, false); 
		xmlhttp.send(); 
		if(xmlhttp.status==200)
		{
			document.getElementById("show").innerHTML = xmlhttp.responseText
		}
	}
}

AjaxServer.ShowMenu = function(sort)
{
	var xmlhttp = AjaxServer.CreateHttpObj();
	if(xmlhttp)
	{
		xmlhttp.open("GET","/www/js/server.asp?flag=showmenu&sort="+sort+"&num="+Math.random(),false);
		xmlhttp.send();
		if(xmlhttp.status==200)
		{
			document.getElementById("submenu").innerHTML = xmlhttp.responseText;
		}
	}
}

AjaxServer.ShowMenu = function(sort)
{
	var xmlhttp = AjaxServer.CreateHttpObj();
	if(xmlhttp)
	{
		xmlhttp.open("GET","/www/js/server.asp?flag=showmenu&sort="+sort+"&num="+Math.random(),false);
		xmlhttp.send();
		if(xmlhttp.status==200)
		{
			document.getElementById("submenu").innerHTML = xmlhttp.responseText;
		}
	}
}

AjaxServer.submitVote = function(voteid,OptTotal,votetype,votemaxselect)
{
	var str="",commnent,currentselect=0
	var xmlhttp = AjaxServer.CreateHttpObj();
	if(xmlhttp)
	{
		for(j=1;j<=OptTotal;j++)
		{
			if(document.getElementById("S"+voteid+j).checked)
			{
				if(str=="")
				{
					str = document.getElementById("S"+voteid+j).value;
				}
				else
				{
					str = str + "," + document.getElementById("S"+voteid+j).value;
				}
				currentselect = currentselect + 1
			}
		}
		if(votetype=="02"&& currentselect > votemaxselect)        //如果是多选
		{
			alert("你最多只能选择"+ votemaxselect + "项!");
			return false
		}
		xmlhttp.open("GET","/www/js/server.asp?flag=vote&voteid="+ voteid +"&optstr="+str+"&comment="+ document.getElementById("Comment"+voteid).value+"&num="+Math.random(),false);
		xmlhttp.send();
		if(xmlhttp.status==200)
		{
			alert(xmlhttp.responseText);
		}
	}
}



