//根据厂商获取车系
function getS()
{
	var nid = document.getElementById("brand").value;
	if(nid!='')
	{
		var url='/News/getS';
		var pars = 'bid='+nid;
		$.ajax({
				type: "GET",
   			 	url: url,
   			 	data: pars,
   			 	success: function (Request){writeS(Request);}
 		   	  });
	}
	else
	{
		document.getElementById("wserial").innerHTML='<select name="serial" id="serial" style="width:115px;height:20px;"><option value="">---请选择车系---</option></select>';
	}
}
function writeS(Request)
{
	if(Request!='')
	{
		document.getElementById("wserial").innerHTML=Request;
	}
}
/*
//根据车系获取车型
function getCar()
{
	var nid = document.getElementById("serial").value;
	if(nid!='')
	{
		var url='/News/getCar';
		var pars = 'sid='+nid;
		$.ajax({
				type: "GET",
   			 	url: url,
   			 	data: pars,
   			 	success: function (Request){wCar(Request);}
 		   	  });
	}
}
function wCar(Request)
{
	if(Request!='')
	{
		document.getElementById("wcar").innerHTML=Request;
	}
}
*/
function headto(url)
{

	var host = window.location.host;	
	var url = "http://"+host+url;
	//alert(url);
	window.location = url;	
}
//搜索按钮
function Search(type)
{
	url     = '/car/search?';
	bid     = document.getElementById("brand").value;
	sid     = document.getElementById("serial").value;
	max     = document.getElementById("max").value;
	min     = document.getElementById("min").value;
	keyword = document.getElementById("keyword").value;
	if(type==1)
	{
		if(bid=='')
		{
			alert("请选择品牌！");
			return false;
		}
		if(sid=='')
		{
			url=url+"brands="+bid;
		}
		else
		{
			url=url+"&series="+sid;
		}	
	}	
	if(type==2)
	{
		if(min=='')
		{
			alert("请指定价格范围！");
			return false;
		}
		if(max=='')
		{
			alert("请指定价格范围！");
			return false;
		}
		url=url+"byPrice=1&min="+min+"&max="+max;
	}
	if(type==3)
	{
		if(keyword=='')
		{
			alert("请输入关键字！");
			return false;	
		}
		url=url+"keyword="+keyword;
	}
	headto(url);
}
/*
var Client = {	Engine: {'name': 'unknown', 'version': ''},	Features: {}};Client.Features.xhr = !!(window.XMLHttpRequest);Client.Features.xpath = !!(document.evaluate);if (window.opera) Client.Engine.name = 'opera';else if (window.ActiveXObject) Client.Engine = {'name': 'ie', 'version': (Client.Features.xhr) ? 7 : 6};else if (!navigator.taintEnabled) Client.Engine = {'name': 'webkit', 'version': (Client.Features.xpath) ? 420 : 419};else if (document.getBoxObjectFor != null) Client.Engine.name = 'gecko';Client.Engine[Client.Engine.name] = Client.Engine[Client.Engine.name + Client.Engine.version] = true;




var H=0;//'tab1'高
var W=0;//'tab1'宽id='ad'
var timeBegin=new Date();
var status=true;
var eStatus=true;
var clientW=0;
if(Client.Engine.ie){
		H=363;//'tab1'高
		W=264;//'tab1'宽id='ad'
		//clientW=document.documentElement.clientWidth-(W+16);
	}
	else{
		H=370;//'tab1'高
		W=264;//'tab1'宽id='ad'
		//clientW=document.documentElement.clientWidth-(W)-19;
	}
document.write('<div id="ad" style="position:absolute;background:#eeeeee;width:'+W+'px;height:'+H+'px;z-index:1000;">'
		+'<div class="tit" style="z-index:100;"><h1>精彩阅读</h1><a href="javascript:closeAd();">'
		+'<img src="../../../Public/images/article_close.gif" style=" border:0px;"/></a></div>'
		+'<iframe id="fr1" style="z-index:9;width:'+W+'px;height:'+(H-15)+'px;'
		+'top:25;left:0;" frameborder="0" src="/news/popAd">'
		+'</iframe>'
		+'</div>');
document.getElementById('ad').style.display="none";
var clientH=0;

window.scroll(0,0);
//document.body.scrollTop=0;
function scrollImg(){ //浮动广告 
    var posX,posY;
	substarctStatusShow=false;

	if(Client.Engine.ie){
		clientW=document.documentElement.clientWidth-(W);
		clientH=document.documentElement.clientHeight-H+2-15;
	}
	else{
		clientW=document.documentElement.clientWidth-(W);
		clientH=document.documentElement.clientHeight-H+2-21;
	}
    if (window.innerHeight) { 
        //posX = window.pageXOffset; 
        posY = window.pageYOffset; 
    } 
    else if (document.documentElement && document.documentElement.scrollTop) { 
        posY = document.documentElement.scrollTop;
    } 
    else if (document.body) { 
        posY = document.body.scrollTop; 
    } 
    var ad=document.getElementById("ad"); 

    ad.style.top=(clientH+posY)+"px"; 
	ad.style.left=(clientW)+"px";
	if(eStatus){
		var timeEnd=new Date();
		var timeSubtract=(timeEnd-timeBegin)/1000;
		if(timeSubtract>=15){
				closeAd();
				status=false;
			}
	}
	else{
			status=true;
		}
	if(status){
    	status=setTimeout("scrollImg()",50); 
	}
}
function showDiv()
	{
		window.document.documentElement.scrollTop=0;
		window.scroll(0,0);
		document.getElementById('ad').style.display="";
		var ad=document.getElementById("ad"); 
		ad.onmouseover=new Function("eStatus=false");
		ad.onmouseout=new Function("eStatus=true;timeBegin=new Date();");
		if(Client.Engine.ie){
			clientW=document.documentElement.clientWidth-(W);
			clientH=document.documentElement.clientHeight-H+2-15;
		}
		else{
			clientW=document.documentElement.clientWidth-(W);
			clientH=document.documentElement.clientHeight-H+2-21;
		}
		if (window.innerHeight) { 
        //posX = window.pageXOffset; 
        posY = window.pageYOffset; 
		} 
		else if (document.documentElement && document.documentElement.scrollTop) { 
			posY = document.documentElement.scrollTop;
		} 
		else if (document.body) { 
			posY = document.body.scrollTop; 
		} 
		ad.style.top=(clientH+posY+H)+"px"; 
		ad.style.left=(clientW)+"px";
		substarct();
		
	}
var substarctStatusShow=true;
var subIShow=0;
var scrollBegin=GetPageScroll().Y;
	function substarct(){
			var dfd=GetPageScroll();
			if(scrollBegin<GetPageScroll().Y){
					scrollImg();
				}
			var ad=document.getElementById("ad"); 
			if(Client.Engine.ie){
				clientW=document.documentElement.clientWidth-(W);
				clientH=document.documentElement.clientHeight-H+2-15;
			}
			else{
				clientW=document.documentElement.clientWidth-(W);
				clientH=document.documentElement.clientHeight-H+2-21;
			}
			if (window.innerHeight) { 
			//posX = window.pageXOffset; 
				posY = window.pageYOffset; 
			} 
			else if (document.documentElement && document.documentElement.scrollTop) { 
				posY = document.documentElement.scrollTop;
			} 
			else if (document.body) { 
				posY = document.body.scrollTop; 
			} 
		
			var adTop=parseInt(ad.style.top);
			//alert(ad.style.top);
			//ad.style.top=(adTop-1)+"px";
			ad.style.top=(clientH+posY+H-subIShow)+"px";
			ad.style.left=(clientW)+"px";
			if(subIShow>=(H)){
				substarctStatusShow=false;
				scrollImg();
			}
			subIShow++;
			if(substarctStatusShow){
				setTimeout("substarct()",10);
			}
		}
var substarctStatusClose=true;
var subIClose=0;
	function substarctClose(){
			status=false;
			substarctStatusShow=false;
			var ad=document.getElementById("ad"); 
			if(Client.Engine.ie){
				clientW=document.documentElement.clientWidth-(W);
				clientH=document.documentElement.clientHeight-H+2-10;
			}
			else{
				clientW=document.documentElement.clientWidth-(W);
				clientH=document.documentElement.clientHeight-H+2-16;
			}
			if (window.innerHeight) { 
			//posX = window.pageXOffset; 
				posY = window.pageYOffset; 
			} 
			else if (document.documentElement && document.documentElement.scrollTop) { 
				posY = document.documentElement.scrollTop;
			} 
			else if (document.body) { 
				posY = document.body.scrollTop; 
			} 
		
			var adTop=parseInt(ad.style.top);
			//alert(ad.style.top);
			//ad.style.top=(adTop-1)+"px";
			//alert(clientH+posY);
			ad.style.top=(clientH+posY+subIClose)+"px";
			ad.style.left=(clientW)+"px";
			//alert(ad.style.top+":"+subIShow);
			if(subIClose>=(H)){
				substarctStatusClose=false;
				ad.style.display='none';
			}
			subIClose++;
			if(substarctStatusClose){
				setTimeout("substarctClose()",10);
			}
	}
function closeAd(){
		//closeCon();
		//setTimeout("document.getElementById('ad').style.display='none'",1000); 
		substarctClose();
		status=false;
		substarctStatusShow=false;
		//document.getElementById('ad').style.display='none';
	}

setTimeout("ad()",2000);
function ad(){
		//document.getElementById('fr1').style.display="none";
		//show();
		showDiv();
 		//scrollImg();
	}

function getPageSize(){    
    var xScroll, yScroll;    
    if (window.innerHeight && window.scrollMaxY) {    
        xScroll = document.body.scrollWidth;    
        yScroll = window.innerHeight + window.scrollMaxY;    
    } else if (document.body.scrollHeight > document.body.offsetHeight){    
        xScroll = document.body.scrollWidth;    
        yScroll = document.body.scrollHeight;    
    } else {    
        xScroll = document.body.offsetWidth;    
        yScroll = document.body.offsetHeight;    
    }    
   
    var windowWidth, windowHeight;    
    if (self.innerHeight) {    
        windowWidth = self.innerWidth;    
        windowHeight = self.innerHeight;    
    } else if (document.documentElement && document.documentElement.clientHeight) {    
        windowWidth = document.documentElement.clientWidth;    
        windowHeight = document.documentElement.clientHeight;    
    } else if (document.body) {    
        windowWidth = document.body.clientWidth;    
        windowHeight = document.body.clientHeight;    
    }    
   
    if(yScroll < windowHeight){    
        pageHeight = yScroll;    
    } else {    
        pageHeight = windowHeight;    
    }    
   
    if(xScroll < windowWidth){    
        pageWidth = xScroll;    
    } else {    
        pageWidth = windowWidth;    
    }    
   
    arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight)    
    return arrayPageSize;    
}  

function GetPageScroll() {  
var x, y;  
if(window.pageYOffset) {    // all except IE    
	y = window.pageYOffset;    x = window.pageXOffset;  
} else if(document.documentElement     && document.documentElement.scrollTop) {    // IE 6 Strict    
	y = document.documentElement.scrollTop;    x = document.documentElement.scrollLeft;  } 
else if(document.body) {    // all other IE    
	y = document.body.scrollTop;    x = document.body.scrollLeft;   
	}  
	return {X:x, Y:y};
}*/