// 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 getElementsByClass(searchClass,node,tag) {
 var classElements = new Array();
 if ( node == null )
  node = document;
 if ( tag == null )
  tag = '*';
 var els = node.getElementsByTagName(tag);
 var elsLen = els.length;
 var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
 for (var i = 0, j = 0; i < elsLen; i++) {
  if ( pattern.test(els[i].className) ) {
   classElements[j] = els[i];
   j++;
  }
 }
 return classElements;
}

/*nextSibling*/
function get_nextSibling(n){
	var y = n.nextSibling;
	while (y.nodeType != 1) {
		y = y.nextSibling;
	}
	return y;	
}
/*firstChild*/
function get_firstChild(n){
	var y = n.firstChild;
	while (y.nodeType != 1) {
		y = y.nextSibling;
	}
	return y;		
}
/*lastChild*/
function get_lastChild(n){
	var y = n.lastChild;
	while (y.nodeType != 1) {
		y = y.previousSibling;
	}
	return y;		
}

/*previousSibling*/
function get_previousSibling(n){
	var y=n.previousSibling;
	while (y.nodeType!=1){
	y=y.previousSibling;
	}
	return y;
}


/*break ul tag*/
function breakul(ul_ID,li_num){
		if (!document.getElementById(ul_ID)) return false;
		var divid = document.getElementById(ul_ID).parentNode; 
		var sfEls = divid.getElementsByTagName("li"); 
		var loopCount = Math.ceil(sfEls.length/li_num) - 1; 
		for(var less = 0;less<loopCount;less++) {
			var bod = document.createElement("ul");  
			divid.appendChild(bod);
			for(var i = 0;i<li_num;i++) {
					   if(sfEls[li_num] && ((less+1)*li_num +i)<sfEls.length){
					   bod.appendChild(sfEls[li_num]);
			}  
		}   
	}
}

function all_func(){
	breakul('break_hangqing',7);
	breakul('break_weihu',6);
	breakul('break_shangjia',5);
	breakul('break_redian',8);	
	breakul('break_jinghua',8);
	breakul('break_daogou',7);
	tabs("car_tab_ul","data_table","best_car",true);
	tabs("car_tab_ul1","data_table1",null,true);
	tabs("car_tab_ul2","data_table2","best_car2",true);
	tabs("car_tab_ul3","data_table3",null,true);
	tabs("car_tab_ul4","data_table4","best_car4",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("link_tab_ul1","link_box1",null,true);	
	tabs("hot_rank_per","hot_rank_per_box",null,true);	
	tabs("sub_credit","sub_credit_con",null,true);
	tabs("car_tab_ul5","data_table5","best_car5",true);	
	tabs("car_tab_ul6","data_table6",null,true);	
	tabs("sub_bbs","sub_bbs_con",null,true);
	var focusa = new focusObj('focus_chart',3000);
    city_drop();
	popprice("data_table5_0");
	popprice("data_table_0");
	setFocusAtt();
	process();
	clickNum();
}
addLoadEvent(all_func)
	
/*==================focus=====================*/

/*imgchange*/
function focusbigimg(obj,focus_obj){	
	var focus_box = focus_obj;
	var divs = focus_box.getElementsByTagName("div");
	var ps = focus_box.getElementsByTagName("p");
	
	for(var i=0;i<ps.length;i++){
		if (divs[i]==obj){ps[i].style.display = "block";}
		else{ps[i].style.display = "none";}
	}
	
}

/*wdith*/
function widthElement(elementID,final_width,interval) {
  
  if(typeof(elementID)=='object'&&typeof(elementID.tagName)!='undefined'){
	  var elem = elementID;
	}else if(typeof(elementID)=='string'){
		var elem = document.getElementById(elementID);
	}else if(!document.getElementById(elementID)){
		return false;  
	}

  if (elem.movement) {
   clearTimeout(elem.movement); 
  }
  if (!elem.style.width) {
    elem.style.width = "0px";
  }
  var xpos = parseInt(elem.style.width);
  if (xpos == final_width) {
	 return true;	
  }  
  if (xpos < final_width) {
    var dist = Math.ceil((final_width - xpos)/2);
    xpos = xpos + dist;
  }
  if (xpos > final_width) {
    var dist = Math.ceil((xpos - final_width)/2);
    xpos = xpos - dist;
  }
  elem.style.width = xpos + "px";
  var repeat = "widthElement('"+elementID+"',"+final_width+","+interval+")";
  elem.movement = setTimeout(repeat,interval);
}

getcurrent=0;	

/*auto*/
function focusAuto(bt_autokey,focus_box,bt_max_width,bt_min_width,bt_interval){
	
	if(bt_autokey) {return false;}//key
	if(!focus_box) {return false;}
	var f_div = focus_box.getElementsByTagName("div");

	var getc = getElementsByClass("current",focus_box,"div");
	li_active();
					
	var getc = getElementsByClass("current",focus_box,"div");	
	focusbigimg(getc[0],focus_box);	
	
	
	function li_active(){
		if(f_div[f_div.length-1].className == "current" && f_div[f_div.length-1].style.width == bt_max_width+"px" ){
					removeClass(f_div[f_div.length-1], "current");		
					addClass(f_div[0],"current")	
					//widthElement(f_div[f_div.length-1].id,bt_min_width,bt_interval);
					//widthElement(f_div[0].id,bt_max_width,bt_interval);
					f_div[f_div.length-1].style.width = bt_min_width  + "px";
					f_div[0].style.width = bt_max_width  + "px";
					return false;
				}
			if(getc[0].style.width == bt_max_width+"px"){					
					for(var i=0;i<f_div.length;i++){
						if(f_div[i] == getc[0]){
							var getcurrent = i;//sub key
						}					
					}					
					removeClass(f_div[getcurrent], "current");
					addClass(f_div[getcurrent+1],"current")
					//widthElement(f_div[getcurrent].id,bt_min_width,bt_interval);
					//widthElement(f_div[getcurrent+1].id,bt_max_width,bt_interval);
					f_div[getcurrent].style.width = bt_min_width + "px";
					f_div[getcurrent+1].style.width = bt_max_width + "px";
					getcurrent=getcurrent++;					
				}	
	}
}
//addLoadEvent(focusAuto);



function focusObj(id,settime){
	if (!document.getElementById(id)) return false;
	this.focus_box = document.getElementById(id);
	this.f_p = this.focus_box.getElementsByTagName("p");
	this.f_em = this.focus_box.getElementsByTagName("em");
	this.f_div = this.focus_box.getElementsByTagName("div");
	this.getc = getElementsByClass("current",this.focus_box,"div");

	var w_max_width=parseInt(this.focus_box.clientWidth-this.f_div.length*18);
	
	this.bt_autokey = false;
	this.bt_interval = 30;	
	this.bt_min_width = 18;
	this.bt_max_width = w_max_width+8;
	this.getc[0].style.width=w_max_width+8 + "px";//load width
	
	var wbt_autokey=this.bt_autokey;
	var wfocus_box=this.focus_box;
	var wbt_max_width=this.bt_max_width;
	var wbt_min_width=this.bt_min_width;
	var wbt_interval=this.bt_interval;
	var wf_em=this.f_em;
	var wf_div=this.f_div;
	
	
	for(var i=0;i<this.f_em.length;i++){
		this.f_div[i].onmouseover = function(){wbt_autokey = true;};//key
		this.f_div[i].onmouseout = function(){wbt_autokey = false;};//key	
		this.f_p[i].onmouseover = function(){wbt_autokey = true;};//key
        this.f_p[i].onmouseout = function(){wbt_autokey = false;};//key  

		this.f_p[i].style.display = "none";
		this.f_p[0].style.display = "block";
		
		this.f_em[i].num = i;
	
		this.f_em[i].onclick = function(){
			var getc = getElementsByClass("current",wfocus_box,"div");
			if(getc[0].style.width != wbt_max_width+"px"){return false};//unable quick click
			if(getc[0]==this.parentNode.parentNode){return false};//unable click current
			
			//widthElement(getc[0].id,wbt_min_width,wbt_interval);
			//widthElement(wf_div[this.num].id,wbt_max_width,wbt_interval);
			getc[0].style.width = wbt_min_width + "px";
			wf_div[this.num].style.width = wbt_max_width + "px";
			removeClass(getc[0],"current");
			addClass(wf_div[this.num],"current");
			focusbigimg(wf_div[this.num],wfocus_box);
			return false;
			
			}; 
		
	}
	this.bt_settime = setInterval(function(){focusAuto(wbt_autokey,wfocus_box,wbt_max_width,wbt_min_width,wbt_interval);},settime);
	


}

	
/*=======================dealer logo========================*/

function dealer_logo(){
		if (!document.getElementById("dealer_logo")) return false;
		var PMarquee = document.getElementById("dealer_logo"); 
		var lis = PMarquee.getElementsByTagName("li");
		var lisw = lis[0].clientWidth;
		var celnum = Math.floor(PMarquee.clientWidth/lisw);
		//cel mun
		
		var PLineCount = Math.ceil(lis.length/celnum);  
		//line mun
		
		var copynum = (PLineCount*celnum)-lis.length;		
		
		if (PLineCount>1){	
		var Pjia;
		Pjia = PMarquee.innerHTML;
		
		for(i=0;i<copynum+1;i++){
			
			PMarquee.innerHTML = PMarquee.innerHTML + Pjia;
			// double box
			}
			setTimeout("srun()",1000); 
			//start
		}
}
//addLoadEvent(dealer_logo);
//onload

function srun() {	
			if (!document.getElementById("dealer_logo")) return false;
			var PMarquee = document.getElementById("dealer_logo"); 
			var lis = PMarquee.getElementsByTagName("li");
			var lisw = lis[0].clientWidth;
			var	PLineHeight = lis[0].clientHeight; 
			
			var celnum = Math.floor(PMarquee.clientWidth/lisw);
			//cel mun
			var PLineCount = Math.ceil(lis.length/celnum);  
			//line mun
			PMarquee.scrollTop ++;	
			if (PMarquee.scrollTop == PLineCount * PLineHeight-(2*PLineHeight)) {
					PMarquee.scrollTop = 0;					
					//re
			}
			if (PMarquee.scrollTop % PLineHeight == 0 ) {
				setTimeout( "srun()", 500 ); 
			}
			else {
				setTimeout( "srun()", 5 );
				//one px time
			}
			
}





/*=======================tab=============================*/
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].onmouseover = function(){
					var thisobj = this;
					thetabstime = setTimeout(function(){changetab(thisobj);},150);
					}
				alis[i].onmouseout = function(){
					clearTimeout(thetabstime);
					}			
		}
		else{			
					alis[i].onclick = function(){
						if(this.className == "current" || this.className == "last current"){
							changetab(this);
							return true;
						}
						else{
							changetab(this);						
							return false;
						}
					
				}
		}
		
		function changetab(thebox){
			tabsRemove(thebox.num,head,divs,div2s);			
		}
  
     } 
  }
}

/*bt login*/
function bt_login_more(overID,boxID,add_Class,iframeID,add_iframeClass){
	if (!document.getElementById(overID)) return false;
	var btli = document.getElementById(overID);	
	var btpop = document.getElementById(boxID);	
	btli.onmouseover = function(){
			addClass(btpop,add_Class);
			popiframeon();
		}
	btli.onmouseout = function(){
			removeClass(btpop,add_Class);
			popiframeout();
		}
	if (document.getElementById(iframeID)){		
		var btpopiframe = document.getElementById(iframeID);
		function popiframeon(){addClass(btpopiframe,add_iframeClass);	}
		function popiframeout(){removeClass(btpopiframe,add_iframeClass);	}	
	}
}
function all_login_box(){
	bt_login_more('bt_login_bt','bt_login_pop','pop_block','popiframe','popiframeblock');
	bt_login_more('bt_login_ibit','bt_login_ibitpop','ibitpop_block','ibitpopiframe','ibitpopiframeblock');
}
addLoadEvent(all_login_box);


/*reset fields*/
function resetFields(whichform) {	
   	if (!document.getElementById("txtkeyword")) return false;
	var element = document.getElementById("txtkeyword");

    element.onfocus = function() {
	//document.charset='gb2312';
    if (this.value == this.defaultValue) {
      this.value = "";
	  addClass(this,"on");
     }
    }
    element.onblur = function() {
      if (this.value == "") {
        this.value = this.defaultValue;
		removeClass(this, "on")
      }
	  

    }
}

function prepareForms() {
  for (var i=0; i<document.forms.length; i++) {
    var thisform = document.forms[i];
    resetFields(thisform);
  }
}
addLoadEvent(prepareForms);

/*city pop*/
function AreasTrans(BtnChange,BtnClose,AreaList) {
	var div=document.getElementById(AreaList);
	var btn=document.getElementById(BtnChange);
	if ((div) && (btn)) {
		btn.onclick = function() {
			if (div.style.display=="none"){
			div.style.display="block";
			btn.className="change_btn_open";
			} 
			else {
			div.style.display="none";		
			btn.className="change_btn_close";
			}		
		}
	var close_btn=document.getElementById(BtnClose);
		close_btn.onclick = function() {
			document.getElementById(AreaList).style.display="none";	
			btn.className="change_btn_close";
		}
	}
}
function allcitypop() { 
	AreasTrans("change_btn","area_list_close","area_list");
	AreasTrans("change_btn1","area_list_close1","area_list1");
}
addLoadEvent(allcitypop);


function popprice(theID){
	//if (!document.getElementById("data_table_0")) return false;
	if (!document.getElementById(theID)) return false;
	popprice_div = document.getElementById(theID);
	popprice_dl = popprice_div.getElementsByTagName("dl");
	
	for(var i=0;i<popprice_dl.length;i++){
		popprice_dl[i].onmouseover = function(){
			this.style.position = "relative";
		}
		popprice_dl[i].onmouseout = function(){
			this.style.position = "static";
		}


	}
	
	
}
//addLoadEvent(popprice);

function closefestival(){
	if (!document.getElementById("close_f")) return false;
	close_festival = document.getElementById("close_f");
	festival_body = document.getElementsByTagName("body");
		close_festival.onclick = function(){
			festival_body[0].className = "";
			close_festival.style.display="none";
		}
		
}
addLoadEvent(closefestival);

//100423 wdd 
function check_tabs(num){
	if(document.getElementById("car_tab_ul")&&document.getElementById("car_tab_ul").getElementsByTagName("li")[num]){
		var car_tab_ul_lis=document.getElementById("car_tab_ul").getElementsByTagName("li");
		for(i=0;i<car_tab_ul_lis.length;i++){
			car_tab_ul_lis[i].className="";
			document.getElementById("data_table_"+i).style.display="none";
		}
		car_tab_ul_lis[num].className="current";
		document.getElementById("data_table_"+num).style.display="block";
	}
}
function check_tabs_init(){
 check_tabs(8);
}
//addLoadEvent(check_tabs_init);

//100913
function city_drop(){
	if (!document.getElementById("city_drop_b")) return false;
	if (!document.getElementById("city_drop_c")) return false;
	if (!document.getElementById("city_drop")) return false;	
	city = document.getElementById("city_drop");
	city_c = document.getElementById("city_drop_c");
	city_b = document.getElementById("city_drop_b");
	city.onmouseover = function(){
			addClass(city_b,"ho");
			addClass(city_c,"show");
		}
	city.onmouseout = function(){
			removeClass(city_b, "ho");
			removeClass(city_c, "show");	
		}
	city_b.onclick = function(){
		if(city_c.className == "show"){			
			removeClass(city_b, "ho");
			removeClass(city_c, "show");	
			//alert("asdf");
			}
		else{
			addClass(city_b,"ho");
			addClass(city_c,"show");
			}
	}
}


//20101118 city drop. box,iframe,arrow
function bt_login_more2(overID,boxID,add_Class,iframeID,add_iframeClass,arrowID,add_arrowClass){
	if (!document.getElementById(overID)) return false;
	var btover = document.getElementById(overID);	
	var btpop = document.getElementById(boxID);	
	if (document.getElementById(iframeID)){		
		var btpopiframe = document.getElementById(iframeID);
		var arrowbox = document.getElementById(arrowID);
		btover.onmouseover = function(){
			addClass(btpop,add_Class);
			addClass(btpopiframe,add_iframeClass);
			addClass(arrowbox,add_arrowClass);
		}
		btover.onmouseout = function(){
			removeClass(btpop,add_Class);
			removeClass(btpopiframe,add_iframeClass)
			removeClass(arrowbox,add_arrowClass)
		}
	}
}
function all_login_box2(){
bt_login_more2("city_for","city_drop_c","show","city_i","show","city_em","ho")
bt_login_more2("city_for1","city_drop_c1","show","city_i1","show","city_em1","ho")
}
addLoadEvent(all_login_box2);

/**/
function goLink(url){
	if(currentCityEName)
		url = url.replace('{currentCityEName}',currentCityEName);
	if(currentCityName)
		url = url.replace('{cityName}',currentCityName);
	if(currentCityId)
        url = url.replace('{cityId}',currentCityId);
	if(centerEName)
		url = url.replace('{centerEName}',centerEName);
	if(centerCityId)
		url = url.replace('{centerCityId}',centerCityId);
    window.open(url);
    return false;
}


/*车市页焦点图*/
	var vflag=0;
	var runs;
	
	function setFocusAtt() {
		if (!document.getElementById("allDiv")) return false;
		var divBox = document.getElementById("allDiv");
		var allDiv = divBox.getElementsByTagName("div");
		if (!document.getElementById("focusNum")) return false;
		var numBox = document.getElementById("focusNum");
		for(var i=0; i<allDiv.length; i++){
			//图片内容
			allDiv[i].setAttribute("id", "focus_info_1"+i);
			allDiv[i].onmouseover = function() {clearTimeout(runs);}
			allDiv[i].onmouseout = function() {runs=setTimeout("process()",3000);}
			//数字			
			var allNum = document.createElement("div");
			allNum.setAttribute("id","focus_tab_1"+i);
			allNum.setAttribute("class","focus_off");
			allNum.setAttribute("className","focus_off");
			numBox.appendChild(allNum);
			allNum.innerHTML = i+1;
		}
	}
	
	function process(){	
		if (!document.getElementById("allDiv")) return false;
		var divBox = document.getElementById("allDiv");
		var allDiv = divBox.getElementsByTagName("div");		
		var started=1;			
		if(started == 1){
			goFocus(vflag,0);
			vflag++;
			if( vflag == allDiv.length ){vflag = 0;};
			runs = setTimeout("process()",3000);
		}
	}
	function goFocus(num,flag){
		if (!document.getElementById("allDiv")) return false;
		var divBox = document.getElementById("allDiv");
		var allDiv = divBox.getElementsByTagName("div");
		for(var j=0; j<allDiv.length; j++){
			document.getElementById("focus_info_1"+j).style.display = "none";
			document.getElementById("focus_tab_1"+j).className = "focus_off";
		}   
		document.getElementById("focus_tab_1"+num).className = "focus_on";
		document.getElementById("focus_info_1"+num).style.display = "block";
	}
	
	function focusimgtext(obj){	
		if (!document.getElementById("allDiv")) return false;
		var divBox = document.getElementById("allDiv");
		var divs = divBox.getElementsByTagName("div");
		if (!document.getElementById("focusNum")) return false;
		var numBox = document.getElementById("focusNum");
		var ps = numBox.getElementsByTagName("div");	
		for(var i=0;i<ps.length;i++){
			if (ps[i]==obj){
				divs[i].style.display = "block";
				ps[i].className = "focus_on"
			} else {
				divs[i].style.display = "none";
				ps[i].className = "focus_off";
			}
		}
	}
	
	function clickNum() {
		if (!document.getElementById("allDiv")) return false;
		var divBox = document.getElementById("allDiv");
		var allDiv = divBox.getElementsByTagName("div");
		var numBox = document.getElementById("focusNum");
		var k=0;
		var Nums = numBox.getElementsByTagName("div");
		for(var k=0; k<allDiv.length; k++) {
			Nums[k].onclick = function() {
				focusimgtext(this);	
			}
		}  
	}

//2011index_focus
try {
$.fn.extend({
        rollable: function (option) {
            var setting = { index: 0, autoPlay: true, interval: 3000 };
            if (!option) { option = {}; }
            $.extend(setting, option);
            $.each(this, function (k, v) {
                var container = $(v);
                var len = container.find('.focusPic li').length;
                if (len == 1) {
                    container.find('.focusNum li').remove();
                    container.find(".focusPic li").show();
                    container.find('.fP').remove();
                    container.find('.fN').remove();
                    return;
                }
                var index = setting.index - 1;
                var timer = null;
                var setFocus = function () {
                    var emptyItem = container.find(".focusTxt li").eq(index);
                    if (emptyItem.html() == "") {                        
                        globeTxt = container.find(".focusPic li").eq(index).find("a")[1];
                        if (globeTxt) {
                            container.find(".focusTxt li").eq(i).append(globeTxt);
                        }
                    }
                    container.find(".focusTxt li").filter(":visible").hide().parent().children().eq(index).show();
                    container.find(".focusNum li").removeClass("current").eq(index).addClass("current");
                    container.find(".focusPic li").filter(":visible").hide().parent().children().eq(index).fadeIn(500, function () {
                        synFocus(container);
                    });

                }
                var rollUp = function () {
                    if (index == 0) {
                        index = len - 1;
                    } else {
                        index = (index - 1) % len;
                    }
                    setFocus();
                };
                var rollDown = function () {
                    index = (index + 1) % len;
                    if (index == len) {
                        index = 0;
                    }
                    setFocus();
                };
                container.find('.focusBox').hover(
				function () { clearTimeout(timer); },
				function () { timer = setInterval(rollDown, setting.interval); }
			);
                container.find(".focusNum li").mouseover(function () {
                    index = $(this).html() - 1;
                    setFocus();
                });

                container.find('.fP').click(function () { rollUp(); });
                container.find('.fN').click(function () { rollDown(); });

                setFocus();
                if (setting.autoPlay == true) {
                    timer = setInterval(rollDown, setting.interval);
                }
            })
        }
    });
	
	var isInit = false;
    $(function () {
        if (isInit == true) return;
        $.each($('.focusPic'), function (k, v) {
            var numbers = $(this).parent().find(".focusNum");
            var text = $(this).parent().find(".focusTxt");
            var items = $(this).find('li');
            var html = "";
            for (var i = 0; i < items.length; i++) {
                html += "<li>" + (i + 1) + "</li>";
                text.append("<li></li>");
                globeTxt = $(this).find("li").eq(i).find("a")[1];
                if (globeTxt) {
                    $(this).parent().find(".focusTxt li").eq(i).append(globeTxt);
                }
            }
            numbers.append(html);
            isInit = true;
        });
        $('.focus').rollable({ autoPlay: true, interval: 3000, index: 1 });
    });

    function synFocus(container) {
        var pic = 0;
        var Num = 0;
        container.find(".focusPic li").each(function (i, e) {
            var $this = $(this);
            if ($this.css("display") != "none") {
                pic = i;
            }
        });
        container.find(".focusNum li").each(function (i, e) {
            var $this = $(this);
            if ($this.attr("class") == "current") {
                Num = i;
            }
        });
        if (Num != pic) {
            container.find(".focusPic li").filter(":visible").hide().parent().children().eq(Num).fadeIn(500);
        }
    }
//2011second_focus
$.fn.extend({
	rollableSecond: function (option) {
		var setting = { index: 0, autoPlay: true, interval: 3000 };
		if (!option) { option = {}; }
		$.extend(setting, option);
		$.each(this, function (k, v) {
			var container = $(v);
			var len = container.find('.focusPic-2 li').length;
			if(len==1){
				container.find('.focusNum-2 li').remove();
				container.find('.focusPic-2 li').show();
				return;
			}
			var index = setting.index-1;
			var timer = null;
			var setFocus = function () {
				container.find(".focusTxt-2 li").filter(":visible").hide().parent().children().eq(index).show();
				container.find(".focusNum-2 li").removeClass("current").eq(index).addClass("current");
				container.find(".focusPic-2 li").filter(":visible").hide().parent().children().eq(index).fadeIn(500, function () {
					synFocusSecond(container);
				});
			}
			var rollUp = function () {
				if (index == 0) {
					index = len - 1;
				} else {
					index = (index - 1) % len;
				}
				setFocus();
			};
			var rollDown = function () {
				index = (index + 1) % len;
				if (index == len) {
					index = 0;
				}
				setFocus();
			};
			container.find('.focusBox-2').hover(
				function () {clearTimeout(timer);},
				function () {timer = setInterval(rollDown, setting.interval);}
			);
			container.find(".focusNum-2 li").mouseover(function() {
				index = $(this).html()-1;
				setFocus();
			});			
			setFocus();
			if (setting.autoPlay == true) {
				timer = setInterval(rollDown, setting.interval);
			}
		})
	}
});

$(function () {
	$.each($('.focusPic-2'), function (k, v) {
			var isInit = $(v).data('init');
			if (isInit && isInit == true) return;
			var numbers = $(this).parent().find(".focusNum-2");
			var text = $(this).parent().find(".focusTxt-2");
			var items = $(this).find('li');
			var html = "";
			for (var i = 0; i < items.length; i++) {
				html += "<li>" + (i + 1) + "</li>";
				text.append("<li></li>");
				var txt = $(this).find("li").eq(i).find("a")[1];
				$(this).parent().find(".focusTxt-2 li").eq(i).append(txt);
			}
			numbers.append(html);	
			$(v).data('init', true);
	});
	
	$('.focus-2').rollableSecond({autoPlay:true,interval:3000,index:1});
});

function synFocusSecond(container) {
	var pic = 0;
	var Num = 0;
	container.find(".focusPic-2 li").each(function (i, e) {
		var $this = $(this);
		if ($this.css("display") != "none") {
			pic = i;
		}
	});
	container.find(".focusNum-2 li").each(function (i, e) {
		var $this = $(this);
		if ($this.attr("class") == "current") {
			Num = i;
		}
	});
	if (Num != pic) {
		container.find(".focusPic-2 li").filter(":visible").hide().parent().children().eq(Num).fadeIn(500);
	}
}
} catch(e){}
<!-- tuangou -->;
//$(function() {
//  $(".img_star_s:eq(0)").hide();
//  $(".img_star_b:eq(0)").show(); 	
//  $(".img_starshow").mouseover(function(){
//	$(".img_star_s").show();
//    $(this).parent().hide();
//	$(".img_star_b").hide();
//	$(this).parent().next().show();
//	return false;
//  });
//});
/*20110523 random*/

