
function addLoadEvent(func){
  var oldonload = window.onload;
  if(typeof window.onload != 'function'){
    window.onload = func;
  }else{
    window.onload = function(){
      oldonload();
      func();
    }
  }
}

function insertAfter(newElement,targetElement){
  var parent = targetElement.parentNode;
  if(parent.lastChild == targetElement){
    parent.appendChild(newElement);
  }else{
    parent.insertBefore(newElement,targetElement.nextSibling);
  }
}

function getElementsByClassName(n) { 
　　var el = [],
　　_el = document.getElementsByTagName('*');
　　for (var i=0; i<_el.length; i++ ) {
　　　if (_el[i].className == n ) {
　　　el[el.length] = _el[i];
　　  }
　　}
　　return el;
}

function nTabs(tabObj,obj){
	var tabList = document.getElementById(tabObj).getElementsByTagName("ul")[0].getElementsByTagName("li");
	for(i=0; i <tabList.length; i++)
	{
		if (tabList[i].id == obj.id)
		{
			document.getElementById(tabObj+"_Title"+i).className = "active"; 
    		document.getElementById(tabObj+"_Content"+i).style.display = "block";
		}else{
			document.getElementById(tabObj+"_Title"+i).className = "normal"; 
			document.getElementById(tabObj+"_Content"+i).style.display = "none";
		}
	} 
}
function nTabsB(tabObj,obj){
	var tabList = document.getElementById(tabObj).getElementsByTagName("ul")[0].getElementsByTagName("li");
	for(i=0; i <tabList.length-1; i++)
	{
		if (tabList[i].id == obj.id)
		{
			document.getElementById(tabObj+"_Title"+i).className = "active"; 
    		document.getElementById(tabObj+"_Content"+i).style.display = "block";
		}else{
			document.getElementById(tabObj+"_Title"+i).className = "normal"; 
			document.getElementById(tabObj+"_Content"+i).style.display = "none";
		}
	} 
}

function showTag(e){
	e = e || window.event
	var tag = e.getElementsByTagName('div');
	for(i=0;i<tag.length;i++){
		if(tag[i].className == 'CollectDiv'){
			tag[i].style.display = 'block';
		}
	}
}
function hiddenTag(e){
	e = e || window.event
	var tag = e.getElementsByTagName('div');
	for(i=0;i<tag.length;i++){
		if(tag[i].className == 'CollectDiv'){
			tag[i].style.display = 'none';
		}
	}
}
function alertWindow(id){
	var sWidth = document.documentElement.clientWidth ;
	//var sHeight = window.innerHeight ;
	var fullDiv = document.createElement('div');
	fullDiv.setAttribute("id","fullDiv");
	fullDiv.style.position = 'absolute';
	fullDiv.style.top = '0';
	fullDiv.style.left = '0';
	
	if (document.body.clientHeight)	{
		var sHeight = document.body.clientHeight + "px";
	}
	else if (window.innerHeight){
		var sHeight = window.innerHeight + "px";
	}
	fullDiv.style.height=sHeight;
	fullDiv.style.width=sWidth + "px";
	fullDiv.style.zIndex = '1000';
	document.body.appendChild(fullDiv);
	
	var id = document.getElementById(id);
	id.style.display = 'block';
	id.style.position = 'absolute';
	id.style.zIndex = '1001';
	//id.style.top = (screen.height-id.style.height) / 2 + 'px'; 
	//alert(id.style.top);
	id.style.left = (document.documentElement.clientWidth - id.offsetWidth) / 2 + document.documentElement.scrollLeft + 'px';
    	//id.style.top = (document.documentElement.clientHeight - id.offsetHeight) / 2 + document.documentElement.scrollTop + 'px';
    	id.style.top = 100 + 'px';
	
}
function closeWindow(e){
	e = e || window.event
	var fullDiv = document.getElementById('fullDiv');
	document.body.removeChild(fullDiv);
	e.parentNode.parentNode.style.display = 'none' ;
}

//窗口的隐藏/出现2008-7-1
function toggleW(obj){
    var t = document.getElementById("allPrice");
    if (t.style.display=="none"){
	     t.style.display="block";
    }else{
	    t.style.display="none";
    }
}
//鼠标移动变色 2008-7-3
function toggleBG(){
		var a = document.getElementById('carList');
		var b= a.getElementsByClassName('listMain')
		for(i=0;i<b.length;i++){
			b[i].onmouseover=function(){
				this.style.backgroundColor = '#FFFBF0';
			}
			b[i].onmouseout=function(){
				this.style.backgroundColor = '#ffffff';
			}
		}
}
////鼠标移动变色 主要是针对table 2008-7-10
function toggle(id,tag){
	var a = document.getElementById(id);
	var b= a.getElementsByTagName(tag);
	for(i=0;i<b.length;i++){
		b[i].onmouseover=function(){
			this.style.backgroundColor = '#FFF6D4';
		}
		b[i].onmouseout=function(){
			this.style.backgroundColor = '#ffffff';
		}
	}
}
