/*******
tab:切换的标签
div_pre:'tab' 切换的div前缀，默认为tab div规则 <div id="tab1"></div><div id="tab2"></div>
cur:'cur' 当前样式
action:'click' 单击切换，mouseover:悬停切换
show:第几个
tabs_tide({tab:'#bq a',prev:'#prev',next:'#next',div_pre:'hh',stop:'#bq,#prev,#next',action:'mouseover',show:1,auto:true,interval:1});
*******/
function tabs_tide(o){
		o=jQuery.extend({
			tab:null,
			cur:'cur',
			prev:null,
			next:null,
			stop:null,
			auto: false,
			action:'click',
			div_pre:'tab',
			show:null,
			interval:1
		},o||{});

	var $obj=jQuery(o.tab);//所用标签
	var len=$obj.length;//个数
	if(len<1) return;
	var divs="";
	var c=1;
	var interval;
	for(n=1;n<=len;n++){n==1?divs+="#"+o.div_pre+n:divs+=",#"+o.div_pre+n;};
	function showDiv($num){
		$obj.removeClass(o.cur);
		jQuery(divs).hide();
		jQuery($obj.get($num-1)).addClass(o.cur);
		jQuery("#"+o.div_pre+$num).show();	
	}

	if(o.action=='click'){
		$obj.each(function(i){		
			jQuery(this).click(function(){
				c=i+1;showDiv(c);	
			});
		});
	}else{
		$obj.each(function(i){		
			jQuery(this).hover(function(){
				c=i+1;showDiv(c);
			},function(){});
		});
	}

	if(o.show){
		c=o.show;showDiv(c);
	}

	if(o.next){
		jQuery(o.next).click(function(){
				c++;c>len?c=1:c;showDiv(c);	
			});
	}

	if(o.prev){
		jQuery(o.prev).click(function(){
				c--;c<=0?c=len:c;showDiv(c);		
			});
	}

	if(o.auto){
		interval=setInterval(function() {
					c++;c>len?c=1:c;showDiv(c);	
				}, o.interval*1000);
	}
	
	if(o.auto){
		if(o.stop){
				jQuery(o.stop).mouseover(function(){
				 clearInterval(interval);
				}).mouseout(function(){
					  interval=setInterval(function() {
						c++;c>len?c=1:c;showDiv(c);	
					}, o.interval*1000);
				});
			}
	}
}
var m_layer1,m_layer2;
function initMove(adl,adr,bottom,left,top) {
	 m_layer1=document.getElementById(adl);
	 m_layer2=document.getElementById(adr);
	 MoveLayers(adl,adr,bottom,left,top);
	 window.onscroll=function(){MoveLayers(adl,adr,bottom,left,top)};
}
function MoveLayers(adl,adr,bottom,left,top) {
	 var st=document.documentElement.scrollTop;
	 var ch=document.documentElement.clientHeight;
	 var oh=m_layer1.offsetHeight;
	 var cw=document.documentElement.clientWidth;
	 if(bottom!=="false"){
		var bottom = st+ch-oh-bottom;}else{
		var bottom = st+top;
	 }
	 m_layer1.style.top = m_layer2.style.top=bottom+"px";
	 m_layer1.style.left = left+"px";
	 m_layer2.style.left = cw-m_layer2.offsetWidth-left+"px";
}
