//创建xmlHttp对象

function createXmlObj()
{
var xmlHttp;
	try { xmlHttp=new XMLHttpRequest;}
	catch(e)
	{
		try { xmlHttp=new ActiveXObject("MSXML2.XMLHttp"); }
		catch(e1)
		{
			try{ xmlHttp=new ActiveXobject("Microsoft.XMLHttp"); }
			catch(e2)
			{return false; }
		}
	}
	return xmlHttp;
}

//ajax通用函数

function ajaxComm(url,objType)
{
	var xmlHttp=createXmlObj();

	xmlHttp.onreadystatechange=function()
	{
		if (xmlHttp.readyState==4&&xmlHttp.status==200)
		{
			if (objType=="text")
				{
					var ajaxObj = xmlHttp.responseText;
					//alert(ajaxObj);
					return ajaxObj;
				}
			else if (objType=="xml")
				{
					var ajaxObj = xmlHttp.responseXML;
					return ajaxObj;
				}
		}
	}
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);

}

//ajaxGetCity 通过ajax技术获取ajaxGetCity.asp中的数据
function ajaxGetCity(Province)
{
	var xmlHttp=createXmlObj();

	xmlHttp.onreadystatechange=function()
	{
		if (xmlHttp.readyState==4&&xmlHttp.status==200)
		{
		var xmlDOM=xmlHttp.responseText;
		document.getElementById("city").innerHTML=xmlDOM;

		}
	}
	xmlHttp.open ("GET","/inc/ajaxGetCity.asp?pro="+escape(Province),true);
	xmlHttp.send(null);

}

//ajax验证对应输入的数据是否重复
function ajaxCheck(str,objId)
{
	var xmlHttp=createXmlObj();


	xmlHttp.onreadystatechange=function()
	{
		if (xmlHttp.readyState==4&&xmlHttp.status==200)
		{
		var xmlDOM=xmlHttp.responseText;
		document.getElementById(objId).innerHTML=xmlDOM;
		}
	}
	xmlHttp.open("GET","/member/checkrepeat.asp?lname="+str,true);
	xmlHttp.send(null);
}

//内容显示交换
function changeContent(obj,classid,objId1,objId2,className1,className2)
{
	if (obj==1)
	{
		document.getElementById(classid).className=className1;
		document.getElementById(objId1).style.display="block";
		document.getElementById(objId2).style.display="none";
	}
	else
	{
		document.getElementById(objId1).style.display="none";
		document.getElementById(objId2).style.display="block";
		document.getElementById(classid).className=className2;
	}
}

//新闻与论坛交换
function tabit(obj,objId,objId1,objId2,objId3,classStr,classStr1)
{
	if (obj==1)
	{
		document.getElementById(objId).className=classStr;
		document.getElementById(objId1).className=classStr1;
		document.getElementById(objId2).style.display="block";
		document.getElementById(objId3).style.display="none";
	}
	else
	{
		document.getElementById(objId).className=classStr1;
		document.getElementById(objId1).className=classStr;
		document.getElementById(objId2).style.display="none";
		document.getElementById(objId3).style.display="block";
	}
}
function getSmallType(pid,tid,isTop)
{
	var url="/member/getAjaxforType.asp?pid="+pid+"&tid="+tid;
	var xmlHttp=createXmlObj();

	xmlHttp.onreadystatechange=function()
	{
		if (xmlHttp.readyState==4&&xmlHttp.status==200)
		{
			var ajaxObj = xmlHttp.responseText;
			if (ajaxObj!=undefined&&ajaxObj!="")
			{
				document.getElementById("typestr"+tid).innerHTML=ajaxObj;

			}
			else
			{
				for(i=1;i<=4;i++)
				if (i>=tid)
				document.getElementById("typestr"+i).innerHTML="";
			}
		}
	}
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);

}

function checkSearch()
{

	if (document.searchForm.keywords.value=="" || document.searchForm.keywords.value=="请输入您感兴趣的关键字")
	{
		alert("请输入你的关键字");
		document.searchForm.keywords.focus();
		return false;
	}
	var stype=document.searchForm.sType.options[document.searchForm.sType.selectedIndex].value;
	switch (parseInt(stype))
	{
		case 2 :
		document.searchForm.action="http://www.xx351.com/search/buy/";
		break;
		case 3 :
		document.searchForm.action="http://www.xx351.com/search/pro/";
		break;
		case 4 :
		document.searchForm.action="http://www.xx351.com/search/company/";
		break;
		case 5 :
		document.searchForm.action="http://www.xx351.com/search/news/";
		break;
	}
}

//js全角转半角（不转换汉字，只转换数字和字母）
function DBC2SBC(str,flag) {
var i;
var result='';
for(i=0;i<str.length;i++)
{ str1=str.charCodeAt(i);
if(str1<65296){ result+=String.fromCharCode(str.charCodeAt(i)); continue;}
if(str1<125&&!flag)
result+=String.fromCharCode(str.charCodeAt(i));
else
result+=String.fromCharCode(str.charCodeAt(i)-65248);
}
return result;
}
