// JavaScript Document
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
	window.onload = func;
	}else{
	window.onload = function() {
    oldonload();
    func();
    }
  }
}

function addClass(element,value) {
  if (!element.className) {
    element.className = value;
  } else {
    newClassName = element.className;
    newClassName+= " ";
    newClassName+= value;
    element.className = newClassName;
  }
}

function removeClass(element, value){
  var removedClass = element.className;
  var pattern = new RegExp("(^| )" + value + "( |$)");
  removedClass = removedClass.replace(pattern, "$1");
  removedClass = removedClass.replace(/ $/, "");
  element.className = removedClass;
  return true;
}

/*className */





function all_func(){
	tabs("TabTitle_login","Tabs_login","Title_login",true);
	tabs("TabTitle_login1","Tabs_login","Title_login",true);
	tabs("TabTitle_login2","Tabs_login","Title_login",true);
	tabs("car_tab_ul3","data_table3",null,true);
	tabs("sub_ul","sub_con",null,true);
	tabs("sub_news","sub_news_con",null,true);	
	tabs("rank_newcar_tab","rank_newcar");
	tabs("pageTop","ctab");
	tabs("link_tab_ul","link_box",null,true);
	tabs("hot_rank_per","hot_rank_per_box",null,true);	

}
addLoadEvent(all_func)

function hide(id){var Div = document.getElementById(id);if(Div){Div.style.display="none"}}  
function show(id){var Div = document.getElementById(id);if(Div){Div.style.display="block"}}  

function tabsRemove(index,head,divs,div2s) { 		
	if (!document.getElementById(head)) return false;
	var tab_heads = document.getElementById(head);
	if (tab_heads) {
		var alis = tab_heads.getElementsByTagName("li");  
		for(var i=0;i<alis.length;i++){
			removeClass(alis[i], "current");
			
			hide(divs+"_"+i);
			if(div2s){hide(div2s+"_"+i)};
			
			if (i==index) {
				addClass(alis[i],"current");
			}
			}
			
			show(divs+"_"+index);
			if(div2s){show(div2s+"_"+index)};
		}
}

function tabs(head,divs,div2s,over){
	if (!document.getElementById(head)) return false;
	var tab_heads=document.getElementById(head);
	
	if (tab_heads) {
	   var alis=tab_heads.getElementsByTagName("li");
	   for(var i=0;i<alis.length;i++) {
		alis[i].num=i;
		
		
		if(over){
				alis[i].onclick = function(){
					var thisobj = this;
					thetabstime = setTimeout(function(){changetab(thisobj);},150);
					}
						
		}
		
		function changetab(thebox){
			tabsRemove(thebox.num,head,divs,div2s);			
		}
  
     } 
  }
}

