// JavaScript Document
var strType;
var strType2;
var strFindType; //搜索类型.KEY,表示回车.否则表示提交
var GetNodeValue = function(obj)
{
var str = "";
if(window.ActiveXObject)    //IE
{
str = obj.text;
}
else //Mozilla
{
try
{
   str = obj.childNodes[0].nodeValue;
}
catch(ex)
{
   str = "";
}
}
return str;
}

if(document.implementation && document.implementation.createDocument)
{
XMLDocument.prototype.loadXML = function(xmlString)
{
var childNodes = this.childNodes;
for (var i = childNodes.length - 1; i >= 0; i--)
   this.removeChild(childNodes[i]);

var dp = new DOMParser();
var newDOM = dp.parseFromString(xmlString, "text/xml");
var newElt = this.importNode(newDOM.documentElement, true);
this.appendChild(newElt);
};

// check for XPath implementation
if( document.implementation.hasFeature("XPath", "3.0") )
{
    // prototying the XMLDocument
    XMLDocument.prototype.selectNodes = function(cXPathString, xNode)
    {
    if( !xNode ) { xNode = this; }
    var oNSResolver = this.createNSResolver(this.documentElement)
    var aItems = this.evaluate(cXPathString, xNode, oNSResolver,
        XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null)
    var aResult = [];
    for( var i = 0; i < aItems.snapshotLength; i++)
    {
    aResult[i] = aItems.snapshotItem(i);
    }
    return aResult;
    }

    // prototying the Element
    Element.prototype.selectNodes = function(cXPathString)
    {
    if(this.ownerDocument.selectNodes)
    {
    return this.ownerDocument.selectNodes(cXPathString, this);
    }
    else{throw "For XML Elements Only";}
    }
}

// check for XPath implementation
if( document.implementation.hasFeature("XPath", "3.0") )
{
    // prototying the XMLDocument
    XMLDocument.prototype.selectSingleNode = function(cXPathString, xNode)
    {
    if( !xNode ) { xNode = this; }
    var xItems = this.selectNodes(cXPathString, xNode);
    if( xItems.length > 0 )
    {
    return xItems[0];
    }
    else
    {
    return null;
    }
    }
  
    // prototying the Element
    Element.prototype.selectSingleNode = function(cXPathString)
    {  
    if(this.ownerDocument.selectSingleNode)
    {
    return this.ownerDocument.selectSingleNode(cXPathString, this);
    }
    else{throw "For XML Elements Only";}
    }
}
}

function loadXML(skey,strObj)
{
    var xmlHttp;
    var name;

    if(window.ActiveXObject)
    {
        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    else if(window.XMLHttpRequest)
    {
        xmlHttp = new XMLHttpRequest();
    }
    try
    {
        xmlHttp.onreadystatechange = function()
        {
            if(xmlHttp.readyState == 4)
            {
                if (xmlHttp.status == 200)
                {
                    // 取得XML的DOM对象
                    var xmlDOM = xmlHttp.responseXML;
                    // 取得XML文档的根
                    var root = xmlDOM.documentElement;
                    try
                    {
						var objType2=document.getElementById(strObj);	
	var k=objType2.length;
	for(var s=k-1;s>=1;s--)
	{
		objType2.remove(s);
	}
                       var items = root.selectNodes("//urlset/url");
                       for(var i=0;i<items.length;i++)
                       {
                        //取得XML文件中内容:)
                        var strloc = GetNodeValue(items[i].selectSingleNode("loc"));
                        var strsite=GetNodeValue(items[i].selectSingleNode("site"));
						var newOption = document.createElement("OPTION"); 
					　　 newOption.text=strsite;
		　　			 newOption.value=strloc;
				　　 objType2.options.add(newOption); 
                        
                       }
                    }
                    catch(exception)
                    {
                        alert("error!");
                    }
                }
            }
        }
        xmlHttp.open("GET", "Newresult.asp?classid="+skey, true);
		
        xmlHttp.send(null);
    }
    catch(exception)
    {
      alert("您要访问的资源不存在!");
    }
}


//////
function ProShowHideArea(id,strTitle)
{
	strType=id;
	for(i=1;i<=4;i++)
	{
		if(id==i)
		{
			document.getElementById("div_"+i).style.display="";
			document.getElementById("aDiv"+i).className='divShow';
			document.title="OLDCP搜索中心--"+strTitle
		}
		else
		{
			document.getElementById("div_"+i).style.display="none";
			document.getElementById("aDiv"+i).className='blueline12b';
		}
	}
}
//
function ProShowHideArea2(id,temp,strTitle)
{
	strType2=id;
	for(i=1;i<=4;i++)
	{
		if(id==i)
		{
			document.getElementById("div_"+i).style.display="";
			document.getElementById("aDiv"+i).className='divShow';

			if(strTitle!=undefined)
			{
				document.title="搜索结果--"+strTitle;
			}
			if(temp!="")
			{
				document.getElementById("BtxtValue"+i).value=temp;
			}
		}
		else
		{
			document.getElementById("div_"+i).style.display="none";
			document.getElementById("aDiv"+i).className='blueline12b';

		}
	}
}

function ProRemoveSpace(strValue)
{
   return  strValue.replace(/(^\s*)|(\s*$)/g,"");   
}

function ShouProEnter(strTemp)
{

	strType=Number(strTemp);

	if(event.keyCode==13)
	{
//		strFindType="KEY";
		document.getElementById("Submit"+strTemp).click();
		//if(strTemp==2)
//		{
	//	 document.getElementById("Submit2").click();
//		}
	//	else
//		{
			//oldshourSubmit();
	//	}
		return false;
	}
	else
	{
		strFindType=="FORM";
		return false;
	}
}

function ShouProEnter2(strTemp)
{

	strType2=Number(strTemp);

	if(event.keyCode==13)
	{
		strFindType="KEY";
		oldshourSubmit2();
	}
	else
	{
		return false;
	}
}

function oldshourSubmit()
{
	 
	var strUrl;
	switch(strType)
	{
		case 1 : //供求信息
			var in_txtValue1=document.getElementById("txtValue1"); //关键字
			in_txtValue1=ProRemoveSpace(in_txtValue1.value);
			if(in_txtValue1=="")
			{
				alert("请输入要搜索的关键词,如二手电脑");
				return false;
			}
			var in_txtType1=document.getElementById("txtType1"); //行业大类别
			in_txtType1=in_txtType1.value;
			
			var in_txtType2=document.getElementById("txtType2"); //行业小类别
			in_txtType2=in_txtType2.value;
			
			var in_txtType3=document.getElementById("txtType3"); //出售，回购
			in_txtType3=in_txtType3.value;
			
			var in_txtType4=document.getElementById("txtType4"); //成色，全新，
			in_txtType4=in_txtType4.value;
			
			var in_txtFromPrice=document.getElementById("txtFromPrice"); //开始价格
			in_txtFromPrice=in_txtFromPrice.value;
			
			var in_txtToPrice=document.getElementById("txtToPrice"); //结束价格
			in_txtToPrice=in_txtToPrice.value;
						
			var in_txtWebSite=document.getElementById("txtWebSite"); //站点
			in_txtWebSite=in_txtWebSite.value;

	strUrl="pageNos=1&searchKey="+in_txtValue1+"&types="+strType+"&type1="+in_txtType1+"&type2="+in_txtType2+"&type3="+in_txtType3;
			strUrl=strUrl+"&type4="+in_txtType4+"&fromPrice="+in_txtFromPrice+"&toPrice="+in_txtToPrice;
			strUrl=strUrl+"&website="+in_txtWebSite+"&requesttype=1&AllRecordCount=-1";
			 
	 
					document.getElementById("oldshou_form").action="oldshouresult.asp?"+strUrl;
		 

			
			break;  
		case 2:    //企业黄页
			var in_txt2=document.getElementById("txtValue2"); //keywords
		 
			in_txt2=ProRemoveSpace(in_txt2.value);
			if(in_txt2=="")
			{
				alert("请输入要搜索的关键词,如二手电脑");
				return false;
			}
			
			var in_1b=document.getElementById("txtType1_b"); //大类别
			in_1b=in_1b.value;
			
			var in_2b=document.getElementById("txtType2_b"); //小类别
			in_2b=in_2b.value;
			
			strUrl="AllRecordCount=-1&pageNos=1&requesttype=2&searchKey="+in_txt2+"&type1="+in_1b+"&type2="+in_2b;
			if (strFindType=="KEY")
			{

				window.open("oldshouresult.asp?"+strUrl);
			}
			else
			{

				document.getElementById("oldshou_form").action="oldshouresult.asp?"+strUrl;
			}
			break;
		case 3:   //行业资讯
			var in_txt3=document.getElementById("txtValue3"); //keywords
	 
			in_txt3=ProRemoveSpace(in_txt3.value);
			if(in_txt3=="")
			{
				alert("请输入要搜索的关键词,如二手电脑");
				return false;
			}
			
			strUrl="AllRecordCount=-1&pageNos=1&requesttype=3&searchKey="+in_txt3;
			if (strFindType=="KEY")
			{
				window.open("oldshouresult.asp?"+strUrl);
			}
			else
			{
				document.getElementById("oldshou_form").action="oldshouresult.asp?"+strUrl;
			}
			break;
		case 4:  //学习信息
			var in_txt4=document.getElementById("txtValue4"); //keywords
 
			in_txt4=ProRemoveSpace(in_txt4.value);
			if(in_txt4=="")
			{
				alert("请输入要搜索的关键词,如二手电脑");
				return false;
			}
			strUrl="AllRecordCount=-1&pageNos=1&requesttype=4&searchKey="+in_txt4;
		 
		if (strFindType=="KEY")
			{

				window.open("oldshouresult.asp?"+strUrl);
			}
			else
			{
				document.getElementById("oldshou_form").action="oldshouresult.asp?"+strUrl;
			}

			break;
		
	}

}

function oldshourSubmit2()
{
	if(strType2==null)
	{
		alert("搜索类型无效");
		return;
	}
	var obj=document.getElementById("BtxtValue"+strType2);
	if(obj==null)
	{
		alert("搜索输入参数无效");
		return;
	}

	var strUrl;

	switch(strType2)
	{
		case 1 : //供求信息

			var in_txtValue1=document.getElementById("BtxtValue1"); //关键字
		 
			in_txtValue1=ProRemoveSpace(in_txtValue1.value);
			if(in_txtValue1=="")
			{
				alert("请输入要搜索的关键词,如二手电脑");
				return false;
			}
			
			var in_txtType1="-1";
			
			var in_txtType2="-1";
			
			var in_txtType3="-1";
			
			var in_txtType4="-1";
			
			var in_txtFromPrice="";
			
			var in_txtToPrice="";
						
			var in_txtWebSite="-1";

	strUrl="pageNos=1&searchKey="+in_txtValue1+"&types="+strType2+"&type1="+in_txtType1+"&type2="+in_txtType2+"&type3="+in_txtType3;
			strUrl=strUrl+"&type4="+in_txtType4+"&fromPrice="+in_txtFromPrice+"&toPrice="+in_txtToPrice;
			strUrl=strUrl+"&website="+in_txtWebSite+"&requesttype=1&AllRecordCount=-1";
			document.getElementById("oldshou_form2").action="oldshouresult.asp?"+strUrl;
			
			
			break;  
		case 2:    //企业黄页
			var in_txt2=document.getElementById("BtxtValue2"); //keywords
		 
			in_txt2=ProRemoveSpace(in_txt2.value);
			if(in_txt2=="")
			{
				alert("请输入要搜索的关键词,如二手电脑");
				return false;
			}
			
			strUrl="pageNos=1&requesttype=2&searchKey="+in_txt2;
			if (strFindType=="KEY")
			{
				window.open("oldshouresult.asp?"+strUrl+"&AllRecordCount=-1","_self");
			}
			else
			{
				document.getElementById("oldshou_form2").action="oldshouresult.asp?"+strUrl+"&AllRecordCount=-1";
			}
			break;
		case 3:   //行业资讯
			var in_txt3=document.getElementById("BtxtValue3"); //keywords
	 
			in_txt3=ProRemoveSpace(in_txt3.value);
			if(in_txt3=="")
			{
				alert("请输入要搜索的关键词,如二手电脑");
				return false;
			}
			
			strUrl="pageNos=1&requesttype=3&searchKey="+in_txt3;
			if (strFindType=="KEY")
			{
				window.open("oldshouresult.asp?"+strUrl+"&AllRecordCount=-1","_self");
			}
			else
			{
				document.getElementById("oldshou_form2").action="oldshouresult.asp?"+strUrl+"&AllRecordCount=-1";
			}
			break;
		case 4:  //学习信息
			var in_txt4=document.getElementById("BtxtValue4"); //keywords
		 
			in_txt4=ProRemoveSpace(in_txt4.value);
			if(in_txt4=="")
			{
				alert("请输入要搜索的关键词,如二手电脑");
				return false;
			}
			
			strUrl="pageNos=1&requesttype=4&searchKey="+in_txt4+"&AllRecordCount=-1";
			if (strFindType=="KEY")
			{
				window.open("oldshouresult.asp?"+strUrl,"_self");
			}
			else
			{				
				document.getElementById("oldshou_form2").action="oldshouresult.asp?"+strUrl;
			}
			break;
		default:
			alert("the default type2 :"+strType2);
	}


}

  function ProKeyWordsFindTip(strId,strType_2)
{
 	       var strUrl_2;

			var in_txtType1="-1";		
			var in_txtType2="-1";			
			var in_txtType3="-1";			
			var in_txtType4="-1";			
			var in_txtFromPrice="";			
			var in_txtToPrice="";						
			var in_txtWebSite="-1";
			strUrl_2="pageNos=1&searchKey="+strId+"&types=1&type1="+in_txtType1+"&type2="+in_txtType2+"&type3="+in_txtType3;
			strUrl_2=strUrl_2+"&type4="+in_txtType4+"&fromPrice="+in_txtFromPrice+"&toPrice="+in_txtToPrice;

			strUrl_2=strUrl_2+"&website=0&requesttype="+strType_2+"&AllRecordCount=-1";
//			strUrl_2=strUrl_2+"&website=0&AllRecordCount=-1";

			window.open('../search/oldshouresult.asp?'+strUrl_2,'_self');	
			 
}
 

