﻿var timer2s;
var timer;
var timer_cheshi;
var tiemr_yongche;
var carstimer;
var timer_all;
var pk_timer;
var height = 150;
var sudu = 15;
var pos;
function Search()
{
	var div = $('search_div').getElementsByTagName('input');
	for(var i=0;i<div.length;i++)
	{
		if(div[i].type == 'radio' && div[i].checked)
		{
			var url;
			var key = $F('txt_key');
			if(key == "请输入关键字"){key = '';}
			else{escape(key);}
			
			switch(div[i].value)
			{
				//case 'news':url='/news/news_search.html?k='+key;break;
				//case 'cars':url='/cars/cars_search.html?k='+key;break;
				//case 'biz':url='/member/search_biz.html?k='+key;break;

				case 'news':url='/news/news_search_new.aspx?k='+key;break;
				case 'cars':url='/cars/search/cars_search_new.aspx?k='+key;break;
				case 'biz':url='/member/search_biz_new.aspx?k='+key;break;
				default:url='';break;
			}
			window.open(url);
			break;
		}
	}
	return false;
}
////////////////////////////////////////////二手车////////////////////////////////
function search_secCars()
{
	var key =$F('txt_seccars');
	if(key == '二手车搜索')
		key = '';
	window.open('http://used.yescar.cn/UsedCarsList.aspx?key='+escape(key));
}


//////////////////////////////////////PK/////////////////////////////////////////
function PKEvent()
{
	var pk_ul = $('pk_ul').getElementsByTagName('li');
	for(var i=0;i<pk_ul.length-1;i++)
	{
		(function(){
				 var p = i; 
						pk_ul[i].onmouseover = function(){
							timer_all = window.setTimeout(function(){
					 		for(var j=0;j<pk_ul.length;j++)
							{
								pk_ul[j].className = null;
							}
							pk_ul[p].className = 'ch';
							if(p == 0)
							{
								$('pk1').style.display = '';
								$('pk2').style.display = 'none';
							}
							else
							{
								$('pk2').style.display = '';
								$('pk1').style.display = 'none';
							}
							
							},150)
					   };
						pk_ul[i].onmouseout = function(){clearTimeout(timer_all);};
		}());

	}
}



///////////////////////////////////////////////用品//////////////////////////////
function PordsEvent()
{
	var prods_change = $('prods_change').getElementsByTagName('li');
	for(var i=0;i<prods_change.length;i++)
	{
		(function(){
				 var p = i; 
						prods_change[i].onmouseover = function(){
							timer_all = window.setTimeout(function(){
					 		for(var j=0;j<prods_change.length;j++)
							{
								prods_change[j].className = null;
							}
							prods_change[p].className = 'ch';
							ProdsChange(p);
							},150)
					   };
						prods_change[i].onmouseout = function(){clearTimeout(timer_all);};
		}());

	}
}

function ProdsChange(a)
{
	var code;
	switch(a)
	{
		case 1:code='500060000';break;
		case 2:code='500050000';break;
		case 3:code='500040000';break;
		case 4:code='500030000';break;
		default:code='';break;
	}
	var url = '/WebService/Market/MarketService.asmx/GetProdsAndBiz';
	var pars = 'code='+code;
	var html = '';
	new Ajax.Request(url,{
		method: 'get',
		parameters: pars,
		onComplete: function(re){
            var docXml;
			docXml = re.responseXML.getElementsByTagName('Table');
			for(var i=0;i<docXml.length;i++)
			{
				var pic = getValue(docXml[i],'prods_pic_url')+getValue(docXml[i],'prods_small_pic');
				html += '<li><img src="'+pic+'"><div><h4><a href="http://market.yescar.cn/ProuctInfo.aspx?pid='+getValue(docXml[i],'prods_id')+'" target="_blank">'+getValue(docXml[i],'prods_name')+'</a></h4><span>市场价'+getValue(docXml[i],'prods_market_price')+'元</span>商城价：<font>'+getValue(docXml[i],'prods_agio_price')+'元</font><br>商家：<font class="csl">'+getValue(docXml[i],'ub_scorp')+'</font></div></li>'
			}
			if(docXml.length == 0)
			{
				html = '<center>暂无商品</center>';
			}
			$('prods_show').innerHTML = html;
		}
	});
}



function ProdsCategory()
{
	url = '/WebService/Market/MarketService.asmx/GetXml';
	var pars = '';
	var innerHtml = '';
	new Ajax.Request(url,{
		method: 'get',
		parameters: pars,
		onComplete: function(re){
           var doc = re.responseXML.getElementsByTagName('p1');	
		   for(var i=0;i<doc.length;i++)
				{
					innerHtml += '<dt><a href="http://market.yescar.cn/ProcutsList.aspx?code='+doc[i].getAttribute('code')+'" target="_blank">'+doc[i].getAttribute('name')+'</a></dt><dd>';
		
					if(doc[i].hasChildNodes())
					{
						for(var j=0;j<doc[i].getElementsByTagName('p2').length;j++)
						{
							if(j>8){break;}
							var p2 = doc[i].getElementsByTagName('p2')[j];
							innerHtml += '<a href="http://market.yescar.cn/ProcutsList.aspx?code='+p2.getAttribute('code')+'" target="_blank">'+p2.getAttribute('name')+'</a> ';
						}
						innerHtml += '...<a href="http://market.yescar.cn/ProcutsList.aspx?code='+doc[i].getAttribute('code')+'"  target="_blank">更多</a></dd>';
					}
				}
				$('prods_list').innerHTML = innerHtml;
		}
   });
	

}



//////////////////////////////////用车养车图片轮换/////////////////////////////////////////
function   YongCheImgBtnEvent()
{
	var yongche_btn = $('yongche_btn').getElementsByTagName('li');
	for(var i=0;i<yongche_btn.length;i++)
	{
		
		(function(){
				 var j = i; 
				 yongche_btn[i].onclick = function(){yongcheImg(j);};			  

		}());
	}
}

function yongcheImg(i)
{
	var yongche_btn = $('yongche_btn').getElementsByTagName('li');
	var yongche_img = $('yongche_img').getElementsByTagName('li');
	
	try{
	$('yongche_btn').style.filter="blendTrans(Duration=0.3)";
	$('yongche_div').style.filter="blendTrans(Duration=0.3)";
	
	$('yongche_btn').filters[0].Apply();
	$('yongche_div').filters[0].Apply();
	}catch(e){}
	
	for(var j=0;j<yongche_btn.length;j++)
	{
		yongche_btn[j].className = null;
		yongche_img[j].className = null;
	}
	yongche_btn[i].className = 'ch';
	yongche_img[i].className = 'ch';
	
	try{
	$('yongche_btn').filters[0].play();
	$('yongche_div').filters[0].play();
	}catch(e){}
	
	clearInterval(tiemr_yongche);
	tiemr_yongche = window.setTimeout('changeYongCheImg('+i+')',5000);
}
function changeYongCheImg(index)
{
	if(index+1 <= 5)
	{
		index++;
	}
	else
	{
		index = 0;
	}
	yongcheImg(index);
}


/////////////////////////////////深圳车市图片轮换///////////////////////////////////////
function cheshiImgChange(i)
{
	var cheshi_btn = $('cheshi_btn').getElementsByTagName('li');
	var cheshi_img = $('cheshi_img').getElementsByTagName('li');
	
	try{
	$('cheshi_btn').style.filter="blendTrans(Duration=0.3)";
	$('cheshi_div').style.filter="blendTrans(Duration=0.3)";
	
	$('cheshi_btn').filters[0].Apply();
	$('cheshi_div').filters[0].Apply();
	}catch(e){}
	
	for(var j=0;j<cheshi_btn.length;j++)
	{
		cheshi_btn[j].className = null;
		cheshi_img[j].className = null;
	}
	cheshi_btn[i].className = 'ch';
	cheshi_img[i].className = 'ch';
	
	try{
	$('cheshi_btn').filters[0].play();
	$('cheshi_div').filters[0].play();
	}catch(e){}
	
	clearInterval(timer_cheshi);
	timer_cheshi = window.setTimeout('changeCheShiImg('+i+')',5000);
}


function changeCheShiImg(index)
{
	if(index+1 <= 5)
	{
		index++;
	}
	else
	{
		index = 0;
	}
	cheshiImgChange(index);
}

function cheshiImgBtnEvent()
{
	var cheshi_btn = $('cheshi_btn').getElementsByTagName('li');
	for(var i=0;i<cheshi_btn.length;i++)
	{
		
		(function(){
				 var j = i; 
				 cheshi_btn[i].onclick = function(){cheshiImgChange(j);};			  

		}());
	}
}

function cheshiEvent()
{
	var cheshi = $('cheshi_ul').getElementsByTagName('li');
	for(var i=0;i<cheshi.length;i++)
	{
		(function(){
				 var p = i; 
						cheshi[i].onmouseover = function(){
							carstimer = window.setTimeout(function(){
					 		for(var j=0;j<cheshi.length;j++)
							{
								cheshi[j].className = null;
							}
							cheshi[p].className = 'ch';
							CheShi_Xml(p+1);
							},150)
					   };
						cheshi[i].onmouseout = function(){clearTimeout(carstimer);};
		}());

	}
}
////////////////////////////////////////////////////////////////////////////////////

function rightListEvent()
{
	var hangqing = $('hangqing_list').getElementsByTagName('li');
	for(var i=0;i<hangqing.length;i++)
	{
		(function(){
				 var p = i; 
						hangqing[i].onmouseover = function(){
							timer_all = window.setTimeout(function(){
					 		for(var j=0;j<hangqing.length;j++)
							{
								hangqing[j].className = null;
							}
							hangqing[p].className = 'ch';
							HangQingAndYaoWen_Xml(p+1);
							},150)
					   };
						hangqing[i].onmouseout = function(){clearTimeout(timer_all);};
		}());

	}
}


function leftListEvent()
{
	var daogou_list = $('daogou_list').getElementsByTagName('li');
	for(var i=0;i<daogou_list.length;i++)
	{
		(function(){
				 var p = i; 
						daogou_list[i].onmouseover = function(){
							timer_all = window.setTimeout(function(){
					 		for(var j=0;j<daogou_list.length;j++)
							{
								daogou_list[j].className = null;
							}
							daogou_list[p].className = 'ch';
							DaoGou_Xml(p+1);
							},150)
					   };
						daogou_list[i].onmouseout = function(){clearTimeout(timer_all);};
		}());

	}
}

function CheShi_Xml(id)
{
	var url = '/xml/homepage/cheshi'+id+'.xml';
	var tid = id;
	var pars = '';
	new Ajax.Request(url,{
		method: 'get',
		parameters: pars,
		onComplete: function(re){
            var docXml;
			var html = '';
			
			if(tid == 1){
				$('cheshi_dl').innerHTML = getValue(re.responseXML,'Table');
				return;
			}
			docXml = re.responseXML.documentElement.getElementsByTagName('Table');
			
			
			for(var i=0; i<docXml.length; i++){
				var title=null;
				var id=null;
				var date=null;
				var newsurl=null;
				var code_name = null;
				var nc_id = null;
				var ub_scorp = null;
				var u_id;
				
				title = getValue(docXml[i],'news_title');
				date = getValue(docXml[i],'news_date');
				id = getValue(docXml[i],'news_id');
				code_name = getValue(docXml[i],'code_name');
				color = getValue(docXml[i],'news_title_color');
				nc_id = getValue(docXml[i],'nc_id');
				ub_scorp=getValue(docXml[i],'ub_scorp');
				u_id = getValue(docXml[i],'u_id');
				if(!getValue(docXml[i],'news_url'))
				{
					newsurl = getValue(docXml[i],'url');
				}
				else
				{
					newsurl = getValue(docXml[i],'news_url')
				}
				if(!color)
				{
					if(ub_scorp)
					{
						html += '<dt><a href="/member/corppage/'+u_id+'/"  target="_blank" title="'+ub_scorp+'">['+ub_scorp+']</a></dt><dd><a href="'+newsurl+'" target="_blank" title="'+title+'">'+	title+'</a></dd>';
					}
					else
					{
                	html += '<dt><a href="/news/newslist.aspx?c='+nc_id+'"  target="_blank" title="'+code_name+'">['+code_name+']</a></dt><dd><a href="'+newsurl+'" target="_blank" title="'+title+'">'+	title+'</a></dd>';
					}
				}
				else
				{
					if(ub_scorp)
					{
					html += '<dt><a href="/member/corppage/'+u_id+'/"  target="_blank" title="'+ub_scorp+'">['+ub_scorp+']</a></dt><dd><a href="'+newsurl+'" target="_blank" title="'+title+'"><font color="'+color+'">'+	title+'</font></a></dd>';
					}
					else
					{
						html += '<dt><a href="/news/newslist.aspx?c='+nc_id+'"  target="_blank" title="'+code_name+'">['+code_name+']</a></dt><dd><a href="'+newsurl+'" target="_blank" title="'+title+'"><font color="'+color+'">'+	title+'</font></a></dd>';
					}
				}
            }
            $('cheshi_dl').innerHTML = html;
		}
	});
}

function HangQingAndYaoWen_Xml(id)
{
	var url = '/xml/homepage/right'+id+'.xml';
	var pars = '';
	new Ajax.Request(url,{
		method: 'get',
		parameters: pars,
		onComplete: function(re){
            var docXml;
			var html = '';
			docXml = re.responseXML.documentElement.getElementsByTagName('Table');
			for(var i=0; i<docXml.length; i++){
				var title=null;
				var newsurl = null
				
				title = getValue(docXml[i],'news_title_summarize');
				if(!getValue(docXml[i],'news_url'))
				{
					newsurl = getValue(docXml[i],'url');
				}
				else
				{
					newsurl = getValue(docXml[i],'news_url')
				}
				
                html += '<li><a href="'+newsurl+'" target="_blank">'+title+'</a></li>';
            }
            $('right_ul').innerHTML = html;
		}
	});
}


function DaoGou_Xml(id)
{
	var url = '/xml/homepage/left_d'+id+'.xml';
	var pars = '';
	new Ajax.Request(url,{
		method: 'get',
		parameters: pars,
		onComplete: function(re){
            var docXml;
			var html = '';
			docXml = re.responseXML.documentElement.getElementsByTagName('Table');
			for(var i=0; i<docXml.length; i++){
				var title=null;
				var id=null;
				var date=null;
				var news_url=null;
				var code_name = null;
				var nc_id = null;
				var code_folder = null;
				var url = null;
				
				title = getValue(docXml[i],'news_title');
				date = getValue(docXml[i],'news_date');
				id = getValue(docXml[i],'news_id');
				code_name = getValue(docXml[i],'code_name');
				nc_id = getValue(docXml[i],'nc_id');
				code_folder = getValue(docXml[i],'code_folder');
				url = getValue(docXml[i],'url');
				news_url = getValue(docXml[i],'news_url');
				
				if(!code_folder)
				{
					if(!news_url)
					{
						news_url = url;
					}	
				}
				else
				{
					if(!news_url)
					{
						news_url = 'http://news.yescar.cn/'+code_folder+'/'+date.replace('-','').substring(0,6)+'/'+id+'.shtml';
					}
				}
				
				
                html += '<li><a href="/news/newslist.aspx?c='+nc_id+'" target="_blank">['+code_name+'] <h3><a href="'+news_url+'" target="_blank" title="'+title+'">'+title+'</a></h3></li>';
            }
			if(docXml == null){html = '没有相关数据'}
            $('left_ul').innerHTML = html;
		}
	});
}


function hiddenDiv(obj)
{
	if(parseInt(obj.style.height.replace('px','')) <= 0 || obj.style.height == '15px')
	{
		obj.style.height = '0px';
	}
	else
	{
		obj.style.height = parseInt(obj.style.height.replace('px',''))-sudu+'px';
		setTimeout(function(){hiddenDiv(obj);},15);
	}
}

function showdiv(obj)
{
	if(parseInt(obj.style.height.replace('px','')) >= height)
	{
		obj.style.height = height+'px';
	}
	else
	{
		obj.style.height = parseInt(obj.style.height.replace('px',''))+sudu+'px';
		setTimeout(function(){showdiv(obj);},15);
	}
}

function public_div(k)
{
	pk_timer = setTimeout(function(){
	for(var i=1;i<=5;i++)
	{
		if(k != i){hiddenDiv($('divshow'+i),i);}
		$('pk_h_'+i).className = '';
	}
	$('pk_h_'+k).className = 'ch3';
	showdiv($('divshow'+k));
	},300);
}

function IECheck()
{
	var browser=navigator.appName ;
	var b_version=navigator.appVersion 
	var version=b_version.split(";"); 
	var trim_Version=version[1].replace(/[ ]/g,""); 
	if(browser=="Microsoft Internet Explorer" && trim_Version=="MSIE7.0") 
	{ 
		sudu = 30;
	}
}


function mouseout()
{
	clearTimeout(pk_timer);
}



function zhuantiEvent()
{
	var btn_zhuanti = $('btn_zhuanti').getElementsByTagName('li');
	var pic_zhuanti = $('pic_zhuanti').getElementsByTagName('li');
	for(var i=0;i<btn_zhuanti.length;i++)
	{
		
		(function(){
				 var p = i; 
				 btn_zhuanti[i].onmouseover = function(){
					 	for(var j=0;j<pic_zhuanti.length;j++)
						{
							btn_zhuanti[j].className = null;
							pic_zhuanti[j].className = null;
						}
						btn_zhuanti[p].className = 'ch';
						pic_zhuanti[p].className = 'ch';
					 };			  

		}());
	}
}



function carsEventMouseover()
{
	var cars_list = $('cars_list_div').getElementsByTagName('li');
	
	
	for(var i=0;i<cars_list.length-1;i++)
	{
		(function(){
				  var p = i;
				  cars_list[i].onmouseover = function(){
					  carstimer = window.setTimeout(function(){
														for(var j=0;j<cars_list.length;j++)
														{
															cars_list[j].className = null;
														}
														cars_list[p].className = 'ch';
														getCommendCars(p+1);
													},150);
				  }
				  cars_list[i].onmouseout = function(){clearInterval(carstimer);};
		}());
	}
}

function getCommendCars(ID){
	var url = '/WebService/Index/IndexService.asmx/GetCommendCars2';
	var pars = 'id='+ID;
	new Ajax.Request(url,{
		method: 'get',
		parameters: pars,
		onComplete: function(re){
            var s = re.responseXML.documentElement.text;
            if(!s){
                s = re.responseXML.documentElement.textContent;
            }
            $('Cars_Commend').innerHTML = s;
		}
	});
}

///////////////////////////////首页焦点图片轮换/////////////////////////
function imgEventButton()
{
	var btn_img = $('img_change').getElementsByTagName('li');
	for(var i=0;i<btn_img.length;i++)
	{
		
		(function(){
				 var j = i; 
				 btn_img[i].onclick = function(){change(j)};			  

		}());
	}
}

function change(i)
{
	var img_li = $('img_list').getElementsByTagName('li');
	var img_change = $('img_change').getElementsByTagName('li');
	
	try{
	$('img_change').style.filter="blendTrans(Duration=0.3)";
	$('img_div').style.filter="blendTrans(Duration=0.3)";
	
	$('img_change').filters[0].Apply();
	$('img_div').filters[0].Apply();
	}catch(e){}
	
	for(var j=0;j<img_li.length;j++)
	{
		img_li[j].className = null;
		img_change[j].className = null;
	}
	img_li[i].className = 'ch';
	img_change[i].className = 'ch';
	
	try{
	$('img_change').filters[0].play();
	$('img_div').filters[0].play();
	}catch(e){}
	
	clearInterval(timer);
	timer = window.setTimeout('changeImg('+i+')',5000);
}
function changeImg(index)
{
	if(index+1 <= 5)
	{
		index++;
	}
	else
	{
		index = 0;
	}
	change(index);
}
////////////////////////////////////////////////

///////////////////////////////
///setEvent
///////////////////////////////

/*function loadEvent1(){
	var lilist = $('toptitleli').getElementsByTagName('li');
	var h1list = $('toptitleli').parentNode.getElementsByTagName('h1');
	
	for(var i=0; i<lilist.length; i++){
		(function(){
			var p = i;
			lilist[i]['onmouseover'] = function(){
				if(lilist[p].className != 'ch'){
					timer2s=setTimeout(function(){
						for(var j=0; j<lilist.length; j++){
							lilist[j].className = null;
							h1list[j].className = null;
						}
						lilist[p].className = 'ch';
						h1list[p].className = 'ch';
					},150);
				}
			}
			lilist[i]['onmouseout'] = function(){
				clearInterval(timer2s);
			}
		})();
	}
}*/

function search_prods()
{
	var key = $F('txt_prod_key');
	if(key == '汽车用品配件搜索')
		key = '';
	window.open('http://market.yescar.cn/ProcutsList.aspx?key='+escape(key));
}

function newCarsEvent()
{
	var new_cars = $('new_cars_ul').getElementsByTagName('li');
	
	
	for(var i=0;i<new_cars.length;i++)
	{
		(function(){
				  var p = i;
				  new_cars[i].onmouseover = function(){
					  carstimer = window.setTimeout(function(){
														for(var j=0;j<new_cars.length;j++)
														{
															new_cars[j].className = null;
														}
														if(p == 0)
														{
															new_cars[p].className = 'ch1';
															$('d1').style.display = 'none';
															$('d2').style.display = '';
														}
														else
														{
															new_cars[p].className = 'ch2';
															$('d2').style.display = 'none';
															$('d1').style.display = '';
														}
														
													},150);
				  }
				  new_cars[i].onmouseout = function(){clearInterval(carstimer);};
		}());
	}
}


function getValue(xmlNode,id)
{
	if(xmlNode.getElementsByTagName(id)[0]==null)
		return '';
	var str;
	str = xmlNode.getElementsByTagName(id)[0].text;
	if(!str)
		str = xmlNode.getElementsByTagName(id)[0].textContent;
	return str;
}

function pinggu()
{
	with(document.all)
	{
		if(isNaN(txt_p.value) || !txt_p.value)
		{
			alert('新车价格必须为数字');
			return;
		}
		if(parseInt(txt_p.value) < 10000)
		{
			alert('价格太低了，请如实填写');
			return;
		}
		if(txt_p.value<=0)
		{
			alert('新车价格不能等于或小于零');
			return;
		}
		if(isNaN(txt_s.value)|| !txt_s.value)
		{
			alert('行程里程必须为数字');
			return;
		}
		if(txt_s.value<0)
		{
			alert('行程里程不能小于零');
			return;
		}1
		
		var url = '/cars/used/Index_PingGu.aspx?p='+txt_p.value+'&s='+txt_s.value+'&year='+select_year.options[select_year.selectedIndex].value+'&month='+select_month.options[select_month.selectedIndex].value+'&kb='+select_koubei.options[select_koubei.selectedIndex].value;
		
		window.open(url,'newwindow','height=150,width=300,top=200,left=0,toolbar=no,menubar=no,scrollbars=no, resizable=no,location=no,status=no');
	}
}


function on_init()
{
	//ad_hid();//首页置顶下拉广告
	
	change(0);//首页焦点图片轮换
	cheshiImgChange(0);//深圳车市图片轮换事件
	yongcheImg(0);//用车养车图片轮换
	YongCheImgBtnEvent();//用车养车图片点击事件
	//loadEvent1();
	PKEvent();//pk事件	
	imgEventButton();
	carsEventMouseover()//汽车切换事件;
	zhuantiEvent();
	newCarsEvent();
	leftListEvent();
	rightListEvent();
	cheshiEvent();
	cheshiImgBtnEvent();
	IECheck();

	qckbEvent();
}
window.onload = on_init;


////////////首页置顶下拉广告////////////
function ad_hid(){
	window.setTimeout(hid,10000);
}
function hid(){
	var height = $('ad_div').offsetHeight;
	$('ad_div').style.height = height+'px';
	if(parseInt($('ad_div').style.height) <= 10){
		$('ad_div').style.display= 'none';
		return;
	}
	$('ad_div').style.height = height-8+'px';
	window.setTimeout(hid,5);
}



/////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
function load_cars_series(){
	if ($('tg_cars_brand')!= ''){
		document.all["get_url"].src = '/club/tg/tg_cars_series.aspx?gc_id='+$('tg_cars_brand').value;	
	}
	else{
		$('tg_cars_series').length = 1;
		$('tg_cars_series').options[0] = new Option('请先选汽车品牌','');
	}
}

function turn_tg(){
	if($("tg_cars_brand").value==""){
		alert("请选择汽车品牌！");
	}
	else{
  		window.open("/tgbm.aspx?g_id="+document.all.tg_cars_series.value);
	}
}

function changeCarsPh(id){
	for(var i=1; i<=2; i++){
		$('phhead' + i).className = '';
		$('phbody' + i).className = 'divhide';
	}
	$('phhead' + id).className = 'ch';
	$('phbody' + id).className = '';
}

function changeCarsPrice(baojia_type,id){	
	for(var i=1; i<=3; i++){
		$('CarsPrice'+i).className='';
		}
	$('CarsPrice'+id).className='ch';
	var url="/WebService/column/baojiaservice.asmx/Baojia_index_htm";
	var pars="baojia_type="+baojia_type+"&price_min=0&price_max=500";
	new Ajax.Request(url,{
		method: 'get',
		parameters: pars,
		onComplete: function(re){
			var s = re.responseXML.documentElement.text;
			if(!s){
				s = re.responseXML.documentElement.textContent;
			}
    		$('baojia').innerHTML = s;
		},
		onFailure: function(){
			alert('网络故障！');
		}
	});
}
/////////////////////////汽车口碑/////////////////////////////
function qckbEvent(){
	var list = $('qckb_ul').getElementsByTagName('li');
	for(var i=0;i<list.length;i++){
		(function(){
			var p = i;
			list[i].onmouseover = function(){
				carstimer = window.setTimeout(function(){
					$('kbb').style.display = 'none';
					$('qckb_list').style.display = 'block';
					for(var j=0;j<list.length;j++){
						list[j].className = '';
						$('qckb'+j).style.display = 'none';					
					}
					if(p==0){
						list[p].className = 'ch1';}
					else{
						list[p].className = 'ch2';
						}
					$('qckb'+p).style.display = 'block';
				},200);
			}
		list[i].onmouseout = function(){clearInterval(carstimer);};
		}());
	}
}

function kbb(){
	$('kbb').style.display='block';
	$('qckb_list').style.display='none';
	}

function Ad_New_XmlDoc() {
  var xmlDoc = false;
  /*@cc_on @*/
  /*@if (@_jscript_version >= 5)
  try {
	xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
  } catch (e) {
    try {
      xmlDoc = new ActiveXObject("Msxml2.XMLDOM");
    } catch (e2) {
      xmlDoc = false;
    }
  }
  @end @*/

  if (!xmlDoc) {
    xmlDoc = document.implementation.createDocument('','',null);
  }
  return xmlDoc;
}
function load_series(){
  	var xmlDoc = new Ad_New_XmlDoc();
  	var xml_file = "/xml/cars/series/"+$F('brand')+".xml";
  	if($F('brand') != ""){
  		$('series').length = 1;
  		$('series').options[0] = new Option('------请选择系列------','');
  		
  		xmlDoc.async="false";
  		xmlDoc.load(xml_file);
  		
  		var series_name=xmlDoc.documentElement.getElementsByTagName('series_name');
		var series_code=xmlDoc.documentElement.getElementsByTagName('series_code');
   		for(var i=0;i<series_name.length;i++){
    		var opn=new Option;
    		opn.text = series_name(i).text;
    		opn.value = series_code(i).text;
    		$('series').options.add(opn);
   			}
  		}
  	else{
	  $('series').length = 1;
      $('series').options[0] = new Option('------请选择系列------','');
  		}
	}
	
function turn_cars(){
	$('search_cars').action="";
	if($('series').value!=""){
		$('search_cars').action="/cars/chexing/turn_series.aspx?series_code="+$('series').value;
		$('search_cars').target="_blank";
		return true;
	}
	else{
		alert("请输入汽车查询条件！");
		return false;
	}
}
function go_url(url){
		window.open(url,"","");
}




/*兼容IE和FF的添加收藏和设为首页*/
function addCookie() 
{　 // 加入收藏夹 
　　 if (document.all) 
　　 {
　　    window.external.addFavorite('http://www.yescar.cn', '亚迅车网'); 
　　 }
　　 else if (window.sidebar) 
　　 { 
　　   window.sidebar.addPanel('亚迅车网', 'http://www.yescar.cn', ""); 
　　 }
}

function setHomepage()
{　 // 设置首页 
　　if (document.all)
　　{
　　document.body.style.behavior = 'url(#default#homepage)'; 
　　document.body.setHomePage('http://www.yescar.cn'); 
　　} 
　　else if (window.sidebar) 
　　{
　　    if (window.netscape)
　      　{ 
　　      　try { 
　　　　          etscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); 
　　          　} 
　　       catch (e)
　　           {
　　              alert("该操作被浏览器拒绝，如果想启用该功能，请在地址栏内输入 about:config,然后将项 signed.applets.codebase_principal_support 值该为true"); 
　　           } 
　        　} 
　　var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch); 
　　prefs.setCharPref('browser.startup.homepage', 'http://www.yescar.cn'); 
　　} 
} 

function getElementPos(elementId) {
 var ua = navigator.userAgent.toLowerCase();
 var isOpera = (ua.indexOf('opera') != -1);
 var isIE = (ua.indexOf('msie') != -1 && !isOpera); // not opera spoof
 var el = document.getElementById(elementId);
 if(el.parentNode === null || el.style.display == 'none') {
  return false;
 }      
 var parent = null;
 var pos = [];     
 var box;     
 if(el.getBoundingClientRect)    //IE
 {         
  box = el.getBoundingClientRect();
  var scrollTop = Math.max(document.documentElement.scrollTop, document.body.scrollTop);
  var scrollLeft = Math.max(document.documentElement.scrollLeft, document.body.scrollLeft);
  return {x:box.left + scrollLeft, y:box.top + scrollTop};
 }else if(document.getBoxObjectFor)    // gecko    
 {
  box = document.getBoxObjectFor(el); 
  var borderLeft = (el.style.borderLeftWidth)?parseInt(el.style.borderLeftWidth):0; 
  var borderTop = (el.style.borderTopWidth)?parseInt(el.style.borderTopWidth):0; 
  pos = [box.x - borderLeft, box.y - borderTop];
 } else    // safari & opera    
 {
  pos = [el.offsetLeft, el.offsetTop];  
  parent = el.offsetParent;     
  if (parent != el) { 
   while (parent) {  
    pos[0] += parent.offsetLeft; 
    pos[1] += parent.offsetTop; 
    parent = parent.offsetParent;
   }  
  }   
  if (ua.indexOf('opera') != -1 || ( ua.indexOf('safari') != -1 && el.style.position == 'absolute' )) { 
   pos[0] -= document.body.offsetLeft;
   pos[1] -= document.body.offsetTop;         
  }    
 }              
 if (el.parentNode) { 
    parent = el.parentNode;
   } else {
    parent = null;
   }
 while (parent && parent.tagName != 'BODY' && parent.tagName != 'HTML') { // account for any scrolled ancestors
  pos[0] -= parent.scrollLeft;
  pos[1] -= parent.scrollTop;
  if (parent.parentNode) {
   parent = parent.parentNode;
  } else {
   parent = null;
  }
 }
 return {x:pos[0], y:pos[1]};
}


/*首页登录弹出层开始*/
function displayed(){
	pos=getElementPos("denglu");
	//document.getElementById("boxesss").style.display="block";
	var xx = pos.x;
	var yy = pos.y;
	var show = $('boxesss');
	show.style.display="block";//初始化为不可见，这里设置为可见
	//event代表事件状态,如时间发生的元素，键盘状态，鼠标位置和鼠标按钮状
	if(window.navigator.userAgent.indexOf("MSIE")>=1){
		//为IE浏览器
		show.style.left=xx-25;
		show.style.top=yy+19;
		show.style.position="absolute";
	}
	else if(window.navigator.userAgent.indexOf("Firefox")>=1)
	{
		show.style.left=(xx-25)+"px";
		show.style.top=(yy+22)+"px";
		show.style.position="absolute";
	}
	else
	{
		show.style.left='724px';
		show.style.top='275px';
		show.style.position="absolute";
	}
	
}
function disappeared(){
	//document.getElementById("boxesss").style.display="none"; 
	$('boxesss').style.display="none";
}
/*首页登录弹出层结束*/

//首页登录中的验证码
function changeImgs(){
	$("imgSafeCode").src="/member/SafeCode.aspx?stamp=" + new Date().getTime();
}

function checkLogin(){

	var name = document.getElementsByName('username')[0].value;
	var pwd = document.getElementsByName('password')[0].value;
	var safecode = document.getElementsByName('safecode')[0].value;

	if(!name){
		alert('请输入姓名!');
		return false;
	}else if(!pwd){
		alert('请输入密码!');
		return false;
	}
	else if(!safecode){
		alert("请输入验证码!");
		return false;
	}
}


function Search1()
{
	var div = $('hidvalue').value;
	
	var url;
	var key = $F('txt_key');
	if(key == "请输入关键字"){key = '';}
	else{escape(key);}
	switch(div)
	{
		case '0':url='/news/news_search_new.aspx?k='+escape(key);break;  //新闻
		case '1':url='/cars/search/cars_search_new.aspx?k='+escape(key);break;//车型
		case '2':url='/member/search_biz_new.aspx?k='+escape(key);break;//商家
		case '3':url='http://used.yescar.cn/UsedCarsList.aspx?key='+escape(key);break;//二手
		case '4':url='http://market.yescar.cn/ProcutsList.aspx?key='+escape(key);break;//用品
		case '5':url='/szcars/cars/search/Auto_Search.aspx';break;//更多
		default:url='/news/news_search_new.aspx?k='+escape(key);break;//新闻
	}
	window.open(url);
	return false;
}


function change1(i){
	var img_change = $('changUl').getElementsByTagName('li');
	
	for(var j=0;j<img_change.length;j++)
	{
		if(j==5)
			img_change[j].className = 'ch33';
		else
			img_change[j].className = 'ch11';
	}
	if(i==5){
		img_change[i].className = 'ch44';
		window.open('/cars/search/Auto_Search.aspx');
	}

	else
		img_change[i].className = 'ch22';
	$('hidvalue').value=i;
}

function usedrightchange(type)
{
	$("divin").style.display="block";
    $("divincontent").style.display="none";
    //$("divpg").style.display="block";
    //$("divpgcontent").style.display="none";
    $("divbuy").style.display="block";
    $("divbuycontent").style.display="none";
    $("divsell").style.display="block";
    $("divsellcontent").style.display="none";
    $("divchange").style.display="block";
    $("divchangecontent").style.display="none";
    //$("divmap").style.display="block";
    //$("divmapcontent").style.display="none";
    
    $("div"+type).style.display="none";
    $("div"+type+"content").style.display="block";
    
}











