﻿// JScript 文件
        function ff()
	    {
			var s0=document.getElementById("Radio1");
			var s1=document.getElementById("Radio2");
			var s2=document.getElementById("Radio3");
			if(s0.checked)
			{
				sendAJAX("?type=0");
			}
			else if(s1.checked)
			{
				sendAJAX("?type=1");
			}
			else if(s2.checked)
			{
			    sendAJAX("?type=2");
			}
		}
		
        function fff()
		{
			var tr="";
			var s=document.getElementById("brand");
			var t=document.getElementById("series");
			if(s.value!="请选择车的品牌")
			{
				tr="?car="+escape(s.value);
			}
			else if(s.value=="请选择车的品牌")
			{
            document.getElementById("series").options.length = 0;   
            var varItem1 = new Option("全部车系","全部车系");    
			document.getElementById("series").options.add(varItem);
			document.getElementById("series").value = "全部车系";
			document.getElementById("model").options.length = 0;   
            var varItem2 = new Option("全部车型","全部车型");    
			document.getElementById("model").options.add(varItem2);
			document.getElementById("model").value = "全部车型";        
			return;
			}			
			s0=document.getElementById("Radio1");
			s1=document.getElementById("Radio2");
			s2=document.getElementById("Radio3");
			if(s0.checked)
			{
			     tr+="&from=0";
			}
			if(s1.checked)
			{
				tr+="&from=1";
			}
			if(s2.checked)
			{
			    tr+="&from=2";
			}			
			sendAJAX1(tr);
		}
	    function fff1()
		{
			var tr="";
			var s=document.getElementById("brand");
			var t=document.getElementById("series");
			if(t.value!="全部车系")
			{
				tr="?car="+escape(s.value)+"&carseries="+escape(t.value);
			}
			else if(s.value=="全部车系")
			{
			document.getElementById("model").options.length = 0;   
            var varItem = new Option("全部车型","全部车型");    
			document.getElementById("model").options.add(varItem);
			document.getElementById("model").value = "全部车型";        
			return;
			}
			s0=document.getElementById("Radio1");
			s1=document.getElementById("Radio2");
			s2=document.getElementById("Radio3");
			if(s0.checked)
			{
			     tr+="&from=0";
			}
			if(s1.checked)
			{
				tr+="&from=1";
			}
			if(s2.checked)
			{
			    tr+="&from=2";
			}			
			sendAJAX2(tr);
		}
		var XmlHttp;
		
		//创建XMLHttpRequest对象
        function createXMLHttpRequest()
		{
        if(window.ActiveXObject)
        {
        XmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
        else if(window.ActiveXObject)
        {
          XmlHttp = new ActiveXObject("Msxml2.XMLHTTP.4.0");
        }
        else if(window.ActiveXObject)
        {
          XmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
        }
        else if(window.XMLHttpRequest)
        {
         XmlHttp = new XMLHttpRequest();
        }		
		}
		
		createXMLHttpRequest();

		
		function sendAJAX(par)
		{
			XmlHttp.Open("GET","Search_Ajax.aspx"+par,true);
			XmlHttp.send();
			XmlHttp.onreadystatechange=ServerProcess;
		}
		
		function sendAJAX1(par)
		{
			XmlHttp.Open("GET","Search_Ajax.aspx"+par,true);
			XmlHttp.send();
			XmlHttp.onreadystatechange=ServerProcess1;
		}
	    function sendAJAX2(par)
		{
			XmlHttp.Open("GET","Search_Ajax.aspx"+par,true);
			XmlHttp.send();
			XmlHttp.onreadystatechange=ServerProcess2;
		}
		function ServerProcess()
		{
			if (XmlHttp.readystate==4 || XmlHttp.readystate=='complete')
			{
				var s=XmlHttp.responsetext;
				var al=s.split(";");
				var op;
				document.getElementById("brand").innerHTML="";
				//op=document.createElement("option");
				//op.innerText="请选择车的品牌";
				//op.value="请选择车的品牌";
				//document.getElementById("brand").appendChild(op);
				for(var i=0;i<al.length;i++)
				{
					op=document.createElement("option");
					op.innerText=al[i];
					op.value=al[i];
					document.getElementById("brand").appendChild(op);
				}
				var op1;
				document.getElementById("series").innerHTML="";
				op1=document.createElement("option");
				op1.innerText="全部车系";
				op1.value="全部车系";
				document.getElementById("series").appendChild(op1);
				var op2;
				document.getElementById("model").innerHTML="";
				op2=document.createElement("option");
				op2.innerText="全部车型";
				op2.value="全部车型";
				document.getElementById("model").appendChild(op2);
			}
		}
		function ServerProcess1()
		{
			if (XmlHttp.readystate==4 || XmlHttp.readystate=='complete')
			{
				var s=XmlHttp.responsetext;
				var al=s.split(";");		
				var op;
				document.getElementById("series").innerHTML="";
				op=document.createElement("option");
				op.innerText="全部车系";
				op.value="全部车系";
				document.getElementById("series").appendChild(op);
				for(var i=0;i<al.length;i++)
				{
					op=document.createElement("option");
					op.innerText=al[i];
					op.value=al[i];
					document.getElementById("series").appendChild(op);
				}
				var op2;
				document.getElementById("model").innerHTML="";
				op2=document.createElement("option");
				op2.innerText="全部车型";
				op2.value="全部车型";
				document.getElementById("model").appendChild(op2);
			}
		}
	    function ServerProcess2()
		{
			if (XmlHttp.readystate==4 || XmlHttp.readystate=='complete')
			{
				var s=XmlHttp.responsetext;
				var al=s.split(";");		
				var op;
				document.getElementById("model").innerHTML="";
				op=document.createElement("option");
				op.innerText="全部车型";
				op.value="全部车型";
				document.getElementById("model").appendChild(op);
				for(var i=0;i<al.length;i++)
				{
					op=document.createElement("option");
					op.innerText=al[i];
					op.value=al[i];
					document.getElementById("model").appendChild(op);
				}
			}
		}
		function openSearchPage()
		{		
			if(document.all.brand.value=="请选择车的品牌")
			{
				alert("请选择车的品牌！");
				document.all.brand.focus();
				document.all.brand.select();
				return false;
			}
			var s0=document.getElementById("Radio1");
			var s1=document.getElementById("Radio2");
			var s2=document.getElementById("Radio3");
			var s3="";
			if(s0.checked)
			{
				s3=s0.value;
			}
			else if(s1.checked)
			{
				s3=s1.value;
			}
			else if(s2.checked)
			{
			    s3=s2.value;
			}
			if(document.all.series.value=="全部车系"&&document.all.model.value=="全部车型")
			{
			window.open("CarSearch.aspx?brand="+document.all.brand.value+"&mode="+s3,"_blank");
			return true;
			}
			if(document.all.series.value!="全部车系"&&document.all.model.value=="全部车型")
			{
			window.open("CarSearch.aspx?brand="+document.all.brand.value+"&carseries="+document.all.series.value+"&mode="+s3,"_blank");
			return true;
			}
			if(document.all.series.value!="全部车系"&&document.all.model.value!="全部车型")
			{
			window.open("CarSearch.aspx?brand="+document.all.brand.value+"&carseries="+document.all.series.value+"&model="+document.all.model.value+"&mode="+s3,"_blank");
			return true;
			}
		}
		function priceSearch1()
		{
		    if(document.all.startprice.value=="")
			{
				alert("请输入起始价格！");
				document.all.startprice.focus();
				document.all.startprice.select();
				return false;
			}
			if(document.all.endprice.value=="")
			{
				alert("请输入起始价格！");
				document.all.endprice.focus();
				document.all.endprice.select();
				return false;
			}
		    var s0=document.getElementById("Radio6");
			var s1=document.getElementById("Radio7");
			var s2=document.getElementById("Radio8");
			var s3="";
			if(s0.checked)
			{
				s3=s0.value;
			}
			else if(s1.checked)
			{
				s3=s1.value;
			}
			else if(s2.checked)
			{
			    s3=s2.value;
			}
			var txt_start=document.getElementById("startprice");
			var txt_end=document.getElementById("endprice");
			var url="";
			if(parseFloat(txt_start.value)>parseFloat(txt_end.value))
		    {
		    url="CarSearch.aspx?smallprice="+txt_end.value+"&bigprice="+txt_start.value+"&mode="+s3;
		    }
		    else
		    if(parseFloat(txt_start.value)<parseFloat(txt_end.value))
		    {
		    url="CarSearch.aspx?smallprice="+txt_start.value+"&bigprice="+txt_end.value+"&mode="+s3;
		    }
		    window.open(url,"_blank");
			
		}
		function priceSearch2()
		{
		    if(document.all.Text1.value=="")
			{
				alert("请输入起始价格！");
				document.all.Text1.focus();
				document.all.Text1.select();
				return false;
			}
			if(document.all.Text2.value=="")
			{
				alert("请输入起始价格！");
				document.all.Text2.focus();
				document.all.Text2.select();
				return false;
			}
		    var s0=document.getElementById("Radio9");
			var s1=document.getElementById("Radio10");
			var s2=document.getElementById("Radio11");
			var s3="";
			if(s0.checked)
			{
				s3=s0.value;
			}
			else if(s1.checked)
			{
				s3=s1.value;
			}
			else if(s2.checked)
			{
			    s3=s2.value;
			}
			var txt_start=document.getElementById("Text1");
			var txt_end=document.getElementById("Text2");
			var url="";
		    if(parseFloat(txt_start.value)>parseFloat(txt_end.value))
		    {
		    url="CarSearch.aspx?smallprice="+txt_end.value+"&bigprice="+txt_start.value+"&mode="+s3;
		    }
		    else
		    if(parseFloat(txt_start.value)<parseFloat(txt_end.value))
		    {
		    url="CarSearch.aspx?smallprice="+txt_start.value+"&bigprice="+txt_end.value+"&mode="+s3;
		    }
		    window.open(url,"_blank");
		}