var timer;
isie = String(navigator.appVersion).indexOf("MSIE") > -1;
function on_load()
{
	SetEven();
	Change_img_Even();
	init();//初始化显示第一张图片
}

function SetEven()
{
	var lilist=document.getElementById('lilist').getElementsByTagName('li');
	changeDiv(1);
	for(var i=0;i<lilist.length;i++)
	{
		(function(){
					  var p=i;
						  lilist[i]["onmouseover"]=function(){
							  if(lilist[p].className!='ch')
							  {
								 timer = window.setTimeout(function(){
									for(var j=0;j<lilist.length;j++)
									{
										lilist[j].className='';
									}
								  lilist[p].className='ch';
								  changeDiv(p+1);
								},100);
							 }
						  }
						  lilist[i]["onmouseout"]=function(){
							  clearInterval(timer);
						  }
		})();
	}
}

function Change_img_Even()
{
	var as=document.getElementById('news_top').getElementsByTagName('a');
	var li_list = document.getElementById('news_top').getElementsByTagName('li')
	for(var i=0;i<as.length;i++)
	{
		(function(){
					  var p=i;
						  as[i]["onmouseover"]=function(){
							  if(as[p].className!='ch')
							  {
								 timer = window.setTimeout(function(){								
									for(var j=0;j<li_list.length;j++)
									{
										li_list[j].className='';
									}
								  li_list[p].className='ch';
								  document.getElementById('big_img').src = as[p].name;
								  document.getElementById('big_img_a').href = as[p].href;
								},100);
							 }
						  }
						  as[i]["onmouseout"]=function(){
							  clearInterval(timer);
						  }
		})();
	}
}

function getXmlHttpObject()
{
	var xmlHttp=null;
	if (window.ActiveXObject){
		try{
			xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e){
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}else if (window.XMLHttpRequest){
		xmlhttp=new XMLHttpRequest();
	}
	return xmlHttp;
}

function changeDiv(p)
{
 	//var xmlDoc=new ActiveXObject('Microsoft.XMLDOM');
	var xmlDoc=null;
	var url="/xml/bianji/yangchefy.xml";
	var nodes=null;
	var carsdiv=document.getElementById('carsdiv');
	carsdiv.innerHTML='';
	if(isie){
		xmlDoc=new ActiveXObject('Microsoft.XMLDOM');
		xmlDoc.async="false";
		xmlDoc.load(url);
		nodes=xmlDoc.getElementsByTagName('Table'+p)[0].childNodes;
		for(var i=0;i<nodes.length;i++)
		{
		carsdiv.innerHTML+='<ul><li class="td1">'+getValue(nodes[i],'cars_name')+'</li><li class="td2">'+getValue(nodes[i],'address')+'</li><li class="td3">'+getValue(nodes[i],'price')+'/月</li><li><a href='+getValue(nodes[i],'url')+' target="_blank">详细</a></li></ul>';
		}
	}else{
		xmlDoc=new XMLHttpRequest();
		xmlDoc.open("GET",url,false);
		xmlDoc.send(null);
		//var xmlDoc2=xmlDoc.responseXML;
		//xmlDoc2=document.implementation.createDocument("", "", null);
		//xmlDoc2.async = false;
		//xmlDoc2.load(url);.getElementsByTagName('cars')
		nodes=xmlDoc.responseXML.getElementsByTagName('Table'+p);
		//alert(nodes[0].getElementsByTagName('cars').length);
		if(nodes[0].hasChildNodes()){
			for(var j=0;j<nodes[0].getElementsByTagName('cars').length;j++){
				childNodes=nodes[0].getElementsByTagName('cars');
				carsdiv.innerHTML+='<ul><li class="td1">'+getValue(childNodes[j],'cars_name')+'</li><li class="td2">'+getValue(childNodes[j],'address')+'</li><li class="td3">'+getValue(childNodes[j],'price')+'/月</li><li><a href='+getValue(childNodes[j],'url')+' target="_blank">详细</a></li></ul>';
			}
		}
	}
}

function init()
{
	var li = document.getElementById('news_top').getElementsByTagName('li')[0];
	var a = document.getElementById('news_top').getElementsByTagName('a')[0];
	document.getElementById('big_img').src = a.name;
	li.className = 'ch';
	document.getElementById('big_img_a').href = a.href;
}

function getValue(node,id){
	if(!node){ return null; }
	var value;
	if(isie){
		value = node.getElementsByTagName(id)[0].text;
	}else{
		//value = node.getElementsByTagName(id).textContent;
		//alert(node);
		value = node.getElementsByTagName(id)[0].textContent;
	}
	return value;
}
