var span
var xmlHttp = false;
try {
  xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
  try {
    xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
  } catch (e2) {
    xmlHttp = false;
  }
}
if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
  xmlHttp = new XMLHttpRequest();
}

function getTop() {
  //var SellAreaID = document.getElementById("SellAreaID").value;
  var url = "nTop/nTop.asp";
  xmlHttp.open("GET", url, true);
  xmlHttp.onreadystatechange = updatePage;
  xmlHttp.send(null);  
}

function updatePage() {
	//alert(xmlHttp.readyState);
  if (xmlHttp.readyState == 4) { 
		//if(xmlHttp.status==200){
			document.getElementById(span).innerHTML=xmlHttp.responseText;
		//}else{
		//	document.getElementById(span).innerHTML="数据请求失败...";
		//}
  }
}

function hotQuestion()
{
	span="hotQuestion";
	var url = "qlist/hotList.asp"
	xmlHttp.open("GET",url,true);
	xmlHttp.onreadystatechange=updatePage;
	xmlHttp.send(null);	
}
function newQuestion()
{ span = "newQuestion";
	var url = "qlist/newQlist.asp"
	xmlHttp.open("GET",url,true);
	xmlHttp.onreadystatechange=updatePage;
	xmlHttp.send(null);
}
function waitSolve()
{ 
	span = "waitSolve";
	var url = "qlist/waitSolveList.asp"
	xmlHttp.open("GET",url,true);
	xmlHttp.onreadystatechange=updatePage;
	xmlHttp.send(null);
}
function toupiaoQuestion()
{ span = "toupiaoQuestion";
	var url = "qlist/toupiaolist.asp"
	xmlHttp.open("GET",url,true);
	xmlHttp.onreadystatechange=updatePage;
	xmlHttp.send(null);
}
function solvedQuestion()
{ //alert("aaa");
	span="solvedQuestion";
	var url = "qlist/solvedList.asp"
	xmlHttp.open("GET",url,true);
	xmlHttp.onreadystatechange=updatePage;
	xmlHttp.send(null);	
}
function getSecondSort(spanId)
{ span = spanId.name;  //获取对象的NAME属性值；
	var fid=document.askForm.ask_first.value;
  var url = "ask_second.asp?fid="+fid+"&size=6";
	xmlHttp.open("GET",url,true);
	xmlHttp.setRequestHeader("Content-Type","text/html;charset=GB2312");
  xmlHttp.onreadystatechange = updatePage;
	xmlHttp.send(null);
}
function Fun_GetSecondSort(spanId,fidvalue,size)
{ span = spanId.name;  //获取对象的NAME属性值；
	//var fid=document.FormApp.AppFirst.value;
  var url = "../question/ask_second.asp?fid="+fidvalue+"&size="+size;
	xmlHttp.open("GET",url,true);
	xmlHttp.setRequestHeader("Content-Type","text/html;charset=GB2312");
  xmlHttp.onreadystatechange = updatePage;
	xmlHttp.send(null);
}
function getCityList(spanId)
{ span=spanId.name;
	var pid=document.form1.prov.value;
	var url="getCity.asp?pid="+pid;
	xmlHttp.open("GET",url,true);
	xmlHttp.setRequestHeader("Content-Type","text/html;charset=GB2312");
  xmlHttp.onreadystatechange = updatePage;
	xmlHttp.send(null);
}
function getWeatherList(inttype)
{	span="weatherlist";
	var ProvinceValue=document.form1.prov.value;
	var CityValue=document.form1.getCityWeather.value;
	if(inttype=="2"){
	if(CityValue==""){alert("请选择城市!");return false;}
	}
	var url="getWeather.asp?Prov="+ProvinceValue+"&City="+CityValue;
	//parent.document.all.getweather.location.href
	xmlHttp.open("GET",url,true);
	xmlHttp.setRequestHeader("Content-Type","text/html;charset=GB2312");
  xmlHttp.onreadystatechange = updatePage;
	xmlHttp.send(null);	
}

function getCity(spanId)
{ span = spanId.name;
	var pid=document.askForm.province.value;
	var url="city.asp?pid="+pid;
	xmlHttp.open("GET",url,true);
	xmlHttp.setRequestHeader("Content-Type","text/html;charset=GB2312");
	xmlHttp.onreadystatechange = updatePage;
	xmlHttp.send(null);
}
function getanswer(nid)
{
  span ="answer";
	var url="answer.asp?nid="+nid;
	xmlHttp.open("GET",url,true);
	xmlHttp.setRequestHeader("Content-Type","text/html;charset=GB2312");
	xmlHttp.onreadystatechange = updatePage;
	xmlHttp.send(null);	
 }
function YzbmGetCity(pid) 
{
	span ="YzGetCity";
	var url="YzGetCity.asp?pid="+pid;
	xmlHttp.open("GET",url,true);
	xmlHttp.setRequestHeader("Content-Type","text/html;charset=GB2312");	
	xmlHttp.onreadystatechange = updatePage;
	xmlHttp.send(null);	
}
function ge()
{
alert(document.all.mfram.height);
}

function LoginCheck(uid,pwd,utype)
{ var hexmd5;
  var isture;
  if(uid=="")
	{
		alert("用户名不能为空");
		return false;
	}
	if(pwd=="")
	{
		alert("登陆密码不能为空");
		return false;
	}
	
	if(utype==1 || utype==3){
	hexmd5=hex_md5(pwd);
	return hexmd5;
	}
}
function checksub(action)
{
	form1.mark.value=action;
	form1.submit();
}

function uLogin()
{ var hexmd5;
  if(document.uLoginForm.User_LoginID.value=="")
	{
		alert("用户名不能为空");
		document.uLoginForm.User_LoginID.focus();
		return false;
	}
	if(document.uLoginForm.User_LoginPass.value=="")
	{
		alert("登陆密码不能为空");
		document.uLoginForm.User_LoginPass.focus();
		return false;
	}
	//if(document.uLoginForm.uType.value==1 || document.uLoginForm.uType.value==3){	
	hexmd5=hex_md5(document.uLoginForm.User_LoginPass.value);
	document.uLoginForm.User_LoginPass01.value=hexmd5;
	//}
	//else
	//{
	//	document.uLoginForm.User_LoginPass01.value=document.uLoginForm.User_LoginPass.value;
	//}	
	//document.uLoginForm.uURL.value="Login"	
	return true;
}
function linkTo(ButtonName,chref)
{
 if(ButtonName.name=="ask")
 { document.nKeyForm.action=chref+"question/addnew.asp";document.nKeyForm.target="_parent";
	}

 if(ButtonName.name=="search")
 { document.nKeyForm.action=chref+"search/search_list.asp";
   
 }
 document.nKeyForm.submit();
}
function bookmarkit(){

	window.external.addFavorite('http://www.wenbida.cn/index.asp','问必答')

}

function chkphone(thisName,SpanName)
{
	if(chkphoneresult(thisName.value))
	{	SpanName.innerHTML="<img src='../img/check_error.gif'>手机号码错误";		
	}else
	{	SpanName.innerHTML="<img src='../img/check_right.gif'>手机号码正确";		
	}
}
function chkphoneresult(strPhone)
{	var result=false; //验证结果
	result=/[^0-9]/g.test(strPhone);
	if(result)return result;
	if(strPhone.length==0)return true;
	result=!(strPhone.length==11 ||strPhone.length==12);
	if(result)return result;
	return result;
	//return (/[^0-9]/g.test(strPhone) || (strPhone.length==11 ||strPhone.length==12))	 
	//判断号码是否不全是数字，或者没有11位,12位，如果是，返回TRUE，表示输入的号码有错。
}

function selectall(f,s,ename) //表单名，全选框名，复选框名
{
	var objchk=ename; //复选框对象
	//alert(objchk);
	//return false;
	if(s.checked)
	{
		for(i=0;i<ename.length;i++)objchk[i].checked=true;
	}else{
		for(i=0;i<ename.length;i++)objchk[i].checked=false;
	}
}