﻿function focus(tabId,conId,tabtn,contn){
	this.tabs=document.getElementById(tabId).getElementsByTagName(tabtn||'li');
	this.total=this.tabs.length;
	this.cons=document.getElementById(conId||tabId).getElementsByTagName(contn||'div');
	if(this.cons.length!=this.total){
		alert('An Error Occured');
		return;
	}
	this.cn=new Array;
	this.current=0;
	var obj=this;
	for(i=0;i<this.total;i++){
		(function(){
			var b=i;
			obj.cn[i]=obj.tabs[i].className;
			obj.tabs[i].onclick=function(){
				obj.current=b;
				clearTimeout(obj.run);
				obj.run=setTimeout(obj.start,10);
			}
		})()
	}
	(this.start=function(){
		if(obj.current>=obj.total)obj.current=0;
		if(obj.current<0)obj.current=obj.total-1;
		for(i=0;i<obj.total;i++){
			obj.tabs[i].className=(obj.current==i)?'current '+obj.cn[i]:obj.cn[i];
			obj.cons[i].style.display=(obj.current==i)?'block':'none';
		}
		obj.current++;
		obj.run=setTimeout(obj.start,3000)
	})()
}
